
var Domain=location.href;
function gup( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( Domain );  if( results == null )    return "";  else    return results[1];}

var ctryCd= gup("cntryCd");
var MdlCode="";
var TrimName="";
var formAlert="This service is not yet available in Iraq";
//Original Toolbox Functions ********************************

//Request A Test Drive ********************************
function call_testdrive()
{
	var width = 600;
	var height = 700;
	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=yes,toolbar=no,menubar=no"
	var address = "/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=ar&WebSiteID=GBPME&ReqsType=Pull&ServiceName=TestDrive&NampltCd=001^BSBSE^TD^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=BSBSE&ModelCode=BS";
	
	if(ctryCd != 'EG' && ctryCd != 'IQ')
	{
		try{			
			disWindow = window.open(address, "disclaimer", features);
		}
		catch(e)
			{
			try{
			disWindow = window.open(address, "disclaimer", features);
			}
		   catch(e)
			{ 
			disWindow = window.open(address, "disclaimer", features);
			}
		}
	}
	else 
		{
			if(ctryCd =='EG')
			{
				alert(" Test drive faclilty is not available in Egypt");}
			else{
				if(ctryCd == 'IQ')alert(formAlert);
				}
		}
}
//Keep Me Updated ********************************
function call_me_updated()
{
	var width = 600;
	var height = 350;
	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 address = "/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=ar&WebSiteID=GBPME&ReqsType=Pull&ServiceName=EntryForm&newPage="+ctryCd+"&NampltCd=001";
	
if(ctryCd == 'IQ')
{
	alert(formAlert);
}
else{
	
	
	disWindow = window.open(address, "disclaimer", features);
}

}
// function for eBrochure start
//Download E Brochure OLD ********************************
function download_eBrochure_old()
{
if(ctryCd == 'IQ')
{
	alert(formAlert);
}
else if (ctryCd == 'SY')
{
	alert(formAlert1);
}
else if (ctryCd == 'EG')
{
	window.open('/content_data/LAAM/ME/ar/GBPME/001/EG/downloade-brochure.html?cntryCd=EG','dwn_eBrochure','width=750,height=500'); 
}
else{

	window.open('/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=ar&WebSiteID=GBPME&ReqsType=Pull&ServiceName=EntryForm&newPage='+ctryCd+'&NampltCd=CEB','dwn_eBrochure','width=750,height=500'); 
	
}
}
//Download E Brochure New ********************************
function download_eBrochure()
{
	
	if (ctryCd != "EG"){
	var width = 594;
	var height = 716;
	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 address = "http://www.globalbuypower.com/content_data/LAAM/ME/ar/GBPME/999/G1/ebrochure.html?brand=chevrolet" + "&cntryCd="+ctryCd;
	disWindow = window.open(address, "disclaimer", features);	
	}
	else{
	width = 600;
	height = 590;
	left = (window.screen.width-width) / 2;
	top = (window.screen.height-height) / 2;
	features = "top="+top+",left="+left+",width="+width+",height="+height+",resizable=no,location=no,scrollbars=no,toolbar=no,menubar=no"
	address = "/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=ar&WebSiteID=GBPME&ReqsType=Pull&ServiceName=TestDrive&NampltCd=001^^DEB^N^EG^&SellingSrc=72&MerchModlDesgtr=BSE&ModelCode=1B";
	disWindow = window.open(address, "disclaimer", features);
	}
}

//Contact Us ********************************
function contactus()
{
	var width = 600;
	var height = 700;
	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=yes,toolbar=no,menubar=no"
	var address = "/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=ar&WebSiteID=GBPME&ReqsType=Pull&ServiceName=ContactSector&NampltCd=001^"+ctryCd;
	disWindow = window.open(address, "disclaimer", features);	

}


//Request A Brochure ********************************
function call_brochure()
{
	var width = 600;
	var height = 700;
	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=yes,toolbar=no,menubar=no"
	var address = "/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=ar&WebSiteID=GBPME&ReqsType=Pull&ServiceName=TestDrive&NampltCd=001^BSBSE^RB^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=BSBSE&ModelCode=BS";
if(ctryCd == 'IQ')
{
	alert(formAlert);
}
else
	{

	try{
		disWindow = window.open(address, "disclaimer", features);	
		}
	
	catch(e)
		{
			try{
				disWindow = window.open(address, "disclaimer", features);	
			}
			catch(e)
			{
				disWindow = window.open(address, "disclaimer", features);	
			}
		}
	}
}

//Dealer Locator ********************************
  function	read_cncd()
	   {
			var strHref=window.location.href;
    if(strHref.indexOf("?")> -1){ 
		var questionindex=strHref.indexOf("?")	;
		questionindex=questionindex+1
		var strQueryString= strHref.substr(questionindex,strHref.length); }
        //alert("strQueryString"+strQueryString);
        
		var blah = strQueryString.split("=");
		//alert("blah"+blah);

		 if(blah[0]=="cntryCd")
			 {
		   if(blah[1]=="SA") 
			   {
			   //alert("Sa")
			   location.href = "/content_data/LAAM/ME/ar/GBPME/001/G1/dealer-locator.html?cntryCd=SA" ; 
			    }
				else if(blah[1]=="AE") 
			   {
			   //alert("AE")
			   location.href = "/content_data/LAAM/ME/ar/GBPME/001/G1/dealer-locator.html?cntryCd=AE" ; 
			    }
				else if(blah[1]=="EG") 
			   {
			   //alert("AE")
			   location.href = "/content_data/LAAM/ME/ar/GBPME/001/EG/dealer-locator.html?cntryCd=EG" ; 
			    }
			   else{
			   //call_page('001/dllocator.html');
			   location.href = "/content_data/LAAM/ME/ar/GBPME/001/G1/dealer-locator.html?cntryCd="+blah[1] ; 
			   }
			 }
		   
		
	   }

function call_dealer_locator()
{

	 read_cncd();
	
	

}
