/*******************************************************************************
* Title:		Crystal Mortgages						                       *
* Date:			2010-05-17                                                     *
* Author:		Jason Lemm <jason@vividual.co.uk>                              *
* Copyright:	©2010 Vividual                                                 *
*******************************************************************************/

function checkContactForm(){
	var t = false;
	$("[class*=f_req]").each(function(){
		if($(this).val()=='')
			t = true;
	});

	return t;
}



$(document).ready(function(){
	//$(document).pngFix();	

	$("img#chat").tooltip({ position: "bottom center", effect: 'slide', slideOffset: -15, offset: [-30,0]});
	//$("#submitContact").tooltip({ position: "bottom center", effect: 'slide', slideOffset: -15, offset: [-20,0]});


	/*$("[class*=f_req]").mouseenter(function(){
		if(checkContactForm()==true){

		}
	}
	
	$("#submitArea").mouseenter(function(){
		if(checkContactForm()==true){
			$("#submitContact").attr("title",'Please check and complete<br />the above form before<br />submitting your query');
	$("#submitContact").tooltip({
		position: "bottom center",
		effect: 'slide',
		slideOffset: -15,
		offset: [-20,0]
	});		
		} else {
			$("#submitContact").attr("title",'blah');
	$("#submitContact").tooltip({
		position: "bottom center",
		effect: 'slide',
		slideOffset: -15,
		offset: [-20,0]
	});		}
	});*/

	$("select#form-loan").change(function(){
		if($(this).val()=='Other'){
			$("input#form-other").fadeIn(250,function(){
				$(this).focus();
			});
		} else
			$("input#form-other").fadeOut(250);
	});


	jQuery.preloadImages = function() {   
		for(var i = 0; i<arguments.length; i++){
			  jQuery("<img>").attr("src", arguments[i]);   
		}
	}

	$.preloadImages(
		"images/hero-1.jpg",
		"images/hero-2.jpg",
		"images/hero-3.jpg",
		"images/hero-4.jpg",
		"images/hero-5.jpg"
	); 

	if($('#hero .image_rotate li').length>1){
		$('#hero .image_rotate').innerfade({ 
			animationtype: 'fade',
			speed: 'slow', 
			timeout: 5000, 
			type: 'sequence'
		});
	} else {
		$('#hero .image_rotate li').show();
	}

	if($('#quick-understanding .image_rotate li').length>1){
		$('#quick-understanding .image_rotate').innerfade({ 
			animationtype: 'fade',
			speed: 'medium', 
			timeout: 15000, 
			type: 'random'
		});
	} else {
		$('#quick-understanding .image_rotate li').show();
	}
});
