//Testimonial Cycle Function
function cycleTestimonials(){
		if($("#cycle_1").css("display") == "block"){
			$("#cycle_1").fadeOut("slow",function(){
				$("#cycle_1").css("display","none");
				$("#cycle_2").fadeIn("slow");
			});
		}
		
		if($("#cycle_2").css("display") == "block"){
			$("#cycle_2").fadeOut("slow",function(){
				$("#cycle_2").css("display","none");
				$("#cycle_3").fadeIn("slow");
			});
		}
		
		if($("#cycle_3").css("display") == "block"){
			$("#cycle_3").fadeOut("slow",function(){
				$("#cycle_3").css("display","none");
				$("#cycle_4").fadeIn("slow");
			});
		}
		
		if($("#cycle_4").css("display") == "block"){
			$("#cycle_4").fadeOut("slow",function(){
				$("#cycle_4").css("display","none");
				$("#cycle_1").fadeIn("slow");
			});
		}
}



// Page Load Initialization
$(document).ready(function(){
						   
	$('a[rel=external]').attr('target','_blank');
	
	// Automatic image and input[type=image] roll-over initiation
	// Grabs all <img> tags and <input type="image"> tags with the "rollOver" class
	// and sets up rollOver and active states. Image name syntaxing:
	// image_i.gif : (_i) idle image
	// image_o.gif : (_o) over image
	// image_a.gif : (_a) active image
	$('img.rollOver, input[type=image].rollOver').mouseover(function(){
		src = $(this).attr('src');
		$(this).attr('src',src.replace('_i.','_o.'));
		
	}).mouseout(function(){
		preSrc = '_o.';
		src = $(this).attr('src');
		if($(this).attr('src').indexOf('_a.') != -1) {
			preSrc = '_a.';
		}
		$(this).attr('src',src.replace(preSrc,'_i.'));
	}).not('img').mousedown(function(){
		src = $(this).attr('src');
		$(this).attr('src',src.replace('_o.','_a.'));
	}).mouseup(function(){
		src = $(this).attr('src');
		$(this).attr('src',src.replace('_a.','_i.'));
	});
	
	$('form.validatethis').each(function(){
				ID = $(this).attr("id");
				initValidator(ID);				
	});
	setInterval("cycleTestimonials()", 5000);
});		
function submitter(){
	$('#id_submit').attr({src:'http://usarealestateloan.com/images/btn_submit_sending.gif'});
	// For Testing
	$('#id_submit').attr('disabled','disabled');
	
	$.post("http://usarealestateloan.com/contact.php",
	// For Testing
		{
			name: $('#id_name').val(),
			email: $('#id_email').val(),
			phone: $('#id_phone').val(),
			time: $('#id_time').val(),
			location: $('#id_location').val(),
			borrowamount: $('#id_borrowamount').val(),
			assist: $('#id_assist').val(),
			comments: $('#id_comments').val(),
			submit: 'yes',
			ajax: "yes"
		},
		function(data){
			if(data == "<ul id='form_errors'></ul>"){
				$('#contact_form').slideUp("slow");
				$('#mail_response').html("<p>Your information was submitted successfully!</p>").slideDown("slow");
				$('#mail_response').fadeOut(12000);
				$('#thanks_response').html("<p>Thanks for taking the time to contact us. We will be in touch soon.</p>").slideDown("slow");
				//alert("It Worked!");
			}else{
				$('#contact_form_container').fadeOut("slow");
				$('#mail_response').css("background-color","#fcc").html("<p>OOPS! It looks like we had an error, please try again later or contact us directly at <a href='mailto:info@financenorthamerica.com'>info@financenorthamerica.com</a></p>").slideDown("slow");
				//alert("It No Worked!");
			}
		}
	);
	return false;
}
