/* http://www.biasecurities.com/blogs/jim/archive/2005/04/28/1794.aspx */
var mHPtracking= "MASTHEAD";

function AttachEvent(elementObj, eventName, eventHandlerFunctionName)
{
  if (elementObj.addEventListener)
  { // Non-IE browsers
    elementObj.addEventListener(eventName, eventHandlerFunctionName, false);
  }
  else if (elementObj.attachEvent)
  { // IE 6+
    elementObj.attachEvent('on' + eventName, eventHandlerFunctionName);
  }
  else
  { // Older browsers
    var currentEventHandler = elementObj['on' + eventName];
    if (currentEventHandler == null)
    {
      elementObj['on' + eventName] = eventHandlerFunctionName;
    }
    else
    {
      elementObj['on' + eventName] = function(e) { currentEventHandler(e); eventHandlerFunctionName(e); }
    }
  }
}

function getESTHour() {
	var date = new Date();
	date = new Date(Date.UTC(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),date.getUTCHours(),date.getUTCMinutes(),date.getUTCSeconds()) - 18000000);
	var dsti = 14 - (Math.floor (1 + date.getUTCFullYear() * 5 / 4) % 7);
	var dste = 7 - (Math.floor (1 + date.getUTCFullYear() * 5 / 4) % 7);
	var tmpi = new Date(Date.UTC(date.getUTCFullYear(), 2, dsti, 2));
	var tmpe = new Date(Date.UTC(date.getUTCFullYear(), 10, dste, 2));
	if ((date.getTime() >= tmpi.getTime()) && (date.getTime() <= tmpe.getTime())) date = new Date(Date.UTC(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),date.getUTCHours(),date.getUTCMinutes(),date.getUTCSeconds()) + 3600000);
	return date.getUTCHours();
}

  /* UTILITY FUNCTIONS */

function getObj(eventArgs){
 	var obj;

	if (eventArgs.target) {
		obj = eventArgs.target;
	} else if (eventArgs.srcElement) {
		obj = eventArgs.srcElement;
	}
	/* For most browsers, obj would now be the object we're after; Safari however
		returns a text node so we need to check the node type to make sure */
	if (obj.nodeType == 3) {
	    obj = obj.parentNode;
	}

 	return obj;
}

function getObjID(eventArgs){
  var obj = getObj(eventArgs)
  return obj.id;
}

function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );

    while ( idx > -1 ) {
        str = str.replace( from, to );
        idx = str.indexOf( from );
    }
    return str;
}

function getElemRefs(id) {
    var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
    if (el) el.css = (el.style)? el.style: el;
    return el;
}
function showOnstar() {
	clickTrack({s_linkName:'GMC | ' + sprop2Aux + ' | KEY FEATURES | ONSTAR DEMO', s_prop5:'GMC | ' + sprop2Aux + ' | KEY FEATURES | ONSTAR DEMO', s_prop14:'ONSTAR',s_prop28: 'ONSTAR EXTERNAL'}); 	
	showWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=acadia&deepLink=overview', 'onStart', 'width=675,height=461,scrollbars=no');
}
function showBluetooth(){
	var temp = "";
	temp = window.open('http://www.gm.com/vc/bluetooth/index.jsp?brand=gmc&landing=true ','','',0,0,0);
	temp.focus();
}
function showXM(){	
	var temp = "";
	temp = window.open('http://www.gm.com/vehicles/services/xmradio/experience-xm/xm-navtraffic/','','',0,0,0);
	temp.focus();
}
function showOnstarBrand(brand) {
	clickTrack({s_linkName:'GMC | ' + sprop2Aux + ' | KEY FEATURES | ONSTAR DEMO', s_prop5:'GMC | ' + sprop2Aux + ' | KEY FEATURES | ONSTAR DEMO', s_prop14:'ONSTAR',s_prop28: 'ONSTAR EXTERNAL'}); 	
	showWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=' + brand + '&deepLink=overview', 'onStart', 'width=675,height=461,scrollbars=no');
}


function showOnstarSafety() {
	clickTrack({s_linkName:'GMC | SAFETY | ONSTAR DEMO | EXPERIENCE ONSTAR', s_prop5:'GMC | SAFETY | ONSTAR DEMO | EXPERIENCE ONSTAR', s_prop14:'ONSTAR',s_prop28: 'ONSTAR EXTERNAL'}); 	
	showWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=acadia&deepLink=overview', 'onStart', 'width=675,height=461,scrollbars=no');
}

function showWindow(url, id, params) {
	window.open(url, id, params);
}

function swapMainImage()
/* This function changes the masthead's image everytime the user refreshes/reloads the main page. */
{
   var mainImage= new Array("MH_alex.jpg", "MH_brian.jpg", "MH_kirk.jpg", "MH_don.jpg", "MH_doug.jpg", "MH_ed.jpg");
   var mastheadLink= new Array("letstalk_masthead_alex_handling&owner=alex_handling", "letstalk_masthead_brian_exceptionalEngineering&owner=brian_Engineering", "letstalk_masthead_kirk_fuelEconomy&owner=kirk_fuelEconomy", "letstalk_masthead_don_reliability_&owner=don_reliability", "letstalk_masthead_doug_intro_&owner=doug_intro", "letstalk_masthead_ed_style&owner=ed_style");
   var pLink= "http://www.letstalktrucks.com/?cmp="
   var imageCount = mainImage.length-1;
   var imageBase = "/images/home/";
   var random = Math.random();
   var index = 1;
   for(i=0; i < imageCount; i++)
      if(random >= (i*(1/imageCount)) && random < ((i+1)*(1/imageCount)))
         index = i+1;
   /* The "masthead" element is the div id, in content/index_content.jsp, that contains
      the masthead image and buttons */
   var elem= document.getElementById("masthead");
   if (elem)
   {
      var clickEvent = "popUpWindow('" + pLink + mastheadLink[index] + "', 'gmc', 'location=no, menubar=yes, scrollbars=yes, status=yes, toolbar=yes, resizable=yes, screenx=20, screeny=150, left=0, top=0')";
      elem.innerHTML = '<img class="phHomeHero" src=' + imageBase + mainImage[index] +' width="840" height="457" border="0" alt="" title="" onclick="' + clickEvent + '"/>' + elem.innerHTML;
      var owners = document.getElementById("owners");
      owners.href = pLink + mastheadLink[index];
   }
}


/* pop-up function. only needs a url and winName parameter -- attributes are defaulted.
it is recommended that call to function at least include width and height attributes.
any attribute passed in will take precedence over default. -- dtw 8/5/05 */
function popUpWindow(url, winName, attributes) {
	if (attributes.indexOf("directories") == -1) { attributes += ",directories=0"; }
	if (attributes.indexOf("location") == -1) {	attributes += ",location=0"; }
	if (attributes.indexOf("menubar") == -1) { attributes += ",menubar=0"; }
	if (attributes.indexOf("resizable") == -1) { attributes += ",resizable=0"; }
	if (attributes.indexOf("scrollbars") == -1) { attributes += ",scrollbars=1"; }
	if (attributes.indexOf("status") == -1) { attributes += ",status=0"; }
	if (attributes.indexOf("toolbar") == -1) { attributes += ",toolbar=0"; }
	if (attributes.indexOf("top") == -1) { attributes += ",top=80";	}
	if (attributes.indexOf("left") == -1) { attributes += ",left=50"; }

	var newWindow = window.open(url,winName,attributes);
	if (window.focus && newWindow) { newWindow.focus() }
}

// We have a lot of popup windows that show up all over the site.
// We define them commonly here, so that should a request come in to change a param of the window (say the size, or position),
// we can update it in one place as opposed to accross the site.

/* 
  This function is called in 'content/include/footer.jsp'.
  It resizes the height of the popup window shown according to the browser in use.
*/
function showCopyRightPopup()
{
  if (navigator.appName.indexOf("Explorer") > 0)
     popUpWindow('/common/copyright.jsp','copyright','height=590, width=605, scrollbars=N');
  else
     popUpWindow('/common/copyright.jsp','copyright','height=540, width=605, scrollbars=N');
}

function onstarHome() {
	popUpWindow('http://www.onstar.com/us_english/jsp/index.jsp?division=gc','onstar_win','width=785,height=650');
}

function onstarDemo() {
    if (brand == "canyon"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=canyon&deepLink=overview','onstar_win','width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=canyon&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	

    if (brand == "acadia"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=acadia&deepLink=overview','onstar_win','width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=acadia&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	

    if (brand == "envoy"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=envoy&deepLink=overview','onstar_win','width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=envoy&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	

    if (brand == "yukon"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=yukon&deepLink=overview','onstar_win','width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=yukon&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	
	
    if (brand == "savana"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=savana&deepLink=overview','onstar_win','width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=savana&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	
	
    if (brand == "sierra900"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=sierraNew&deepLink=overview','onstar_win', 'width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=sierraNew&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	

    if (brand == "sierra"){
	   var browser=navigator.appName;
	   if (browser=="Microsoft Internet Explorer"){
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=sierraClassic&deepLink=overview','onstar_win', 'width=693,height=490', 'scrollbars=no');
	   } 
	   else{
	      popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc&model=sierraClassic&deepLink=overview','onstar_win','width=675,height=465', 'scrollbars=no');
	   }
    }	
 }

function openkbb() {
	popUpWindow('http://www.kbb.com/kb/ki.dll/ke.kb.sz?gmsg&&&zip;5945&1&GMC','kbb_win','width=795,height=650');
}

function lowesPromo() {
  window.location.href = "/promo/lowes/sweeps.jsp?source=lowes_2006_news";
}

function superPopUpWindow(url, window_name) {
	popUpWindow(url, window_name, 'width=605, height=580, scrollbars=no');
}
function openNFTop(){
	window.open("http://www.gmfleet.com/email/email_updates.jsp");
}


//-- BEGIN tracking function ------------------------------------------------------------------------------

function clickTrack(oArg) 
{ 
   if (typeof(oArg.s_pageName) == "string") { s_pageName = oArg.s_pageName; }
   if (typeof(oArg.s_lnk) == "boolean") {s_lnk = oArg.s_lnk;} else {s_lnk = true;}
   if (typeof(oArg.s_linkName) == "string") { s_linkName = oArg.s_linkName; }
   if (typeof(oArg.s_linkType) == "string") { s_linkType = oArg.s_linkType; } else { s_linkType="o"; }                                                            
   if (typeof(oArg.s_events) == "string") {s_events = oArg.s_events; }  
   if (typeof(oArg.s_prop1) == "string") { s_prop1 = oArg.s_prop1; }                                                           
   if (typeof(oArg.s_prop2) == "string") { s_prop2 = oArg.s_prop2; }                                                           
   if (typeof(oArg.s_prop3) == "string") { s_prop3 = oArg.s_prop3; } 
   if (typeof(oArg.s_prop4) == "string") { s_prop4 = oArg.s_prop4; } 
   if (typeof(oArg.s_prop5) == "string") { s_prop5 = oArg.s_prop5; } 
   if (typeof(oArg.s_prop6) == "string") { s_prop6 = oArg.s_prop6; } 
   if (typeof(oArg.s_prop7) == "string") { s_prop7 = oArg.s_prop7; } 
   if (typeof(oArg.s_prop8) == "string") { s_prop8 = oArg.s_prop8; } 
   if (typeof(oArg.s_prop11) == "string") { s_prop11 = oArg.s_prop11; }
   if (typeof(oArg.s_prop12) == "string") { s_prop12 = oArg.s_prop12; }
   if (typeof(oArg.s_prop13) == "string") { s_prop13 = oArg.s_prop13; }
   if (typeof(oArg.s_prop14) == "string") { s_prop14 = oArg.s_prop14; }
   if (typeof(oArg.s_prop15) == "string") { s_prop15 = oArg.s_prop15; }
   if (typeof(oArg.s_prop16) == "string") { s_prop16 = oArg.s_prop16; }
   if (typeof(oArg.s_prop17) == "string") { s_prop17 = oArg.s_prop17; }
   if (typeof(oArg.s_prop18) == "string") { s_prop18 = oArg.s_prop18; }
   if (typeof(oArg.s_prop19) == "string") { s_prop19 = oArg.s_prop19; }                                                           
   if (typeof(oArg.s_prop20) == "string") { s_prop20 = oArg.s_prop20; }
   if (typeof(oArg.s_prop21) == "string") { s_prop21 = oArg.s_prop21; }  
   if (typeof(oArg.s_prop24) == "string") { s_prop24 = oArg.s_prop24; }
   if (typeof(oArg.s_prop23) == "string") { s_prop23 = oArg.s_prop23; }
   if (typeof(oArg.s_prop25) == "string") { s_prop25 = oArg.s_prop25; }   
   if (typeof(oArg.s_prop28) == "string") { s_prop28 = oArg.s_prop28; }   
   if (typeof(oArg.s_prop30) == "string") { s_prop30 = oArg.s_prop30; }   
   if (typeof(oArg.s_eVar10) == "string") { s_eVar10 = oArg.s_eVar10; }   


   //alert(s_pageName+"~"+s_linkName+"~"+s_linkType+"~"+s_prop1+"~"+s_prop2+"~"+s_prop3+"~"+s_prop19+"~"+s_prop20+"~");
   //alert(s_account);
  // s_lnk=true;
   s_gs(s_account);
   s_pageName = "";
   s_prop1 = "";
   s_prop2 = "";
   s_prop3 = "";
   s_prop4 = "";
   s_prop5 = "";
   s_prop6 = "";
   s_prop7 = "";
   s_prop8 = "";
   s_prop11 = "";
   s_prop12 = "";
   s_prop13 = "";
   s_prop14 = "";
   s_prop15 = "";
   s_prop16 = "";
   s_prop17 = "";
   s_prop19 = "";
   s_prop20 = "";
   s_prop21 = "";
   s_prop25 = "";
   s_prop24 = "";
   s_prop23 = "";
   s_prop28 = "";
   s_prop30 = "";
   eVar10="";
}
//-- END tracking function ------------------------------------------------------------------------------

function flashIsReady() {
	if (typeof isFlashReady != "undefined") {
		isFlashReady = true; 
	}
}

// called by flash whenever the active vehicle trim changes
function setActiveVehicle(newVehicle) {
	if (typeof vehicle != "undefined") {
		vehicle = newVehicle; 
	}
}

function validateZIP(ZipField)
{
     var valid = "0123456789";
     var length = ZipField.length
     if (length !=5)
     {

       alert("Please enter your 5 digit zip code.");
       return false;
     }
     for (var i=0; i < length; i++) {
     	temp = "" + ZipField.substring(i, i+1);
     
     	if (valid.indexOf(temp) == "-1")
       	{
        	alert("Invalid characters in your zip code.  Please try again.");
        	return false;
     	}
     }
}

// --------------------------------------------------------------
// generic name/value pair function
// return a hash (of sorts) of name value pairs from the querystring
// uasge: var qsParams = getQsParams();
// then: qsParams['url'] whould equal whatever url=XXX in the querystring

function getQsParams() {
	var qs = location.search;
	qs = qs.substring(1);
	// create an 'array' called newArray with the name value pairs from the querystring
	var qsArray = new Array;
	qsArray = qs.split('&'); //creating an array in which the values are separated by ampersands in the code//
	var keyValueArray = new Array; //this one loads the names and values into a hash (of sorts)//
	for(i=0; i<qsArray.length; i++) {
		var nameValue = qsArray[i].split('='); //splitting what we find between each ampersand into key value pairs //
		keyValueArray[nameValue[0]] = unescape(nameValue[1]); //we are then turning all the escaped characters back into the 'real thing' ie. %3F turns into a '?' //
	}
	return keyValueArray;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1); 
}

/*usage: url = setURLParameter(, "year"., value)*/
function setURLParameter(url, parameter, value){
	regexS = "([\\?&])" + parameter + "=[^&#]*";
	regex = new RegExp(regexS, "g");
	var results = regex.exec(url);
	if (results == null)
		return url + ((url.indexOf("?") == -1)?"?":"&") + parameter + "=" + value;
	else
		return url.replace(regex, results[1] + parameter + "=" + value);
}


function resizeSafetyFooter(){
	/* Check for older browsers */
	if (document.getElementById) {
			var str = navigator.appVersion; 
			var browser=navigator.appName;
		/*Checks to see if there is a embedded flash on the page*/
		if (typeof document.getElementById('flashReplaced') != "undefined") {								
			if(browser == "Microsoft Internet Explorer"){
			document.getElementById('flashReplaced').height = "570px";
			document.getElementById('gContent').style.height = "570px";
			document.getElementById('gContent').style.minHeight = "570px";
			
			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "572px";
			document.getElementById('gFooter').style.left = "0px";
			
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "638px";
			document.getElementById('gDisclaimer').style.left = "5px";
				
 		  }else{ 
		  		if(str.match("Safari") == "Safari"){
		  	/* Resizes the embedded flash */
			document.getElementById('flashReplaced').height = "570px";
			document.getElementById('gContent').style.height = "570px";
			document.getElementById('gContent').style.minHeight = "570px";
			
			/* Relocating footer to new position */
/*			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "574px";
			document.getElementById('gFooter').style.left = "0px";*/
			
			/* Relocating disclaimer to new position */
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "-290px";
			document.getElementById('gDisclaimer').style.left = "0px";
		  	
			}else{
			 /* Resizes the embedded flash */
			document.getElementById('flashReplaced').height = "570px";
			document.getElementById('gContent').style.height = "570px";
			document.getElementById('gContent').style.minHeight = "570px";
			
			/* Relocating footer to new position */
			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "574px";
			document.getElementById('gFooter').style.left = "0px";
			
			/* Relocating disclaimer to new position */
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "634px";
			document.getElementById('gDisclaimer').style.left = "0px";
		 }
		}
	}
	}
}

function restoreSafetyFooter(uri){
	/* Check for older browsers */
	var uri= window.document.URL;
	if (document.getElementById) {
		/*Checks to see if there is a embedded flash on the page*/
		if (typeof document.getElementById('flashReplaced') != "undefined") {
			var str = navigator.appVersion; 
			if(str.match("Safari") == "Safari"){
				// Resizes the embedded flash
				document.getElementById('flashReplaced').height = "765px";
				document.getElementById('gContent').style.height = "765px";
				document.getElementById('gContent').style.minHeight = "765px";
				
				if(uri.indexOf('/sierra/hybrid/') > -1){
					document.getElementById('flashReplaced').height = "800px";
					document.getElementById('gContent').style.height = "800px";
					document.getElementById('gContent').style.minHeight = "800px";
					document.getElementById('gFooterInfo').style.top = "860px";
					}
					
			
				// Restoring footer to previous position
/*				document.getElementById('gFooter').style.position = "absolute";
				document.getElementById('gFooter').style.top = "860px"; 
				document.getElementById('gFooter').style.left = "0px"; */
				
				//This fix the disclaimer position on canyon chassis and savana cutaway
				document.getElementById('gDisclaimer').style.position = "absolute";
				if(uri.indexOf('canyon/chassis/') > -1)
					document.getElementById('gDisclaimer').style.top = "-100px";
				else				
					if(uri.indexOf('/sierra/hybrid/') > -1)
			    		document.getElementById('gDisclaimer').style.top = "-30px";
						else
						document.getElementById('gDisclaimer').style.top = "-65px";
						document.getElementById('gDisclaimer').style.left = "0px";
						
				if((uri.indexOf('/savana/cutaway/') > -1) || (uri.indexOf('/savana/conversion/') > -1)){
					document.getElementById('flashReplaced').height = "800px";
					document.getElementById('gContent').style.height = "800px";
					document.getElementById('gContent').style.minHeight = "800px";
					document.getElementById('gFooter').style.top = "0px";
					document.getElementById('gDisclaimer').style.top = "-60px";
				}
				if(uri.indexOf('/savana/conversion/') > -1){
					document.getElementById('gFooterInfo').style.top = "860px";
					document.getElementById('gDisclaimer').style.top = "-30px";
				}
				
			}else{
				// Resizes the embedded flash
				document.getElementById('flashReplaced').height = "765px";
				document.getElementById('gContent').style.height = "765px";
				document.getElementById('gContent').style.minHeight = "765px";
						
				// Restoring footer to previous position
				document.getElementById('gFooter').style.position = "absolute";
				document.getElementById('gFooter').style.top = "765px";
				document.getElementById('gFooter').style.left = "0px";
				
				// Restoring disclaimer to previous position
				document.getElementById('gDisclaimer').style.position = "absolute";
				//This fix the disclaimer position on canyon chassis and savana cutaway
				if(uri.indexOf('/sierra/hybrid/') > -1){
					document.getElementById('flashReplaced').height = "800px";
					document.getElementById('gContent').style.height = "800px";
					document.getElementById('gContent').style.minHeight = "800px";
					document.getElementById('gFooter').style.top = "800px";
					document.getElementById('gFooterInfo').style.top = "860px";
				}
					
				if(uri.indexOf('canyon/chassis/') > -1)
					getElementDiscl().style.top = "835px";
				else	
					if(uri.indexOf('/sierra/hybrid/') > -1)
						document.getElementById('gDisclaimer').style.top = "900px";
					else
			    		document.getElementById('gDisclaimer').style.top = "865px";
   						document.getElementById('gDisclaimer').style.left = "0px";
						
				if((uri.indexOf('/savana/cutaway/') > -1) || (uri.indexOf('/savana/conversion/') > -1)){
					document.getElementById('flashReplaced').height = "800px";
					document.getElementById('gContent').style.height = "800px";
					document.getElementById('gContent').style.minHeight = "800px";
					document.getElementById('gFooter').style.top = "800px";
					document.getElementById('gDisclaimer').style.top = "868px";
				}
				if(uri.indexOf('/savana/conversion/') > -1){
					document.getElementById('gFooterInfo').style.top = "855px";
					document.getElementById('gDisclaimer').style.top = "895px";
				}
			}
			if(str.indexOf("MSIE 6.0") > -1){
				document.getElementById('gDisclaimer').style.position = "absolute";
				if(uri.indexOf('/sierra/hybrid/') > -1)
					document.getElementById('gDisclaimer').style.top = "800px";
				  else
					document.getElementById('gDisclaimer').style.top = "765px";
					if(uri.indexOf('canyon/chassis/') < -1){
						document.getElementById('gFooterInfo').style.top = "823px";
						document.getElementById('gFooterInfo').style.left = "20px";
						document.getElementById('gDisclaimer').style.top = "765px";
					}else{
						 if(uri.indexOf('canyon/chassis/') > -1)
						 	document.getElementById('gDisclaimer').style.top = "835px";   
					}
				if (uri.indexOf('/savana/conversion/') > -1)
					document.getElementById('gDisclaimer').style.top = "800px";
				if(uri.indexOf('/savana/cutaway/') > -1)
					document.getElementById('gDisclaimer').style.top = "868px";
			}else{
				if(str.indexOf("MSIE 7.0") > -1){
					document.getElementById('gDisclaimer').style.position = "absolute";
					if(uri.indexOf('/sierra/hybrid/') > -1)
					document.getElementById('gDisclaimer').style.top = "800px";
				 	 else
					document.getElementById('gDisclaimer').style.top = "765px";   
					if(uri.indexOf('canyon/chassis/') < -1){
				  		 	document.getElementById('gFooterInfo').style.top = "823px";
				   			document.getElementById('gFooterInfo').style.left = "20px";
				   			document.getElementById('gDisclaimer').style.top = "765px";   
				     }else{
						 if(uri.indexOf('canyon/chassis/') > -1)
						 document.getElementById('gDisclaimer').style.top = "835px";   
					}
					if (uri.indexOf('/savana/conversion/') > -1)
					document.getElementById('gDisclaimer').style.top = "800px";
					if(uri.indexOf('/savana/cutaway/') > -1)
					document.getElementById('gDisclaimer').style.top = "868px";
			
			  }
			 
		   }
		}
	}
			setHeightCanyonContent()
}


function resizeCapabilitiesFooter(){
	/* Check for older browsers */
	if (document.getElementById) {
		/*Checks to see if there is a embedded flash on the page*/
		if (typeof document.getElementById('flashReplaced') != "undefined") {
				/* Resizes the embedded flash */
				var str = navigator.appVersion; 
				var browser=navigator.appName;
		if( (browser == "Microsoft Internet Explorer")){
			
			document.getElementById('flashReplaced').height = "760px";
			document.getElementById('gContent').style.height = "760px";
			document.getElementById('gContent').style.minHeight = "760px";
			
			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "764px";
			document.getElementById('gFooter').style.left = "0px";
			
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "820px";
			document.getElementById('gDisclaimer').style.left = "5px";
 		  }else{
		  
			if(str.match("Safari") == "Safari"){
			
			document.getElementById('flashReplaced').height = "770px";
			document.getElementById('gContent').style.height = "770px";
			document.getElementById('gContent').style.minHeight = "770px";
			
			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "774px";
			document.getElementById('gFooter').style.left = "0px";
				/* Relocating disclaimer to new position */
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "-88px"; 
			document.getElementById('gDisclaimer').style.left = "0px"; 
			
			}else{
	
			document.getElementById('flashReplaced').height = "760px";
			document.getElementById('gContent').style.height = "760px";
			document.getElementById('gContent').style.minHeight = "760px";
			
			/* Relocating footer to new position */
			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "764px";
			document.getElementById('gFooter').style.left = "0px";
			
			/* Relocating disclaimer to new position */
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "825px";
			document.getElementById('gDisclaimer').style.left = "0px";
			
			document.getElementById('testRestoreButton').style.zIndex = "1000";
		}
 	   }
  	  }
	}
}
function restoreCapabilitiesFooter(){
	/* Check for older browsers */
	if (document.getElementById) {
		/*Checks to see if there is a embedded flash on the page*/
		if (typeof document.getElementById('flashReplaced') != "undefined") {
			// Resizes the embedded flash
			document.getElementById('flashReplaced').height = "860px";
			document.getElementById('gContent').style.height = "860px";
			document.getElementById('gContent').style.minHeight = "860px";
			
			// Restoring footer to previous position
			document.getElementById('gFooter').style.position = "absolute";
			document.getElementById('gFooter').style.top = "860px";
			document.getElementById('gFooter').style.left = "0px";
			
			// Restoring disclaimer to previous position
			document.getElementById('gDisclaimer').style.position = "absolute";
			document.getElementById('gDisclaimer').style.top = "920px";
			document.getElementById('gDisclaimer').style.left = "0px";
		}
	}
}


function changeBtnImage(srcImage, newImage)
{
   var e= document.getElementById(srcImage);
   e.src= newImage;
}

//Start of DoubleClick Spotlight Tag: Please do not remove

function spotlightTag(tagUrl) {
var click1 = new Image();
var axel = Math.random() + "";
var ord = axel * 1000000000000000000;
click1.src = tagUrl + ord + '?';
}

function openParentWindow(url,obj){
	obj.opener.location.href= url;
	obj.opener.focus();
}

/* Sets the length of zip field in left navigator */
function SetZipFieldLength(pEvent, e)
{
   mZip= document.getElementById(e);
   if (pEvent=="focus")
   {
      mZip.setAttribute('maxLength', 5);
      mZip.value="";
   }
   else
   {
      mZip.setAttribute('maxLength', 10);
      mZip.value="Enter ZIP";
   }
}


function getPage(uri)
{
   var result= "";
   if (uri.indexOf("/byo/") > 0) result = "BYO";
   if (uri.indexOf("/locatedealer/") > 0) result = "DEALOC";
   if (uri == "/common/bp/compare.jsp") result = "COMPARISON";
   if (uri == "/helpcenter/index.jsp") result = "CONTACT US";
   if (uri == "/index.jsp") result = "HOMEPAGE";
   if (uri == "/currentoffers/index.jsp") result = "OFFERS";
   if (uri == "/vehiclelocator/gmc/locatevehicle.jsp") result = "VEHLOC";
   if (uri == "/ws/nvlWindowSticker.gc") result = "WINSTICKER";
   
   if (uri == "/sierra/1500/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/sierra/2500HD/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/sierra/3500/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/sierra/denali/index.jsp") result = "MODEL HOMEPAGE";
   
   if (uri == "/yukon/yukon/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/yukon/xl/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/yukon/denali/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/yukon/hybrid/index.jsp") result = "MODEL HOMEPAGE";
   
   if (uri == "/acadia/acadia/index.jsp") result = "MODEL HOMEPAGE";
   
   if (uri == "/canyon/canyon/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/canyon/chassis/index.jsp") result = "MODEL HOMEPAGE";
   
   if (uri == "/envoy/envoy/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/envoy/denali/index.jsp") result = "MODEL HOMEPAGE";
   
   if (uri == "/savana/cargo/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/savana/conversion/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/savana/cutaway/index.jsp") result = "MODEL HOMEPAGE";
   if (uri == "/savana/passenger/index.jsp") result = "MODEL HOMEPAGE";
   if (uri.indexOf("/specsStandard.jsp") > 0) result = "MODEL HOMEPAGE";
   return result;
}


function doClickTrack(pUri)
{
   var strSite= getPage(pUri); 
   if (strSite != '')
   { 
      if ((strSite == "MODEL HOMEPAGE") && (mHPtracking != "MASTHEAD"))
         strSite= mHPtracking;
      if (mHPtracking == "SPECS")
         strSite= mHPtracking;
      clickTrack({s_linkName:'GMC | ' + strSite + ' | GM CUV', s_prop5:'GMC | ' + strSite + ' | GM CUV', s_prop24:'EN', s_prop25:'GMC', s_prop30:'X'}); 
   }
}


function setModelHomepageTracking(pSection)
{
  mHPtracking= pSection;
  mHPtracking= mHPtracking.toUpperCase();
}
/*****************************************************/
/* SEO FOOTER SECTION                                */
/*****************************************************/
function showSeoContent(){
	document.getElementById('gFooterInfoDescription').style.display='block'; 
	document.getElementById('gFooterInfoDescription').style.left='180px';
	document.getElementById('gFooterInfoDescription').style.top='-436px';
	//document.getElementById('gFooterInfo').style.position='absolute'; 
}
/*
Overview         = masthead
Photots & Videos = gallery
Accessories      = accessories
Color & 360      = colors
Features & Specs = specs
*/

function showEventPopUp(brandId, year, VIN, make,modelsubmodel, typestyle, pvcId, lang, zip){
	popUpWindow('http://pprod.gm.gmgssm.com/redtag/redtag.do?brandId='+brandId+'&lang='+lang+'&zip='+zip+'&year='+year+'&VIN='+VIN+'&make='+make+'&pvcId='+pvcId,'ViewYourEmployeePrice','width=830,height=550', 'status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resize=no');

}

function openOnStarAndTrack() {
	trackFloodlightTagOnClick('ronst928', 'onsta171');
	popUpWindow('http://www.onstar.com/us_english/jsp/services/index.jsp?make=gmc%26model=homepage%26deepLink=overview ','onstar','width=675,height=461,scrollbars=no');
	clickTrack({s_linkName:'GMC | FOOTER | GLOBAL FOOTER | ONSTAR', s_prop5:'GMC | FOOTER | GLOBAL FOOTER | ONSTAR', s_prop14:'ONSTAR',s_prop28: 'ONSTAR EXTERNAL'});
	clickTrackLocation('GLOBAL FOOTER | ONSTAR', 'GLOBAL FOOTER | ONSTAR', 'Onstar');
}

function trackFloodlightTagOnClick(type, cat) {
		var inputs = document.getElementsByTagName( 'div' );
		var descField = null;
		for(var i=0;i<inputs.length;i++){
			if(inputs.item(i).getAttribute( 'id' ) == 'floodlightTagOnClickDiv' ){
				descField = inputs.item(i);
				break;
			}
		}
		
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var htmlContent = '<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1139835;type='+type+';cat='+cat+';ord='+ a + '?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>';
		if (descField) {
			descField.innerHTML = htmlContent;
		}
}

function getElementDiscl(){
        var input = document.getElementsByTagName( 'div' );
		var desField = null;
		for(var i=0;i<input.length;i++){
			if(input.item(i).getAttribute( 'id' ) == 'gDisclaimer' ){
				desField = input.item(i);
			}
		}
		return desField;
	}
	
function setHeightContent(Contheight){
	    document.getElementById('gContent').style.height = Contheight+"px";
		var contH=document.getElementById('gContent').style.height;
		if(contH=="675px"){
			        document.getElementById('gFooterInfo').style.top="737px";
			}else{
				if(contH=="727px"){
					document.getElementById('gFooterInfo').style.top="789px";
					}else{
						if(contH=="698px"){
						document.getElementById('gFooterInfo').style.top="759px";
					}
				  } 
				}
				
				if (Contheight == "727"){
					document.getElementById('gContent').style.height="729px";
					document.getElementById('gFooterInfo').style.top="787px";
					}
					 
				if (Contheight == "714"){ 
				  	document.getElementById('gContent').style.height="716px";
					document.getElementById('gFooterInfo').style.top="774px";
					}			
	}
	
function setHeightCanyonContent(){
	var uri= window.document.URL;
	var browser=navigator.appName;
	var str = navigator.appVersion;
	var gContH = document.getElementById('gContent').style.height;
				if ((uri.indexOf("/canyon/canyon/")> -1) || (uri.indexOf('/sierra/1500/') > -1) || (uri.indexOf('/sierra/denali/') > -1) || (uri.indexOf('/sierra/hybrid/') > -1)){
					if(browser == "Microsoft Internet Explorer"){
								document.getElementById('flashReplaced').height = "860px";
								document.getElementById('gContent').style.height="860px";
								document.getElementById('gFooter').style.top = "850px";
								document.getElementById('gFooterInfo').style.top="902px";
								document.getElementById('gDisclaimer').style.top = "840px";
									
									if(str.indexOf("MSIE 8.0") > -1){
										document.getElementById('gDisclaimer').style.top="940px";
									}
						
					}else{
						if(str.match("Safari") == "Safari"){
								document.getElementById('flashReplaced').height = "860px";
								document.getElementById('gContent').style.height="860px";
								document.getElementById('gFooter').style.top = "-3px";
								document.getElementById('gFooterInfo').style.top="912px";
								document.getElementById('gDisclaimer').style.top = "15px";
								
							}else{
								document.getElementById('flashReplaced').height = "860px";
								document.getElementById('gContent').style.height="860px";
								document.getElementById('gFooter').style.top = "850px";
								document.getElementById('gFooterInfo').style.top="902px";
								document.getElementById('gDisclaimer').style.top = "938px";
								}
					}
				}	
				
				if ((uri.indexOf("/sierra/safety.jsp")> -1) || (uri.indexOf('/canyon/safety.jsp') > -1)){
					if (gContH == "765px"){
						document.getElementById('flashReplaced').height = "850px";
						document.getElementById('gContent').style.height="850px";
						document.getElementById('gFooter').style.top = "840px";
						document.getElementById('gDisclaimer').style.top = "900px";
							if(str.match("Safari") == "Safari"){
								document.getElementById('flashReplaced').height = "860px";
								document.getElementById('gContent').style.height="860px";
								document.getElementById('gFooter').style.top = "-3px";
								document.getElementById('gDisclaimer').style.top = "0px";
						}
				
				}

			}
			if (uri.indexOf("/denali/safety.jsp")> -1){
						if (gContH == "765px"){
						document.getElementById('gDisclaimer').style.top = "830px";
						if(str.match("Safari") == "Safari"){
								document.getElementById('gDisclaimer').style.top = "-100px";
						} 
					}
				}
	}
	
	
	function showShareThis(DispValue){ 
	if(DispValue == "show"){
		document.getElementById('shareThis').style.display = 'block';
		}else{
		document.getElementById('shareThis').style.display = 'none';
		}
	}
	
