//////////////////////////////////////////////////////////////////////////
/* ------------------------      VARIABLES      ----------------------- */
var hovercolor   = "#FFFFFF";	// color name/code
var bgcolor      = "#FFFFFF";	// color name/code
var background   = "";			// picture url // currently not used
var arrow_pic    = "http://www.heatheringtonconsulting.com/images/drop_arrow.gif"; // url of arrow picture for submenus
var arrow_pic2    = "http://www.heatheringtonconsulting.com/images/drop_arrow_reverse.gif"; // url of arrow picture for submenus at the very right end of the page
var shimLocation = "http://www.heatheringtonconsulting.com/images/spacer.gif";
var arrow = "&nbsp;&nbsp;<IMG SRC='"+arrow_pic+"' BORDER=0 ALT=''>";
var arrow2 = "<IMG SRC='"+arrow_pic2+"' BORDER=0 ALT=''>&nbsp;&nbsp;";
var breakSpacer = '<TR><TD><IMG SRC="http://www.heatheringtonconsulting.com/images/spacer.gif" HEIGHT="1" WIDTH="110" BORDER="0" ALT=""></TD></TR>';
var borderSpacer = '<IMG SRC="http://www.heatheringtonconsulting.com/images/spacer.gif.com" HEIGHT="1" WIDTH="1" BORDER="0" ALT="">';
//////////////////////////////////////////////////////////////////////////

var No3 = (parseInt(navigator.appVersion) > 3) ? 1:0;
var isMac45 = (navigator.userAgent == "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)") ? 1:0;
var layer = "";
if(document.all && No3){layer = "document.all['L'+menu].style";}
if(document.getElementById){layer = "document.getElementById('L'+menu).style";}
else if(document.layers && No3){layer = "document.layers['L'+menu]";}
else{layer=0;}
var timer;
var Layer = new Array();

function Show() { if(layer) {
	if(timer) clearTimeout(timer);
	for(menu=0; menu<Layer.length; menu++)  { if(Layer[menu] && Layer[menu].isVis) { eval(layer).visibility = "hidden"; } }

	for(i=0; i<arguments.length; i++) { menu=arguments[i]; eval(layer).visibility = "visible"; Layer[menu].isVis = true; }
} }
function Hide() { 
	if(timer) clearTimeout(timer);
	timer = setTimeout("Show()", 500);
}
function highlight(layerId) {  //alert("hey")
	if(document.getElementById || document.all){
		layer.backgroundColor=hovercolor;
		//alert(layer.backgroundColor);
	}
	//document.all[layerId].style.backgroundColor=linkOverColor;
	//document.all[layerId].style.color=linkOverTextColor;
}
function unhighlight(layerId) {
	if(document.getElementById || document.all){
		layer.backgroundColor=bgcolor;
	}
}

function LayerSpecs(ID,Left,Top,Width,isSub) { if(No3) {
	this.ID = ID;
	this.left  = Left;
	this.top   = Top;
	this.info = "";
        this.width = Width;
	this.isVis = false;
	this.isSub = false;
	if (isSub) { this.isSub = true; }
	T=0;
	counter=0;
	for(i=5; i<arguments.length; i++) {
		var subMenuJSOver = "", subMenuJSOut = "";
		if (arguments[i].subMenuID != null) { subMenuJSOver = " Show(" + ID + "," + arguments[i].subMenuID + ");"; 
		//subMenuJSOut = " Hide(" + ID + ");";
		}  else if (!isSub) { subMenuJSOver = " Show(" + ID + ");"; }
		var hoverJS = (isMac45) ? " onMouseOver='highlight("+ID+"_"+counter+");" + subMenuJSOver + "' onMouseOut='unhighlight("+ID+"_"+counter+");" + subMenuJSOut + "'" : " onMouseOver='this.bgColor=\"" + arguments[i].hoverColor + "\";" + subMenuJSOver + "' onMouseOut='this.bgColor=\"" + arguments[i].bgColor + "\";" + subMenuJSOut + "'";
		var index = arguments[i].content.toUpperCase().indexOf("HREF=\"");
		var index2 = arguments[i].content.indexOf("\"",index+6);
		if (index != -1 && index2 != -1) { index += 6; hoverJS += " onClick=\"document.location.href='" + arguments[i].content.slice(index, index2).replace(new RegExp("'","g"),"\\'") + "';\""; }

		if (arguments[i].type == "break") {
			if (isMac45) {}
			else if(document.getElementById || document.all) { this.info += "<TR><TD WIDTH="+Width+" onMouseOver=\""+subMenuJSOver+"\" bgColor=\""+arguments[i].bgColor+"\">"+menuBreak(Width,1)+"</TD></TR>"; }
			else { this.info += "<LAYER WIDTH="+Width+" onMouseOver=\""+subMenuJSOver+"\" POSITION=RELATIVE TOP="+T+" bgColor=\""+arguments[i].bgColor+"\">"+menuBreak(Width,1)+"</LAYER>"; }
			T+=1;
		} else if (arguments[i].type == "header"){ /* default for a link */
			//if (isMac45) { this.info += "<DIV style=\"position:relative; left:0; top:0;  background-color:" + arguments[i].bgColor + "; width:" + Width + "px;\" "+hoverJS+" CLASS='navLink'>&nbsp;"+arguments[i].content+"</DIV>"; }

			if (isMac45) { this.info += "<DIV id=\""+ID+"_"+counter+"\" style=\"position:relative; left:0; top:0;  background-color:" + arguments[i].bgColor + "; width:" + Width + "px;\" "+hoverJS+" CLASS='header'>&nbsp;<A HREF=\"#\" CLASS=\"header\">"+arguments[i].content+"</A></DIV>"; }
			else if(document.getElementById || document.all) { this.info += "<TR><TD WIDTH="+Width+hoverJS+" CLASS='header' bgColor=\""+arguments[i].bgColor+"\">&nbsp;"+arguments[i].content+"</TD></TR>"; }
			else { this.info += "<LAYER WIDTH="+Width+hoverJS+" POSITION=RELATIVE TOP="+T+" CLASS='header'>&nbsp;&nbsp;"+arguments[i].content+"</LAYER>"; }
			T+=20;
		} else { /* default for a link */
			//if (isMac45) { this.info += "<DIV style=\"position:relative; left:0; top:0;  background-color:" + arguments[i].bgColor + "; width:" + Width + "px;\" "+hoverJS+" CLASS='navLink'>&nbsp;"+arguments[i].content+"</DIV>"; }

			if (isMac45) { this.info += "<DIV id=\""+ID+"_"+counter+"\" style=\"position:relative; left:0; top:0;  background-color:" + arguments[i].bgColor + "; width:" + Width + "px;\" "+hoverJS+" CLASS='navLink'>&nbsp;<A HREF=\"#\" CLASS=\"navLink\">"+arguments[i].content+"</A></DIV>"; }
			else if(document.getElementById || document.all) { this.info += "<TR><TD WIDTH="+Width+hoverJS+" CLASS='navLink' bgColor=\""+arguments[i].bgColor+"\">&nbsp;"+arguments[i].content+"</TD></TR>"; }
			else { this.info += "<LAYER WIDTH="+Width+hoverJS+" POSITION=RELATIVE TOP="+T+" CLASS='navLink'>&nbsp;&nbsp;"+arguments[i].content+"</LAYER>";}
			T+=15;
		}
	} 

        if (document.layers) {
           this.info += "<LAYER BGCOLOR=#000000 WIDTH="+Width+" POSITION=RELATIVE TOP="+T+">"+borderSpacer+"</LAYER>";
        }
} }

function menuBreak(w,h) {
	return "<div id=\"br\"><img src=\""+ shimLocation +"\" width=\"" + w + "\" height=\""+ h +"\" alt=\"\"></div>";
}

function menuItem(content,type,bgColor,hoverColor,subMenuID) {
	/* DEFAULTS */
	if (!type) { type = "link"; }
	if (!bgColor) { bgColor = bgcolor; }
	if (!hoverColor) { hoverColor = hovercolor; }
	this.content = content;
	this.type = type;
	this.bgColor = bgColor;
	this.hoverColor = hoverColor;
	this.subMenuID = subMenuID;
}

////////////////////////////////////////////////////////////////
/// call this when the Layer array is constructed
////////////////////////////////////////////////////////////////
function createLayers() {

      var app=null;
      if(navigator.appName == "Netscape" && document.layers != null && navigator.appVersion.charAt(0)=="4") app="N";
      else if(navigator.appName == "Microsoft Internet Explorer" && document.all != null) app="E";
      else if(navigator.appName == "Netscape" && document.getElementById != null && navigator.appVersion.charAt(0)=="5") app="N5";

	// Link the propper CSS file depending on the browsers. This is necessary for the way that netscape and ie 4 handle fonts on the macintosh.


	var j = (Layer[0]) ? 0:1;
// put the table variable declaration here

        var borderTableStart = '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD COLSPAN="3" BGCOLOR="#000099" HEIGHT="1">'+borderSpacer+'</TD></TR><TR><TD BGCOLOR="#000099" WIDTH="1">'+borderSpacer+'</TD><TD>';
        var borderTableEnd = '</TD><TD BGCOLOR="#000099" WIDTH="1">'+borderSpacer+'</TD></TR><TR><TD COLSPAN="3" BGCOLOR="#000099" HEIGHT="1">'+borderSpacer+'</TD></TR></TABLE>';


	for(var i=j; i<Layer.length; i++) {
		if (isMac45) { document.write("<DIV onMouseOver='clearTimeout(timer)' onMouseOut='Hide()' ID='L"+i+"' STYLE='position:absolute; visibility:hidden; top:"+Layer[i].top+"; left:"+Layer[i].left+"; z-index=1;'>"+borderTableStart+Layer[i].info+borderTableEnd+"</DIV>"); }
		else if((document.getElementById || document.all) && No3) { document.write("<DIV onMouseOver='clearTimeout(timer)' onMouseOut='Hide()' ID='L"+i+"' STYLE='position:absolute; visibility:hidden; top:"+Layer[i].top+"; left:"+Layer[i].left+";'>"+borderTableStart+"<TABLE border=0 cellspacing=0 cellpadding=0>"+Layer[i].info+"</TABLE>"+borderTableEnd+"</DIV>"); }
		else if(document.layers && No3) { document.write("<LAYER BGCOLOR=#000000 WIDTH="+(Layer[i].width+2)+" POSITION=ABSOLUTE TOP="+(Layer[i].top-1)+" LEFT="+(Layer[i].left-1)+" VISIBILITY=HIDDEN onMouseOver='clearTimeout(timer)' onMouseOut='Hide()' ID='L"+i+"'><LAYER onMouseOver='clearTimeout(timer)' onMouseOut='Hide()' ID='Lin"+i+"' POSITION=ABSOLUTE VISIBILITY=INHERIT BGCOLOR='"+bgcolor+"' BACKGROUND='"+background+"' TOP=1 LEFT=1>"+Layer[i].info+"</LAYER>"+borderSpacer+"</LAYER>"); }
	}
}


// for the left and top pixels of the sub layers, we have to give different x,y for IE, IE MacPPC, NS6.0
var isIE = (navigator.appName == "Microsoft Internet Explorer")? 1:0;
var isMacPPC = (navigator.platform == "MacPPC")? 1:0;
var isNS6 = (!document.all && document.getElementById)? 1:0;

//var name = navigator.appName;
//var version = navigator.appVersion; 
//var agent = navigator.userAgent;

//alert("isMacPPC:  "+isMacPPC);
//alert("isNS6:  "+isNS6);
//alert("appName:  "+name);
//alert("appVersion:  "+version);
//alert("userAgent:  "+agent);

function useBrand() {
   var useBrandforBuypower = "";
   if ((brand == "envoy") || (brand == "safari") || (brand == "savana") || (brand == "sierra") || (brand == "sonoma") || (brand == "yukon") || (brand == "divisional")) {
      useBrandforBuypower = brand + "/";
   } else {
      useBrandforBuypower = "divisional/";
   }
   return useBrandforBuypower;
}
var useBrandforBuypower = useBrand();

// the below is to put the buypower reskinning for ie only, because netscape has a glitch
function bpStyle() {
   var useBpStyle = "";
   if (navigator.appName == "Microsoft Internet Explorer") {
      useBpStyle = "www.gmbuypower.com/app/linksin?destination=homepage&creative=gmbp&style=gmc";
   } else {
      useBpStyle = "www.gmbuypower.com/app/linksin?destination=homepage&creative=gmbp&style=gmbp";
   }
   return useBpStyle;
}
var useBpStyle = bpStyle();
var locateYour = 'GMC';
if (brand == 'sierra') {locateYour = 'Sierra';} if (brand == 'sonoma') {locateYour = 'Sonoma';} if (brand == 'envoy') {locateYour = 'Envoy';} if (brand == 'safari') {locateYour = 'Safari';}if (brand == 'savana') {locateYour = 'Savana';} if (brand == 'yukon') {locateYour = 'Yukon';}

//for the kelly blue book, a ns and an ie version for reskinning
function bpKelley() {
   var useBpKelley = "";
   if (navigator.appName == "Microsoft Internet Explorer") {
      useBpKelley = "www.gmbuypower.com/app/gmbp/us/en/gmbp/gmc/tool?page=T4_splash&modelYear=2003";
   } else {
      useBpKelley = "www.gmbuypower.com/app/gmbp/us/en/gmbp/gmbp/tool?page=T4_splash&modelYear=2003";
   }
   return useBpKelley;
}
var useBpKelley = bpKelley();




