var gal_cImage = "";
var gal_cCaption = "";
var api;

$(document).ready(docReady);
function docReady(){
	
	$("#homePage").attr("href","/content_data/LAAM/ME/en/GBPME/001/"+ctryCd+"/index.html?cntryCd="+ctryCd);
    $("#allModelsA").attr("href","../allvehicles.html?cntryCd="+ctryCd);
	//alert($("#allModelsA").attr("href"));
	$("#gallerys").append("<div id=\"galmenu\"></div>");
	href="/content_data/LAAM/ME/en/GBPME/001/G1/"+MdlCode+"/"+MdlCode+"_imagegallery.html?cntryCd="+ctryCd+"\""+" onmouseover=\"stopHide(5)\" onmouseout=\"beforeHide('"+"galmenu"+"',"+"5"+")";
	href1="/content_data/LAAM/ME/en/GBPME/001/G1/"+MdlCode+"/"+MdlCode+"_wallpapers.html?cntryCd="+ctryCd+"\"" +" onmouseover=\"stopHide(5)\" onmouseout=\"beforeHide('"+"galmenu"+"',5)";
	
	if(ctryCd=="EG")
				 {
					href="/content_data/LAAM/ME/en/GBPME/001/EG/"+MdlCode+"/"+MdlCode+"_imagegallery.html?cntryCd="+ctryCd+"\""+" onmouseover=\"stopHide(5)\" onmouseout=\"beforeHide('"+"galmenu"+"',"+"5"+")";
	href1="/content_data/LAAM/ME/en/GBPME/001/EG/"+MdlCode+"/"+MdlCode+"_wallpapers.html?cntryCd="+ctryCd+"\"" +" onmouseover=\"stopHide(5)\" onmouseout=\"beforeHide('"+"galmenu"+"',5)"; 
					 
					 }
	
	$("#galmenu").append("<a href=\""+href+"\" >"
				  +"<div id=\"" +"imageG" + "\" class=\" carItem \">" + "Image Gallery" +"</div>"+"</a>");
	$("#galmenu").append("<a href=\""+href1+"\" >"
				  +"<div id=\"" +"wallpapers" + "\" class=\" carItem \">" + "Wallpapers" +"</div>"+"</a>");

	$("#gallerys").bind('mouseover',"#galmenu",showMenu);
	
	api = $("a[rel]").click(setImage).overlay({ 
		onLoad:loadImage,
		onBeforeClose:removeImage,
		close: 'img.close' ,
		finish:  {
				  top: 0,
				  left: 'center',
				  absolute: false
               }   ,
	    
		preload:false,
		api:true,
		expose: { 
			color: '#FFFFFF', 
			opacity: 0.7, 
			closeSpeed: 600 }
			});

if(location.href.indexOf("home")>0)
{$(".call_800:first").attr('src','/content_data/LAAM/ME/en/GBPME/001/images/arc_call_phone_B.jpg');
$(".call_800:last").attr('src','/content_data/LAAM/ME/en/GBPME/001/images/arc_call_info_B.jpg');
$(".call_num").attr('src','/content_data/LAAM/ME/en/GBPME/001/images/arc_call_number_EN_B_'+ctryCd+'.jpg');}
else
$(".call_num").attr('src','/content_data/LAAM/ME/en/GBPME/001/images/arc_call_number_EN_'+ctryCd+'.jpg');
$(".call_num").css('display','block');
//$("#requestTest").css("display","none");
//User Toolbox Section
//var specXML;
//var specURL = "/content_data/LAAM/ME/en/GBPME/001/G1/arc_Specifications.xml";
$.get(specURL,{},function(xml){
	
	xml = parseXml(xml);
	specXML = xml;
	
	
	      $("Model",specXML).each(function(i){		
				if($(this).attr("model_code")==MdlCode)
				   $(this).find("UserToolBox").find("Item").each(function(i){  
									if($(this).attr("avail_cntry").indexOf(ctryCd)<0)
									switch ($(this).attr("name_en")){
									case "Request a Test Drive":
									$("#requestTest").css("display","none");
									$("#requestTest a").attr("href","call_testdrive()");break;
									case "Request a Brochure":
									$("#requestBrochure").css("display","none");break;
									case "Locate a Dealer":
									$("#locateDealer").css("display","none");break;
									case "Keep me Updated":
									$("#keepMeUpdated").css("display","none");break;
									case "Download e-Brochure":
									$("#downloadEB").css("display","none");break;
									default:{}
									}
									
									
									});
	   
												 
									
								
						
								  
	
	})
	
	
	
	})





}

function setImage(){
	gal_cImage = $(this).attr("imgURL");
	gal_cCaption = $(this).attr("title");
	
}

function loadImage(){
	$("#GImage").attr("src", gal_cImage);
	$("#imgCaption").text(gal_cCaption);
}

function removeImage(){
	$("#GImage").attr("src", "../../../../ges/arc_spacer.gif");
	$("#imgCaption").empty();
}