function activateCacheImgIE6(){
	try {
	  javascript:void(document.execCommand("BackgroundImageCache",false,true));
	} catch(e) {}
}

activateCacheImgIE6();

function OnEnterItemList(anchor) {
	anchor.childNodes[2].style.display = "block";
	anchor.childNodes[1].style.display = "none";
}

function OnExitItemList(anchor) {
	anchor.childNodes[1].style.display = "block";
	anchor.childNodes[2].style.display = "none";
}

//http://www.biasecurities.com/blogs/jim/archive/2005/04/28/1794.aspx
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 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 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();
}

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;
}

// --------------------------------------------------------------
// 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);
}

/* 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 (navigator.appName=="Microsoft Internet Explorer" && winName=="gallery")
  {
		attributes += ",width=709"; 
		attributes += ",height=675"; 
		attributes += ",top=5";
		attributes += ",left=50";
	}
	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.

function getParameter (queryString, parameterName ) {
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if (queryString.length > 0 ) {
		// Find the beginning of the string
		begin = queryString.indexOf ( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
			// Return the string
			return unescape ( queryString.substring ( begin, end ) );
		}
		// Return "null" if no parameter has been found
		return "null";
	}
}


function addParameter (queryString, parameterName, parameterValue) {
	if(queryString.indexOf ( "?" )==-1){
		queryString+="?";
	}
	else{
		queryString+="&";
	}
	queryString+=parameterName+"="+parameterValue;
	return queryString;
}


function breakWord(word) {
	if (word.indexOf("/") > -1) word = word.split("/").join("/<wbr/>");
	if (word.indexOf("-") > -1) word = word.split("-").join("-<wbr/>");
	if (word.indexOf("_") > -1) word = word.split("_").join("_<wbr/>");
	if (word.indexOf(",") > -1) word = word.split(",").join(",<wbr/>");
	word = word.split(" ").join(" <wbr/>");
	return word;
}

function breakName(word) {
	if(word.indexOf("/")>-1){
		word = word.split("/").join("/<wbr/>");
	}
	if(word.indexOf(",")>-1){
		word = word.split(",").join(",<wbr/>");
	}
	return word;
}

function pageTrack(pagename, oArg) {
	s_pageName = pagename;
	if (oArg) {
		if (typeof(oArg.s_prop5) == "string") { s_prop5 = oArg.s_prop5.toUpperCase(); }
		if (typeof(oArg.s_prop1) == "string") { s_prop1 = oArg.s_prop1.toUpperCase(); }
		if (typeof(oArg.s_prop2) == "string") { s_prop2 = oArg.s_prop2.toUpperCase(); }
		if (typeof(oArg.s_prop3) == "string") { s_prop3 = oArg.s_prop3.toUpperCase(); }
		if (typeof(oArg.s_prop11) == "string") { s_prop11 = oArg.s_prop11.toUpperCase(); }
		if (typeof(oArg.s_prop12) == "string") { s_prop12 = oArg.s_prop12.toUpperCase(); }
		if (typeof(oArg.s_prop13) == "string") { s_prop13 = oArg.s_prop13.toUpperCase(); }
		if (typeof(oArg.s_prop14) == "string") { s_prop14 = oArg.s_prop14.toUpperCase(); }
		if (typeof(oArg.s_prop15) == "string") { s_prop15 = oArg.s_prop15.toUpperCase(); }
		if (typeof(oArg.s_prop16) == "string") { s_prop16 = oArg.s_prop16.toUpperCase(); }
		if (typeof(oArg.s_prop17) == "string") { s_prop17 = oArg.s_prop17.toUpperCase(); }
	}
	s_linkName = "";
	s_lnk = false;
	s_linkType = "";
	s_gs(s_account);
}

function clickTrack(oArg) { 
   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_prop5) == "string") { s_prop5 = oArg.s_prop5.toUpperCase(); }
	 if (typeof(oArg.s_prop1) == "string") { s_prop1 = oArg.s_prop1.toUpperCase(); }
	 if (typeof(oArg.s_prop2) == "string") { s_prop2 = oArg.s_prop2.toUpperCase(); }
	 if (typeof(oArg.s_prop3) == "string") { s_prop3 = oArg.s_prop3.toUpperCase(); }
	 if (typeof(oArg.s_prop11) == "string") { s_prop11 = oArg.s_prop11.toUpperCase(); }
	 if (typeof(oArg.s_prop12) == "string") { s_prop12 = oArg.s_prop12.toUpperCase(); }
	 if (typeof(oArg.s_prop13) == "string") { s_prop13 = oArg.s_prop13.toUpperCase(); }
	 if (typeof(oArg.s_prop14) == "string") { s_prop14 = oArg.s_prop14.toUpperCase(); }
	 if (typeof(oArg.s_prop15) == "string") { s_prop15 = oArg.s_prop15.toUpperCase(); }
	 if (typeof(oArg.s_prop16) == "string") { s_prop16 = oArg.s_prop16.toUpperCase(); }
	 if (typeof(oArg.s_prop17) == "string") { s_prop17 = oArg.s_prop17.toUpperCase(); }

	 s_pageName = s_linkName;
	 
   s_gs(s_account);
}

function superPopup(pOptions){
	
	var url, type, directories, location, menubar, resizable, scrollbars, status, toolbar, top, left, width, height, winName, clickTrackValue;
	
	// URL is the only required field.
	if (pOptions.url != null) {	url = pOptions.url;} else { alert('Error: Link URL Missing')};
	
	if (pOptions.type != null) { type = pOptions.type;};

	// type will set some basic options to make the function cleaner -- otherwise all values can be set
	if(type == "_blank"){	//used to generate a window the same size as the previous
		var windowWidth = f_clientWidth();
		var windowHeight = f_clientWidth();	
			
		//used to generate original "window names"
		var randomNumber = Math.floor(Math.random()*1000);
		winName="blank" + randomNumber; width=windowWidth; height=windowHeight; scrollbars="yes"; menubar="yes"; toolbar="yes"; directories="yes"; location="yes"; top="0"; left="0";
	} else if(type == "mapwin"){
		winName="mapwin"; width = "586"; height= "550"; scrollbars = "yes"; resizable = "yes"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
	} else if(type == "KBB"){
		winName="kbbPopup"; width = "780"; height= "500"; scrollbars = "yes"; resizable = "yes"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
    } else if(type == "regionDetails"){
		winName="regionDetails"; width = "750"; height= "650"; scrollbars = "yes"; resizable = "yes"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
    } else if(type == "otherPage"){
		winName="outsidePage"; width = "780"; height= "780"; scrollbars = "yes"; resizable = "yes"; toolbar="yes"; directories="no"; location="yes"; status="yes"; menubar="yes";
    } else if(type == "reqBrochure"){
		winName="reqBrochure"; width = "800"; height= "600"; scrollbars = "no"; resizable = "yes"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
    } else if(type == "bonusCash"){
		winName="bonusCash"; width = "720"; height= "610"; scrollbars = "no"; resizable = "no"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
    } else if(type == "windowSticker"){
		winName="windowSticker"; width = "900"; height= "610"; scrollbars = "no"; resizable = "no"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
    } else if(type == "map"){
		winName="map"; width = "590"; height= "630"; scrollbars = "yes"; resizable = "no"; toolbar="no"; directories="no"; location="no"; status="no"; menubar="no";
    }
	 
					
	// test to see if we have set a window option on the function or in a profile above, if not then set the value to be a default.
	if (pOptions.directories != null) { directories = pOptions.directories;} else if (directories == null) { directories = "no" ;}
	if (pOptions.location != null) { location = pOptions.location;} else if (location == null) { location = "no" ;}
	if (pOptions.menubar != null) { menubar = pOptions.menubar;} else if (menubar == null) { menubar = "no" ;}
	if (pOptions.resizable != null) { resizable = pOptions.resizable;} else if (resizable == null) { resizable = "no" ;}
	if (pOptions.scrollbars != null) { scrollbars = pOptions.scrollbars;} else if (scrollbars == null) { scrollbars = "yes" ;}
	if (pOptions.status != null) { status = pOptions.status; } else if (status == null) { status = "yes" ;}
	if (pOptions.toolbar != null) { toolbar = pOptions.toolbar; } else if (toolbar == null) { toolbar = "no" ;}
	if (pOptions.top != null) { top = pOptions.top} else if (top == null) { top = "50";}
	if (pOptions.left != null) { left = pOptions.left;} else if (left == null) { left = "50" ;}
	if (pOptions.width != null) { width = pOptions.width;} else if (width == null) { width = "250" ;}
	if (pOptions.height != null) { height = pOptions.height;} else if (height == null) { height = "250" ;}
	if (pOptions.winName != null) { winName = pOptions.winName;} else if (winName == null) { winName = "popUp" ;}
	if (pOptions.clickTrack != null) { clickTrackValue = pOptions.clickTrack;}
	
	// build our complete window options statement
	windowOptions = "width=" + width + ", height=" + height + ", directories=" + directories + ", location=" + location + ", menubar=" + menubar + ", resizable=" + resizable + ", scrollbars=" + scrollbars + ", toolbar=" + toolbar + ", status=" + status + ", toolbar=" + toolbar + ", top=" + top + ", left=" + left;

	var newWindow = window.open(url,winName,windowOptions);
	//alert(windowOptions);
	if (newWindow == null){
		//alert('A popup containing important information was blocked by your browser. Please enable popups for this site in order to view this information.');
		var errorBox = document.getElementById("blockedPopup");
		errorBox.style.display = "block";

		
	} else { 
		if (window.focus && newWindow) { newWindow.focus() }
	}
}

/**********/
var interstitialPopUp = null;
var exLink = "";
var openNewWin = true;
var ifPopUp = null;
var type = "";

function interstitialExternal(strLink,optOpenWin,popUp,typePop){
	exLink = strLink;
	if(optOpenWin != null){
		openNewWin = optOpenWin;
	}
	if(popUp != null){
		ifPopUp = popUp;	
		type = typePop;
	}
	var w = 355, h = 340;
	var popW = 355, popH = 192;
	if (navigator.appName=="Microsoft Internet Explorer"){
		if(navigator.appVersion.indexOf("MSIE 7.0")!=-1){
			var popW = 354, popH = 187;
		}
		 else{
			var popW = 354, popH = 187;
		}
	}
	if (document.all || document.layers) {
		w = screen.availWidth;
	    h = screen.availHeight;
	}
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	interstitialPopUp =  window.open("/include/interstitial_warning/interstitialWarning.htm","","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+popW+",height="+popH+",top="+topPos+",left="+leftPos);
}

function exitGMCOM(){
	if(ifPopUp != null)
		openWin();
	else
		if(openNewWin)
			window.open(exLink);
		else
			document.location = exLink;
}

function openWin(){
	if (type=="new"){
		var newW;
		newW =	window.opener.open(exLink, "blank");
		newW.focus();
	}else{
		window.opener.location.href= exLink;
		window.opener.focus();
	}
}
/*
var interstitialPopUp = null;
var exLink = "";
var openNewWin = true;

function interstitialExternalRecall(strLink,optOpenWin){
	exLink = strLink;
	if(optOpenWin != null){
		openNewWin = optOpenWin;
	}
	var w = 480, h = 340;
	var popW = 320, popH = 300;
	if (document.all || document.layers) {
		w = screen.availWidth;
	    h = screen.availHeight;
	}
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	interstitialPopUp =  window.open("/include/interstitial_warning/interstitialWarningRecall.htm?query=recall","","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+popW+",height="+popH+",top="+topPos+",left="+leftPos);
}

function exitGMCOM(){
	if(openNewWin)
		window.open(exLink);
	else
		document.location = exLink;
}


var interstitialPopUp = null;
var exLink = "";
var openNewWin = true;

function interstitialExternalWarranty(strLink,optOpenWin){
	exLink = strLink;
	if(optOpenWin != null){
		openNewWin = optOpenWin;
	}
	var w = 480, h = 340;
	var popW = 320, popH = 300;
	if (document.all || document.layers) {
		w = screen.availWidth;
	    h = screen.availHeight;
	}
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	interstitialPopUp =  window.open("/include/interstitial_warning/interstitialWarningWarrantee.htm?query=warrantee","","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+popW+",height="+popH+",top="+topPos+",left="+leftPos);
}

function exitGMCOM(){
	if(openNewWin)
		window.open(exLink);
	else
		document.location = exLink;
}
*/

function showTab(mdiv)
{
   var e1= document.getElementById(mdiv);
   e1.className= "divOn";
   var e2= "";
   if (mdiv=="houston1")
      e2= document.getElementById("houston2");
   else
      e2= document.getElementById("houston1");
   e2.className= "divOff";
}

function openWindow(url, type){
	if (type=="new"){
		var newW;
		newW =	window.opener.open(url, "blank");
		newW.focus();
	}else{
		window.opener.location.href= url;
		window.opener.focus();
	}
}