$(function()
{
	//$('.date-pick').datePicker({startDate:'01/01/1900'});
	$(function() {
		$( ".date-pick" ).datepicker({
			showOn: "button",
			buttonImage: "/images/calendar.png",
			buttonImageOnly: true,
			yearRange: '1920:2015',
			changeYear: true
		});
	});
});

$(document).ready(function()
{
	//$('.selectbox').selectbox();

	$('.input_hint').each(function()
	{
		if ( ( $(this).val() == "" ) || ( $(this).val() == $(this).attr("title") ) )
		{
			$(this).val( $(this).attr("title") );
			$(this).addClass("hint");
		}
	});

	$('.input_hint').focus(function()
	{
		if ( $(this).val() == $(this).attr("title") )
		{
			$(this).val("");
			$(this).removeClass("hint");
		}
	});

	$('.error .input_hint').focus(function()
	{
		$(this).parent().parent().removeClass("error");				
	});
	
	$('.error .psc-pick').focus(function()
	{
		$(this).parent().parent().removeClass("error");				
	});	


	$('.input_hint').blur(function()
	{
		if ( $(this).val() == "" )
		{
			$(this).val( $(this).attr("title") );
			$(this).addClass("hint");
		}
	});
	
	$('.error .input_hint').blur(function()
	{
		if ( $(this).val() == $(this).attr("title") )
		{
			$(this).parent().parent().addClass("error");
		}
	});	
	
	$('.error .psc-pick').blur(function()
	{
		if ( $(this).val() == $(this).attr("title") )
		{
			$(this).parent().parent().addClass("error");
		}
	});	
	
	$('.input_hint').change(function()
	{
		if ( $(this).val() == "" )
		{
			$(this).val( $(this).attr("title") );
			$(this).addClass("hint");
		}
		else
			$(this).removeClass("hint");
	});
		
	$('.error .input_hint').change(function()
	{
		if ( $(this).val() == $(this).attr("title") )
		{
			$(this).parent().parent().addClass("error");
		}
		else
		{
			$(this).parent().parent().removeClass("error");	
		}
			
	});

	$('.psc-pick[value=""]').each(function()
	{
		$(this).val( $(this).attr("title") );
		$(this).addClass("hint");
	});

	$('.psc-pick').focus(function()
	{
		if( $(this).val() == $(this).attr("title") )
		{
			$(this).val("");
			$(this).removeClass("hint");
		}
		
	});

	$('.psc-pick').blur(function()
	{
		
		if ( $(this).val() == "" )
		{
			$(this).val( $(this).attr("title") );
			$(this).addClass("hint");
			$('.septy').empty();
		}
		
		/*
		if ( ! MOUSE_IN_SEPTY )
		{
			$(this).val( $(this).attr("title") );
			$(this).addClass("hint");
			$('.septy').empty();
		}
		*/
		
	});
	

	$('.switch input:checked').each(function()
	{
		
		if ( $(this).val() == $(this).attr("title") )
		{
			
			if ( $(this).parents("tr").parent().get(0).tagName.toLowerCase() == "tbody" )
			{
				$(this).parents("tbody").next().hide();
			}
			else
			{
				$(this).parents("tr").next().hide();
			}
				
		}
		else
		{
			if ( $(this).parents("tr").parent().get(0).tagName.toLowerCase() == "tbody" )
			{
				$(this).parents("tbody").next().show();
			}	
			else
			{
				$(this).parents("tr").next().show();
			}
		}
		
	});


	$('.switch input').change(function()
	{	
		// $(this).parents('tbody').next().toggle();
		
		if( $(this).parents('tbody').next().css('display') == 'none' )
			$(this).parents('tbody').next().show();
		else
			$(this).parents('tbody').next().hide();
		
		
		/*
		if( $(this).parents('table').find('tbody').css('display') == 'none' )
			$(this).parents('table').find('tbody').show();
		else
			$(this).parents('table').find('tbody').hide();
		*/
		
	});

	$('.hidden_row').hide();
});

