function getSiteChannelUrl (dlrCode, dest, params) {
	if(dlrCode == "01120"){
		dlrCode = "01329";
	}
	if(dlrCode == "22127"){
		dlrCode = "22120";
	}
	if(dlrCode == "47100"){
		dlrCode = "21100";
	}
	if(dlrCode == "51158"){
		dlrCode = "52101";
	}
    var queryStr = '';
	if (params.length > 0) {
		params = params.replace(/ /g, "").replace(/,/g, "&");
	}
	queryStr = "&" + params;
	var url = "/mbusa-templating/IDG00/views/channelRedirect.jsp?dest=" + dest + "&path=/portal/site/DWS" + dlrCode + queryStr;
	if(dlrCode == "22438"){
		var url = "http://www.mbusa.com/";
	}
	if(dlrCode == "22118"){
		var url = "http://www.mbusa.com/";
	}
	//location.href = url;
	window.open(url);
}
function getMTUrl (mtUrl, dest, params) {
    var queryStr = '';
	if (params.length > 0) {
		params = params.replace(/ /g, "").replace(/,/g, "&");
	}
	queryStr = "?" + params;
	var url = "http://" + mtUrl + dest + queryStr;
	//location.href = url;
	window.open(url);
}

//Search by Dropdown for Dealer Information
function showDealer(dealerID) {
var dlrID = "dws"+dealerID;
if(dealerID == "blank"){
	dlrID = dealerID;
}else{
	dlrID = "dws"+dealerID;
}
//alert(dlrID);
document.getElementById('default').innerHTML=document.getElementById(dlrID).innerHTML;


	if(dlrID == "blank"){
	document.getElementById('default').style.display = "none";
	document.getElementById('default').style.backgroundColor = "transparent";
	}else{
	document.getElementById('default').style.display = "block";
	if (location.pathname.indexOf("IDG06") > -1 || location.pathname.indexOf("IDG08") > -1 || location.pathname.indexOf("IDG12") > -1 || location.pathname.indexOf("IDG13") > -1) {
	document.getElementById('default').style.backgroundColor = "#1d4289";
	}
}
}

//Search By Zipcode AJAX for Dealer Information
var xmlHttp;

function getDealer(){

var dCode = document.getElementById("zipCode").value;
//alert(dCode);
	if (dCode.length==0){ 
	document.getElementById("default").innerHTML="Please enter your zipcode";
	document.getElementById('default').style.display = "block";
	if (location.pathname.indexOf("IDG06") > -1 || location.pathname.indexOf("IDG08") > -1 || location.pathname.indexOf("IDG12") > -1 || location.pathname.indexOf("IDG13") > -1) {
	document.getElementById('default').style.backgroundColor = "#1d4289";
	}
	return;
	}

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null){
	alert ("Your browser does not support AJAX!");
	return;
	} 

	var url="/mbusa-templating/IDG00/searchZip.jsp";
	url=url+"?zipCode="+dCode;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	//alert(url);
	xmlHttp.send(null);
	document.getElementById('default').style.display = "block";
	if (location.pathname.indexOf("IDG06") > -1 || location.pathname.indexOf("IDG08") > -1 || location.pathname.indexOf("IDG12") > -1 || location.pathname.indexOf("IDG13") > -1) {
	document.getElementById('default').style.backgroundColor = "#1d4289";
	}
}

function GetXmlHttpObject(){
var xmlHttp=null;
try
	{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
	}
	catch (e)
		{
		// Internet Explorer
		try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
return xmlHttp;
}

function stateChanged(){ 
	//alert(xmlHttp.readyState);
	if (xmlHttp.readyState==4){ 
		var dCode=xmlHttp.responseText;
		var trimmed = "dws"+dCode.replace(/^\s+|\s+$/g, '');
		//alert(dCode);
		if(null != document.getElementById(trimmed)){
			document.getElementById("default").innerHTML=document.getElementById(trimmed).innerHTML;
		}else{
			document.getElementById("default").innerHTML="A Mercedes-Benz Dealer could not be found.<br/> Please enter a valid zip code within your local area.";
			document.getElementById('default').style.display = "block";
			if (location.pathname.indexOf("IDG06") > -1 || location.pathname.indexOf("IDG08") > -1 || location.pathname.indexOf("IDG12") > -1 || location.pathname.indexOf("IDG13") > -1) {
			document.getElementById('default').style.backgroundColor = "#1d4289";
			}
		}
	}
}

/** allow only numbers to be entered in text box, such as phone number and zip code. */
function isNumberKey(evt){
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57))
	  return false;

   return true;
}

//Webtrends return campaign code function

function Campaign(){
	/**
	var CActive = 1;
	var ccode=4172;
	if (CActive !=1 ){
		ccode=0;
	}*/
	return ccode;
}
function getchc(){
	//var chc = "30081P";//session.getAttribute("chc_code");
	//if(chc == null){chc="38084P";}
	return chc;
}
function getcls(){
	//var cls = "10765";//session.getAttribute("cls_code"); 
	//if(cls == null){cls="11033";}
	return cls;
}
function GetIDGCode(){
	var idgc;
	 if (location.hostname.indexOf("www.arizonamb.com") > -1) {
		idgc = "01";
	 }
	 else if (location.hostname.indexOf("www.bayareamercedes.com") > -1) {
		idgc = "02";
	 }
	 else if (location.hostname.indexOf("www.socalmb.com") > -1) {
		idgc = "03";
	 }
	 else if (location.hostname.indexOf("www.mbsocal.com") > -1) {
		idgc = "04";
	 }
	 else if (location.hostname.indexOf("www.mbsouthflorida.com") > -1) {
		idgc = "05";
	 }
	 else if (location.hostname.indexOf("www.mbchicagoland.com") > -1) {
		idgc = "06";
	 }
	 else if (location.hostname.indexOf("www.searchmercedes.com") > -1) {
		idgc = "07";
	 }
	 else if (location.hostname.indexOf("www.dfwmercedesdealers.com") > -1) {
		idgc = "08";
	 }
	 else if (location.hostname.indexOf("www.pugetsoundmb.com") > -1) {
		idgc = "09";
	 }
	 else if (location.hostname.indexOf("www.mbatlantadealers.com") > -1) {
		idgc = "10";
	 }
	 else if (location.hostname.indexOf("www.suncoastmercedesbenz.com") > -1) {
		idgc = "11";
	 }
	 else if (location.hostname.indexOf("www.neohiomercedes.com") > -1) {
		idgc = "12";
	 }
	 else if (location.hostname.indexOf("www.mbmn.com") > -1) {
		idgc = "13";
	 }
	 return idgc;
}
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}