function creditStepOne(){
	
	var sendForm = true;
	
	$('#credit1 input:not(.notrequired)').each(function() {
		if( $(this).val() == '' ){
			$(this).css('border-color','red');
			sendForm = false;
		}
	});
	
	if (sendForm){
		$('#credit1 input').css('border-color','#cccccc');
		
		//send info
		$.post("lead_form_ajax.asp",$('#credit1').serialize(),function(data){
			//alert(data);
			$('#credit_resend').val(data);
			if( isFinite($('#credit_resend').val()) ){
				$('#credit-step2').css('display','');
				$('#credit_b1').css('display','none');
			}
		});
		
	} else {
		alert('Please enter a value for highlighted fields.');
	}
	
	return sendForm;
}

function creditStepTwo(){
	
	//open review div/populated
	$('#credit_button2').css('display','none');
	$('#credit-step3').css('display','');
	
}

function creditStepThree(){
	
	if( $('#credit_terms').attr('checked') ){
		var formString = $('#credit1').serialize() + "&" + $('#credit2').serialize();
		
		var sendForm = true;
		$('#credit2 input,#credit2 select').each(function() {
			if( $(this).val() == '' ){
				$(this).css('border-color','red');
				sendForm = false;
			}
		});
		
		if (sendForm){
			$('#credit2 input,#credit2 select').css('border-color','#cccccc');
			if( $('#credit_terms').attr('checked') && $('#credit-review').css('display') == 'none' )
				$.post("lead_form_ajax.asp",formString,function(data){
					
					if( data.toLowerCase() == "success" ){
						$('#credit-form').css("display","none");
						$('#credit-submitted').css("display","block");
						location.href = "#top";
					}
				});
		} else {
			alert('Please enter a value for highlighted fields.');
		}
	} else {
		alert("You must accept the terms to continue.");
		
	}
}

$(document).ready(function(){
	
	$("#credit-form input,#credit-form select").change(function(){
		$(this).css("border-color","#cccccc");
	});
	$("#credit-form .numbers input").change(function(){
		if( isNaN($(this).val()) ){
			$(this).val('');
			$(this).css("border-color","red");
			alert('Please enter a number for this field.');
		}
	});
	
});