/* ---------------------------------------------------- */
/* JQuery												*/
/* ---------------------------------------------------- */
$(document).ready(function() 
{
	
	/* ---------------------------------------------------- */
	/* jQuery cookie system								    */
	/* ---------------------------------------------------- */
	/* Get the homepage overlay cookie, if present */
	//var cookie = $jQuery.cookie('show-homepage-overlay-130809');
	
	/* ####### Cookie system that only shows again when a code is changed ########## */
	/* Create a code (date), so the cookies can be forced to expire when the used vehicles are updated */
	//var cookie_code = '230209';
	/* 	If there's no cookie present, or the value of the cookie doesn't match the code,
		run the show overlay function and set the cookie, so it doesn't show again */
	//if (!cookie || cookie != cookie_code )
	//{
		/* Hide the 4 homepage divs and show the Used Car Offer overlay, the fade back to normal */
		//show_overlay_system();
		/* Set Cookie */
		//$jQuery.cookie('show-homepage-overlay', cookie_code);
	//}

	/* ####### Cookie system that displays once per day ########## */
	
	//if (!cookie )
	//{
		/* Hide the 4 homepage divs and show the overlay instead, the fade back to the normal 4 divs */
		// commented temporarily while offers show
	//	show_overlay_system();
		/* Set a Cookie which will expire after 1 day */
	//	$jQuery.cookie('show-homepage-overlay-130809', { expires: 1});
	//}
	/* Uncomment this next line to always show the overlay system (for testing purposes) */
	//show_overlay_system();	
	
	
	/* ---------------------------------------------------- */
	/* Does the FadIn and fadeOut on Summary Images 	    */
	/* ---------------------------------------------------- */
	$jQuery("#home_box1").hoverShade();
	$jQuery("#home_box2").hoverShade();
	$jQuery("#home_box3").hoverShade();
	$jQuery("#home_box4").hoverShade();
	$jQuery("#home_box5").hoverShade();
	$jQuery("#home_box6").hoverShade();
	
	
});


/* ---------------------------------------------------- */
/* Hides and shows appropriate divs                     */
/* ---------------------------------------------------- */
function show_overlay_system() 
{
	$jQuery("div#overlay1").fadeIn(800);
	$jQuery("div#home_box1").hide();
	$jQuery("div#home_box2").hide();
	$jQuery("div#home_box4").hide();
	$jQuery("div#home_box5").hide();
	
	
	window.setTimeout(function() {
		$("div#overlay1").fadeOut(1000, function() {
			$jQuery("div#home_box1").fadeIn(800);
			$jQuery("div#home_box2").fadeIn(800);
			$jQuery("div#home_box4").fadeIn(800);
			$jQuery("div#home_box5").fadeIn(800);
		});		
	}, 7000);
	
}