/* Scripts for Website */
/* Dependencies: jQuery 1.4.x */




/* **************************** */
/* Pre-document.ready functions */
/* **************************** */
	// Functions that must run BEFORE document.ready functions



/* ************************ */
/* Document.Ready functions */
/* ************************ */
//do stuff when DOM is ready
$(document).ready(function() {

	/* *********************** */
	/* Hacks for IE6 and below */
	/* *********************** */
	if ($.browser.msie && $.browser.version < 7 )  { 
		//attach a class to the BODY
		$('body').addClass('ieOld');
	} else {
		if ($.browser.msie && $.browser.version < 8 )  {
			//attach a class to the BODY
			$('body').addClass('ie7');
		} else {
			if ($.browser.msie) {
				//attach a class to the BODY
				$('body').addClass('ie');
			}
		}
	}


	/* ****************** */
	/* INIT for all pages */
	/* ****************** */

	// Any INIT functions for all pages
	
	// initialize the nav
	initNav();	
	
	

	/* ******************* */
	/* INIT for HOME pages */
	/* ******************* */
	if ($("body#home").length) {
		// Any home-page specific INIT functions
	
	
		// initialize the SEO Toggle
		$('#seoToggle').click(function () {
			// toggles visibility of the content
			$("#seoTextWrap").toggle();
			document.getElementById('seoTextWrap').scrollIntoView();
			return false;
		});
		
		//PopOver PopUp Thing
		$(window).resize(function() {
			$("#popOver").stop().animate({"top": $(window).height()-230}, 5000);
		});
		$("#popOver").animate({"top": $(window).height()-230}, 5000);
		$("#popOver a.closeIt").click(function(){
			$("#popOver").hide();
		});
		$("#popOver").hover(function(){ //hover stoping
			$(this).stop();
		}, function() {
		  $(this).animate({"top": $(window).height()-230}, 4000);
		});
		
	}

	
	

	/* *********************** */
	/* INIT for INTERIOR pages */
	/* *********************** */
	if ($("body#int").length) {
		// Any home-page specific INIT functions
		
	}
	
	
	
	
	
	/* ****************************** */
	/* Add'l document.ready functions */
	/* ****************************** */
	
		// add'l document.ready functions

});

/* *************** */
/* Add'l Functions */
/* *************** */

try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {}

var Pic = new Array();
Pic[0] = 'images/header_bg.jpg'
Pic[1] = 'images/wrap_bg.gif'

var p = Pic.length;

var preLoad = new Array();
for (r = 0; r < p; r++){
   preLoad[r] = new Image();
   preLoad[r].src = Pic[r];
}

images = new Array();
images[0]='home'
images[1]='new'
images[2]='used'
images[3]='specials'
images[4]='credit'
images[5]='consign'
images[6]='trade'
images[7]='parts'
images[8]='staff'
images[9]='contact'
images[10]='canada'

var j=0;
var navImg = new Array;
var navImgo = new Array;
for(j=0; j<images.length; j++) 
{
	navImg[j] = new Image();
	navImg[j].src='images/nav_'+images[j]+'.gif';
	navImgo[j] = new Image();
	navImgo[j].src='images/nav_'+images[j]+'_live.gif';
}

function navOver(i) {
	document.getElementById("nav"+i).src = navImgo[i].src;
}

function navOff(i) {
	document.getElementById("nav"+i).src = navImg[i].src;
}
function initNav() {
	var x = [];
	for(var i=0;i<images.length;i++)
	{
		x[i] = document.getElementById("nav"+i);
		if(x[i]){
			x[i].onmouseover = function () {navOver(this.id.substr(3))}
			x[i].onmouseout = function () {navOff(this.id.substr(3))}
		}
	}
}

function popVid(URL,w,h) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+w+",height="+h+"');");
}









/* ***************** */
/* Utility Functions */
/* ***************** */


/* Console Logging for debugging help
 * ==================================
 * 	USE:  
 * 		jQuery.log('my message') or $.log('my message') 
 */
;jQuery.log = function(message) {
  try {
     console.debug(message);
  } catch(e) {
	  try {
		console.log(message);
	  } catch(e) {
		alert(message);
	  }
  }
};





/* ******************* */
/* 3rd Party Functions */
/*      (plug-ins)     */
/* ******************* */










