/* This first inline block is to replace browser hawk with client-side browser detection.*/
var BROWSER_ISMAC = (navigator.appVersion.indexOf("Windows") == -1);
var BROWSER_ISPC = (navigator.appVersion.indexOf("Windows") != -1);
var PLATFORMNAME = "";
var BROWSER_NAME = navigator.appName.toLowerCase();
var IS_IE7 = (navigator.appVersion.indexOf("MSIE 7") != -1);
var gIVI_section = "";

if(BROWSER_NAME == "microsoft internet explorer"){
	BROWSER_NAME = "explorer";
}

if(BROWSER_ISPC){
	PLATFORMNAME = "pc";
}else if(BROWSER_ISMAC){
	PLATFORMNAME = "mac";
}else{
	PLATFORMNAME = "unix";
}


function include(script_filename) {
    document.write('<' + 'script');
    document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="' + script_filename + '">');
    document.write('</' + 'script' + '>');
}


// code was in flashAPI.js
if(navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
			document.write('<script language=\"VBScript\"\>\n')
			document.write('On Error Resume Next\n')
			document.write('Sub start_FSCommand(ByVal command, ByVal args)\n')
			document.write('	Call start_DoFSCommand(command, args)\n')
			document.write('End Sub\n')
			document.write('</script\>\n')
		}

function CheckHTMLSwitch(){
	var retVal

	if (oCookie.getCookieValue("html") == "true" && document.location.href.indexOf("v=") <= 0){
		sSep = "?"
		if(document.location.href.indexOf("?") > 0){
			sSep = "&"
		}
		retVal  = document.location.href + sSep + "v=html"
		document.location = retVal
		return retVal
	}
}

function IsFastEnough(){
	/* rerwrite to use getAkamaiSubCookieValue in the future. */
	bIsFastEnough = true
	sTemp = document.cookie

	if ((/throughput=[0-9A-Za-z_]+/.test(sTemp)) && (!oCookie.getCookieValue("scheck"))){
		sTemp=sTemp.match("throughput=[0-9A-Za-z_]+")
		var aT = sTemp[0].split('=')
		if (aT.length > 1){
			sTemp = aT[1]
			bIsFastEnough = false
			oCookie.setCookieValue("scheck","false",1)
			if  (sTemp.search(/high|med|NA/i)>=0){
					bIsFastEnough = true
					oCookie.setCookieValue("scheck","true",1)
			}
		}
	} else {
		if(oCookie.getCookieValue("scheck").length > 0)
			bIsFastEnough = oCookie.getCookieValue("scheck")
	}

	return bIsFastEnough
}

function gotoFlash(){
	//If they 'actually' don't have flash, go to the get flash page
	if(oCookie.getCookieValue("html") == "" && canPlayFlash()==false){
		strURL  = "/getflash/?url=" + document.location.href.replace("?v=html","")
		oCookie.setCookieValue("html", "true", 1)
		//if they had flash, but had chosen HTML then we can go to the flash version
	}else{
		strURL = document.location.href.replace("?v=html&","?")
		strURL = strURL.replace("?v=html","")
		strURL = strURL.replace("&v=html","")
		oCookie.setCookieValue("html","false",1)
	}

	document.location = strURL;

	return strURL
}

function createflash(width, height, swfname, flashvars, sbghex, wmode, connection){
		if (typeof(sbghex)=="undefined") sbghex="ffffff";
		if (typeof(wmode)=="undefined") wmode="";
		if (connection!="https") connection="http";

		document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"" + connection + "://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"" + width + "\" height=\"" + height + "\" id=\"start\" align=\"middle\" VIEWASTEXT>");
		document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
		document.write("<param name=\"movie\" value=\"" + swfname + "\" />");
		document.write("<param name=\"FlashVars\" value=\"" + flashvars + "\" />");
		document.write("<param name=\"quality\" value=\"best\" />");
		document.write("<param name=\"bgcolor\" value=\"#" + sbghex + "\" />");
		document.write("<param name=\"menu\" value =\"false\" />");
		document.write("<param name=\"wmode\" value =\"" + wmode + "\" />");
		document.write("<embed name=\"start\" SWLIVECONNECT=\"true\" src=\"" + swfname + "\" FlashVars=\"" + flashvars + "\" quality=\"best\" bgcolor=\"#" + sbghex + "\" width=\"" + width +"\" height=\"" + height + "\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"" + connection + "://www.macromedia.com/go/getflashplayer\" wmode=\"" + wmode + "\" />");
		document.write("</object>");
}

function createflash8(width, height, swfname, flashvars, sbghex, wmode, connection,id){

		if (typeof(id)=="undefined") id="start";
		if (typeof(sbghex)=="undefined") sbghex="ffffff";
		if (typeof(wmode)=="undefined") wmode="";
		if (connection!="https") connection="http";

		document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"" + connection + "://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8 \" width=\"" + width + "\" height=\"" + height + "\" id=\""+id+"\" align=\"middle\" VIEWASTEXT>");
		document.write("<param name=\"allowScriptAccess\" value=\"always\" />");
		document.write("<param name=\"movie\" value=\"" + swfname + "\" />");
		document.write("<param name=\"FlashVars\" value=\"" + flashvars + "\" />");
		document.write("<param name=\"quality\" value=\"best\" />");
		document.write("<param name=\"bgcolor\" value=\"#" + sbghex + "\" />");
		document.write("<param name=\"menu\" value =\"false\" />");
		document.write("<param name=\"wmode\" value =\"" + wmode + "\" />");
		document.write("<embed name=\""+id+"\" SWLIVECONNECT=\"true\" src=\"" + swfname + "\" FlashVars=\"" + flashvars + "\" quality=\"best\" bgcolor=\"#" + sbghex + "\" width=\"" + width +"\" height=\"" + height + "\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"" + connection + "://www.macromedia.com/go/getflashplayer\" wmode=\"" + wmode + "\" />");
		document.write("</object>");
}

function createquicktime(width, height, name, connection){
	if (connection!="https") connection="http";

	document.write ("<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='" + connection +  "://www.apple.com/qtactivex/qtplugin.cab' width='" + width + "' height='" + height + "'>");
	document.write("<param name='SRC' value='" + name + "'>");
	document.write("<param name='AUTOPLAY' value='true'><param name='CONTROLLER' value='true'>");
	document.write("<embed src='" + name + "' width='" + width + "' height='" + height + "' autoplay='true' controller='true'  pluginspage='" + connection + "://www.apple.com/quicktime/download/'></embed>");
	document.write("</object>");
}


/*
OGate=function(){
	this.TheWindow = 'window.location'
}

OGate.prototype.Gateway = function(App, Line, ModelID, Parameter1){
	var sApp = ''
	var sLine = ''
	var sModelId=''
	var sPartner = ''
	var sBanner = ''
	var sZip = ''
	var sParameter1 = ''

	sApp = 'App=' + App

	if (Line.length > 0)
		sLine = '&Line=' + Line

	if (ModelID.length > 0)
		sModelId = '&nModelId=' + ModelID

	if  (oCookie.getCookieValue("partner").length > 0)
		sPartner = '&partner='  + oCookie.getCookieValue("partner")

	if  (oCookie.getCookieValue("bannerid").length > 0)
		sBanner = '&banner='  + oCookie.getCookieValue("bannerid")

	if  (oCookie.getSubCookieValue("FPI", "zip").length > 0)
		sZip =  '&zip=' + oCookie.getSubCookieValue("FPI", "zip")

	if (typeof(Parameter1) != "undefined")
		if (Parameter1.length > 0)
			sParameter1 = '&Parameter1=' + Parameter1

	eval(this.TheWindow + '="'+   strSite + '/asp/util/gateway.asp?' + sApp + sLine + sModelId + sPartner + sBanner + sZip + sParameter1 +'"')

}
*/
function OGate(){

	this.TheWindow = 'window.location'
	this.getURL = getURL
	this.Gateway = Gateway
	
	function getURL(App, Line, ModelID, Parameter1){
		var sApp = ''
		var sLine = ''
		var sModelId=''
		var sPartner = ''
		var sBanner = ''
		var sZip = ''
		var sParameter1 = ''
	
		sApp = 'App=' + App
	
		if (Line.length > 0)
			sLine = '&Line=' + Line
	
		if (ModelID.length > 0)
			sModelId = '&nModelId=' + ModelID
	
		if  (oCookie.getCookieValue("partner").length > 0)
			sPartner = '&partner='  + oCookie.getCookieValue("partner")
	
		if  (oCookie.getCookieValue("bannerid").length > 0)
			sBanner = '&banner='  + oCookie.getCookieValue("bannerid")
	
		if  (oCookie.getSubCookieValue("FPI", "zip").length > 0)
			sZip = '&zip=' + oCookie.getSubCookieValue("FPI", "zip")
	
		if (typeof(Parameter1) != "undefined")
			if (Parameter1.length > 0)
				sParameter1 = '&Parameter1=' + Parameter1	
				
		return strSite + '/asp/util/gateway.asp?' + sApp + sLine + sModelId + sPartner + sBanner + sZip + sParameter1
	}
	
	function Gateway(App, Line, ModelID, Parameter1){
		eval(this.TheWindow + '="'+ getURL(App,Line,ModelID, Parameter1 +'"') )
	}
	
}

function Gateway(App, Line, ModelID, Parameter1){
	var oGate = new OGate();
	oGate.Gateway(App, Line, ModelID, Parameter1)
}

function GatewayParentWindow(App, Line, ModelID, Parameter1){
	var oGate = new OGate();
	oGate.TheWindow = "window.parent.location";
	oGate.Gateway(App, Line, ModelID, Parameter1);
}


function GatewayNewWindow(App, Line, ModelID, Parameter1, x, y){
	var oGate = new OGate();

	if (x != null && y != null)  {
		newWin = openNewWindow(oGate.getURL(App, Line, ModelID, Parameter1), '', 'width=' + x + ',height=' + y + 'toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');		
	} else {	
		newWin = openNewWindow(oGate.getURL(App, Line, ModelID, Parameter1),'', 'width=700,height=500,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	}
    
}

function getBuildPriceLink(){
	window.parent.location = 'http://localhost/asp/util/gateway.asp?app=BuildAndPrice'
}

function fusionChallenge(){
	window.parent.location = 'http://www.forddirect.com/PromotionCampaign.jsp?campaignname=Fusion+Challenge&modelyear=2007&vehicle=Fusion&referrer=FordVehicles&partner=null'
}

function getPriceQuote(){
	window.parent.location = '/asp/util/gateway?App=PriceQuote'
}

function fusionChallenge(){
	window.parent.location = 'http://www.forddirect.com/PromotionCampaign.jsp?campaignname=Fusion+Challenge&modelyear=2007&vehicle=Fusion&referrer=FordVehicles&partner=null'
}

function openWin( html, name, wval, hval, scroll) {
	var n=open( html, name, 'width='+wval+',height='+hval+',toolbar=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no');
}

function openFullScreenWin( html, name, scroll) {
	var features;
	features = 'width='+ screen.width +',height='+ screen.height + ',top=0,left=0,toolbar=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no';
	var n=window.open( html, name, features);
}

function openNewWindow(theURL,winName,features) {
	var newWin;
	var locationString = '';
	if (newWin && ieX){
		locationString = locationString + newWin.location;
		if (locationString != ''){
			newWin.location.href = theURL;
		} else {
			newWin = window.open(theURL,winName,features);
		}
	} else {
		newWin = window.open(theURL,winName,features);
	}
	return newWin;
}


function fipAjax(sURL,nFipId,sFunction) {
	var http = false;

	if(navigator.appName == "Microsoft Internet Explorer") {
	  http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	  http = new XMLHttpRequest();
	}

	http.open("GET", sURL+nFipId);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
			eval(sFunction+"("+ nFipId + "," + http.responseText+")");
		}
	} 
	http.send(null);
}

function UADWin(nFipID, iWinType){
	fipAjax("/asp/util/getFip.asp?nFipID=",nFipID,"FIPpop");
}

function FIPpop(nFipID,nFipType)	{
	
	if(nFipType=="1"){
		winSize = "width=350,height=470,top=0,left=50,screenX=50,screenY=0"
	} else if(nFipType=="2"){
		winSize = "width=635,height=540,top=0,left=50,screenX=50,screenY=0"
	}
	else if(nFipType=="3"){
		winSize = "width=447,height=450,top=0,left=50,screenX=50,screenY=0"
	}
	else if(nFipType=="4"||nFipType=="5"){
		winSize = "width=620,height=440,top=0,left=50,screenX=50,screenY=0"
	}
	
	var loc = document.location.pathname.split("/")
	
	while(loc.length > 3){
		loc.pop()
	}
	loc = loc.join("/")+"/fip/";
	
	window.open(loc +"index.asp?nPopupID=" + nFipID +"&nType="+nFipType,"fip","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,"+winSize);
}

function AWDWin(){
	var loc = document.location.pathname.split("/")
		
	loc.pop()
	
	if (loc.length==4)
		loc.pop()
		
	loc = loc.join("/")+"/awd/";
	window.open(loc,"fip","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,width=396,height=400,top=0,left=50,screenX=50,screenY=0");
}

function popupPageWithNav(loc, name, width, height) {
	window_options = "'toolbar=yes,location=yes,buttons=yes;directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes,scrollbars,copyhistory=yes,height=" + height + ",width=" + width + ",screenX=100,screenY=100'";
	nwn = window.open(loc,name,window_options);
	nwn.focus();
}

function popOutside(sURL) {
	if( confirm( "You are linking to a non-Ford website.  Your browsing and interaction are subject to the rules and policies of that site.  Please read over the site's rules and policies before proceeding." ) )
	{
		n = window.open(sURL, 'n', 'width=750,height=555,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
		n.focus();
	}
}


function TurnOnImage(oE){
	var img = eval(oE + "On.src");
	document [oE].src = img;
}

function TurnOffImage(oE){
	var img = eval(oE + "Off.src");
	document [oE].src = img;
}

function roll(ele) {
	var img = ele.getElementsByTagName("img")[0];
	var src = img.src;
	img.src = (/_on/.test(src)) ? src.replace('_on', '_off') : src.replace('_off', '_on');
}

function rollit(ele){
	var obj = document.getElementById(ele);
	var src = obj.getAttribute("src");
	obj.setAttribute("src",(/_on/.test(src)) ? src.replace('_on', '_off') : src.replace('_off', '_on'));
}

function SetLastVehicleVisited(nVehAbstID, FPIModel, FPIYear){
	//This function is used on the homepage of fordvehicles. Sets the last visited vehicle.
	if(nVehAbstID.length > 0){
		// oCookie is created in /asp/util/cookieJS.asp
		if ((oCookie.getSubCookieValue("FPI", "Personalization") != "no" ) && (oCookie.getCookieValue("LastVehicleVisited") == "")){
			oCookie.setSubCookieValue("FPI", "Personalization", "no")
		}

		oCookie.setCookieValue("LastVehicleVisited",nVehAbstID,65)
		oCookie.setSubCookieValue("FPI", "Model", FPIModel, 65)
		oCookie.setSubCookieValue("FPI", "Year", FPIYear, 65)

	}
}

function openNewWindowWithFeatures(theURL,winName,features) {
	newWin = window.open(theURL,winName,features);
}

function fGetPage(loc, name, width, height) {
	window_options = "'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars,copyhistory=no,height=" + height + ",width=" + width + ",screenX=100,screenY=100'";
	var sWin = window.open(loc,name,window_options);
	sWin.focus();
}

function fGetColorPopupPage(loc, name) {

	if(navigator.appName != "Microsoft Internet Explorer") {
		iWindowLeft = window.screenX
		iWindowTop = window.screenY
	} else {
		iWindowLeft =window.screenLeft
		iWindowTop =window.screenTop
	}

 	mytop =iWindowTop 
	myleft =iWindowLeft + 140

	window_options = "'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,height=318,width=714,top=" + mytop +",left=" +myleft + ",screenX=100,screenY=100'";
	var sWin = window.open(loc,name,window_options);

	sWin.focus();
}

function popFullFunc( window_http, window_name, nW, nH ) {
	var	window_left = 140;
	var window_top = 150;

	window_options = "'toolbar=yes,location=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,height=" + nH + ",width=" + nW + ",left=" + window_left + ",screenX=" + window_left + ",top=" + window_top + ",screenY=" + window_top + "'";
	window.open( window_http, window_name, window_options );
}

/* TOWING MODULE START */

function FV_openBrWindow(theURL,winName,features){
	window.name = "towingWindow";
	window.open(theURL,winName,features);
}

function FV_openTowingModle( type, vehicle, cab ) {
	window.name = "towingWindow";
	self.name = "towingWindow";
	if( cab == "" ) {
		FV_openBrWindow('http://' + window.location.host + '/towing/popup.asp?type='+ type +'&uid=' + vehicle + '' ,'TowingGuide','width=725,height=581,resizable=1');
	} else {
		FV_openBrWindow('http://' + window.location.host + '/towing/popup.asp?type='+ type +'&uid=' + vehicle + '&cid=' + cab + '' ,'TowingGuide','width=725,height=581,resizable=1');
	}
}

// Spelling correction that doesn't break the original
function FV_openTowingModule(type,vehicle,cab) {
  FV_openTowingModle( type, vehicle, cab );
}
/* TOWING MODULE END */


function goTo(strLoc, popup){
	var dest = '';
	if (strLoc.substring(0,1) == '/')
		dest = "http://" + window.location.host + strLoc;
	else
		 dest = strLoc;

	if (popup) {
		n = window.open(dest, 'n', 'width=780,height=555,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
		n.focus();
	} else {
		window.parent.location = dest;
	}
}



function goToAccessories(ModelID){
	GatewayNewWindow("GoToAccessories", "",ModelID)
	 
//	var dest = "http://www.fordaccessories.com/GfaWeb/catalog.do?lstMake=Ford&lstModel="+ strVehName + "&lstYear="+ strYear;
//	
//	if (popup) {
//		n = window.open(dest, 'n', 'width=800,height=600,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
//		n.focus();
//	} else {
//		window.parent.location = dest;
//	}
}

function leftNavOn(obj, bgN){
	obj.className = "leftNavOn";
}
function leftNavOff(obj,bgN){
	obj.className = "leftNavOff";
}

function bottomleftNavOn(obj, bgN){
	
	obj.className = "bottomleftNavOn";
}
function bottomleftNavOff(obj,bgN){
	obj.className = "bottomleftNavOff";
}

function goexternal(sURL){
	if( confirm( "You are linking to a non-Ford website. When you click ‘OK’, you are subject to the terms and conditions of that site. Please read over the site’s terms and conditions and privacy policy.") ) {
		document.location = sURL;
	}
}

function switchToHTML() {
	var sAdd = "";
	var sLocation
	sLocation = document.location.href
	sAdd = "SECTION=" + gIVI_section	
	if(document.location.href.indexOf("?") > 0){	
		sLocation= sLocation + "&v=html";
	}else{
		if(document.location.href.indexOf("v=html") <= 0){
			sLocation = sLocation + "?v=html"
		}
	}
	if (gIVI_section.length > 0){			
		if (/SECTION\=[a-zA-z0-9_]+/.test(sLocation)==true){
		 	sLocation = sLocation.replace(/SECTION\=[a-zA-z0-9_]+/, sAdd)
		} else {
			sLocation = sLocation + "&" + sAdd
		}
	} 

	document.location = sLocation
	oCookie.setCookieValue("html","true",1);

}

// OQueryString Object 
function OQueryString(){
	var m_aKey = new Object()
	
	// Constructor
	init()

	/* Public Method Pointers */
	this.getQueryStringValue = getQueryStringValue
	
	function init(){
		var querystring=location.search.substring(1,location.search.length);
		
		// parse out name/value pairs separated via &
		var args = querystring.split('&');

		// split out each name = value pair
		for (var i=0;i<args.length;i++){
			var pair = args[i].split('=');
	
			// Fix broken unescaping
			temp = unescape(pair[0]).split('+');
			name = temp.join(' ');
	
			temp = unescape(pair[1]).split('+');
			value = temp.join(' ');
			
			if (name.toLowerCase().length > 0){
				m_aKey[name.toLowerCase()]=value;
			}
		
		}
	}

	function getQueryStringValue(sKey, sDefault){
		var value
		value=sDefault;
		if (sKey.toLowerCase() in m_aKey){
			value = m_aKey[sKey.toLowerCase()];
			if (value==null || value==undefined){
				value=sDefault;
			}
		}
		return value;
	}
}

/* WRAPPER FUNCTIONS - deprecated, but used by 3rd party templates */
function getCookieValue(cname){
	return oCookie.getCookieValue(cname)	
}

function SetCookieValue(name,val,nDays){
	oCookie.setCookieValue(name, val, nDays)
}

function MyFolderJSHome(){
			var path = "openpath";
			var backUrl = escape(document.location.href);
			document.location = "http://www.myfolder.fordvehicles.com/myfolder/welcome.do?path=openpath&backURL=" + backUrl;
} 

function FordStoryJS(){
	window.open("http://www.thefordstory.com", 'n', 'width=1000,height=768,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}

function SyncJSHome(){
	window.open("/discoversync/", 'n', 'width=1000,height=768,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	
}
 
function searchSite(val){
	window.parent.document.location = "/search/index.asp?origin=0&query=" + val;
	window.onunload = null;
}

function launchEnhanced360(ModelID){
	sPath = document.location.pathname.replace(/index\.asp/, '');
	fGetColorPopupPage(strSite + sPath + 'gallery/colors/', "");
}

function cookie_inish(){
	// Comment out try catch when developing this code...	
	 try{
		//only executes on our own templates because oCookie declard on those only
		oQS = new OQueryString()
		oCookie = new OCookie();	
		
		// OLD COOKIE.ASP CODE ported to javascript

		//Passed in from banner advertisements
		qs_bannerid = oQS.getQueryStringValue("bannerid")
		if (qs_bannerid != undefined){
			oCookie.setSessionCookie("bannerid", qs_bannerid)
			oCookie.setSubSessionCookie("FPISession", "bannerid", qs_bannerid)
			qs_szListID =  oQS.getQueryStringValue("szListID")

			if (qs_szListID  != undefined){
				oCookie.setSessionCookie("partner", qs_szListID + "|" + qs_bannerid)
			}
		}
	
		qs_zip = oQS.getQueryStringValue("zip")
		if (qs_zip != undefined){
			oCookie.setSubCookieValue("FPI", "zip", qs_zip, 65)
		}
		
		qs_srccode = oQS.getQueryStringValue("srccode")
		if (qs_srccode != undefined){
	
			if (oCookie.getCookieValue("szListID") != undefined){
				oCookie.setSessionCookie("szListID", qs_srccode)
			}
		}
		
		qs_partner = oQS.getQueryStringValue("partner")
		if (qs_partner != undefined){
			oCookie.setSessionCookie("partner", qs_partner)
		} 
		
		if (oCookie.getCookieValue("partner") == undefined){
			oCookie.setSessionCookie("partner",  "fv")
		}
	
		SetZipForMetrics(); 
		if(oQS.getQueryStringValue("planType")!= undefined){
				oCookie.setSessionCookie("planType", oQS.getQueryStringValue("planType"));
		}
		if(oQS.getQueryStringValue("referrer")!= undefined){
			oCookie.setSessionCookie("referrer",oQS.getQueryStringValue("referrer"));
		}
	} catch(e){
		//calling page needs to have cookiejs.asp in a <script> tag before the global.js file.
	 }

}

function SetZipForMetrics(){
	//what about if zip is on q-string?
	sZip = oCookie.getSubCookieValue("FPI", "zip")
	if (sZip.length!=5){
		if(oCookie.getAkamaiSubCookieValue("userInfo", "zip").length > 0){
			sZip = oCookie.getAkamaiSubCookieValue("userInfo", "zip").toString().substring(0,5)
			oCookie.setSubCookieValue("FPI", "zip", sZip, 65)
		}
	}
	oCookie.setSubCookieValue("FPI", "zip", sZip, 65) 
}

function openSirius() {
	window.open('/SIRIUS-Ford/','windowName','status,width=540,height=650,scrollbars');
}

function openSiriusRadio() {
	window.open('/SIRIUS-Ford/Radio/','windowName','status,width=540,height=650,scrollbars');
}

function openLinkInNewWindow(link) {
	if(confirm("You are linking to a non-Ford website. Your browsing and interaction are subject to the rules and policies of that site. Please read over the site’s rules and policies before proceeding.")){
		window.open(link,'windowName','status=1,scrollbars=1,resizable=1');
	}
}

cookie_inish();