function sendToOmniture(pageName){
	s.pageName=""
	s.server=""
	s.channel=""
	s.pageType=""
	s.prop1=""
	s.prop2=""
	s.prop3=""
	s.prop4=""
	s.prop5=""
	/* Conversion Variables */
	s.campaign=""
	s.state=""
	s.zip=""
	s.events=""
	s.products=""
	s.purchaseID=""
	s.eVar1=""
	s.eVar2=""
	s.eVar3=""
	s.eVar4=""
	s.eVar5=""

	// seting  page name
	var pName = '';
	
	// pay attention to the order of v-series in the arrays "v-serires" should be the last one
	var carFolders = new Array("/cts/", "/ctsv/", "/ctscoupe/", "/ctsvcoupe/", "/dts/", "/srx/", "/escalade/", "/esv/", "/ext/", "/escaladeplatinum/","/offers/");
	var carPrefix = new Array("cts", "ctsv", "ctscoupe", "ctsvcoupe", "dts", "srx", "escalade", "esv", "ext", "escaladeplatinum","offers");
	
	// add language prefix
	pName += (window.location.href.toLowerCase().indexOf('/ar/') > -1 ? "ar:" : "en:");
	
	// add car model prefix
	var url = window.location.href.toLowerCase();
	for(var n=0; n<carFolders.length; ++n){
		if(url.indexOf(carFolders[n].toLowerCase()) > -1){
			pName += carPrefix[n].toLowerCase() + ":";
			break;
		}// if indexOf
	}// for
	
	// add file name
	var path = url.split('/');
	var fileName = path[path.length-1];
	
	// check if the url contains file name of not
	if(!fileName){
		// no file name 
		fileName = 'index';	
	}
	else{
		// add the file name without file extention
		fileName = fileName.split('.')[0];	
	}
	pName += fileName;
	
	// if page name is been sent to function use it or use the automatic genterated page name
	s.pageName = pageName ? pageName : pName.toLowerCase();
	
	// update the staut bar for testing
	//window.status = s.pageName;
	//document.title = s.pageName;
	
	// fine channel (Site Section Arabic/English) form URL
	s.channel = window.location.href.toLowerCase().indexOf('/ar/') > -1 ? "Arabic" : "English";
	
	var s_code=s.t();if(s_code)document.write(s_code);
	
}// fun. sendToOmniute

function sendPropToOmniture(propNumber, propValue){
	var s=s_gi(s_account);
	s.linkTrackVars="prop"+propNumber.toString();
	s["prop"+propNumber] = propValue;
	
	s.tl(this, 'o', 'Prop');
}// fun. sendEventToOmniute

sendToOmniture();

function openWindow(obj, w, h){
	var width = w != null ? w : 400;
	var height = h != null ? h : 520;
	var left = (window.screen.width-width) / 2;
	var top = (window.screen.height-height) / 2;
	var features = "top="+top+",left="+left+",width="+width+",height="+height+",resizable=no,location=no,scrollbars=no,toolbar=no,menubar=no"
	var url = obj.href;
	//if(url.indexOf('http://www.cadillacarabia.com/')>-1)
	//{
		obj.href = url.replace('http://www.gmarabia.com/','http://www.globalbuypower.com/');
	//}
	disWindow = window.open(obj.href, "popupwindow", features);
	return false;
}

function openForm(car, mode, lang){
	if(!car) car = "CTS";
	var url;
	if(lang == 'AR'){
		lang = 'ar';	
	}
	else lang = 'en';
	
	var domain = "www.globalbuypower.com";
	//if(location.href.indexOf("cadillacarabia.") < 0) domain = "origin-laam-fusion-itl.e-gm.torsdc.ca";
	
	if(mode && mode == "testdrive"){
		url = "http://"+domain+"/GBPServiceMgr2.dyn?CntryCd=ME&LangCd="+lang+"&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=cadillac^"+car+"^TD^N^^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
	}
	else{
		url = "http://"+domain+"/GBPServiceMgr2.dyn?CntryCd=ME&LangCd="+lang+"&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=cadillac^"+car+"^RB^N^^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";

	}
	var width = 700;
	var height =  800;
	var left = (window.screen.width-width) / 2;
	var top = (window.screen.height-height) / 2;
	var features = "top="+top+",left="+left+",width="+width+",height="+height+",resizable=yes,location=no,scrollbars=yes,toolbar=no,menubar=no"
	disWindow = window.open(url, "popupwindow", features);
	
}

///////////////////
function switchLanguage()
{
	var url = window.location.href;
	var currLang;
	var distLang;
	
	
	// decide which language
	if(url.indexOf('/en/GBPME/') > -1){
		// page in english section
		currLang = '/en/GBPME/';
		distLang = '/ar/GBPME/';
	}
	else if(url.indexOf('/ar/GBPME/') > -1){
		// page in arabic section
		currLang = '/ar/GBPME/';
		distLang = '/en/GBPME/';
	}
	else{
		// language is not decided redirect to website url
		window.location.href = 'http://www.cadillacarabia.com/';
	}
	
	// do the language redirection
	window.location.href = url.replace(currLang, distLang);
	
}
