function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}

function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape(value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  return window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	if (checkIt('mac')&&v=='visible') obj.pixelTop = obj.pixelTop ;
    obj.visibility=v; }
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}
		 
function queryString(keyName) {
  var keyValue = "";
  keyName = keyName.toUpperCase();

  if (window.location.href.indexOf("?") != "-1")
  {
	var queryString = window.location.href.substring(window.location.href.indexOf("?")+1);

	var keyValuePairs = queryString.split("&");
	for (var i = 0; i < keyValuePairs.length; i++) {
		var theKeyValuePair = keyValuePairs[i].split("=");

		if (theKeyValuePair.length == 2) {
			if (theKeyValuePair[0].toUpperCase() == keyName) {
				keyValue = theKeyValuePair[1];
				break;
			}
		}
	}
  }
  return unescape(keyValue.replace(/\+/g," "));
}

function trim(a) {  //trims whitespace from start/end of string
	return a.replace(/^\s+/,'').replace(/\s+$/,'');
}

function checkIt(string) {
	var detect = navigator.userAgent.toLowerCase();
	return detect.indexOf(string) + 1;
}

function renderStateList() {
	var values = new Array( "AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI", "WV", "WY" ) ;
	var captions = new Array( "Alaska", "Alabama", "Arkansas", "Arizona", "California", "Colorado", "Connecticut", "District of Columbia", "Delaware", "Florida", "Georgia", "Hawaii", "Iowa", "Idaho", "Illinois", "Indiana", "Kansas", "Kentucky", "Louisiana", "Massachusetts", "Maryland", "Maine", "Michigan", "Minnesota", "Missouri", "Mississippi", "Montana", "North Carolina", "North Dakota", "Nebraska", "New Hampshire", "New Jersey", "New Mexico", "Nevada", "New York", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Virginia", "Vermont", "Washington", "Wisconsin", "West Virginia", "Wyoming" ) ;
	var buffer = "" ;
	for ( var i = 0 ; i < values.length ; i++ ) {
		buffer += "<option value=\"" + values[ i ] + "\">" + captions[ i ] + "</option>" ;
	}
	return buffer ;
}

function renderFlashTag( Movie, Width, Height, Params ) {
	var buffer = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + Width + '" height="' + Height + '">' ;
	buffer += '<param name="movie" value="' + Movie + '">' ;
	var pairs = Params.split( ';' ) ;
	for ( var i = 0 ; i < pairs.length ; i++ ) {
		var name = pairs[ i ].split( '=' )[ 0 ] ;
		var value = pairs[ i ].split( '=' )[ 1 ] ;
		buffer += '<param name="' + name + '" value="' + value + '">' ;			
	}
	buffer += '<embed src="' + Movie + '" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + Width + '" height="' + Height + '" ' ;
	for ( var i = 0 ; i < pairs.length ; i++ ) {
		var name = pairs[ i ].split( '=' )[ 0 ] ;
		var value = pairs[ i ].split( '=' )[ 1 ] ;
		buffer += name + '="' + value + '" ' ;
	}
	buffer += '></embed></object>' ;
	return buffer ;
}

function printImg( image ) {
	document.write( '<img src="' + image.src + '" alt="' + image.alt + '" width="' + image.width + '" height="' + image.height + '" border="0">' ) ;
}

function featureZoom( modelKey, featureKey, modelYear ) {
	var params = "width=466,height=314,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,top=20,left=20,screenX=20,screenY=20";
	var url = "featureZoom.jsp?model=" + modelKey + "&feature=" + featureKey + "&year=" + modelYear;
	window.open( url, "featureZoom", params, true );
}

function featureDisclaimer( modelKey, featureKey ) {
	var params = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,top=20,left=20,screenX=20,screenY=20,width=600,height=360";
	var url = "featureDisclaimer.jsp?model=" + modelKey + "&feature=" + featureKey;
	window.open( url, "featureDisclaimer", params, true );
}

function xlrStory() {
	var newWindow=MM_openBrWindow('/Spotlights/XLRStory/index.html','_timeline','width=740,height=420,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function srxExperience() {
	var newWindow=MM_openBrWindow('/Spotlights/SRXExperience/index.html','_timeline','width=772,height=445,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function stsExperience() {
	var newWindow=MM_openBrWindow('/Spotlights/STSExperience/index.html','_timeline','width=772,height=510,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function vseriesFeature() {
	var newWindow=MM_openBrWindow('/Spotlights/vseries/index.html','_vseries_feature','width=780,height=480,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1');
	newWindow.focus();
}

function under5() {
	var newWindow=MM_openBrWindow('http://www.cadillacunder5.com','_vseries_under5','');
	newWindow.focus();
}


function under5Feature() {
	var newWindow=MM_openBrWindow('http://cadillacunder5.com','_under5_feature','width=780,height=500,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1');
	newWindow.focus();
}

function devilleLimitedEdition(){
	var newWindow=MM_openBrWindow('/deville/limitededition/popup.html','_dev_limited_edition','width=618,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function devillePresLimo(){
	var newWindow=MM_openBrWindow('/Spotlights/PresLimo/popup.html','_dev_pres_limo','width=618,height=420,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function dts2006Feature(){
	var newWindow=MM_openBrWindow('/Spotlights/DTS2006/popup.html','_dts_2006','width=618,height=405,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function srxPop(selection)
				{
					var windowprops = "left=30,top=30,width=500,height=405";
					var url = selection;
					preview = window.open(url, "SRX", windowprops);
					preview.focus();
				}

function truckfest() {
	var newWindow=MM_openBrWindow('http://www.gm.com/automotive/vehicle_shopping/currentoffers/truckfest.html','_truckfest','width=790,height=580,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1');
	newWindow.focus();
}

function challenge() {
	var newWindow=MM_openBrWindow('http://www.gm.com/automotive/vehicle_shopping/currentoffers/challenge.html','_challenge','width=800,height=600,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1');
	newWindow.focus();
}


function xmradio() {
	var newWindow=MM_openBrWindow('http://www.gm.com/beyond_automotive/xmradio/mod/cadillac.htm','_challenge','width=525,height=490,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1');
	newWindow.focus();
}


function escaladeFamily() {
	var newWindow=MM_openBrWindow('/Spotlights/EscaladeFamily/index.html','_timeline','width=700,height=450,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function innovations() {
	var newWindow=MM_openBrWindow('/Spotlights/Timeline/index.html','_challenge','width=750,height=350,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function cadillacCollection() {
	var newWindow=MM_openBrWindow('http://www.cadillaccollection.com','_cadillacCollection','');
	newWindow.focus();
}

function gmFleet() {
	var newWindow=MM_openBrWindow('http://www.gmfleet.com','_gmfleet','');
	newWindow.focus();
}

function hotButton() {
	var newWindow=MM_openBrWindow('http://www.gm.com/vc/hotbutton/index.html','_hotbutton','width=800,height=505,toolbar=1,location=1,directories=0,status=0,menuBar=1,scrollBars=1,resizable=1');
	newWindow.focus();
}

function JDPower() {
	var newWindow=MM_openBrWindow('/Spotlights/JDPower/index.html','_JDPower','width=579,height=510,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function onstar2() {
	var newWindow=MM_openBrWindow('http://www.onstar.com/us_english/jsp/index.jsp','_onstar2','');
	newWindow.focus();
}

function onstar() {
	var newWindow=MM_openBrWindow('/cadillacjsp/cpo/onstar.jsp','_onstar','width=700,height=565,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function prov_advancedprotect(){
	var newWindow=MM_openBrWindow('/prov/security.htm','_prov_advancedprotect','width=611,height=575,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function prov_ceo(){
	var newWindow=MM_openBrWindow('/prov/execUtility.htm','_prov_ceo', 'width=611,height=562,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function prov_des(){
	var newWindow=MM_openBrWindow('/prov/execSedan.htm','_prov_des','width=611,height=430,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function prov_northstar(){
	var newWindow=MM_openBrWindow('/cadillacjsp/prov/northStar.jsp','_prov_northstar','width=611,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function prov_onstar(){
	var newWindow=MM_openBrWindow('/cadillacjsp/prov/onStar.jsp','_prov_onstar','width=611,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function paXLR() {
	var newWindow=MM_openBrWindow('/cadillacjsp/PersonalAssistant/customer_input.jsp?model=XLR','_onstar','width=612,height=790,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}
function paDTS() {
	var newWindow=MM_openBrWindow('/cadillacjsp/PersonalAssistant/customer_input.jsp?model=DTS','_onstar','width=612,height=790,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function paSRX() {
	var newWindow=MM_openBrWindow('/cadillacjsp/PersonalAssistant/customer_input.jsp?model=SRX','_onstar','width=612,height=790,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}
function paCTSV() {
	var newWindow=MM_openBrWindow('/cadillacjsp/PersonalAssistant/customer_input.jsp?model=CTSV','_onstar','width=612,height=790,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}
function paSTS() {
	var newWindow=MM_openBrWindow('/cadillacjsp/PersonalAssistant/customer_input.jsp?model=STS','_onstar','width=612,height=790,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function sts2005() {
	var newWindow=MM_openBrWindow('http://cadillacsts.feedroom.com','_stsunveil','width=706,height=425,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}
function sts20052() {
	var newWindow=MM_openBrWindow('http://cadillacsts.feedroom.com','_stsunveil','width=706,height=425,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function financeTools() {
	var newWindow=MM_openBrWindow('/cadillacjsp/financetools/index.jsp','_financetools','width=640,height=450,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function privacy() {
	var newWindow = MM_openBrWindow( 'http://www.gm.com/privacy', '_privacypolicy', '' );
	newWindow.focus();
}

function ctsvRaceCar() {
	var newWindow=MM_openBrWindow('/ctsv/RacePopup.htm','_CTSVRaceCar','width=580,height=600,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}
function hotButton() {
	var newWindow=MM_openBrWindow('http://www.gm.com/hotbutton','hotButton','width=580,height=600,toolbar=1,location=1,directories=1,status=1,menuBar=1,scrollBars=1,resizable=1');
	newWindow.focus();
}
function ctsvRacing() {
	var newWindow=MM_openBrWindow('/Spotlights/Racing/RacingHomePop.html','Race','width=616,top=0,left=0,height=510,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	//var newWindow=MM_openBrWindow('/ctsv/racing.html','_CTSVRaceCar','width=600,height=420,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}
function XMNavTraffic() {
	var newWindow=MM_openBrWindow('/Spotlights/XMNav/XMPromo.html','XMNav','width=616,top=0,left=0,height=510,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	//var newWindow=MM_openBrWindow('/ctsv/racing.html','_CTSVRaceCar','width=600,height=420,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function ctsvVelocity() {
	var newWindow=MM_openBrWindow('/Spotlights/CTSV/default.htm','_CTSVVelocity','width=772,height=430,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	newWindow.focus();
}

function srxCarDriver() {
	var newWindow=MM_openBrWindow('/Spotlights/SRXAward/popup.html','_srxCarDriver','width=620,height=470,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}

function AICcopyright() {
	var newWindow = MM_openBrWindow( '/AICcopyright.html', '_copyright', 'width=610,height=490,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	newWindow.focus();
}

function copyright() {
	var newWindow = MM_openBrWindow( '/common/copyright.jsp', '_copyright', '' );
	newWindow.focus();
}

function contactus() {
	var newWindow = MM_openBrWindow( '/helpCenter/contact_us.jsp', '_contactus', '' );
	newWindow.focus();
}

function brochure( model ) {
	var newWindow = MM_openBrWindow( '/cadillacjsp/brochure/index.jsp?model='+model, '_brochure', 'width=600,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0' );
	newWindow.focus();
}

function gmsitemenu() {
	popup('/common/gmsites.jsp','GMSites','width=680,height=530,scrollbars=no');
}

function searchHelp() {
	var newWindow = MM_openBrWindow( '/search/SearchServer/wwwtemplates/query/help.html', '_searchelp', 'width=610,height=350,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0' );
	newWindow.focus();
}

function desktopShowcase() {
	var modelKey = queryString("model");
	var newWindow=MM_openBrWindow('/cadillacjsp/models/desktopShowcase.jsp?model=' + modelKey,'_desktopshowcase','width=628,height=450,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
	newWindow.focus();
}

function cpoSearchInventory(model,year,style) {
	document.location.href = "/cuv/cadillac/uis.jhtml?model=" + model + "&year=" + year + "&style=" + style ;
}

function popup(url,winName,attributes){
  var newWindow = window.open(url,winName,attributes);
  if(newWindow == null){
	  alert('A popup containing important information was blocked by your browser.\n Please enable popups for this site in order to view this information.');
  }else{
    newWindow.focus();
  }
}

function requestQuote(model) {
	saveValidModel(model);
	var _dealer = getDealer();
	var _model = getModel();
	var _style = getStyle();
	
	if (_dealer != null && _dealer != "" && _model != null && _model != "") {
		if (!isGmbpDealer()) { // is NOT a gmbp dealer
			document.location.href = "/locatedealer/cadillac/start.jsp?bptool=rq&referer=rq&model=" + model ;
		} else {
			var dealerArr = _dealer.split ("$");
			var phone = dealerArr[6];
			var fax = dealerArr[7];
				
			if (_style == null || _style == "") {
				document.location.href = "/messaging/cadillac/selectmodel.jsp?&dealer=" +_dealer;
			} else {
				document.location.href = "/messaging/cadillac/senddealer.jsp?" +
					"dealer=" +_dealer + "&year=2005&msrpPrice="+ getMsrpPrice(_style) +
					"&bac=" + dealerArr[0] + "&dealerName=" + dealerArr[1] + "&dealerAddress=" + dealerArr[2] + 
					"&dealerCity=" + dealerArr[3] + "&dealerState=" + dealerArr[4] + "&dealerZip=" + dealerArr[5] +
					"&dealerPhoneNumber=(" + phone.substring(0,3) + ") " + phone.substring(3,11) +
					"&dealerFax=(" + fax.substring(0,3) + ") " + fax.substring(3,11) +
					"&modelName=2005+"+ getProperName(_style) +"&MMC="+_style;
			}
		}
	} else if (_dealer != null && _dealer != "") {
		if (isGmbpDealer()) { // is a gmbp dealer
			document.location.href = "/messaging/cadillac/selectmodel.jsp?&dealer=" +_dealer;
		} else {
			document.location.href = "/locatedealer/cadillac/start.jsp?bptool=rq&referer=rq&model=" + model ;
		}
	} else {
		document.location.href = "/locatedealer/cadillac/start.jsp?bptool=rq&referer=rq&model=" + model ;
	}
}

function searchInventory(model) {
	saveValidModel(model);
	var _dealer = getDealer();
	var _model = getModel();
	var _style = getStyle();
	var UDValue1 = (isGmbpDealer()) ? "true" : "false";
	if (_dealer != "" && _dealer != null)
		if (_model != null && _style != null) {
			var dealerArr = _dealer.split ("$");
			var phone = dealerArr[6];
			var fax = dealerArr[7];
	
			document.location.href = "/vehiclelocator/locateVehicle.do?" +
				"dealer=" +_dealer + "&maximumCount=100&includeDuplicateVendors=true&year=2005&make=ca&searchType=4&UDName1=isGMBuyPower&UDValue1="+ UDValue1 +
				"&vendorId=" + dealerArr[0] + "&bac=" + dealerArr[0] + "&dealerName=" + dealerArr[1] + "&dealerAddress=" + dealerArr[2] + 
				"&dealerCity=" + dealerArr[3] + "&dealerState=" + dealerArr[4] + "&dealerZip=" + dealerArr[5] +
				"&dealerPhoneNumber=(" + phone.substring(0,3) + ") " + phone.substring(3,11) +
				"&dealerFax=(" + fax.substring(0,3) + ") " + fax.substring(3,11) +
				"&SearchByPostalCodePostalCode=" + dealerArr[5] + "&model="+_model+"&modelDesignator="+_style;
		}
		else
			document.location.href="/vehiclelocator/cadillac/selectmodel.jsp?dealer="+_dealer+"&isGMBuyPower="+UDValue1;
	else
		document.location.href = "/locatedealer/cadillac/start.jsp?bptool=si&referer=si&model=" + model ;
}
function isValidModel (model) {
//	return ("cts ctsv xlr srx deville sts escalade ext esv".indexOf(model) > -1 ) ? true : false;
	var retval = false;
	var models = new Array("cts","ctsv","xlr","srx","deville","sts","escalade","ext","esv");
	for (var i = 0; i < models.length; i++) {
		if (models[i] == model) {
			retval = true;
			break;
		}
	}
	return retval;		
}
function saveValidModel (model) {
	var save = false;
	if (model != null && model != "") {
		if (isValidModel (model)) {
			save = true;
		} else if (model == "home" || model == "financeoptions") {
			clearModel(); clearStyle();
		} else if (model == "currentoffers") {
			save = true;
			var comodel = queryString('model');
			model = (isValidModel(comodel)) ? comodel : "cts";
		}
		
		if (save) {
			saveModel(model); clearStyle();
			switch (model) {
				case 'cts': saveStyle('6DP69'); break;
				case 'xlr': saveStyle('6YV67'); break;
				case 'ext': saveStyle('6K15936'); break;
				case 'ctsv': saveStyle('6DN69'); break;
				case 'esv': saveStyle('6K15906'); break;
			}	
		}
	}
}
function getProperName(mmc)
{
	var retval = null;
	switch (mmc)
	{
		case "6DP69": retval = "CTS Sedan"; break;
		case "6DN69": retval = "CTS-V"; break;
		case "6YV67": retval = "XLR"; break;
		case "6EB26": retval = "SRX V6"; break;
		case "6ED26": retval = "SRX V8"; break;
		case "6KD69": retval = "DeVille"; break;
		case "6KE69": retval = "DeVille DHS"; break;
		case "6KF69": retval = "DeVille DTS"; break;
		case "6DW29": retval = "STS V6"; break;
		case "6DC29": retval = "STS V8"; break;
		case "6C15706": retval = "Escalade 2WD"; break;
		case "6K15706": retval = "Escalade AWD"; break;
		case "6K15936": retval = "Escalade EXT"; break;
		case "6K15906": retval = "Escalade ESV"; break;
	}
	return retval;
}
function getMsrpPrice(style)
{
	var retval = null;
	switch (style)
	{
		case "6DP69": retval = '30,885.00'; break; // cts
		case "6DN69": retval = '50,185.00'; break; // ctsv
		case "6YV67": retval = '76,650.00'; break; // xlr
		case "6EB26": retval = '39,035.00'; break; // srx v6
		case "6ED26": retval = '50,830.00'; break; // srx v8
		case "6KD69": retval = '46,840.00'; break; // dev
		case "6KE69": retval = '52,395.00'; break; // dev dhs
		case "6KF69": retval = '52,395.00'; break; // dev dts
		case "6DW29": retval = '41,220.00'; break; // sts v6
		case "6DC29": retval = '47,720.00'; break; // sts v8
		case "6C15706": retval = '54,700.00'; break; // esc 2wd
		case "6K15706": retval = '57,255.00'; break; // esc awd
		case "6K15936": retval = '54,185.00'; break; // ext
		case "6K15906": retval = '59,655.00'; break; // esv
	}
	
	return retval;
}
//start 101204
function setExpirationDays (days) {
	var expires = new Date();
	expires.setTime(expires.getTime() + (days * 31536000));//86400000
	return expires;
}
function setDropDownSelection(_select, _value)
{
	var myVal = _value.toUpperCase();
	if (_select.selectedIndex == 0)
	for ( var i = 0 ; i < _select.length ; i++ ) {
		var option = _select.options[ i ] ;
		if ( option.value.toUpperCase() == myVal) {
			option.selected = true ;
			break ;
		}
	}
}

function saveModel(model) {	SetCookie( 'model', model, setExpirationDays(1), '/' ); }
function getModel() { return GetCookie('model'); }
function saveStyle(style) {	SetCookie( 'style', style, setExpirationDays(1), '/' ); }
function getStyle() { return GetCookie('style'); }
function saveDealer(dealer, isGmbp) {
	dealer = (isGmbp == "true") ? "1-"+dealer : "0-"+dealer;
	SetCookie( 'dealer', dealer, setExpirationDays(365), '/' );
}
function getDealer() {
	var dealer = GetCookie('dealer');	
	return ( dealer != null && dealer != "" ? dealer.substring( 2 ) : null ) ;	
}
function isGmbpDealer() {
	var dealer  = GetCookie('dealer'); 
	var marker = (dealer != null && dealer != "") ? GetCookie('dealer').substring(0,1) : 0;
	return (marker == "1") ? true : false;
}
function saveCityState(city, state) {
	var expires = setExpirationDays(365)
	SetCookie( 'city', city, expires, '/' ) ;
	SetCookie( 'state', state, expires, '/');
}
function getCity() { return GetCookie ('city'); }
function getState() { return GetCookie ('state'); }
function saveZip(zip) {	SetCookie( 'zip', zip, setExpirationDays(365), '/' ); }
function getZip() { return GetCookie('zip'); }
function clearModel() {	SetCookie( 'model', "", new Date("January 1, 1970"), '/' ); }
function clearStyle() {	SetCookie( 'style', "", new Date("January 1, 1970"), '/' ); }
function clearCityState() {
	SetCookie( 'city', "", new Date("January 1, 1970"), '/' );
	SetCookie( 'state', "", new Date("January 1, 1970"), '/' );
}
function clearZip() { SetCookie( 'zip', "", new Date("January 1, 1970"), '/' ); }
//end 101204

function futureRequest(model) {
	var url = null ;
	if ( model == "ctsv" )
		url = "/cadillacjsp/VseriesRequestInfo/customer_input.html?model=cts";
	else if ( model == "esvplat" )
		url = "/cadillacjsp/VseriesRequestInfo/customer_input.html?model=esv";
	else if ( model == "sts" )
		url = "/cadillacjsp/VseriesRequestInfo/customer_input.html?model=sts";
	if ( url != null ) {
		var newWindow = MM_openBrWindow( url, '_futureRequest', 'width=610,height=370,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0' );
		newWindow.focus();
	}
}

function buildYourOwn( model ) {
	switch (model)
	{
		case "sts": document.location.href = "/byo/jsp/cadillac/selectstyle_html.jsp?model=sts"; break;
		case "xlr": document.location.href = "/byo/selectColor.cd?cad_modelDesc=2005+XLR&noType=0&style=Base&styleId=Base&noStyle=1&make=Cadillac&subModel=&model=XLR&makeId=006&zip=48226&year=2005&subModelId=193&modelId=054&pvc=520&iPi=1&fPi=3&newVehicle=true&styleH=true"; break;
		case "srx": document.location.href = "/byo/jsp/cadillac/selectstyle_html.jsp?model=srx"; break;
		case "cts": document.location.href = "/byo/jsp/cadillac/selectstyle_html.jsp?model=cts"; break;
		case "ctsv": document.location.href = "/byo/selectColor.cd?cad_modelDesc=2005+CTS-V&iPi=2&fPi=4&styleId=CTS-V%201SA&style=CTS-V%201SA&pvc=5140&make=Cadillac&zip=48226&noType=0&makeId=006&model=CTS-V&subModelId=210&year=2005&modelId=060&styleH=true"; break;
		case "deville": document.location.href = "/byo/jsp/cadillac/selectstyle_html.jsp?model=deville"; break;
		case "escalade": document.location.href = "/byo/jsp/cadillac/selectstyle_html.jsp?model=escalade"; break;
		case "esv": document.location.href = "/byo/jsp/cadillac/selectstyle_html.jsp?model=esv"; break;
		case "esvplat": document.location.href = "/byo/selectColor.cd?cad_modelDesc=2005+ESV+Platinum&iPi=2&fPi=4&styleId=Platinum%20Edition&style=Platinum%20Edition&pvc=517&make=Cadillac&noType=0&makeId=006&model=Escalade&subModelId=60&year=2005&modelId=028"; break;
		case "ext": document.location.href = "/byo/selectColor.cd?cad_modelDesc=2005+Escalade+EXT&cabSizeId=&cabSize=&boxSizeId=&boxSize=&driveTypeId=8&driveType=AWD&wheelBaseId=&wheelBase=&noType=1&style=SUT&styleId=SUT&noStyle=1&make=Cadillac&subModel=EXT&model=Escalade&makeId=006&zip=48226&year=2005&subModelId=59&modelId=028&pvc=512&iPi=1&fPi=3&newVehicle=true"; break;
		default: document.location.href = "/byo/jsp/cadillac/index.jsp?model=" + model ;
	}
}
function loadGallery( model ) {
	switch (model)
	{
		case "sts": document.location.href = "/cadillacjsp/models/gallery.jsp?model=sts"; break;
		case "xlr": document.location.href = "/cadillacjsp/models/gallery.jsp?model=xlr"; break;
		case "srx": document.location.href = "/cadillacjsp/models/gallery.jsp?model=srx"; break;
		case "cts": document.location.href = "/cadillacjsp/models/gallery.jsp?model=cts"; break;
		case "ctsv": document.location.href = "/cadillacjsp/models/gallery.jsp?model=ctsv"; break;
		case "deville": document.location.href = "/cadillacjsp/models/gallery.jsp?model=deville"; break;
		case "escalade": document.location.href = "/cadillacjsp/models/gallery.jsp?model=escalade"; break;
		case "esv": document.location.href = "/cadillacjsp/models/gallery.jsp?model=esv"; break;
		case "ext": document.location.href = "/cadillacjsp/models/gallery.jsp?model=ext"; break;
		default: document.location.href = "/cadillacjsp/models/gallery.jsp?model=" + model ;
	}
}

function getComparatorModel (key) {
	var model = "";
	if (isValidModel (key))
		model = key;
	else if (key == "currentoffers") {
		model = queryString("model");
		if (!isValidModel (model)) model = "cts";
	} else if (key == "cadillac") {
 	  	model = queryString("model");
		if (!isValidModel (model)) model = "";
	}

	if (model != "") {
		saveModel(model); clearStyle();
		switch (model) {
			case 'cts': saveStyle('6DP69'); break;
			case 'xlr': saveStyle('6YV67'); break;
			case 'ext': saveStyle('6K15936'); break;
			case 'ctsv': saveStyle('6DN69'); break;
			case 'esv': saveStyle('6K15906'); break;
		}	
	} else { clearModel(); clearStyle(); }

	//convert to comparator models
	if (model == "deville") model = "dev";
	if (model == "escalade") model = "esc";
	return model;	
}
function competitiveCompare (key) {
	var model = getComparatorModel (key);
	if (model == "cts") document.location.href = "/comparator/compareVehicle.do?tool=null&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=&model=cts&baseVehicleId=5160";
	else if (model == "xlr") document.location.href = "/comparator/compareVehicle.do?tool=null&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=&model=xlr&baseVehicleId=520";
	else if (model == "ctsv") document.location.href = "/comparator/compareVehicle.do?tool=null&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=&model=ctsv&baseVehicleId=5140";
	else if (model == "ext") document.location.href = "/comparator/compareVehicle.do?tool=null&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=&model=ext&baseVehicleId=512";
	else document.location.href = "/comparator/cadillac/comparevehicle.jsp?model="+model;
}

function modelCompare( key ) {
	var model = getComparatorModel (key);
	if (model == "cts") document.location.href = "/comparator/compareVehicle.do?tool=cadillac&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=NONE&model=cts&baseVehicleId=5160";
	else if (model == "xlr") document.location.href = "/comparator/compareVehicle.do?tool=cadillac&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=NONE&model=xlr&baseVehicleId=520";
	else if (model == "ctsv") document.location.href = "/comparator/compareVehicle.do?tool=cadillac&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=NONE&model=ctsv&baseVehicleId=5140";
	else if (model == "ext") document.location.href = "/comparator/compareVehicle.do?tool=cadillac&trimID=null&divisionCode=ca&modelYear=2005&comparisonVehicles=NONE&model=ext&baseVehicleId=512";
	else document.location.href = "/comparator/cadillac/comparevehicle.jsp?tool=cadillac&model="+model;
}

/**
 * This method generates the table of probabilites
 * that a number will occur randomly.  The array
 * is the summation of the probabilities up the 
 * current location.  
 * For example P[N-1] = W[0]+W[1] + ... + W[N-2].
 * We also must ensure the last element of the table
 * is 1.
 * @param weights
 * @return double[]
 */
function Table( weights ) {
	var table = new Array() ;
	var p = 0 ;
	table[ 0 ] = 0 ;
	for ( var i = 0 ; i < weights.length ; i++ ) {
		p += weights[ i ] ;
		table[ i + 1 ] = p ;
	}
	table[ table.length - 1 ] = 1 ;
	return table ;
}

/**
 * This method performs a binary search for the value x,
 * and returns the lower bound for the search.
 * @param table
 * @param x
 * @return int
 */
function Locate( table, x ) {
	var lo = 0 ;
	var hi = table.length ;
	while ( hi > lo + 1 ) {
		var mid = Math.floor( lo + ( hi - lo ) / 2 ) ;
		if ( table[ mid ] <= x )
			lo = mid ;
		else
			hi = mid ;	
	}	
	return lo ;
}

/**
 * Returns a random number based on a random value
 * and the weights assigned to the number.  We assume 
 * the set of numbers is continuous and is within the 
 * set 1..N where N is the size of the weight array.
 * @param weights
 * @return int
 */
function getRandomNumber( weights ) {
	var p = Table( weights ) ;
	return Locate( p, Math.random() ) ;	
}

function sts() {
	var newWindow = MM_openBrWindow( '/sts/index.html', '_sts', 'width=595,height=339,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	newWindow.focus();
}



// remove this section after the subnav updates
if (document.layers) {
        visible = 'show';
        hidden = 'hide';

} else if (document.all || document.getElementById) {
        visible = 'visible';
        hidden = 'hidden';
}

var daLayer = '_topnav_compare_dd';
var daLast = '_topnav_compare_dd';
var onLayer = false;
var subnavTimer = null;
var subnavTimeout = 3000; //milliseconds

function subnavclear() {
	if (onLayer) {
		subnav('subnavnone');
	} else {
		clearTimeout(subnavTimer);
		subnavTimer = setTimeout("subnavclear()", subnavTimeout);
	}
}

function subnav(daLayer){

	//alert("this layer=" + daLayer);
	//alert("last layer=" + daLast);
	
	if ( daLayer == 'subnavnone' ) {
		onLayer = false;
	} else {
		onLayer = true;
	}
	
	clearTimeout(subnavTimer);
	subnavTimer = setTimeout("subnavclear()", subnavTimeout);

	if (daLayer != daLast) {

		if (document.layers) {
			document.layers[daLast].visibility = hidden;

		} else if (document.all) {
			document.all(daLast).style.visibility = hidden;
        
		} else if (document.getElementById) {
			document.getElementById(daLast).style.visibility = hidden;
        
		} daLast = daLayer;

	}

	if (document.layers) {
		document.layers[daLayer].visibility = visible;
        
	} else if (document.all) {
		document.all(daLayer).style.visibility = visible;
        
	} else if (document.getElementById) {
		document.getElementById(daLayer).style.visibility = visible;
        
	}
}

function printWindow(){
	if (window.print){
		window.print()
	}
	else{
		alert("Your browser does not support this function. Please click the Print button in your browser's toolbar.");
	}
}
function textRollOn( eid ) {
	var over=document.getElementById(eid);
	if (over!=null) over.style.color="#336699";
}
function textRollOff( eid ) {
	var over=document.getElementById(eid);
	if (over!=null) over.style.color="#666666";
}
function subnavRoll( inew ) {
	document.images["subnav"].src = eval("subnav" + '_' + inew + '.src');
}
function dealerLocator(tool) {
	document.location.href = "/locatedealer/cadillac/start.jsp?bptool="+ tool +"&referer=" +tool;
}