$(document).ready(function(){

	// email active functionality
	$('#email').focus(function()
	{		 
		$('#email').attr('value', "");
	});
	
	// primary phone active functionality
	$('#primary_phone').focus(function()
	{		 
		$('#primary_phone').attr('value', "");
	});

	// cell phone active functionality
	$('#cell_phone').focus(function()
	{		 
		$('#cell_phone').attr('value', "");
	});

	
	
	// easing functionality
	// t: current time, b: begInnIng value, c: change In value, d: duration
	jQuery.easing['jswing'] = jQuery.easing['swing'];
	
	jQuery.extend( jQuery.easing,
	{
		easeOutQuart: function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		},

		easeOutSine: function (x, t, b, c, d) {
			return c * Math.sin(t/d * (Math.PI/2)) + b;
		}
	});
	
	$('a#additional').click(function()
	{
		$('#additional_info').slideToggle(1000, 'easeOutSine');
	});	
	
	
	// preload the rollover states on the buttons
	$.preloadImages("../../images/btn_submit_o.gif", "../../images/btn_print_o.gif", "../../images/btn_reset_o.gif", "../../images/btn_browse_o.gif");
	
	// agent jobs form validation
	$('#frm_agent').validate({ 
		rules:
		{
		    fname:
			{
				required: true
			},
			lname:
			{
				required: true
			},
			address1:
			{
				required: true
			},
			city:
			{
				required: true
			},
			state:
			{
				required: true
				
			},
			zip:
			{
				required: true
			},
			email:
			{
				required: true,
				email: true
			},
			resume: 
			{
			      required: false,
			      accept: "doc|rtf|pdf|txt"
			},
			following_opportunities:
			{
				required:true
			},
			more_opportunities:
			{
				required: true
			},
			hear_opportunities:
			{
				required: true
			}
		}
		
	});
	
	// first name blur validation
//  $("#fname").blur(function() 
//	{
//		validateTextBlur( $("#fname"), $("#fname_warning"), "Enter your First Name" );  // args: input id, input warning id, warning msg
//	}); 
	

    // last name blur validation
//	$("#lname").blur(function() 
//	{ 
//		validateTextBlur( $("#lname"), $("#lname_warning"), "Enter your Last Name" );
//	});
	
	// address blur validation
	//$("#address1").blur(function()
//	{ 
//		validateTextBlur( $("#address1"), $("#address_warning"), "Enter your Street Address" );
//	});
	
	// city blur validation
//	$("#city").blur(function()
//	{ 
//		validateTextBlur( $("#city"), $("#city_warning"), "Enter your City" );
//	});
	
	// state blur validation
	//$("#state").blur(function()
//	{ 
//		validateTextBlur( $("#state"), $("#state_warning"), "Enter your State" );
//	});

    // zip blur validation
	//$("#zip").blur(function()
//	{ 
//		validateTextBlur( $("#zip"), $("#zip_warning"), "Enter your Postal/Zip Code" );
//	});

    // email blur validation
	//$("#email").blur(function()
//	{ 
//		validateTextBlur( $("#email"), $("#email_warning"), "Enter your email address" );
//	});
	
    // more opportunities blur validation
	//$("#more_opportunities").blur(function()
//	{ 
//		validateSelectBlur( $("#more_opportunities"), $("#moreOpp_warning"), "" );
//	});
	
	
	// reset button functionality
	$('#btn_reset').click(function()
								   {
									   $('#frm_agent').clearForm();
								   });
	
	$('#btn_print').click(function()
								   {
									   window.print() ;
								   });

});
// -- end DOM ready events -- //


// validate text input fields on blur
//function validateTextBlur(i_input, i_warning, i_msg)
//{
//	//if ( !$('#frm_agent').validate() )
////	{
////	}
//	var length;
//	var input = i_input.attr('id');
//    length = i_input.val().length;
//    i_warning.empty(); 
// 
//    if (length < 1) 
//	{
//    	i_warning.append(i_msg);
//		alert(input);
//	}
//}

// validate select inputs on blur
//function validateSelectBlur(i_input, i_warning, i_msg)
//{
//	var value;
//	value = i_input.val();
//	i_warning.empty();
//	
//	if (value == "")
//	{
//		i_warning.append(i_msg); 
//	}
//}
