var omni_langCd="en";
var ctryCd="";
var countryXML;
var countryURL = "/content_data/LAAM/ME/en/GBPME/012/includes/arc_countries.xml";
var specXML;
var specURL = "/content_data/LAAM/ME/en/GBPME/012/Menu_en.xml";
$(document).ready(docReady);
var wmenu=null;
var wimage=null;
var current=null;
var endsecond;
var v=0;
var su=0;close_var=0;
function docReady(){
	/*
	if(!survey_get_cookie('stc')){
	    survey_createCookie('stc','1');
		var d=new Date();
		h=d.getHours();m=d.getMinutes();s=d.getSeconds();
		if(s<30){endsecond=s+30;endminute=m;endhour=h;}
		if(s==30)
		{
			if(m<59)
			{
				endsecond=0;endminute=m+1;endhour=h;
			}
			else if(m==59)
			{
			   endsecond=0;endminute=0;endhour=h+1;
			}
		}
		else if(s>30)
		{
			if(m<59)
			{
				endsecond=s-30;endminute=m+1;endhour=h;
			}
			else if(m==59)
			{
			   endsecond=s-30;endminute=0;endhour=h+1;
			}
			
		}
		
		survey_createCookie('hour',endhour);survey_createCookie('min',endminute);survey_createCookie('sec',endsecond);
			

	}
	/*
	var d1=new Date();
	h1=d1.getHours();m1=d1.getMinutes();s1=d1.getSeconds();
	if(survey_get_cookie('hour')==h1)
	{
		if(m1==survey_get_cookie('min'))
		{
			setTimeout("survey_showpopup()",(survey_get_cookie('sec')-s1)*1000);
		}
		else if(m1<survey_get_cookie('min'))
		{
			setTimeout("survey_showpopup()",((60-s1)+survey_get_cookie('sec'))*1000);
		}
	}
	else if(survey_get_cookie('hour')==h1+1)
	{
		if((survey_get_cookie('min')==0)||(survey_get_cookie('min')==1))
		{
		 setTimeout("survey_showpopup()",((60-s1)+survey_get_cookie('sec'))*1000);	
		}
	}
	*/
	var xloc=location.href;
	if(xloc.indexOf("cntryCd=")>0) 
	{
		ctryCd=xloc.substr(xloc.indexOf("cntryCd=")+8,2);
		
	    var country_list = new Array();
		var country_list_name = new Array();
			country_list[1] = "BH";	country_list_name[1] = "Bahrain";			
			country_list[2] = "JO";	country_list_name[2] = "Jordan";		
			country_list[3] = "KW";	country_list_name[3] = "Kuwait";		
			country_list[4] = "LB"; country_list_name[4] = "Lebanon";
			country_list[5] = "OM"; country_list_name[5] = "Oman";
			country_list[6] = "QA"; country_list_name[6] = "Qatar";
			country_list[7] = "SA"; country_list_name[7] = "Saudi Arabia";
			country_list[8] = "SY"; country_list_name[8] = "Syria";
			country_list[9] = "AE"; country_list_name[9] = "U.A.E.";
			country_list[10] = "IQ"; country_list_name[10] = "Iraq";
			country_list[11] = "EG"; country_list_name[11] = "Egypt";
			
			j=0;
			for(i=1;i<12;i++)
		       if(country_list[i]==ctryCd) 
			      {j=1;
				  $("#country_click").text(country_list_name[i]);
				  }
		    if(j==0) 
			   callSelectCd();
	}
	else callSelectCd();
	var dc = $("#dd_country");
	
	$.get(countryURL,{},function(xml){
	
	xml = parseXml(xml);
	countryXML = xml;
	
	$("#country_container").append("<div id=\"menu\"></div>");
	var dc = $("#menu");
			k=0;
	$("country",countryXML).each(function(i){
			 idc=$(this).attr("id");
			 namec=$(this).attr("name");if(namec=="United Arab Emirates")namec="U.A.E.";
             dc.append("<div id=\"" + idc
		     + "\" class=\" ctrItem \" onmouseover=\"stopHide(1);\" onmouseout=\"beforeHide('menu',1);\" >"
			 + namec +"</div>");
			 ct="#"+$(this).attr("id");
			 $(ct).bind('click',ct,setCountryCode);
			 if(k<4)
			 {$("#ctrSel").append("<div id=\""+idc+"P"+"\" class=\"ctryItem\" >"+namec+"</div><br />");
			 k+=1;}
			 else if(k<8)
			 {$("#ctrSel1").append("<div id=\""+idc+"P"+"\" class=\"ctryItem\" >"+namec+"</div><br />");
			 k+=1;}
			 else if(k>=8)
			 {$("#ctrSel11").append("<div id=\""+idc+"P"+"\" class=\"ctryItem\" >"+namec+"</div><br />");
			 k+=1;}
			 
			 
			 
			 vv="#"+idc+"P";
			 $(vv).bind('click',ct,setCountryCode);
										     })
		
                                      })

$("#country_click").bind('click',"#menu",showMenu);
$("#go").bind('click',"#menu",showMenu);


/**************************************/

$.get(specURL,{},function(xml){
xml = parseXml(xml);
	specXML = xml;
	var cars=$("#nav_button");
	cars.append("<div id=\"vehiclem\" onmouseout=\"beforeHide('vehiclem',6);\"></div>");
    var carm=$("#vehiclem");
	var vans=$("#nav_button");
	vans.append("<div id=\"experiencem\"></div>");	
	var vanm=$("#experiencem");
	var suvs=$("#nav_button");
	suvs.append("<div id=\"ownerm\"></div>");	
	var suvm=$("#ownerm");
//Vehicle Menu 
//allPath="../G1";
//if(MdlCode!="1ARC"){
	//allPath="..";
//}else allPath="../G1";
 $("#vehiclem").append("<a id=\"allModelsA\" href=\"/content_data/LAAM/ME/en/GBPME/012/G1/allvehicles.html?cntryCd="+ctryCd+"\" onmouseover=\"stopHide(6);\" onmouseout=\"beforeHide('vehiclem',6);\">"
				  +"<div id=\"" +"allModels" + "\" class=\" carItemMainFirst \"  >" + "View All Vehicles" +"</div>"+"</a>");
 $("#vehiclem").append("<div class=\""+"Menuline"+"\" >"+"</div>"+"</a>");
 $("#vehiclem").append("<a href=\""+"#"+"\" onmouseover=\"stopHide(6);\" onmouseout=\"beforeHide('suvm',4);\">"
				  +"<div id=\"suvs\" class=\" carItemMainMid \" >" + "Crossovers & SUVs" +"</div>"+"</a>");
 $("#vehiclem").append("<div class=\""+"Menuline"+"\" >"+"</div>"+"</a>");
 $("#vehiclem").append("<a href=\""+"#"+"\" onmouseover=\"stopHide(6);\" onmouseout=\"beforeHide('vanm',3);\">"
				  +"<div id=\"vans\" class=\" carItemMainEnd \" >" + "Trucks & Vans" +"</div>"+"</a>");
 
// Experience Menu
var ex=-1;
$("Experience",specXML).each(function(i){
				$("link",this).each(function(i){ex++;})})
$("Experience",specXML).each(function(i){
				$("link",this).each(function(i){
						var classEx="carItemMainMidupEX";				 
						if(i==0)classEx="carItemMainFirstEX";if(i==ex)classEx="carItemMainEndEX";if(i==ex-1)classEx="carItemMainMidEX";
						if($(this).attr("avail_cntry").indexOf(ctryCd)>=0){
						$("#experiencem").append("<a href=\""+$(this).attr("path")+"?cntryCd="+ctryCd+"\" onmouseover=\"stopHide(7);\" onmouseout=\"beforeHide('experiencem',7);\">"+"<div id=\"" +$(this).attr("name_en") + "\" class=\" "+classEx+" \"  >" + $(this).attr("name_en") +"</div>"+"</a>");	
						if(i!=ex)
						$("#experiencem").append("<div class=\""+"MenulineEX"+"\" >"+"</div>"+"</a>");
								   
						}
							/*test*/
					else{
						u=$(this).attr("name_en");
						$("#experiencelink ul li a").each(function(i){
															 if($(this).text().toUpperCase()==u.toUpperCase())
															     {$(this).parent().css("display","none");}
															   })
						
						}
						})
								   })

//Owner Menu
var ow=-1;
$("Owners",specXML).each(function(i){
				$("link",this).each(function(i){ow++;})})
$("Owners",specXML).each(function(i){
					$("link",this).each(function(i){
						var classOW="carItemMainMidupOW";				 
				if(i==0)classOW="carItemMainFirstOW";if(i==ow)classOW="carItemMainEndOW";if(i==ow-1)classOW="carItemMainMidOW";
						if($(this).attr("avail_cntry").indexOf(ctryCd)>=0){
							$("#ownerm").append("<a  href=\""+$(this).attr("path")+"?cntryCd="+ctryCd+"\" onmouseover=\"stopHide(8);\" onmouseout=\"beforeHide('ownerm',8);\">"
				  +"<div id=\"" +$(this).attr("name_en") + "\" class=\" "+classOW+" \"  >" + $(this).attr("name_en") +"</div>"+"</a>");		   
					if(i!=ow)
					$("#ownerm").append("<div class=\""+"MenulineOW"+"\" >"+"</div>"+"</a>");			   
						}
						/*test*/
					else{
						u=$(this).attr("name_en");
						$("#ownerslink ul li a").each(function(i){
															 if($(this).text().toUpperCase()==u.toUpperCase())
															     {$(this).parent().css("display","none");}
															   })
						
						}
						
					
						
						})
								   })

//

$("#vans").append("<div id=\"vanm\" onmouseover=\"stopHide(3);\" onmouseout=\"beforeHide('vanm',3);\""+"  ></div>");
$("#suvs").append("<div id=\"suvm\" onmouseover=\"stopHide(4);\" onmouseout=\"beforeHide('suvm',4);\""+"  ></div>");

$("#vans").bind('mouseover',"#vanm",showSubMenus);
$("#suvs").bind('mouseover',"#suvm",showSubMenus);

//*********** Append Cars & Photos >>>	

	$("Segment",specXML).each(function(i){				   
		switch($(this).attr("desc"))
			{
			case "Van":
			  
			  $("Model",this).each(function(i){appendMenus("#vanm",$(this).attr("cd"),$(this).attr("desc"),
			  $(this).attr("avail_cntry"));v=1;})
			  break;
			case "4x4":
			 $("Model",this).each(function(i){
			  appendMenus("#suvm",$(this).attr("cd"),$(this).attr("desc"),
			  $(this).attr("avail_cntry"));su=1;})
			  break; 
			default:
			}
										   }) 
	
	})
				  
//*********** Add Events >>>
$("#vans").bind('mouseover',"#vanm",showMenu);
$("#suvs").bind('mouseover',"#suvm",showMenu);
$("#vehicles").bind('mouseover',"#vehiclem",showMenu);			

$("#experiences").bind('mouseover',"#experiencem",showMenu);
$("#owners_m").bind('mouseover',"#ownerm",showMenu);

first=location.href.substr(0,location.href.indexOf("/en/"));
last=location.href.substr(location.href.indexOf("/en/")+4);
$("#arabic_imageLink").attr("href",first+"/ar/"+last);

//Footer Links
ss="/content_data/LAAM/ME/en/GBPME/012/";
$("#siteMap a").attr("href",ss+"G1/sitemap.html");
$("#privacy a").attr("href",ss+"G1/privacy.html");
$("#termsConditions a").attr("href",ss+"G1/termsandconditions.html");
$("#contactUs a").attr("href","javascript:contactus();");
$("#arabiaSites a").attr("href",ss+"G1/othersites.html");
//


$("a[href]").each(function(){
						   if($(this).attr("href").indexOf("?cntryCd=")<0)
						    if($(this).attr("href")!="#")
							if($(this).attr("href").indexOf("javascript:")<0)
							if($(this).attr("href").indexOf("mailto:")<0)
							{rr=$(this).attr("href")+"?cntryCd="+ctryCd;
							 $(this).attr("href",rr);}
							   });




	}
	
	
// Function ******* Parsing XML 
function parseXml(xml){
	if (jQuery.browser.msie && location.protocol == "file:"){
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML($.trim(xml));
		xml = xmlDoc;
	}
	return xml;
}

// Function ******* Show Photos On Menus 
function showPhoto(Event){
	
	var tp=0;
	if(Event.data[1]=="#suvm")tp=180;
	if(Event.data[1]=="#vanm")tp=195;
var id=Event.data[0];  
var idi=id+"img";
wimage=idi;

$(idi).css('display', 'block');
var pos = $("#vehiclem").offset();    
var width = $(id).width();
var top = $("#vehiclem").height();
nleft=width+6;
ntop=pos.top-81;
$(idi).css( { "left": +nleft+"px"  } );
$(idi).css( {"top":ntop + "px" } );
	}

// Function ******* Hide Photos On Menus 
function hidePhoto(Event){
	$(Event.data).css('display', 'none');
	}
	

var hidInt = new Array();
var menuDist = new Array(null, 220, 600, 600, 600, 495, 500, 220, 335 ,550, 550);
var b1g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_menu_b1_over.jpg) center no-repeat";
var b2g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_menu_b2_over.jpg) center no-repeat";
var b3g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_menu_b3_over.jpg) center no-repeat";
var b4g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_menu_b4_over.jpg) center no-repeat";
var b5g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_nav_b3_over.jpg) center no-repeat";
var v1g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_menubgover.jpg) repeat-x";
var v2g="url(/content_data/LAAM/ME/en/GBPME/012/images/arc_nav_overbg.jpg) repeat-x";

// Function ******* Show Menus 
function showMenu(Event){
	var h=0;
	var s=0;
	var id=null;
	switch(Event.data){
		case "#menu": {id="#country_click";s=28;h=18;break;}
		case "#vanm": {id="#vans";break;}
		case "#suvm": {id="#suvs";break;}
		case "#vehiclem": {id="#vehicles";h=35;break;}
		case "#experiencem": {id="#experiences";h=35;break;}
		case "#ownerm": {id="#owners_m";h=35;break;}
		case "#galmenu": {id="#specifications";s=1;h=27;break;}
		//Event.stopPropagation();
		//Event.cancelBubble = true;
	}

	if(id=="#vehicles")
	{$("a.b1").css("background-position","center bottom");}
	else if(id=="#experiences")
	{$("a.b2").css("background-position","center bottom");}
	else if(id=="#owners_m")
	{$("a.b3").css("background-position","center bottom");}
	else if(id=="#specifications")
	{$("a.mb3").css("background-position","center bottom");}

	window.clearTimeout(hidInt[ind(Event.data)]);
	
	//$(Event.data).slideDown("fast");
	//$(Event.data).css('display', 'block');
    var pos = $(id).offset();    
    var width = $(id).width();
    var top = $(id).height();
    nleft=pos.left -s;
    ntop=pos.top +h;
    $(Event.data).css( { "left": +nleft+"px"  } );
    $(Event.data).css( {"top":ntop + "px" } );
	$(Event.data).slideDown(300);
}



// Function ******* beforeHide
function beforeHide(menu,h){
	
	window.clearTimeout(hidInt[h]);
	hidInt[h] = window.setTimeout("hideMenu('"+menu+"')", 200);
	$("#"+menu).stop(true,true);
}

// Function ******* stopHide Menus
function stopHide(h){
	window.clearTimeout(hidInt[h]);
	
	if(h==6||h==3||h==4)
	{$("a.b1").css("background-position","center bottom");}
	else if(h==7)
	{$("a.b2").css("background-position","center bottom");}
	else if(h==8)
	{$("a.b3").css("background-position","center bottom");}
	else if(h==5)
	{$("a.mb3").css("background-position","center bottom");}
	
	
}

/// Function ******* Hide Menus 
function hideMenu(menu){
	var objMenu = document.getElementById(menu);
	
	if(menu=="vehiclem")
	{$("a.b1").css("background-position","center top");}
	else if(menu=="experiencem")
	{$("a.b2").css("background-position","center top");}
	else if(menu=="ownerm")
	{$("a.b3").css("background-position","center top");}
	else if(menu=="galmenu")
	{$("a.mb3").css("background-position","center top");}
	/*
	{$("a.mb3").css("background","url(/content_data/LAAM/ME/en/GBPME/012/images/arc_nav_b3.jpg) center no-repeat" );
	$("#specifications").css("background",sb3 );	}*/
	objMenu.style.display = "none";
	//alert(menu);
	//$("#"+menu).stop();
	
	
	
}
// Function ******* Set Country Code
function setCountryCode(Event){	
	ctryCd=Event.data.substr(1);	
	location.href='/content_data/LAAM/ME/en/GBPME/012/'+ctryCd+'/index.html?cntryCd='+ctryCd;
	}
	
// Function ******* Call Country Page

var gal_cImage = "";
var gal_cCaption = "";
var api;
function callSelectCd()
{   
var api; 
	api = $("*").overlay({ 
		closeOnClick:false,
		target:"#GOverlay",	
		preload:false,
		api:true,
		expose: { 
			color: '#FFFFFF', 
			opacity: 0.7, 
			closeSpeed: 600 }
			});
	api.load();
}

// Function ******* Append Menus 
function appendMenus(menuName,code,name,avc){
		          h=ind(menuName);
				  
				  m=menuName.substr(1);
				  
				  pathi="/content_data/LAAM/ME/en/GBPME/012/images/arc_"+code+".png\"";
				  path="/content_data/LAAM/ME/en/GBPME/012/G1/";
				  if(ctryCd=="EG")
				  path="/content_data/LAAM/ME/en/GBPME/012/EG/";
                  //******** Append Car Names >>>
				  if(avc.indexOf(ctryCd)>=0){
					  href=path+code +"/"+ code + "_home.html?cntryCd="+ctryCd+"\"";
				 
				  var className="carItem";
				  if(m=="vanm"&&v==0||m=="suvm"&&su==0)
				  {className="carItemF";}
				  
				  
				  $(menuName).append("<a href=\""+href+"\" >"
				  +"<div id=\"" +code + "\" class=\" "+className+" \">" + name +"</div>"+"</a>");
				  //******** Append Photos  >>>				 
				
				 $("#"+code).append("<div id=\""+code+"img\" class=\"carImage\" ></div>");
			      $("#"+code+"img").append("<a href=\""+href+"\"><img id=\""+code+"photo\" src=\""+pathi+" /></a>");
				   
				  var carImage=$("#"+code);
				  var data = new Array();
				  data[0]="#"+code;
				  data[1]=menuName;
				  //alert("#"+code+"img");
				  carImage.bind('mouseover',data,showPhoto);
                  carImage.bind('mouseout',"#"+code+"img",hidePhoto);	
				  }

}

// Function ******* Index For Menus
function ind(name){
	if(name=="#menu")return 1;
	if(name=="#carm")return 2;
	if(name=="#vanm")return 3;
	if(name=="#suvm")return 4;
	if(name=="#commercialm")return 5;
	//new
	if(name=="#vehiclem")return 6;
	if(name=="#experiencem")return 7;
	if(name=="#ownerm")return 8;
	if(name=="#futurem")return 9;
	
	}
	

function showSubMenus(Event){

switch(Event.data){
		case "#carm": {id="#cars";break;}
		case "#vanm": {id="#vans";break;}
		case "#suvm": {id="#suvs";break;}
		case "#vehiclem": {id="#vehicles";break;}
		case "#experiencem": {id="#experiences";break;}
		case "#ownerm": {id="#owners_m";break;}
		case "#futurem": {id="#futures";break;}
		
		}
var idi=Event.data;
wimage=idi;
//$(idi).slideDown("slow");
$(idi).css('display', 'block');
var pos = $("#vehiclem").offset();    
var width = $("#vehiclem").width();
var top = $("#vehiclem").height();
nleft=width ;
ntop=pos.top-81;
$(idi).css( { "left": +nleft+"px"  } );
$(idi).css( {"top":ntop + "px" } );
	}

function call_model( mdlID  )
{
	path="/content_data/LAAM/ME/en/GBPME/012/G1/";
	location.href=path+mdlID+'/'+mdlID+'_home.html?cntryCd='+ctryCd;
	
	}


var timePop;
function doBo1(EVENT){
	window.clearTimeout(timePop);
	var w = window.open("http://www.surveymonkey.com/s.aspx?PREVIEW_MODE=DO_NOT_USE_THIS_LINK_FOR_COLLECTION&sm=DfDM7BTRuvOs2brX5rHhA%2fT%2by718Z311%2bN1G01PbZbQ%3d", "survey","status = 0, height = 600, width = 620,resizable = 0,scrollbars=yes");
        w.opener.focus();
		//api2.close();

	}
	
function call_testdrive(){
	var URLVar ="";
	try
	{
		      //http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^TD^N^BH^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B
			  //http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^TD^N^JO^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B
		//URLVar="http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^"+MdlCode+"^TD^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
		URLVar="http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^TD^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
	}
	catch(e)
	{
		URLVar="http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^TD^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
	}

	window.open(URLVar,"Fleet","width=700,height=600,left=150,top=80,scrollbars=yes,resizable=disabled");
}// fun. call_testdrive

function call_brochure(){
	var x_url ="";
	try
	{
		     //http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^RB^N^KW^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B
			 //http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^RB^N^JO^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B
		//x_url="http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^"+MdlCode+"^RB^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
		x_url="http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^RB^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
	}
	catch(e)
	{
		x_url="http://www.globalbuypower.com/GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=GlobalComponent&func=TD&NampltCd=012^^RB^N^"+ctryCd+"^&SellingSrc=72&MerchModlDesgtr=1BBSE&ModelCode=1B";
	}
	
	window.open(x_url,"Fleet","width=700,height=600,left=150,top=80,scrollbars=yes,resizable=disabled");
}// fun. call_brochure

function download_eBrochure(){
	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/en/GBPME/999/G1/ebrochure.html?brand=gmc" + "&cntryCd="+ctryCd;
	//var address = "/content_data/LAAM/ME/ar/GBPME/999/G1/ebrochure.html?brand=hummer";
	window.open(address, "disclaimer", features);
}// fun. download_eBrochure

function call_dealer_locator(){
	location.href = "/content_data/LAAM/ME/en/GBPME/012/G1/dealer-locator.html?cntryCd=" + ctryCd;
}// fun. call_dealer_loactor

function call_me_updated(){
	URLVar="http://www.gmcarabia.com//GBPServiceMgr2.dyn?CntryCd=ME&LangCd=en&WebSiteID=GBPME&ReqsType=Pull&ServiceName=ContactSector&NampltCd=012^"+ctryCd;
	window.open(URLVar,"Fleet","width=700,height=600,scrollbars=yes,resizable=disabled,left=150,top=100");
}// fun. call_me_updated

function contactus(){
	call_me_updated();
}

// Survey  Code

var api2;
function survey_callPop()
{

{
api2 = $("#mypopup").overlay({ 
		closeOnClick:false,
		preload:false,
		onClose:survey_setOnce,
		api:true
			}).load();
//survey_createCookie('gmc','1','1000');

}
}

function survey_doBo1(EVENT){
	window.clearTimeout(timePop);
	 w = window.open("/content_data/LAAM/ME/en/GBPME/012/G1/survey-listener.html", "survey","status = 1, height = 50, width = 50,resizable = yes,scrollbars=yes");
	
        w.opener.focus();
		//w.onfocus =function(){w.opener.focus();alert('df');}
		api2.close();

	}
function survey_doBo2(EVENT){
	close_var=1;
	api2.close();
	
}
	
function survey_setOnce(){
	if(close_var==0){
	survey_createCookie('gmc','1','1000');
	}
	else
	{
	survey_createCookie('gmc1','1');
	}
	}


function survey_get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}


function survey_createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function survey_createSessionCookie(name,value,sec) {
	if (sec) {
		var date = new Date();
		date.setTime(date.getTime()+(sec*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function survey_showpopup(){
	/**************************************/
// Survey Popup

if((survey_get_cookie('gmc') != '1')&&(survey_get_cookie('gmc1') != '1'))
{

$("#container").append("<div id='mypopup' class='overlay3'><div class='mytextconS'><span id='poptext'><p>At GMC, your opinion makes a difference. By taking a few minutes to tell us what <br/>you think of our new site, you'll be helping us improve it.</p><p>So please click one of the links below to let us know whether you wish to proceed <br/>after your visit, or would prefer not to participate:</p></span><br /><a href='#' id='bot1' class='bo1'>Yes, I'd like to take the survey at the end of my visit*</a><br /><br /><a href='#' id='bot2' class='bo2'> No, I'm not interested </a></div><br /><span class='mytextconS' id='survey_small'>*Any information you choose to share will be treated as strictly confidential.</span>");
/// set the time out if not chrome and not opera
if($.browser.msie || $.browser.mozilla || $.browser.safari){
	timePop=setTimeout("survey_callPop()",5000);
}//// if 

}
$("#bot1").bind('click',"#carm",survey_doBo1);
$("#bot2").bind('click',"#carm",survey_doBo2);

/////////////////////////

}
	

