/* 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_IE6 = (navigator.appVersion.indexOf("MSIE 6") != -1);
var IS_IE7 = (navigator.appVersion.indexOf("MSIE 7") != -1);
var gIVI_section = "";
var isIE=navigator.appName=="Microsoft Internet Explorer";

var urlParts=document.location.toString().split("/");
var creativeVersion=urlParts[3];
var testingVersion=urlParts[4];
var getVars=getUrlVars();

if(BROWSER_NAME == "microsoft internet explorer"){
	BROWSER_NAME = "explorer";
}

if(BROWSER_ISPC){
	PLATFORMNAME = "pc";
}else if(BROWSER_ISMAC){
	PLATFORMNAME = "mac";
}else{
	PLATFORMNAME = "unix";
}

// 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 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>");
}


function OGate(){
	
	this.Gateway = Gateway	
	this.TheWindow = 'window.location'
	
	function Gateway(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 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 != '' && y != '' && x != undefined && y != undefined)  {
		newWin = openNewWindow('','', 'width=' + x + ',height=' + y + 'toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');		
		}
	else {	
		newWin = openNewWindow('','', 'toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
		}
	oGate.TheWindow= "newWin.window.location"
	oGate.Gateway(App, Line, ModelID, Parameter1)
}

function getBuildPriceLink(){
	window.parent.location = 'http://localhost/asp/util/gateway.asp?app=BuildAndPrice'
}

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 SyncJSHome(){
	window.open("/discoversync/", 'n', 'width=1000,height=768,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}

function goToAccessories(strYear, strVehName, popup){
	var dest = "http://www.fordaccessoriesstore.com/fas/b2c/catalog.asp?extmake=Ford&extyear="+ strYear +"&extmodel="+ strVehName;
	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 getPriceQuote(){
	window.parent.location = '/asp/util/gateway?App=PriceQuote'
}

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 openWin( html, name, wval, hval, scroll) {
	var features;
	
	if (wval != '' && hval != '' && wval != undefined && hval != undefined)  {
		features = 'width='+wval+',height='+hval+',toolbar=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no';
	} else {
		features = 'width=940,height=620,toolbar=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no';
	}
	
	var nW = window.open(html, name, features);
	
}

function openNewWindowWithFeatures(theURL,winName,features) {
	newWin = window.open(theURL,winName,features);
}

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=325,height=470,top=0,left=50,screenX=50,screenY=0"
	} else if(nFipType=="2"){
		winSize = "width=617,height=570,top=0,left=50,screenX=50,screenY=0"
	}
	else if(nFipType=="3"){
		winSize = "width=423,height=450,top=0,left=50,screenX=50,screenY=0"
	}
	else if(nFipType=="4"||nFipType=="5"){
		winSize = "width=603,height=460,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 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 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 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 );
}

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 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;
	}
}

// OQueryString Object 
function OQueryString(){
	var m_aKey = new Object()
	
	// Constructor
	init()

	/* Public Method Pointers */
	this.getQueryStringValue = getQueryStringValue
	
	function init(){
		var temp
		var name
		var value
		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 searchSite(val){
	window.parent.document.location = "/search/index.asp?origin=0&query=" + val;
	window.onunload = null;
}

function cookie_inish(){
	var oQS
	var oCookie
	var qa_bannerid
	var qs_zip
	var qs_szListID
	var qs_srccode
	var qs_partner

	// 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()

		// No Cookie check 
		
		var oRegExp = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
		
		if (oCookie.getCookieValue("gtmo") == undefined || oCookie.getCookieValue("gtmo")=="" && window.location.host!='localhost'  && oRegExp.test(window.location.host)!=true){
			//alert("Get No cookie website address here")
			// document.location = "http://www.yahoo.com"
		}
		
		// 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 && isValidZip(qs_zip)){
			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?
	var 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) 
}

cookie_inish();

function showObject(name){
	if (document.getElementById(name)) document.getElementById(name).style.display="block";
}

function hideObject(name){
	if (document.getElementById(name)) document.getElementById(name).style.display="none";
}


function isValidZip(s) 
{
     var bRes = true;
	 reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

     if (!reZip.test(s)) {
          //alert("Zip Code Is Not Valid");
          bRes = false;
     }
	return bRes;
}

function isValidEmail(s) 
{
     var bRes = true;
	 reE = new RegExp(/^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/);

     if (!reE.test(s)) {
          //alert("Email Is Not Valid");
          bRes = false;
     }
	return bRes;
}

function isValidPhone(s) 
{
     var bRes = true;
	 reP = new RegExp(/^([0-9]{11})$/);

     if (!reP.test(s)) {
          //alert("Phone Is Not Valid");
          bRes = false;
     }
	return bRes;
}

function stripHTML(oldString) {

  return oldString.replace(/<&#91;^>&#93;*>|\n|\t/g, "");
  
}

/********************************************************
	Generic layer visibility function
	layerName -- identifies the div layer being affected
********************************************************/

// show layer
function divShow( divName ){
	document.getElementById( divName ).style.display='block';
}

// hide layer
function divHide( divName ){
	document.getElementById( divName ).style.display='none';
}

// show layer visible
function divVisible( divName ){
	document.getElementById( divName ).style.visibility='visible';
}

// hide layer hidden
function divHidden( divName ){
	document.getElementById( divName ).style.visibility='hidden';
}

function getUrlVars(){
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

	for(var i = 0; i < hashes.length; i++){
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}

	return vars;
}

function stringTrim(sVal) {
	return sVal.replace(/^\s+|\s+$/g,"");
}

//Usage: onmouseout='if (isMouseLeaveOrEnter(event, this)) YourActionHere();' onmouseover='if (isMouseLeaveOrEnter(event, this)) YourOtherActionHere();'
function isMouseInOrOut(e, handler) {
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

function findPos(obj) {
	var curleft = curtop = 0;
	while( obj != null)
	{
		curleft += obj.offsetLeft ;
		curtop += obj.offsetTop ;
		obj = obj.offsetParent ;
	}
	
	return [curleft,curtop];
}

function findPos_n(oObj, bUseParent){
    if(typeof(oObj) == "string") oObj = document.getElementById(oObj)
    var b = document.getElementsByTagName("body")[0]
    var sl = document.documentElement.scrollLeft
    var st = document.documentElement.scrollTop
    if(document.getBoxObjectFor){
        var r = document.getBoxObjectFor(oObj)
        var rect = {l:r.x,t:r.y,r:r.width+r.x,b:r.y+r.height}
    } else{
        if(oObj.getBoundingClientRect){
	        var r = oObj.getBoundingClientRect()
	        var rect = {l:r.left-2+sl,t:r.top-2+st,r:r.right-2+sl,b:r.bottom-2+st}
        } else {
	        var l = oObj.offsetLeft
	        var t = oObj.offsetTop
	        var rect = {l:l,t:t,r:l+oObj.offsetWidth,b:t+oObj.offsetHeight}
	        var p = oObj.offsetParent
	        if(bUseParent) p = oObj.parentNode
	        while(p){
		        l = p.offsetLeft
		        t = p.offsetTop
		        if(l){
		        	rect.l += l
		        	rect.r += l
		        }
		        if(t){
		        	rect.t += t
		        	rect.b += t
		        }
		        if(bUseParent){
		        	p = p.parentNode
		        } else {
		        	p = p.offsetParent
		        } 
	        }
        }
    }
    return rect
}

function findMousePos(e) {
	var posx = 0;var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return [posx, posy];
}

function rollClass(ele) {
	ele.className = (/_on/.test(ele.className)) ? ele.className.replace('_on', '_off') : ele.className.replace('_off', '_on');
}

function getPositionLeft(This){
	var el = This;var pL = 0;
	while(el){pL+=el.offsetLeft;el=el.offsetParent;}
	return pL
}
function getPositionTop(This){
	var el = This;var pT = 0;
	while(el){pT+=el.offsetTop;el=el.offsetParent;}
	return pT
}

function isInBox(sName,evt) {
	var oBox = document.getElementById(sName);
	
	var boxCoord = findPos(oBox);
	var mouseCoord = findMousePos(evt);

	if ((mouseCoord[1]>=boxCoord[1] || mouseCoord[1]<=(boxCoord[1] + oBox.offsetHight)) 
		&& (mouseCoord[0]>=boxCoord[0] || mouseCoord[0]<=(boxCoord[0] + oBox.offsetWidth)) )
	{	return true; }
	else
	{	return false; }
		
	
}

 
 function showDebug(sShow) {
	if (document.getElementById("status"))
		document.getElementById("status").innerHTML = sShow;
 }
 
 //function mMoveHandler(e) {
//  if (!e) e = window.event;  // IE event model
//  
//	document.getElementById('status').innerHTML = e.clientX + "px";
//    // Move the element to the current mouse position, adjusted as
//	// necessary by the offset of the initial mouse click.
//	//elementToDrag.style.left = (e.clientX - deltaX) + "px";
//	//elementToDrag.style.top = (e.clientY - deltaY) + "px";
//
//	// And don't let anyone else see this event.
//  if (e.stopPropagation) e.stopPropagation();       // DOM Level 2
//  else e.cancelBubble = true;                       // IE
//
//	//add to document body
//	if (document.addEventListener)
//		document.addEventListener("mousemove", moveHandler, true);
// }

// function bgHoverAt(ele) {
//	ele.style.backgroundImage = /_at/.test(ele.style.backgroundImage)?ele.style.backgroundImage.replace("_at","_on"):ele.style.backgroundImage.replace("_on","_at");
// }
// 
// function bgHover(el){
//	if (el.style.backgroundImage.indexOf('off')==-1){
//		el.style.backgroundImage=el.style.backgroundImage.replace('on','off');
//	}else{
//		el.style.backgroundImage=el.style.backgroundImage.replace('off','on');
//	}
// }
 
function hover(el) {
	return;
	if (el.src.indexOf('off')==-1){
		el.src=el.src.replace('on','off');
	}else{
		el.src=el.src.replace('off','on');
	}
}

var inishScript = {
	run:[
	
	],
	inish:function(oSelf){
		for(var i = 0; i<oSelf.run.length; i++) oSelf.run[i].inish()
		oSelf.run = 0
	}
}

	var MP = {
<!-- mp_trans_disable_start -->
Version: '1.0.16',
Domains: {'es':(location.host.match(/wwwqa/)?'www.mp.fordenespanol.com':'www.fordenespanol.com')},
SrcLang: 'en',
<!-- mp_trans_disable_end -->
UrlLang: 'mp_js_current_lang',
SrcUrl: unescape('mp_js_orgin_url'),
<!-- mp_trans_disable_start -->
init: function(){
if (MP.SrcUrl.indexOf('p_js_')==1) {
MP.SrcUrl=location.href;
MP.UrlLang=MP.SrcLang;
}
},
getCookie: function(name){
var start=document.cookie.indexOf(name+'=');
if(start < 0) return null;
start=start+name.length+1;
var end=document.cookie.indexOf(';', start);
if(end < 0) end=document.cookie.length;
while (document.cookie.charAt(start)==' '){ start++; }
return unescape(document.cookie.substring(start,end));
},
setCookie: function(name,value,path,domain){
var cookie=name+'='+escape(value);
if(path)cookie+='; path='+path;
if(domain)cookie+='; domain='+domain;
var now=new Date();
now.setTime(now.getTime()+1000*60*60*24*365);
cookie+='; expires='+now;
document.cookie=cookie;
},
switchLanguage: function(lang){
if(lang!=MP.SrcLang){
var script=document.createElement('SCRIPT');
script.src=location.protocol+'//'+MP.Domains[lang]+'/'+MP.SrcLang+lang+'/?1023749632;'+escape(MP.SrcUrl);
document.body.appendChild(script);
} else if(lang==MP.SrcLang && MP.UrlLang!=MP.SrcLang){
var script=document.createElement('SCRIPT');
script.src=location.protocol+'//'+MP.Domains[MP.UrlLang]+'/'+MP.SrcLang+MP.UrlLang+'/?1023749634;'+escape(location.href);
document.body.appendChild(script);
}
return false;
},
switchToLang: function(url) {
var mplink=document.createElement('A');
if (mplink.click) { // using location.href will cause IE6 to not report referrer
mplink.href=url;
document.body.appendChild(mplink);
mplink.click();
} else {
location.href=url;
}
}
<!-- mp_trans_disable_end -->
};
function switchLanguage(lang) {
MP.SrcUrl=unescape('mp_js_orgin_url');
MP.UrlLang='mp_js_current_lang';MP.init();
MP.switchLanguage(MP.UrlLang==lang?'en':lang);
return false;
}
