/*
var newdomainurl;
var gmcurrentlocation;

if (location.href.indexOf("preprod.")>-1&&(location.href.indexOf("/saturn/")>-1||location.href.indexOf("/saab/")>-1)&&(location.href.indexOf("saturn.preprod.gm.ca")==-1&&location.href.indexOf("saab.preprod.gm.ca")==-1)){
	newdomainurl = (location.href.indexOf("/saturn/")>-1) ? "saturn.preprod.gm.ca":"saab.preprod.gm.ca"
	gmcurrentlocation = location.href;
	location.replace(gmcurrentlocation.replace(location.hostname,newdomainurl));
} else if(location.href.indexOf("preprod.")==-1&&(location.href.indexOf("/saturn/")>-1||location.href.indexOf("/saab/")>-1)&&(location.href.indexOf("saturn.gm.ca")==-1&&location.href.indexOf("saab.gm.ca")==-1)){
	newdomainurl = (location.href.indexOf("/saturn/")>-1) ? "saturn.gm.ca":"saab.gm.ca"
	gmcurrentlocation = location.href;
	location.replace(gmcurrentlocation.replace(location.hostname,newdomainurl));
}
*/
self.name = "cossette_ssi_window";

/***** cookie functions *****/

// Write a cookie value
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

// Retrieve a named cookie value
function getCookie(name) {
	var dc = document.cookie;

	// find beginning of cookie value in document.cookie
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else begin += 2;

	// find end of cookie value
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;

	// return cookie value
	return unescape(dc.substring(begin + prefix.length, end));
}

/*** deleteCookie overload for 2-term calls (global_nav) kn Sept 22/08***/
function deleteCookie(name, path) {
	var thing =  deleteCookie(name, path, ""); 
	//return thing;
}

// Delete a named cookie value
function deleteCookie(name, path, domain) {
	var value = getCookie(name);
	if (value != null) document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
	return value;
}

// Test for cookie support
function supportsCookies(rootPath) {
   setCookie('checking_for_cookie_support', 'testing123', '', (rootPath != null ? rootPath : ''));
   if (getCookie('checking_for_cookie_support')) return true;
   else return false;
}

/*********** set url for offer search links *************/
// modded jan11/08 kn for gm.ca
var appUrlItl = "http://apps.itl" + ".gm.ca/app/GMCanada/offersearch/ThumbnailDisplay.do";
var appUrlPreprod = "http://apps.preprod" + ".gm.ca/app/GMCanada/offersearch/ThumbnailDisplay.do";
var appUrl = "http://apps" + ".gm.ca/app/GMCanada/offersearch/ThumbnailDisplay.do";

appUrl = (location.href.indexOf('itl.')>-1) ? appUrlItl: appUrl;
appUrl = (location.href.indexOf('preprod.')>-1) ? appUrlPreprod: appUrl;


/********* vehicle offer functions ***********/	
/** these are needed to properly style the vehicle offer search results in crappy IE **/
function styleIEOffers() {
	
	if (top.location.href.indexOf(".do") != -1) {
		if (document.all) {
			// get reference to offer list container
			var objOfferContainer = getRef("vehicle-offer-container");
			
			if (objOfferContainer != null) {
				var arrObjChildren = objOfferContainer.childNodes; // list of offer <ul> nodes
				
				// loop through sets of <ul> for each offer
				for (i = 0; i < arrObjChildren.length; i++) {
					if (arrObjChildren[i].nodeName == "UL") {
						// for each offer, attach specific styles to the first <li> element
						arrObjChildren[i].firstChild.className = "firstOfferChild";
					}	
				}
			}	
		}
		var thebuttimage
		var spantags=document.getElementsByTagName("td")
		var objGoBtn = getElementbyClass(spantags, 'goBtn')
		var orgimg;
		if (objGoBtn != null) {
			var theofferpccontent = objGoBtn.innerHTML;
			if (location.href.indexOf("/english/vehicles/saturn/")>-1 || location.href.indexOf("/english/vehicles/migrated-content/saturn/")>-1) {
				//english saturn
				orgimg = "/images/vehicles/common/8_offe_btn_go_en_CA.gif";
				thebuttimage = "/ss/images/en_CA/saturn/common/saturn_go_btn.gif";
			}
			else if (location.href.indexOf("/french/vehicles/saturn/")>-1 || location.href.indexOf("/french/vehicles/migrated-content/saturn/")>-1) {
				//french saturn
				orgimg = "/images/vehicles/common/8_offe_btn_go_fr_CA.gif";
				thebuttimage = "/ss/images/fr_CA/saturn/common/saturn_go_btn.gif";
			}
			else if (location.href.indexOf("/english/vehicles/saab/")>-1 || location.href.indexOf("/english/vehicles/migrated-content/saab/")>-1) {
				//english saab
				orgimg = "/images/vehicles/common/S_offe_btn_go_en_CA.gif";
				thebuttimage = "/ss/images/en_CA/saab/common/saab-go-bttn.gif";
			}
			else {
				//french saab
				orgimg = "/images/vehicles/common/S_offe_btn_go_fr_CA.gif";
				thebuttimage = "/ss/images/fr_CA/saab/common/saab-go-bttn.gif";
			}
			//alert(thebuttimage);
			
				//if (location.href.indexOf("/saturn/")>-1)thebuttimage = "/ss/images/en_CA/saturn/common/saturn_go_btn.gif";
				//else thebuttimage = "/ss/images/en_CA/saab/common/saab-go-bttn.gif";
			objGoBtn.innerHTML = theofferpccontent.replace(orgimg,thebuttimage);
		}	
	}	
}
function getElementbyClass(rootobj, classname){
	var temparray=null;
	var inc=0; 
	var rootlength=rootobj.length
	for (i=0; i<rootlength; i++){
		if (rootobj[i].className==classname)
			//temparray[inc++]=rootobj[i]
			temparray=rootobj[i]
	}
	return temparray
}


/********* general functions ***********/	
function getCurrentPage() {
	var url = top.location.href;
	url = (url.indexOf("/") > -1) ? url.substring(url.lastIndexOf("/"), url.length) : url;
	url = (url.indexOf(".") > -1) ? url.substring(url.lastIndexOf("."), url.length) : url;
	return url;
}

function getCurrentBrand() {
	var url = top.location.href;
	var brand = (url.indexOf("brand=saturn") !=-1||(url.indexOf("brand=saab") ==-1&&url.indexOf("/saab/") ==-1)) ? "saturn" : "saab";
	return brand;
}

function siteCatalystLink(obj, linkName){
	s_linkType = "o";
	s_linkName = linkName;
	//s_events = "scCheckout";
	//s_eVar1 = "Test Link Event2";
	//s_eVar3 = "english";
	//s_eVar10 = "Tom.com";
	//count=0;for(x in obj){count++;alert(x+' '+obj[x]);if(count > 100)break;}
	s_lnk=s_co(obj);
	
//	var suite_id = (location.href.indexOf('http://gm.ca')>-1 || location.href.indexOf('http://saturncanada.com')>-1 || location.href.indexOf('http://saabcanada.com')>-1 || location.href.indexOf('http://www.')>-1) ? "GM.ca" : "devgmcanadacom";
	var suite_id = (location.href.indexOf('itl.')>-1 || location.href.indexOf('preprod.')>-1) ? "dev.gm.ca" : "GM.ca";
	s_gs(suite_id);
}

function printPage() {
	//alert("not yet functional");
	// redirect to printable version of page
	tmp = location.href
	if (tmp.indexOf("/english/")> -1)location.href=tmp.replace("/english/","/english_lw/");
	else if (tmp.indexOf("/english_lw/")> -1)location.href=tmp.replace("/english_lw/","/english/");
	else if (tmp.indexOf("/french/")> -1)location.href=tmp.replace("/french/","/french_lw/");
	else if (tmp.indexOf("/french_lw/")> -1)location.href=tmp.replace("/french_lw/","/french/");
	
}

function printSPagefjord(){
	//var tmp = location.href +"&contextDisplayMode=lw";
	var tmp = location.href
	if (tmp.indexOf("contextDisplayMode=normal") > -1) location.href = tmp.replace("contextDisplayMode=normal","contextDisplayMode=lw");
	else location.href = tmp +"&contextDisplayMode=lw" ;
}

function printPagefjord(){
	var tmp = location.href;
	//alert(!);
	// check if home pages with only domain
	var r = new RegExp("gm.ca/$");
	if (tmp.match(r)) {
		if (tmp.indexOf("saab") > -1) location.href = tmp +"/ss/english_lw/vehicles/saab/saab.html";
		if (tmp.indexOf("saturn") > -1) location.href = tmp +"/ss/english_lw/vehicles/saturn/saturn.html";
		return;
	}
	
	// account for difference b/w .jsp vehicle pages and .html lw pages
	/*
	if (!(
			tmp.indexOf("/news/") > -1 || 
			tmp.indexOf("/service/") > -1 || 
			tmp.indexOf("/innovations/") > -1 || 
			tmp.indexOf("/difference/") > -1 || 
			tmp.indexOf("/community/") > -1 || 
			tmp.indexOf("saturn.html") > -1 || 
			tmp.indexOf("saab.html") > -1
		)) 
	{
		if (tmp.indexOf(".html") > -1) tmp = tmp.replace(".html", ".jsp");
		else if (tmp.indexOf(".jsp") > -1) tmp = tmp.replace(".jsp", ".html");
	}	
	*/
	
	// toggle URL
	if (tmp.indexOf("/english/") > -1) location.href=tmp.replace("/english/","/english_lw/");
	else if (tmp.indexOf("/english_lw/") > -1) location.href=tmp.replace("/english_lw/","/english/");
	else if (tmp.indexOf("/french/") > -1) location.href=tmp.replace("/french/","/french_lw/");
	else if (tmp.indexOf("/french_lw/") > -1) location.href=tmp.replace("/french_lw/","/french/");
	
	
}

function getServer() {
	var url = location.href;
	var protocol = url.substring(0, url.indexOf("http://") + 7);
	var server = url.substring(protocol.length, url.indexOf("/", protocol.length));
	return protocol + server;
}

//function tellAFriend() {
	//location.href = "/servlet/pageTAF?page=" + escape(location.href);
	//var getServer2 = getServer();
	
	//if (location.href.indexOf("saabcanada.com") > -1) getServer2=getServer().replace("saabcanada.com","gm.ca");
	//location.href = getServer2 + "/servlet/pageTAF?page=" + escape(location.href);
//}


function tellAFriend(divCode) {
	var url = escape(document.location.href);
	document.location = "/servlet/pageTAF?page=" + url + '&div=' + divCode;
    }

// function for email page icon, uses escape method to trap multiple instances of ?
var divCode = '';

function pageTAF() {
	var url = escape(document.location.href);
	document.location = "/servlet/pageTAF?page=" + url + '&div=' + divCode;
    }



function ParseQueryString(searchStr) {
	var tempStr = window.location.search;
    var startOfString = tempStr.indexOf(searchStr);
    var result = "";
    if (startOfString != -1) {
    	var endOfString = tempStr.indexOf("&",startOfString+searchStr.length+1);
       	if (endOfString != -1) {
           	result = tempStr.substring(startOfString+searchStr.length+1, endOfString);
    	}
    	else {
    		result = tempStr.substring(startOfString+searchStr.length+1, tempStr.length);
    	}
    }
	return result;
}










function popWindow(url, wName, options) {
	if (wName == "") wName = "newWin";
	if (options == "") {
		window.open(url, wName); 
	} else {
		window.open(url, wName, options);
	}	
}

function retrieveImgNum(imgName) {
/***********
	this function assumes that all image names will 
	end with with a number of the format
	imagename_##.ext
************/	
	var startIndex = imgName.lastIndexOf("_") + 1;
	var endIndex = imgName.indexOf(".", startIndex);
	return imgName.substring(startIndex, endIndex);

}

function switchLang () {
	engDelimiter = 'english';
	freDelimiter = 'french';
	newURL = switchLangSearch(engDelimiter, freDelimiter);
	if (newURL != 'null') {
		self.location = newURL;
		return;
	} 
	engDelimiter = "lang=en";
	freDelimeter = "lang=fr";
	newURL = switchLangSearch(engDelimiter, freDelimeter);
	if (newURL != 'null') {
		self.location = newURL;
		return;
	}
	engDelimiter = "_code=en";
	freDelimeter = "_code=fr";
	newURL = switchLangSearch(engDelimiter, freDelimeter);
	if (newURL != 'null') {
		self.location = newURL;
		return;
	}
}
function switchLangSearch (engDelim, freDelim) {
	docURL = document.URL;
	if (docURL.indexOf("/english/") == -1 && docURL.indexOf("/french/") == -1 && (docURL.indexOf("saturncanada") != -1 || docURL.indexOf("saabcanada") != -1 || docURL.indexOf("saturn.gmcanada") != -1 || docURL.indexOf("saab.gmcanada") != -1 || docURL.indexOf("preprod.gmcanada") != -1)) {
		if (docURL.indexOf("saturn.gmcanada") != -1 || docURL.indexOf("saturncanada") != -1 || docURL.indexOf("saturn.preprod.gmcanada") != -1) {
			docURL += "/ss/english/vehicles/saturn/saturn.html";
		} else if (docURL.indexOf("saab.gmcanada") != -1 || docURL.indexOf("saabcanada") != -1 || docURL.indexOf("saab.preprod.gmcanada") != -1) {
			docURL += "/ss/english/vehicles/saab/saab.html";
		}
	}
	newURL = 'null';
	engPosition = 0;
	frePosition = 0;
	charStart = 0;
	charEnd = docURL.length + 1;
	engDelimiter = engDelim;
	freDelimiter = freDelim;
	do {
		var test = docURL.substr(charStart, engDelimiter.length);
		if (test == engDelimiter) { engPosition = charStart;}
		charStart++;
	}
	while (charStart < charEnd - engDelimiter.length);
	if (engPosition > 0) {
		newURL = docURL.substr(0,engPosition) + freDelimiter + docURL.substr((engPosition + engDelimiter.length),docURL.length);
	} else {
		charStart = 0;
		do {
			var test = docURL.substr(charStart, freDelimiter.length)
			if (test == freDelimiter) { frePosition = charStart;}
			charStart++;
		}
		while (charStart < charEnd - freDelimiter.length);
		if (frePosition > 0) {
			newURL = docURL.substr(0,frePosition) + engDelimiter + docURL.substr((frePosition + freDelimiter.length),docURL.length);
		}
	}
	return newURL;
}

function switchSLang () {
	engDelimiter = 'en_CA';
	freDelimiter = 'fr_CA';
	newURL = switchSLangSearch(engDelimiter, freDelimiter);
	if (newURL != 'null') {
		self.location = newURL;
		return;
	} 
	engDelimiter = "lang=en";
	freDelimeter = "lang=fr";
	newURL = switchSLangSearch(engDelimiter, freDelimiter);
	if (newURL != 'null') {
		self.location = newURL;
		return;
	}
	engDelimiter = "_code=en";
	freDelimeter = "_code=fr";
	newURL = switchSLangSearch(engDelimiter, freDelimiter);
	if (newURL != 'null') {
		self.location = newURL;
		return;
	}
}
function switchSLangSearch (engDelim, freDelim) {
	docURL = document.URL;
	if (docURL.indexOf("en_CA") == -1 && docURL.indexOf("fr_CA") == -1 && (docURL.indexOf("saturncanada") != -1 || docURL.indexOf("saabcanada") != -1 || docURL.indexOf("saturn.gmcanada") != -1 || docURL.indexOf("saab.gmcanada") != -1 || docURL.indexOf("preprod.gmcanada") != -1)) {
		if (docURL.indexOf("saturn.gmcanada") != -1 || docURL.indexOf("saturncanada") != -1 || docURL.indexOf("saturn.preprod.gmcanada") != -1) {
			docURL += "/ss/gm/homepage.do?lang=en_CA&brand=saturn";
		} else if (docURL.indexOf("saab.gmcanada") != -1 || docURL.indexOf("saabcanada") != -1 || docURL.indexOf("saab.preprod.gmcanada") != -1) {
			docURL += "/ss/gm/homepage.do?lang=en_CA&brand=saab";
		}
	}
	newURL = 'null';
	engPosition = 0;
	frePosition = 0;
	charStart = 0;
	charEnd = docURL.length + 1;
	engDelimiter = engDelim;
	freDelimiter = freDelim;
	do {
		var test = docURL.substr(charStart, engDelimiter.length);
		if (test == engDelimiter) { engPosition = charStart;}
		charStart++;
	}
	while (charStart < charEnd - engDelimiter.length);
	if (engPosition > 0) {
		newURL = docURL.substr(0,engPosition) + freDelimiter + docURL.substr((engPosition + engDelimiter.length),docURL.length);
	} else {
		charStart = 0;
		do {
			var test = docURL.substr(charStart, freDelimiter.length)
			if (test == freDelimiter) { frePosition = charStart;}
			charStart++;
		}
		while (charStart < charEnd - freDelimiter.length);
		if (frePosition > 0) {
			newURL = docURL.substr(0,frePosition) + engDelimiter + docURL.substr((frePosition + freDelimiter.length),docURL.length);
		}
	}
	return newURL;
}




// create a reference to an object in IE and most modern browsers
function getRef(id) { 
        return (document.getElementById ? document.getElementById(id) : document.all[id]); 
}
//Global Variables for flyouts
var cossette_tlaBlock;
var cossette_tlaisNav4 = (document.layers) ? 1 : 0;
var cossette_clayer = "";
var currNav="";

function setLyr(obj,lyr)
{
	if (cossette_clayer!=lyr && cossette_clayer!="") setTimerSpecific(1,cossette_clayer);
	cossette_clayer = lyr;
	
	if (cossette_tlaisNav4) {
		cossette_tlaBlock = 'document.' + lyr;
		eval(cossette_tlaBlock);
	} else {
		cossette_tlaBlock = document.getElementById(lyr).style;
	}

	var brand = getCurrentBrand();
	var browserName=navigator.appName; 
	var xOffset = 0;
	var yOffset = 0;
	if (browserName=="Netscape")
	{ 
		// set offsets
		var xOffset = (brand == "saturn") ? 0 : -273;
		var yOffset = (brand == "saturn") ? 0 : 86;
	
	}
	else if (browserName=="Microsoft Internet Explorer")
	 {
		var xOffset = (brand == "saturn") ? 0 : 0;
		var yOffset = (brand == "saturn") ? 0 : 0;
		
	 }

	cossette_tlaBlock.xpos = parseInt(cossette_tlaBlock.left);	
	cossette_tlaBlock.ypos = parseInt(cossette_tlaBlock.top);
	
	cossette_tlaBlock.xpos = findPosX(document.images[obj]) + xOffset;
	cossette_tlaBlock.ypos = findPosY(document.images[obj]) + yOffset;
	
	cossette_tlaBlock.left = cossette_tlaBlock.xpos;
	cossette_tlaBlock.top = cossette_tlaBlock.ypos;
	cossette_tlaBlock.visibility = 'visible';
	
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}

function getElementWidth(elem) {
	if(document.getElementById) {
		var elem = document.getElementById(elem);
	} else if (document.all){
		var elem = document.all[elem];
	}
	xPos = elem.offsetWidth;
	return xPos;
}


/* Copied from functions.js */

var layerTimeout = 0;
var subNavId = "div_flyout";
var numSubNavLayers = 5;

/***********************************************
	functions for controlling on/off graphic
	states
 ***********************************************/

function setDayNavFlag(name) {
	var boolReturn = false;
	if ((typeof(gStrDay) != "undefined" &&  gStrDay != null) && (typeof(gStrNextDay) != "undefined" &&  gStrNextDay != null)) {
		if (name == "mainnav_day_"+ gStrDay || name == "mainnav_day_"+ gStrNextDay) {
			boolReturn = true;
		}
	}
	return boolReturn;
}

function doswap(layer,name,onoff){
	var layerName = subNavId + layer;
	if (layer.indexOf("_") != -1) layerName = layer;
	// disables rollover for active day navigation buttons when their content is displayed in iframe
	//var dayActiveNavFlag = setDayNavFlag(name);
	
	//if (!dayActiveNavFlag) {
		if(layer!='' && layer!='true' && bw.ns4){
			//if (layerName.indexOf("welcomeFrame") == -1) {
				var imageSrc = eval('document.'+ layerName +'.document.images["'+name+'"].src');
				eval('document.'+ layerName +'.document.images["'+name+'"].src = "'+swapRoll(imageSrc,onoff)+'";');
			//}	
		} else {
			var imageSrc = document.images[name].src;
			document.images[name].src = swapRoll(imageSrc,onoff);
		}
	//}	
}

function swapRoll(tmp1,onoff) {
	if (onoff == true) {
		return tmp1.replace("off.gif","on.gif");
	} else if (onoff == false){
		return tmp1.replace("on.gif","off.gif");
	} else if (onoff.indexOf('active') != -1) {
		return tmp1.replace("on.gif","active.gif");
	} else {
		return tmp1.replace("active.gif","off.gif")
	}
}

function clearTimer() {
	window.clearInterval(layerTimeout);
}

function setTimer(interval,what,arrFlyouts) {
	layerTimeout = window.setTimeout('resetAllLayers(arrFlyouts)',interval);
}


function setTimerSpecific(interval,what) {
	var sub01 = document.getElementById(what);
	//sub01.style.display = "none";
	sub01.style.visibility = "hidden";
}

function resetAllLayers(arrFlyouts) {
	
	for (i = 0; i < arrFlyouts.length; i++) {
		var sub00 = document.getElementById(arrFlyouts[i]);
		sub00.style.visibility = "hidden";
		if (currNav.indexOf(sub00.id) > -1) sub00.style.visibility = "visible";		
	}
	/*
	var sub00 = document.getElementById("flyout-93conv-div");
		sub00.style.visibility = "hidden";
		if (currNav.indexOf(sub00.id) > -1) sub00.style.visibility = "visible";		
		
	var sub01 = document.getElementById("flyout-93sedan-div");
	var sub02 = document.getElementById("flyout-93combi-div");
	var sub03 = document.getElementById("flyout-95sedan-div");
	var sub04 = document.getElementById("flyout-95sportcombi-div");
	var sub05 = document.getElementById("flyout-97x-div");
	var sub06 = document.getElementById("flyout-aerox-div");

	
	sub01.style.visibility = "hidden";
	sub02.style.visibility = "hidden";
	sub03.style.visibility = "hidden";
	sub04.style.visibility = "hidden";
	sub05.style.visibility = "hidden";
	sub06.style.visibility = "hidden";
	
	
	if (currNav.indexOf(sub01.id) > -1) {
		sub01.style.visibility = "visible";		
	}
	if (currNav.indexOf(sub02.id) > -1) {
		sub02.style.visibility = "visible";		
	}
	if (currNav.indexOf(sub03.id) > -1) {
		sub03.style.visibility = "visible";		
	}
	if (currNav.indexOf(sub04.id) > -1) {
		sub04.style.visibility = "visible";		
	}
	if (currNav.indexOf(sub05.id) > -1) {
		sub05.style.visibility = "visible";		
	}
	if (currNav.indexOf(sub06.id) > -1) {
		sub06.style.visibility = "visible";		
	}
//	for (i=1; i<=numSubNavLayers; i++) setLayers("", subNavId + i,false);
*/
}

function currentNavOn(img,flyout) {
	setLyr(img,flyout);
}

function mainNavOn(ref,flyout) {
	//alert(ref + flyout);
	if (flyout) setLyr(ref,flyout);
	hideActiveNav(flyout);
	clearTimer();
	//doswap('true',img,true);
}

function hideActiveNav(flyout) {
	if (flyout.indexOf(currNav) == -1) {
		var currNavEl = document.getElementById(currNav);
		currNavEl.style.visibility = "hidden";
	}
}

function mainNavOff(flyout,arrFlyouts) {
	var flyoutStr = flyout + "";

	//stops page's active nav from hiding on rollover
	if (currNav.indexOf(flyoutStr) == -1) {
		setTimer(50,flyout,arrFlyouts);		
		}

	//doswap('',img, false);
	//}



// shows or hides an object as a block
// NOTE : uses visibility and display styles for collapse/expand effect
function showHideObject(objectId){ 

        var theObject = getRef(objectId); 	
		//var theMovie = getRef('objFlash');
		var theMovie = "";
		
		if (theObject.style.visibility == 'visible') {
			// hide
			theObject.style.visibility = 'hidden'; 
			theObject.style.display = 'none';		
			if (theMovie) { theMovie.wmode = "window"; }
			}
		else {
			// show
			theObject.style.visibility = 'visible'; 
			theObject.style.display = 'block';
			if (theMovie) { theMovie.wmode = "transparent"; }
		}
		
} 







function showFlyout(objToPos, objPosRef) {
	// position object
	var browserName=navigator.appName; 
if (browserName=="Netscape")
	{ 
		if (objPosRef != "") {
			// set offsets
			var objStyleRef = getStyleRef(objToPos);
			var brand = getCurrentBrand();
			var xOffset = (brand == "saturn") ? 160 : 171;
			//var xOffset = (brand == "saab") ? 54 : 291;
			// get position coordinates for reference object
			var theObjectRef = document.images[objPosRef];
			var posx = findPosX(theObjectRef) + xOffset;
			//var posx = findPosX(theObjectRef);
			//var yOffset = (brand == "saturn") ? -5 : -50;
			var yOffset = (brand == "saturn") ? 0 : -50;
			//var yOffset = (brand == "saab") ? -56 : 0;
			var posy = findPosY(theObjectRef) + yOffset;
			
			//alert("pos: "+ posx +", "+ posy);
			
			// position flyout according to reference object
			objStyleRef.top = posy;
			objStyleRef.left = posx;
		}

	}
else 
	{ 
	 if (browserName=="Microsoft Internet Explorer")
		 {
			 if (objPosRef != "") {
			// set offsets
			var objStyleRef = getStyleRef(objToPos);
			var brand = getCurrentBrand();
			var xOffset = (brand == "saturn") ? 160 : 172;
			//var xOffset = (brand == "saab") ? 54 : 291;
			// get position coordinates for reference object
			var theObjectRef = document.images[objPosRef];
			var posx = findPosX(theObjectRef) + xOffset;
			//var posx = findPosX(theObjectRef);
			var yOffset = (brand == "saturn") ? -5 : -50;
			//var yOffset = (brand == "saab") ? -56 : 0;
			var posy = findPosY(theObjectRef) + yOffset;
			
			//alert("pos: "+ posx +", "+ posy);
			
			// position flyout according to reference object
			objStyleRef.top = posy;
			objStyleRef.left = posx;
			}

		 }
 
	}

	showHideObject(objToPos);
}

function showEmbedAttribs() {
	var theMovie = document.getElementById('embedFlash');
	var strReturn = "";
	for (item in theMovie) {
		strReturn += "-> "+ item +" - "+ theMovie[item] +"<br>\n";
	}
	//alert(strReturn);
	//document.write(strReturn);
	document.forms['testform'].testarea.value = strReturn;
}
//showEmbedAttribs();


function showObject(objectId) {
	//alert("hide: "+ objectId);
	var theObject = getRef(objectId); 	
	theObject.style.visibility = 'visible'; 
	theObject.style.display = 'block';
}

function hideObject(objectId) {
	//alert("show: "+ objectId);
	var theObject = getRef(objectId); 	
	theObject.style.visibility = 'hidden'; 
	theObject.style.display = 'none';		
}


/*********** offer page search functions *************/
function submitOfferSearch1(pcode, lang){

//for(k=0;k<document.forms.length;k++){alert(document.forms[k].name)}
   if(validatePostalCodepc(pcode)){
   		document.forms['searchpc'].lang.value = lang;
		/*
		if (location.href.indexOf("preprod.")>-1)document.forms['searchpc'].action='http://itlcs.gmcanada.e-gm.net/app/GMCanada/offersearch/ThumbnailDisplay.do';
		else document.forms['searchpc'].action='http://apps.itl.*gm.ca/app/GMCanada/offersearch/ThumbnailDisplay.do';
		*/
		//document.forms['searchpc'].action=appUrl; // appUrl set at top of page
		document.forms['searchpc'].method='get';
		document.forms['searchpc'].submit();
   }
}

function submitOfferSearchHome(pcode, lang, theform){
   if(validatePostalCodepc(pcode)){
   		theform.pc.value = pcode.toUpperCase();
		theform.lang.value = lang;
		/*
		if (location.href.indexOf("preprod.")>-1)theform.action='http://itlcs.gmcanada.e-gm.net/app/GMCanada/offersearch/ThumbnailDisplay.do';
		else theform.action='http://apps.itl.*gm.ca/app/GMCanada/offersearch/ThumbnailDisplay.do';
		*/
		theform.action=appUrl; // appUrl set at top of page
		theform.method='get';
		theform.submit();
   }
}

function submitTheForm(){
	submitOfferSearchHome(document.forms[0].pc.value, 'en', document.forms[0]);
}

function submit2(pcode){
if(document.regForm&&document.main.pc.value!=""){
	document.regForm.pc.value = "";
	document.regForm.pc.value = pcode;
   if(validatePostalCode()){
   	document.regForm.submit();
   }
   }
}
	
	
function validatePostalCodepc(thecode) {
   var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
   var num = '0123456789';
   var code = '';
   //code = document.regForm.pc.value;
	 code = thecode;
   if (code.length < 6) {
	   if (top.location.href.indexOf("/french/")!=-1){
	   		alert("Desol\u00E9! Le code postal vous avez \u00E9crit est inadmissible. Veuillez resaisir votre code postal et le code postal canadien valide de l'essai encore.(A inclut les lettres (a) et les nombres (#) dans l'ordre suivant : A#A #A#)")
	   }else{ 
			alert("Sorry!The postal code you have entered is not valid. Please re-enter your postal code and try again.(A valid Canadian postal code includes letters (A) and numbers (#) in the following sequence: A#A #A#)");
	   }
     return false;
   } else {
     if (code.length == 7) {
       var loc = code.indexOf(" ");
       if (loc != -1) {
         code = code.substring(0, loc) + code.substring(loc+1, 7);
       }
     }
     for (var i=0; i < code.length; i++) {
       ch = "" + code.substring(i, i+1);       
       if ((((i == 0) || (i == 2) || (i == 4)) && (alpha.indexOf(ch) == -1)) ||
        	(((i == 1) || (i == 3) || (i == 5)) && (num.indexOf(ch) == -1))) {
          if (top.location.href.indexOf("/french/")!=-1){
	   		alert("Desol\u00E9! Le code postal vous avez \u00E9crit est inadmissible. Veuillez resaisir votre code postal et le code postal canadien valide de l'essai encore.(A inclut les lettres (a) et les nombres (#) dans l'ordre suivant : A#A #A#)")
	   }else{ 
			alert("Sorry!The postal code you have entered is not valid. Please re-enter your postal code and try again.(A valid Canadian postal code includes letters (A) and numbers (#) in the following sequence: A#A #A#)");
	   }return false;
       }
     }
     return true;
   }
}
		
function validatePostalCode() {
   var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
   var num = '0123456789';
   var code = '';
   //code = document.regForm.pc.value;
	 code = document.forms[0].pc.value;
   if (code.length < 6) {
      if (top.location.href.indexOf("/french/")!=-1){
	   		alert("Desol\u00E9! Le code postal vous avez \u00E9crit est inadmissible. Veuillez resaisir votre code postal et le code postal canadien valide de l'essai encore.(A inclut les lettres (a) et les nombres (#) dans l'ordre suivant : A#A #A#)")
	   }else{ 
			alert("Sorry!The postal code you have entered is not valid. Please re-enter your postal code and try again.(A valid Canadian postal code includes letters (A) and numbers (#) in the following sequence: A#A #A#)");
	   }
	   return false;
   } else {
     if (code.length == 7) {
       var loc = code.indexOf(" ");
       if (loc != -1) {
         code = code.substring(0, loc) + code.substring(loc+1, 7);
       }
     }
     for (var i=0; i < code.length; i++) {
       ch = "" + code.substring(i, i+1);       
       if ((((i == 0) || (i == 2) || (i == 4)) && (alpha.indexOf(ch) == -1)) ||
        	(((i == 1) || (i == 3) || (i == 5)) && (num.indexOf(ch) == -1))) {
          if (top.location.href.indexOf("/french/")!=-1){
	   		alert("Desol\u00E9! Le code postal vous avez \u00E9crit est inadmissible. Veuillez resaisir votre code postal et le code postal canadien valide de l'essai encore.(A inclut les lettres (a) et les nombres (#) dans l'ordre suivant : A#A #A#)")
	   }else{ 
			alert("Sorry!The postal code you have entered is not valid. Please re-enter your postal code and try again.(A valid Canadian postal code includes letters (A) and numbers (#) in the following sequence: A#A #A#)");
	   }
	   return false;
       }
     }
     return true;
   }
}

/*********** onstar link functions *************/
function browserwe()
	 { 
		if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 )) 
			{ 
				newWindow=window.open("http://www.saabcanada.com/ssi/english/vehicles/saab/onstar/CheckForFlash.html", "MainSaab", "scrollbars=no,menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=660,height=510,left=0,top=0"); 
				//location.replace("thankYou.html");
			} 
			
		else if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )) 
			{ 
				newWindow=window.open("http://www.saabcanada.com/ss/english/vehicles/saab/onstar/CheckForFlash.html", "MainSaab", "scrollbars=no,menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=660,height=510,left=0,top=0"); 
				//location.replace("thankYou.html");
			} 
	
		else 
			{ 
				newWindow=window.open("http://www.saabcanada.com/ss/english/vehicles/saab/onstar/CheckForFlash.html", "MainSaab", "scrollbars=no,menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=660,height=510,left=0,top=0"); 
				//location.replace("thankYou.html");
			} 
}
function browserwf()
	 { 
		if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 )) 
			{ 
				newWindow=window.open("http://www.saabcanada.com/ss/french/vehicles/saab/onstar/CheckForFlash.html", "MainSaab", "scrollbars=no,menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=660,height=510,left=0,top=0"); 
				//location.replace("thankYou.html");
			} 
			
		else if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )) 
			{ 
				newWindow=window.open("http://www.saabcanada.com/ssi/french/vehicles/saab/onstar/CheckForFlash.html", "MainSaab", "scrollbars=no,menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=660,height=510,left=0,top=0"); 
				//location.replace("thankYou.html");
			} 
	
		else 
			{ 
				newWindow=window.open("http://www.saabcanada.com/ss/french/vehicles/saab/onstar/CheckForFlash.html", "MainSaab", "scrollbars=no,menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=660,height=510,left=0,top=0"); 
				//location.replace("thankYou.html");
			} 
}

/***********************************************
	writing 93combi layer
 ***********************************************/	
 

 
if (!window.saveInnerWidth) {
  window.onresize = resizeIt;
  window.saveInnerWidth = getWindowWidth();
  window.saveInnerHeight = getWindowHeight();
}

function resizeIt() {
	//moveLogo();
}

function getWindowWidth() {
	/*
	if (typeof(window.innerWidth) == "number") {
		var width = window.innerWidth;
	} else {
		var width = window.document.body.offsetWidth;
	}	
	*/
	var pageWidth;
	
	if (navigator.appName.indexOf("Microsoft") != -1) pageWidth = 10;//window.document.body.offsetWidth;
	else pageWidth = window.innerWidth;

	return pageWidth;
	//alert(pageWidth);
}

function getWindowHeight() {
	//var height = window.innerHeight;
	//if (typeof(height) != "number") height = window.document.body.offsetHeight;
}

function getStyleRef(objName)  {
	var objRef = null;
	
	if (document.layers) {
		// NN4 reference
		objRef = document[objName];
		
	} else if(document.all){
		// IE reference
		objRef = document.all[objName].style;
		
	} else if (document.getElementById){
		// others (mostly NN6+ and Firefox)
		objRef = document.getElementById(objName).style;
	}
	
	return objRef;
}

function returnLanguage() {
	var url = self.location.href;
	if (url.indexOf("/fr/") > -1) {
		return "french";
	} else {
		return "english";
	}
}

function moveLogo() {
	var objRef = getStyleRef("logo-div");
	var anchorRef = document.images['home'];
	var lang = returnLanguage();
	
	if (typeof(objRef) != "undefined" && objRef != null) {
		// set offset values
		var xOffset = 0;
		var yOffset = 0;
		
		if (lang == "french") {
			xOffset = 0;
			yOffset = 0;
		}
		
		// get reference x and y positions
		var xPos = findPosX(anchorRef) + xOffset;
		var yPos = findPosY(anchorRef) + yOffset;
		
		// move logo
		objRef.left = xPos;
		//objRef.top = yPos;
	}
	
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}


function drawMSRP(thevehicle){
	if(thevehicle!=""){
		drawImageMSRP("from");
		var thevalue = msrpvariableList[thevehicle]+"";
		var count = thevalue.length;
		
		for(i=0;i<thevalue.length+1;i++){
			if (thevalue.charAt(i)!=""){
				drawImageMSRP(thevalue.charAt(i));
				if (i==count-4){
					drawImageMSRP('comma');
				}
			}
		}
		drawImageMSRP("msrp");
	}

}
function drawImageMSRP(thechar){
	var imgName = thechar;

	if (thechar.length > 1)imgName = thechar+'_'+getLang();
	
	document.write('<img src="/ss/images/common/'+imgName+'.jpg" border="0">')
}

function getLang(){
	if (location.href.indexOf("/french/") > -1) return "fr"
	else return "en"
}


/*********** Testimonials *************/
function testimonialsShow(id) {
	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	} 
}

function testimonialsHide(id){
		document.getElementById(id).style.display = "none";
	}
	
	
/***********AURA LMP*****************/

function topSubmit(){				
	dateNow = new Date();
	var dateMonth=dateNow.getMonth()+1;
	var dateDay=dateNow.getDate();
	var dateYear=dateNow.getFullYear();
	var dateHours;
	var dateMins;
	var dateTime;

	dateHours = dateNow.getHours();
	if (dateHours >= 12)
	{
	dateTime = " P.M.";
	}
	else
	{
	dateTime = " A.M.";
	}

	if (dateHours > 12)
	{
	dateHours = dateHours-12;
	}

	if (dateHours == 0)
	{
	dateHours = 12;
	}

	dateMins = dateNow.getMinutes();
	if (dateMins < 10)
	{
	dateMins = "0" + dateMins;
	}

	rightnow=dateMonth+"/"+dateDay+"/"+dateYear+"-"+dateHours+":"+dateMins+""+dateTime;
	var email=document.forms[0].internet_address.value;
	var keyvalue=rightnow+email;
	document.forms[0].key_value.value=keyvalue;		
	document.forms[0].submit();
			
}
		
function formSubmit(){				
	dateNow = new Date();
	var dateMonth=dateNow.getMonth()+1;
	var dateDay=dateNow.getDate();
	var dateYear=dateNow.getFullYear();
	var dateHours;
	var dateMins;
	var dateTime;

	dateHours = dateNow.getHours();
	if (dateHours >= 12)
	{
	dateTime = " P.M.";
	}
	else
	{
	dateTime = " A.M.";
	}

	if (dateHours > 12)
	{
	dateHours = dateHours-12;
	}

	if (dateHours == 0)
	{
	dateHours = 12;
	}

	dateMins = dateNow.getMinutes();
	if (dateMins < 10)
	{
	dateMins = "0" + dateMins;
	}

	rightnow=dateMonth+"/"+dateDay+"/"+dateYear+"-"+dateHours+":"+dateMins+""+dateTime;
	//var email=document.forms[0].internet_address.value;
	//var keyvalue=rightnow+email;
	var keyvalue=rightnow
	document.forms[0].key_value.value=keyvalue;		
	document.forms[0].submit();
			
}		
		
function GetRef(id) {
	if (document.layers) { return null; }
	if (document.all) {	return document.all[id]; }
	else { return document.getElementById(id); }
}

function HideContestForm() {
	var objRef = GetRef("ContestFormContainer");
	if (objRef == null) { return; }
	objRef.style.display = "none";
}

function ShowContestForm() {
	var objRef = GetRef("ContestFormContainer");
	if (objRef == null) { return; }
	objRef.style.display = "block";
}


//IMAGE ROLLOVERS

// code for rollovers start
function newRollover(imgName,imgFiles,has) {
	if (document.images) {
		imgFiles=imgFiles+",";
		imgNo=1;
		while(imgFiles.indexOf(',')!=-1) {
			imgFile=imgFiles.substring(0,imgFiles.indexOf(','));
			imgFiles=imgFiles.substring(imgFiles.indexOf(',')+1,imgFiles.length);
			eval(imgName+"_urc_"+imgNo+"=new Image();");
			eval(imgName+"_urc_"+imgNo+".src='"+imgFile+"'");
			imgNo++;
		}
	}
}

var rollTimeOut;
var rollImg, rollOn, rollType;

function roll(img,on,type) {
	type = type ? type : img;
 	if (document.images) {
		if(navigator.appName.indexOf('Netscape')!=-1 && navigator.appVersion.substr(0,1)<=4) {
			setTimeout("",100);
		} else {
			//showing?
			if(on==2) {
				if(rollTimeOut) {
					if(rollImg!=img) {
						doRoll();
					}
					clearTimeout(rollTimeOut);
				}
				rollImg = img;
				rollOn = on;
				rollType = type;
				doRoll();
			} else {
				rollImg = img;
				rollOn = on;
				rollType = type;
				rollTimeOut = setTimeout("doRoll()",250);
 			}
		}
	}
}

function doRoll() {
   	eval("document.images['"+rollImg+"'].src="+rollType+"_urc_"+rollOn+".src");
}

//newRollover("navoverview","images/subnav/subnav_overview_off.jpg,images/subnav/subnav_overview_on.jpg");
//newRollover("comparsionchart","images/subnav/subnav_chart_off.jpg,images/subnav/subnav_chart_on.jpg");

function showFlyout2(objToPos, objPosRef) {
	if (objPosRef != "") {
		var browserName=navigator.appName;
		var objStyleRef = getStyleRef(objToPos);
		var theObjectRef = document.images[objPosRef];
		//var brand = getCurrentBrand();
		
		// get position coordinates for reference object
		// offsets for IE
		var xOffset = 172;
		var yOffset = -57;
		
		// offsets for NS
		if (browserName=="Netscape") { 
			xOffset = 171;
		} 
		
		// position flyout according to reference object
		var posy = findPosY(theObjectRef) + yOffset;
		objStyleRef.top = posy;
		var posx = findPosX(theObjectRef) + xOffset;
		objStyleRef.left = posx;
	}
	
	// position object
	swapLayers(objToPos);
}
	
		




/*Community Testimonials*/



	function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
	}
	function IsNumeric(sText)
		{
		var ValidChars = "0123456789.-";
		var IsNumber=true;
		var Char;

		 
		for (i = 0; i < sText.length && IsNumber == true; i++) 
			{ 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
				{
				IsNumber = false;
				}
			}
		return IsNumber;
		   
   }


	function checkPage(){
		fullname = document.getElementById("fullname").value;
		email = document.getElementById("email").value;
		phone = document.getElementById("phone").value;
		valid = true;
		if (fullname == "") {
			//hideAllErrors();
			document.getElementById("nameError").style.display = "inline";
			document.getElementById("fullname").select();
			document.getElementById("fullname").focus();
			valid = false;
			}
		else {document.getElementById("nameError").style.display = "none"}	
		if (isEmail(email) == false) {
			//hideAllErrors();
			document.getElementById("emailError").style.display = "inline";
			document.getElementById("email").select();
			document.getElementById("email").focus();
			valid = false;
			} 
		else {document.getElementById("emailError").style.display = "none"}	
		if (phone == "" || phone.length>15) {
			//hideAllErrors();
			document.getElementById("phoneError").style.display = "inline";
			document.getElementById("phone").select();
			document.getElementById("phone").focus();
			valid = false;
			}
		else {document.getElementById("phoneError").style.display = "none"}		
		if(valid == true)
		{document.testimonials.submit();}
	}
 
		function hideAllErrors() {
			//document.getElementById("Error").style.display = "none"
			document.getElementById("nameError").style.display = "none"
			document.getElementById("emailError").style.display = "none"
			document.getElementById("phoneError").style.display = "none"
		}
		
		
function checkpilotsPage(){
		Yfullname = document.getElementById("Yfullname").value;
		Ffullname = document.getElementById("Ffullname").value;
		Yemail = document.getElementById("Yemail").value;
		Femail = document.getElementById("Femail").value;
		valid = true;
		if (Yfullname == "") {
			//hideAllErrors();
			document.getElementById("YnameError").style.display = "block";
			document.getElementById("Yfullname").select();
			document.getElementById("Yfullname").focus();
			valid = false;
			}
		else {document.getElementById("YnameError").style.display = "none"}	
		if (Ffullname == "") {
			//hideAllErrors();
			document.getElementById("FnameError").style.display = "block";
			document.getElementById("Ffullname").select();
			document.getElementById("Ffullname").focus();
			valid = false;
			}
		else {document.getElementById("FnameError").style.display = "none"}	
		if (isEmail(Yemail) == false) {
			//hideAllErrors();
			document.getElementById("YemailError").style.display = "block";
			document.getElementById("Yemail").select();
			document.getElementById("Yemail").focus();
			valid = false;
			} 
		else {document.getElementById("YemailError").style.display = "none"}	
		if (isEmail(Femail) == false) {
			//hideAllErrors();
			document.getElementById("FemailError").style.display = "block";
			document.getElementById("Femail").select();
			document.getElementById("Femail").focus();
			valid = false;
			} 
		else {document.getElementById("FemailError").style.display = "none"}	
		if(valid == true)
		{document.testimonials.submit();}
	}
 
		function hideAllErrors() {
			//document.getElementById("Error").style.display = "none"
			document.getElementById("YnameError").style.display = "none"
			document.getElementById("FnameError").style.display = "none"
			document.getElementById("YemailError").style.display = "none"
			document.getElementById("FemailError").style.display = "none"
		}
		
	}
	
	
	var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer2(cur_lyr);
  showLayer2(id);
  cur_lyr = id;
}

function showLayer2(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "block";
}

function hideLayer2(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}
// Pop-up

	var ie5 = (document.all && document.getElementbyID) ? false : true;
	var isMac = (navigator.appVersion.indexOf("Mac") == -1) ? false : true;
	var win, win2;

	function openWin(url, popWidth, popHeight, popScroll, popStatus, popWin) {
		var winName =  "popup";
		// popWin is a new optional parameter; for backwards compatibility popStatus MUST be
		// specified if popWin is to be used - ppoles 12/24/02
		if (popWin != null)
		{
			winName = popWin;
		}
		// popStatus is a new parameter; it is optional so that old calls will not cause an error
		var statusBar = popScroll;

		if (popStatus != null) {
			statusBar  = popStatus;
			// 'fix' for Mac IE's problem when including a status bar in the pop up window
			// - the browser chops off the bottom 18 pixels of the window to accomodate for the
			//   the status bar, and so we add 18 pixels to the height
			if (!ie5 && !ns && isMac) { popHeight += 18; }
		}

//	    if(win) {
//			if(!win.closed) {
//				if(win.name == "popup") winName = "popup2";
//			  	win.close();
//			}
//			win = null;
//		}

		win=window.open(url, winName, 'width=' + popWidth + ',height=' + popHeight + ',screenX=25,screenY=150,left=25,top=150,scrollbars=' + popScroll + ',resize=no,status=' + statusBar + '');

		if (win.opener == null) win.opener = self;
		win.focus();
	}

// end of pop-up



