function setCookie(name, value, expiration){
	//set the cookie expiration value as a date
	var expires = new Date();

	// set the cookie`s actual expiration date (e.g. expiration can be 30 (as in days))
	expires.setDate(expires.getDate() + expiration);
	var path = "/";

	// get the full url string
	var url = new String( window.location );

	// strip off the leading protocol ("http://") and strip any trailing file-path and query string
	var domain = url.substring(7, url.indexOf( ".com/"));

	// strip off any preceding subdomains (www.sub.subsub...)
	domain = domain.substring(domain.lastIndexOf(".") + 1, domain.length) + ".com";

	//set the domain for the cookie - we are planting a hostname cookie here
	var cookieDomain = url.substring(7, url.indexOf( ".com/"))+".com";
	document.cookie = name+"="+value+";expires="+expires.toGMTString()+";path="+path+";host="+cookieDomain+";false";
}


function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

//deaker zip switch
var dealerZip = true;

// browser detection
function browserStats() {
  var ua = " " + navigator.userAgent.toLowerCase();
  this.nn = ua.indexOf( "mozilla" ) > 0;
  this.safari = ua.indexOf( "safari" ) > 0;
  ua.indexOf( "compatible" ) > 0 ? this.nn = false : "";
  this.ie = ua.indexOf( "msie" ) > 0;
  this.version = parseInt( navigator.appVersion );
  this.mac = ua.indexOf( "mac" ) > 0;
  this.ie ? ua.indexOf( "msie 5" ) > 0 ? this.version = 5 : "" : "";
  this.ie ? ua.indexOf( "msie 6" ) > 0 ? this.version = 6 : "" : "";
  return this;
}

var b = new browserStats();

// get proper domain for global navigation images and links
function getDomain( argLink ) {
    var curUrl = document.location.href;
    var newUrl = "";
    var thisDomain = "dodge.com";

    if( curUrl.indexOf( "iw-mount" ) >= 0 ) {
        // preserve virtualization
        newUrl = "";
    } else if( curUrl.indexOf( "://test" ) >= 0 ) {
        newUrl = "http://test";
    } else if( curUrl.indexOf( "://uat" ) >= 0 ) {
        newUrl = "http://uat";
    } else {
        newUrl = "http://www";
    }
    if (newUrl != ""){
    	newUrl = newUrl + "." + thisDomain;
    }
    if( argLink ) {
        if( argLink.indexOf( "javascript:" ) >= 0 || argLink.indexOf( "/" ) != 0 ) {
            return argLink;
        } else {
            return newUrl + argLink;
        }
    } else {
        return newUrl;
    }
}

// get proper domain and http protocal for global navigation images and links
function getDomainImg( argLink ) {
    var curUrl = document.location.href;
    var newUrl = getDomain();
    var protocol = "";
    
    if(curUrl.indexOf("-5") >= 0){
    protocol = curUrl.indexOf("https:") >= 0 ? "https://":"http://";
	    if(protocol == "https://"){
		  var newUrlSplit = newUrl.split( "://" )[1];
		  newUrlSplit = newUrlSplit.replace( /\./, "-5." );
		  newUrl =  protocol + newUrlSplit;
	    }
      }
      
  return newUrl;
}

// route PSAM function call thru getDomain()
function invokeURL(url){window.location=getDomain(url);}


//File path
var cssPath = getDomainImg() + "/css/", cssFile;


//Netscape
b.nn && b.version >= 5 ? cssFile = "netscape_font_adjust.css":"";

//IE 
b.ie ? cssFile = "ie_font_adjust.css" : b.mac && b.ie && b.version >= 5 ? cssFile = "mac_ie_font_adjust.css":"";

//Safari
b.mac && b.safari ? cssFile = "safari_font_adjust.css":"";

cssFile ? document.write( '<link rel="stylesheet" href="' + cssPath + cssFile + '" type="text/css" />' ) : "";

//alert(cssFile);

//Global Netscape browser resize fix
if(b.nn && b.version < 5) {widthCheck = window.innerWidth;heightCheck = window.innerHeight;window.onresize = resizeFix;}
function resizeFix(){widthCheck != window.innerWidth || heightCheck != window.innerHeight ? window.location.reload(true) : "";}

//Tracking Functions
function trackHit(){
_hbSend();
}

function trackNamedHit(argLid,argPos){
  var whiteSpace = / /g;
  var newId = argLid.replace(whiteSpace,"+"); 
  var newPos = argPos.replace(whiteSpace,"+"); 
  _hbSet('lid',newId);
  _hbSet('lpos',newPos);
  trackHit();
}

//DHTML FUNCTIONS
var d=document; var _a=(d.all)?1:0; var l=(!d.getElementById && b.nn)?1:0;
function getE(e,f){if(l){f=(f)?f:self;V=f.document.layers;if(V[e])return V[e];for(W=0;W<V.length;)t=getE(e,V[W++]);return t;}if(_a)return d.all[e];return d.getElementById(e);}
function showE(e){e=getE(e);if(l)e.visibility='show';else e.style.visibility='visible';}
function hideE(e){e=getE(e);if(l)e.visibility='hide';else e.style.visibility='hidden';}
function getX(e){e=getE(e);if(l)return e.left;else return e.style.left;}
function setX(e,x){e=getE(e);if(l)e.left=x;else e.style.left=x;}
function getY(e){e=getE(e);if(l)return e.top;else return e.style.top;}
function setY(e,y){e=getE(e);if(l)e.top=y;else e.style.top=y;}
function setZ(e,z){e=getE(e);if(l)e.zIndex=z;else e.style.zIndex=z;}
function setW(e,w){e=getE(e);if(l)e.clip.width=w;else e.style.width=w;}
function getW(e){e=getE(e);if(l)return e.document.width;if(_a)return e.scrollWidth;return e.offsetWidth;}
function setH(e,h){e=getE(e);if(l)e.clip.height=h;else e.style.height=h;}
function getH(e){e=getE(e);if(l)return e.document.height;if(_a)return e.scrollHeight;return e.offsetHeight;}
function setC(e,t,r,b,x){e=getE(e);if(l){X=e.clip;X.top=t;X.right=r;X.bottom=b;X.left=x;}else e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
function writeH(e,h){e=getE(e);if(l){Y=e.document;Y.write(h);Y.close();}else e.innerHTML=h;}
function getMouseX(e){if(_a)return event.clientX;return e.pageX;}
function getMouseY(e){if(_a)return event.clientY;return e.pageY;}
function getScrollX(){if(_a)return d.body.scrollLeft;return window.pageXOffset;}
function getScrollY(){if(_a)return d.body.scrollTop;return window.pageYOffset;}

/* ********************************* LIVE PERSON BUTTON INCLUDES *********************************** */
//-- Begin Configuration Code --
if (typeof(lpUASunit)=="undefined")
	var lpUASunit = "dodgesales";

var lpUASimagesPath = "/liveperson/images";


//Optional Variables
if (typeof(lpUASlanguage)=="undefined")
	var lpUASlanguage = "english"; // Define the language, default value is english

// Define the invitation position from the left and top of the browser window
if (typeof(lpUASinvitePositionX)=="undefined")
	var lpUASinvitePositionX = 250;
if (typeof(lpUASinvitePositionY)=="undefined")
	var lpUASinvitePositionY = 175;

// Define the button and invitation ALT properties
var lpCustomInvitationTitle="Invitation popup window for live chat with a representative";
var lpCustomInvitationCloseTitle="Close chat invitation";

var lpUAScontext = document.title;

if (typeof(lpdbButtonImageHeight)=="undefined" || lpdbButtonImageHeight.indexOf('<')>=0)
	lpdbButtonImageHeight = "19";
if (typeof(lpdbButtonImageWidth)=="undefined" || lpdbButtonImageWidth.indexOf('<')>=0)
	lpdbButtonImageWidth = "142";

document.write('<noscript><p>Script section containing code for Liveperson Chat Solution</p></noscript><script type="text/javascript" src="/liveperson/js/lp/configuration_baseline.js"></script><noscript><p>Script section containing code for Liveperson Chat Solution</p></noscript>');
//-- End Configuration Code --
/* ****************************************  END LIVEPERSON INCLUDES *********************************** */