function getHostName ( ) {
	var serverName = location.hostname;
	var flexHttpRoot = "";
	
	// set Flex HTTP root
	if ((serverName == "mbusahoin19.mbusa.com")  ||  (serverName == "mbusahoin20.mbusa.com")) {
		//flexHttpRoot = "http://mbhorsapp111.mbusa.com/psd2html/flex";
		flexHttpRoot = "http://mbusarb-qa.mbusa.com/mercedes/";
		//flexHttpRoot = "http://53.67.66.84:8080/mbusa/";
	}
	else if ((serverName == "previewqa.mbusa.com")  ||  (serverName == "connectionqa.mbusa.com")) {
		flexHttpRoot = "http://mbusarb-qa.mbusa.com/mercedes/";
		//flexHttpRoot = "http://mbusaprod.mbusa.com/mercedes";
		//flexHttpRoot = "http://www.mbusa.com/mercedes";
	}
	else {
		flexHttpRoot = "http://www.mbusa.com/mercedes/";
	}
	return (flexHttpRoot);
}

 function scrollUp(ele)
      {
 		   var theobj = false;

		   if (navigator.appName.indexOf("Microsoft") != -1) {
				window.scrollTo(0,0);
				return;
			}

		   if(typeof ele == 'string')
		   {
				theobj = (document.nativeGetElementById)?document.getElementById(ele):document.all[ele];
		   }
		   else
		   {
				theobj = ele;
		   }

		   if (typeof(theobj)  != "undefined")
		   {
				theobj.scrollTop = theobj.scrollTop - 5000;
		   }

      }
/* Used for links within Flex pages and elsewhere */
function goCrossDomain (dest) {
/*
	var myHost = location.hostname;
	var myPath = location.pathname;
	
	location.href = "http://" + myHost + "/mbusa-templating/DWSMaster/views/channelRedirect.jsp?dest=" + dest + "&path=" + myPath;
*/
	goCrossDomainWithParams (dest, "");
}
/* Request Parameters channelRedirect*/
function goCrossDomainWithParams (dest, params) {
	var myHost = location.hostname;
	var myPath = location.pathname;
	var mySearch = location.search.replace(/\?/,"");
    var queryStr = '';
	
	if (params.length > 0) {
		params = params.replace(/ /g, "").replace(/,/g, "&");
	}
	queryStr = "&" + mySearch + "&" + params;

	if (dest == 'cpoInventorySearch'|| dest == 'cpoOffers') {	// ugly code just to make it work for CPOInventorySearch .......  (agreed - Jeff)
		if  (queryStr.indexOf('vgnextnoice=1') > 0) {
			location.href = "http://" + myHost + "/mbusa-templating/DWSMaster/views/channelRedirect.jsp?dest=" + dest + "&path=" + myPath + "&vgnextnomenu=1&vgnextrefresh=1&vgnextnoice=1&incontextedit=true";
		}
		else {
			location.href = "http://" + myHost + "/mbusa-templating/DWSMaster/views/channelRedirect.jsp?dest=" + dest + "&path=" + myPath + "&&";
		}
	}
	else {
		//alert(dest);
		location.href = "http://" + myHost + "/mbusa-templating/DWSMaster/views/channelRedirect.jsp?dest=" + dest + "&path=" + myPath + queryStr;
	}
	
	//location.href = "http://" + myHost + "/mbusa-templating/DWSMaster/views/channelRedirect.jsp?dest=" + dest + "&path=" + myPath + queryStr;
}


/**
  params has to be  quote=y (or n)  testDrive=y(or n)
  dlrUrl should not contain "http://"
  dest has to be "contact" for now
  example: 
  getSiteChannelUrl('05612', 'www.san-francisco.mercedescenter.com','contact','quote=y')
  OR
  getSiteChannelUrl('05612', 'www.san-francisco.mercedescenter.com','contact','quote=n, testDrive=y')
*/
function getSiteChannelUrl (dlrCode, dlrUrl, dest, params) {
	var mySearch = location.search.replace(/\?/,"");
    var queryStr = '';
	
	if (params.length > 0) {
		params = params.replace(/ /g, "").replace(/,/g, "&");
	}
	queryStr = "&" + mySearch + params;	
	var url = "http://" + dlrUrl + "/mbusa-templating/DWSMaster/views/channelRedirect.jsp?dest=" + dest + "&path=/portal/site/DWS" + dlrCode + queryStr;
	//location.href = url;
	return url;
}

//Floodlight tag randomn number to avoid the browser from caching the request
	var axel = Math.random()+"";
	var a = axel * 10000000000000;
	
	function setFloodlightTag(src,type,cat)
	{
		var floodlightTag = "http://fls.doubleclick.net/activityi;src="+src+";type="+type+";cat="+cat+";ord=1;num="+ a + "?";			    
		document.getElementById("DCLK_IFRAME").src = floodlightTag;
	}

function goLastPage(){
	history.go(-1);
	}