function step0_process() // this is the step from where the person applies from the homepage, enters info and then gets redirected to the application page
{
	$.post(SITE_ROOT+"ajax/apply_process.php",
	{ 
		operation: 'step0_process', 
		fname: $('#fname').val(),
		lname: $('#lname').val(),
		phone_home: $('#phone_home1').val()+$('#phone_home2').val()+$('#phone_home3').val(),
		email: $('#email').val(),
		amount: $('#amount').val(),
		v_year: $('#v_year').val(),
		v_make: $('#v_make').val(),
		v_model: $('#v_model').val()
	},
	function(data)
	{
		extras = new Object();
		extras.page_redirect = 'miniform-thankyou.php';
		
		showResult(data,'login-form',extras);
	}, 
	"json");
}


function step1_process(review) //if review is passed then it means the function is being called from the review page
{	
	 if (typeof review == "undefined"){ review = ''} //define the review variable so that no errors are thrown if the function is called without this paramter
//alert($('input:radio[name=e_paystub]:checked').val());
	$.post(SITE_ROOT+"ajax/apply_process.php",
	{ 
		operation: 'step1_process', 
		fname: $('#fname').val(),
		mname: $('#mname').val(),
		lname: $('#lname').val(),
		phone_home: $('#phone_home1').val()+$('#phone_home2').val()+$('#phone_home3').val(),
		phone_cell: $('#phone_cell1').val()+$('#phone_cell2').val()+$('#phone_cell3').val(),
		email: $('#email').val(),
		email2: $('#email2').val(),
		promo_code : $('#promo_code').val(),
		how_hear : $('#how_hear').val(),
		how_hear_other : $('#how_hear_other').val(),
		promo_code : $('#promo_code').val(),
		lic_state: $('#lic_state').val(),
		dob1: $('#dob1').val(),
		dob2: $('#dob2').val(),
		dob3: $('#dob3').val(),	
		expires1: $('#expires1').val(),
		expires2: $('#expires2').val(),
		expires3: $('#expires3').val(),
		ssn: $('#ssn1').val()+$('#ssn2').val()+$('#ssn3').val(),
		ssn1 : $('#ssn1').val(),
		ssn2 : $('#ssn2').val(),
		ssn3 : $('#ssn3').val(),
		lic_number: $('#lic_number').val(),
		loan_reason: $('#loan_reason').val(),
		explain : $('#explain').val(),
		amount: $('#amount').val(),
		e_employed: ($('input:radio[name=e_employed]:checked').val() != 'undefined' ? $('input:radio[name=e_employed]:checked').val() : ''),
		e_name: $('#e_name').val(),
		e_address: $('#e_address').val(),
		e_address2: $('#e_address2').val(),
		e_name: $('#e_name').val(),
		e_city: $('#e_city').val(),
		e_state: $('#e_state').val(),
		e_zip: $('#e_zip').val(),
		e_income_source: $('#e_income_source').val(),
		//e_time: $('#e_time').val(),
		e_time_years: $('#e_time_years').val(),
		e_time_months: $('#e_time_months').val(),
		e_income: $('#e_income').val(),
		e_paystub: ($('input:radio[name=e_paystub]:checked').val() != 'undefined' ? $('input:radio[name=e_paystub]:checked').val() : ''),
		review: review
	},
	function(data)
	{
		extras = new Object();
		
		if(review=='personal_info')
		{
			//alert('updated personal info. save and then update the data');
			if(data[0].result=='success')
			{	
				$('#personal_info_edit').slideUp();
				update1();
				$('#personal_info').slideDown();
			}
			extras.dont_hide_form ='1';
			extras.dont_reset_form ='1';
			extras.dont_scroll ='1';
			showResult(data,'personalInfo',extras);
		}
		else if(review=='employment_info')
		{
			//alert('updated personal info. save and then update the data');
			if(data[0].result=='success')
			{	
				update3();
				$('#employment_info').slideDown();
				$('#employment_info_edit').slideUp();
			}
			extras.dont_hide_form ='1';
			extras.dont_reset_form ='1';
			extras.dont_scroll ='1';
			showResult(data,'employmentInfo',extras);
		}
		else //means its in the step process
		{
			extras.step_content = "application/step2.php";
			if(data[0].result=='success')
			{
				set_active_step(2);
			}
			showResult(data,'thisForm',extras);
		}
	}, 
	"json");
}

function step2_process(review)
{
	 if (typeof review == "undefined"){ review = ''} //define the review variable so that no errors are thrown if the function is called without this paramter
	//alert(($('input:radio[name=own_or_rent]:checked').val() != 'undefined' ? $('input:radio[name=own_or_rent]:checked').val() : ''));
	$.post(SITE_ROOT+"ajax/apply_process.php",
	{ 
		operation: 'step2_process', 
		address: $('#address').val(),
		address2: $('#address2').val(),
		city: $('#city').val(),
		zip: $('#zip').val(),
		state: $('#state').val(),
		//curr_residence_time: $('#curr_residence_time').val(),
		curr_residence_time_years: $('#curr_residence_time_years').val(),
		curr_residence_time_months: $('#curr_residence_time_months').val(),
		own_or_rent: ($('input:radio[name=own_or_rent]:checked').val() != 'undefined' ? $('input:radio[name=own_or_rent]:checked').val() : ''),
		other: $('#other').val(),
		landlord_name: $('#landlord_name').val(),	
		landlord_phone: $('#landlord_phone1').val()+$('#landlord_phone2').val()+$('#landlord_phone3').val(),
		bill_phone: ($('input:radio[name=bill_phone]:checked').val() != 'undefined' ? $('input:radio[name=bill_phone]:checked').val() : ''),
		bill_electric: ($('input:radio[name=bill_electric]:checked').val() != 'undefined' ? $('input:radio[name=bill_electric]:checked').val() : ''),
		bill_cable: ($('input:radio[name=bill_cable]:checked').val() != 'undefined' ? $('input:radio[name=bill_cable]:checked').val() : ''),
		bill_water: ($('input:radio[name=bill_water]:checked').val() != 'undefined' ? $('input:radio[name=bill_water]:checked').val() : ''),
		bill_mortgage: ($('input:radio[name=bill_mortgage]:checked').val() != 'undefined' ? $('input:radio[name=bill_mortgage]:checked').val() : ''),
		bill_property_taxes: ($('input:radio[name=bill_property_taxes]:checked').val() != 'undefined' ? $('input:radio[name=bill_property_taxes]:checked').val() : ''),
		bill_signed_lease: ($('input:radio[name=bill_signed_lease]:checked').val() != 'undefined' ? $('input:radio[name=bill_signed_lease]:checked').val() : ''),
		bill_cell: ($('input:radio[name=bill_cell]:checked').val() != 'undefined' ? $('input:radio[name=bill_cell]:checked').val() : ''),
		bill_bank_statement: ($('input:radio[name=bill_bank_statement]:checked').val() != 'undefined' ? $('input:radio[name=bill_bank_statement]:checked').val() : ''),
		bill_credit_card_statement: ($('input:radio[name=bill_credit_card_statement]:checked').val() != 'undefined' ? $('input:radio[name=bill_credit_card_statement]:checked').val() : ''),
		bill_government_mail: ($('input:radio[name=bill_government_mail]:checked').val() != 'undefined' ? $('input:radio[name=bill_government_mail]:checked').val() : '')
	},
	function(data){
		extras = new Object();
		
		if(review=='residential_info')
		{
			//alert('updated personal info. save and then update the data');
			if(data[0].result=='success')
			{	
				update2();
				$('#residential_info').slideDown();
				$('#residential_info_edit').slideUp();				
			}
			extras.dont_scroll ='1';
			extras.dont_hide_form ='1';
			extras.dont_reset_form ='1';
			showResult(data,'residentialInfo',extras);
		}
		else //means its in the step process
		{
			//extras.step_content = "application/step3.php";
			extras.function_name = "step2_function";
			showResult(data,'thisForm',extras);
		}
		
	}, 
	"json");

}

function step3_process(review)
{
	 if (typeof review == "undefined"){ review = ''} //define the review variable so that no errors are thrown if the function is called without this paramter

	$.post(SITE_ROOT+"ajax/apply_process.php",
	{ 
		operation: 'step3_process', 
		v_year: $('#v_year').val(),
		v_make: $('#v_make').val(),
		v_model: $('#v_model').val(),
		v_trim: $('#v_trim').val(),
		v_color: $('#v_color').val(),
		v_body: $('#v_body').val(),
		v_plate_num: $('#v_plate_num').val(),
		v_title_num: $('#v_title_num').val(),	
		v_name: $('#v_name').val(),
		v_title_state: $('#v_title_state').val(),
		v_mileage: $('#v_mileage').val(),
		v_vin: $('#v_vin').val()		
	},
	function(data){
		extras = new Object();
		if(review=='vehicle_info')
		{
			//alert('updated personal info. save and then update the data');
			if(data[0].result=='success')
			{	
				update4();
				$('#vehicle_info').slideDown();
				$('#vehicle_info_edit').slideUp();				
			}
			extras.dont_hide_form ='1';
			extras.dont_scroll ='1';
			extras.dont_reset_form ='1';
			showResult(data,'vehicleInfo',extras);
		}
		else //means its in the step process
		{
			extras.step_content = "application/step4.php";
			if(data[0].result=='success')
			{
				set_active_step(4);
			}
			showResult(data,'thisForm',extras);
		}

	}, 
	"json");
}

function step4_process()
{
	 if (typeof review == "undefined"){ review = ''} //define the review variable so that no errors are thrown if the function is called without this paramter

	$.post(SITE_ROOT+"ajax/apply_process.php",
	{ 
		operation: 'step4_process', 
		terms_init1: $('#terms_init1').val(),
		terms_init2: $('#terms_init2').val(),
		terms_init3: $('#terms_init3').val(),
		terms_init4: $('#terms_init4').val(),
		terms_init5: $('#terms_init5').val(),
		terms_agree1: $('#terms_agree1').val(),		
		terms_agree2: $('#terms_agree2').val(),		
		terms_agree3: $('#terms_agree3').val(),		
		terms_agree4: $('#terms_agree4').val(),		
		terms_agree5: $('#terms_agree5').val()	
	},
	function(data){
		extras = new Object();

		extras.function_name = "step4_function";
		showResult(data,'thisForm',extras);
	}, 
	"json");
}

function step5_process()
{
	$('#submitBtn').hide();
	$('#processingGif').show();
	
	$.post(SITE_ROOT+"ajax/apply_process.php",
	{ 
		operation: 'step5_process'
	},
	function(data){
		if(data[0].result=="success")
		{
			document.location = SITE_ROOT+'application/thankYou.php';
		}
		else
		{
			$('#submitBtn').show();
			$('#processingGif').hide();
		}
	}, 
	"json");
}

function getStep(step_to_get) //for getting a step without having to go through the showResult function(ex: going to prev step or initilizing)
{
	$('#step_content').slideUp();
	
	$.ajax({
  		url: SITE_ROOT+'application/step'+step_to_get+'.php',
  		success: function(data) 
  		{
    		//alert('getSTEP:application/step'+step_to_get+'.php');
			_gaq.push(['_trackPageview', '/application/step'+step_to_get+'.php']);

    		$('#step_content').html(data);
    		$('#step_content').slideDown(); //its originally hidden for this animation to work   

			set_active_step(step_to_get);			    		

  		}
	});
}

function set_active_step(step_to_get)
{
	//set to active class the step we retrieved
	for ( var i=0;i<=6;i++) //6 steps so do this six tims
	{
		$('#step'+i).removeClass('active approved'); //remove all active classes				
		
		if(step_to_get < i){ $('#step'+i).addClass('step'+i); } //if step is higher add inactive step class
		else if (step_to_get > i){ $('#step'+i).removeClass('step'+i).addClass('approved'); } //if step is lower add the approved class
		
		if(i==step_to_get) { $('#step'+i).addClass('step'+i+' active'); }//check this is the step we just retrieved, if so add active class
	}
}

function employed(employed_status)
{
	if(employed_status != 'Yes')
	{
		//disable all inputs in the employedInfo form
		//$("#employmentInfo :input").attr("disabled", true);
		$("#not_employed_div").slideDown();
		$("#employed_div").slideUp();//.attr("disabled", true);
	}
	else
	{
		//enable all fields in the employedInfo form
		//$("#employmentInfo :input").attr("disabled", false);
		$("#not_employed_div").slideUp();
		$("#employed_div").slideDown();//.attr("disabled", true);
	}
}


//this is for updating the values on the review page
function update1() //copies the values from the form to the html place holders
{
	$('#f-full-name').html($('#fname').val()+' '+$('#mname').val()+' '+$('#lname').val());
	$('#f-home-phone').html($('#phone_home1').val()+'-'+$('#phone_home2').val()+'-'+$('#phone_home3').val());
	$('#f-email').html($('#email').val());
	$('#f-promo_code').html($('#promo_code').val());
	
	if($('#loan_reason').val()=='Other')
	{
		$('#f-explain').html('('+$('#explain').val()+')');
	}
	else
	{
		$('#f-explain').html('');
	}	
	
	$('#f-reason').html($('#loan_reason').val());
	$('#f-amount').html($('#amount').val());
	$('#f-lic_number').html($('#lic_number').val());
	$('#f-lic_state').html($('#lic_state').val());		
	$('#f-dob').html($('#dob1').val()+'/'+$('#dob2').val()+'/'+$('#dob3').val());
	$('#f-expires').html($('#expires1').val()+'/'+$('#expires2').val()+'/'+$('#expires3').val());
	$('#f-ssn').html($('#ssn1').val()+'-'+$('#ssn2').val()+'-'+$('#ssn3').val());
	
	if($('#how_hear').val() != 'Other')
	{
		$('#f-how_hear').html($('#how_hear').val());
	}
	else
	{
		$('#f-how_hear').html($('#how_hear').val()+'('+$('#how_hear_other').val()+')');
	}
	
	if($('#phone_cell1').val() != '') //only populate the secondary phone if there is one
	{
		$('#f-cell-phone').html($('#phone_cell1').val()+'-'+$('#phone_cell2').val()+'-'+$('#phone_cell3').val()+' - secondary');
	}
	else
	{
		$('#f-cell-phone').html('');
	}

}

function update2() //copies the values from the form to the html place holders
{
	$('#f-address').html($('#address').val()+' '+$('#address2').val());
	$('#f-city-state').html($('#city').val()+' '+$('#state').val());
	$('#f-zip').html($('#zip').val());	
	$('#f-landlord-name').html($('#landlord_name').val());
	$('#f-landlord-phone').html($('#landlord_phone1').val()+'-'+$('#landlord_phone2').val()+'-'+$('#landlord_phone3').val());
	$('#f_curr-residence-time').html($('#curr_residence_time_years').val() + ' years and ' + $('#curr_residence_time_months').val() + ' months');
	
	if($('input:radio[name=bill_electric]:checked').val()=='1'){ $('#bill-electric').html('Yes'); } else{$('#bill-electric').html('No');}
	if($('input:radio[name=bill_phone]:checked').val()=='1'){ $('#bill-phone').html('Yes'); } else{$('#bill-phone').html('No');}
	if($('input:radio[name=bill_cable]:checked').val()=='1'){ $('#bill-cable').html('Yes'); } else{$('#bill-cable').html('No');}
	if($('input:radio[name=bill_water]:checked').val()=='1'){ $('#bill-water').html('Yes'); } else{$('#bill-water').html('No');}
	if($('input:radio[name=bill_mortgage]:checked').val()=='1'){ $('#bill-mortgage').html('Yes'); } else{$('#bill-mortgage').html('No');}
	if($('input:radio[name=bill_property_taxes]:checked').val()=='1'){ $('#bill-property-taxes').html('Yes'); } else{$('#bill-property-taxes').html('No');}
	
	if($('input:radio[name=bill_signed_lease]:checked').val()=='1'){ $('#bill-signed-lease').html('Yes'); } else{$('#bill-signed-lease').html('No');}
	
	if($('input:radio[name=bill_cell]:checked').val()=='1'){ $('#bill-cell').html('Yes'); } else{$('#bill-cell').html('No');}
	
	if($('input:radio[name=bill_bank_statement]:checked').val()=='1'){ $('#bill-bank-statement').html('Yes'); } else{$('#bill-bank-statement').html('No');}
	
	if($('input:radio[name=bill_credit_card_statement]:checked').val()=='1'){ $('#bill-credit-card-statement').html('Yes'); } else{$('#bill-credit-card-statement').html('No');}
	
	if($('input:radio[name=bill_government_mail]:checked').val()=='1'){ $('#bill-government-mail').html('Yes'); } else{$('#bill-government-mail').html('No');}	
}

function update3() //copies the values from the form to the html place holders
{
	if($('input:radio[name=e_employed]:checked').val() == 'Yes')
	{
		$('#f-e-full-address').html($('#e_address').val()+' '+$('#e_address2').val());
		$('#f-e-name').html($('#e_name').val());
		$('#f-e-zip').html($('#e_zip').val());
		$('#f-e-time-years').html($('#e_time_years').val());
		$('#f-e-time-months').html($('#e_time_months').val());
		$('#f-e-income').html($('#e_income').val());
		$('#f-e-paystub').html( $('input:radio[name=e_paystub]:checked').val());
		$('#f-e-city-state').html($('#e_city').val()+' '+$('#e_state').val());
		$('.e_is_working').show();

	}
	else
	{
		$('#f-e-full-address').html($('input:radio[name=e_employed]:checked').val());
		$('#f-e-name').html('');
		$('#f-e-zip').html('');
		$('#f-e-time').html('N/A');
		$('#f-e-income').html('N/A');
		$('#f-e-paystub').html('N/A');
		$('#f-e-city-state').html('');
		
		//hide fields
		$('.e_is_working').hide();
	}
}

function update4()
{
		$('#f-v-year-make-model').html($('#v_year').val()+' '+$('#v_make').val()+' '+$('#v_model').val());
		$('#f-v-trim').html($('#v_trim').val());
		$('#f-v-body').html($('#v_body').val());
		$('#f-v-color').html($('#v_color').val());
		$('#f-v-plate-num').html($('#v_plate_num').val());
		$('#f-v-title-num').html($('#v_title_num').val());
		$('#f-v-name').html($('#v_name').val());
		$('#f-v-title-state').html($('#v_title_state').val());
		$('#f-v-mileage').html($('#v_mileage').val());
		$('#f-v-vin').html($('#v_vin').val());
		$('#f-v-title_num').html($('#v_title_num').val());
}

//webservice calls
function getMakes()
{
	var has_data = false; //a flag that will get set if it returned something.
	
	$.ajax({
		url: 		SITE_ROOT+"ajax/apply_process.php",
		data:		{ 
						operation: 'getMakes', 
						v_year: $('#v_year').val()
					},	
  		success: 	function(data){
  						$('#v_make').append('<option value="" class="">Select Make</option>');
    					for(var i in data['makes'])
						{
							has_data = true;
						    $('#v_make').append('<option value="'+data['makes'][i]+'">'+data['makes'][i]+'</option>');

						}
						//enable the select
						$('#v_make').removeAttr('disabled');
  					},
  		dataType: 	"json",
  		async:		false,
  		type: 		"POST"
	});
	
	return has_data;
}

function getModels()
{
	var has_data = false; //a flag that will get set if it returned something.

	$.ajax({
		url: 		SITE_ROOT+"ajax/apply_process.php",
		data:		{ 
						operation: 'getModels', 
						v_year: $('#v_year').val(),
						v_make: $('#v_make').val()
					},	
  		success: 	function(data){
  						$('#v_model').append('<option value="" class="">Select Model</option>');
						for(var i in data['models'])
						{
							has_data = true;
							//alert(data['makes'][i]);
   						    $('#v_model').append('<option value="'+data['models'][i]+'">'+data['models'][i]+'</option>');
						}
						$('#v_model').removeAttr('disabled');

  					},
  		dataType: 	"json",
  		async:		false,
  		type: 		"POST"
	});
	
	return has_data;
}

function getTrims()
{		
	var has_data = false; //a flag that will get set if it returned something.

	$.ajax({
		url: 		SITE_ROOT+"ajax/apply_process.php",
		data:		{ 
						operation: 'getSeries', 
						v_year: $('#v_year').val(),
						v_make: $('#v_make').val(),
						v_model: $('#v_model').val()
					},	
  		success: 	function(data){
						 //append makes
					    var has_trims = false; // a flag that gets set if there are trims.
						for(var i in data['trims'])
						{
							has_trims = true;
							has_data = true;
   						    $('#v_trim').append('<option value="'+data['trims'][i]+'">'+data['trims'][i]+'</option>');
							$('#v_trim').removeAttr('disabled');
						}
					
						if(has_trims == false) //there are no trims so get body styles
						{
							//alert('no trims available, set NA and call get body');
							getBody();
   						    $('#v_trim').append('<option value="">N/A</option>');
   						    $('#v_trim').val('');
						}
						if(has_trims == true)
						{
							$('#v_trim').append('<option value="">Select Trim</option>');
							$('#v_trim').val('');
						}
  					},
  		dataType: 	"json",
  		async:		false,
  		type: 		"POST"
	});

	return has_data;

}

function getBody()
{		
	var has_data = false; //a flag that will get set if it returned something.

	$.ajax({
		url: 		SITE_ROOT+"ajax/apply_process.php",
		data:		{ 
						operation: 'getBody', 
						v_year: $('#v_year').val(),
						v_make: $('#v_make').val(),
						v_model: $('#v_model').val(),
						v_trim: $('#v_trim').val()
					},	
  		success: 	function(data){
						 //append makes
						 var has_data=false;
						for(var i in data['body'])
						{
							has_data = true;
  						    $('#v_body').append('<option value="'+data['body'][i]+'">'+data['body'][i]+'</option>');
				   			$('#v_body').removeAttr('disabled');
						}
		
						if(has_data != true) //there are no trims so get body styles
						{
							$('#v_body').append('<option value="">N/A</option>');
   						    $('#v_body').val('');
						}
						if(has_data == true)
						{
							$('#v_body').append('<option value="">Select Body Style</option>');
							$('#v_body').val('');
						}
						
  					},
  		dataType: 	"json",
  		async:		false,
  		type: 		"POST"
	});
	
	return has_data;
}


function clearDropdowns(changing) //the option being changed
{
	$('#v_body').attr('disabled','disabled').empty(); //.append('<option selected="selected" value="">Select Body Style</option>'); 
	if(changing == 'trim') { return; }
	
	$('#v_trim').attr('disabled','disabled').empty(); //.append('<option selected="selected" value="">Select Trim</option>'); 
	if(changing == 'model') { return; }
	
	$('#v_model').attr('disabled','disabled').empty(); //.append('<option selected="selected" value="">Select Model</option>'); 
	if(changing == 'make') { return; }
	
	$('#v_make').attr('disabled','disabled').empty(); //.append('<option selected="selected" value="">Select Make</option>'); 
	if(changing == 'year') { return; }

}

function preselect_vehicle_info()
{
	//ajax call to get the vehicle info currently in db
	$.post(SITE_ROOT+"ajax/apply_process.php",
		{ 
			operation: 'getVehicle'
		},
		function(data){		   	
			$('#v_year').val(data[0].year); 
			
			//chain the vehicle make, model, trim and body functions so that page doesnt waste time getting info for something that doesnt have any data.
			if(getMakes())
			{
				$('#v_make').val(data[0].make); 
				if(getModels())
				{
					$('#v_model').val(data[0].model); getTrims();
					$('#v_trim').val(data[0].trim);  getBody();
					$('#v_body').val(data[0].body);
				}
			}
		},
		"json");
}

//callbacks for show results
function step2_function()
{
	set_active_step(3); //set step3 active

	//load page via ajax:
	//taken from main.js
	$("#step_content").hide();	//this has to stay the same because this is where the forms are being loaded into
	
	$("#step_content").load(SITE_ROOT+'application/step3.php',function(){
		//alert("step2:'application/step3.php'");
		_gaq.push(['_trackPageview', '/application/step3.php']);

    	if($('#'+'thisForm'+' .btnSubmit').length > 0) $('#'+'thisForm'+ ' .btnSubmit').show();
    	if($('#'+'thisForm'+' .processing').length > 0) $('#'+'thisForm'+' .processing').hide();
   		$(".tipTip").tipTip(); //initialize the tooltip after the load has been done
    	$("#step_content").slideDown('fast',function(){ preselect_vehicle_info() }); //after step slides down populate the vehicle info  
    });
}

function step4_function()
{
	set_active_step(5); //set step3 active

	//load page via ajax:
	//taken from main.js
	$("#step_content").hide();	//this has to stay the same because this is where the forms are being loaded into
	
	$("#step_content").load(SITE_ROOT+'application/step5.php',function(){
		//alert("step4:'application/step5.php'");
		_gaq.push(['_trackPageview', '/application/step5.php']);

    	if($('#'+'thisForm'+' .btnSubmit').length > 0) $('#'+'thisForm'+ ' .btnSubmit').show();
    	if($('#'+'thisForm'+' .processing').length > 0) $('#'+'thisForm'+' .processing').hide();
    	$("#step_content").slideDown('fast',function(){ preselect_vehicle_info() }); //after step slides down populate the vehicle info  
    });
}





var active_color = '#000'; // Colour of user provided text
var inactive_color = '#ccc'; // Colour of default text

/**
 * No need to modify anything below this line
 */

$(document).ready(function() {
  $("input.dob").css("color", inactive_color);
  var default_values = new Array();
  $("input.dob").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  });
});


//for doing something as you type
var timeoutHnd;
function doLoad()
{
	if(timeoutHnd)	clearTimeout(timeoutHnd)
	{
		timeoutHnd = setTimeout('dbsearch()',1000)
	}
}

function dbsearch()
{
	if($('#promo_code').val()!='')
	{
		 $.post(SITE_ROOT+"ajax/apply_process.php", 
		 { 
		 	operation: "checkPromoCode",
		 	promo_code: $("#promo_code").val()  
		 }, 
		 function (data) 
		 {
			//DO NOTHING....$('#code_msg').html(data.msg);
		 },'json');
	}
	else
	{
		$('#code_msg').html('');
	}
}

function checkHowHear()
{
	if($('#how_hear').val()=='Other')
	{
		//alert('slide down the how hear');
		$('#how_hear_other').slideDown();
	} 
	else
	{
		//alert('slide up the how hear');
		$('#how_hear_other').slideUp();
	}
}


