// Global Home Function


window.onload = function () {
  getaQuote();
  homeNews1();
};

var _ItemListCombobox = null;
var _animationType = "slide";

jQuery(function(){
var comboboxSettings = {animationSpeed: 50};
setupCombobox();
});

// create a jquery combobx and set the Css class styles
function setupCombobox()
{
	_ItemListCombobox = jQuery('.comboboxMd').combobox(
	{
	comboboxContainerClass: "comboboxMdContainer",
	comboboxValueContentContainerClass: "comboboxMdValueContainer",
	comboboxValueContentClass: "comboboxMdValueContent",
	comboboxDropDownClass: "comboboxMdDropDownContainer",
	comboboxDropDownButtonClass: "comboboxMdDropDownButton",
	comboboxDropDownItemClass: "comboboxMdItem",
	comboboxDropDownItemHoverClass: "comboboxMdItemHover",
	comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader2",
	comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer2"
	},					
	{
	animationType: _animationType,
	width: 155
	});
}

function setLocateSite()
{
	setId = document.getElementById("comboRegion").value ;
	if(setId!="" && setId>0){
		if(setId=="r7")
			locateSite(2,7);
		else if(setId=="r2")
			locateSite(1,2);			
		else if(setId==7)
			locateSite(2,setId);
		else
			locateSite(1,setId);
	}
}

function locateSite(mapIdx,addBlockx,strCountry)
{
	var mapId="map";
	var optRegion="optRegion";
	var mapPointId="mapPoints";
	var mapLegndId="mapLegnd";
	var addBlockId="addBlock";
	var defPointId="defPointId";
	var optRegionSrc, i=1;
	
	if(typeof(strCountry)=="undefined")
	{	
		strCountry=document.getElementById('iPoint'+addBlockx).title;
	}
	
	document.getElementById("countrySelTextField").value=strCountry;
	document.getElementById(mapId).className=mapId+mapIdx;
	document.getElementById(defPointId).title=addBlockx;

	addBlockx = (typeof(addBlockx)=="undefined")?(0):(addBlockx);
	
	//regional selection
	for(i=1;i<=2;i++)
	{	
		optRegionSrc = document.getElementById(optRegion+i).src ;
		if(mapIdx==i)
		{
			document.getElementById(optRegion+i).src = optRegionSrc.replace("Off","On");
			document.getElementById(mapPointId+i).style.display="block";
		}
		else
		{
			document.getElementById(optRegion+i).src = optRegionSrc.replace("On","Off");
			document.getElementById(mapPointId+i).style.display="none";		
		}		
	}

	//pointers
	for(i=0;i<=17;i++)
	{	
	if(i>=1){
		bulletSrc = document.getElementById("iPoint"+i).src ;
		if(addBlockx==i)
		{
			document.getElementById(addBlockId+i).style.display="block";
			document.getElementById("iPoint"+i).src = bulletSrc.replace("Off","On");
		}
		else
		{
			document.getElementById(addBlockId+i).style.display="none";
			document.getElementById("iPoint"+i).src = bulletSrc.replace("On","Off");
		}	
	}
	}
}

function showHideLegend(pointX,state)
{
	state = (typeof(state)=="undefined") ? true : false ;
	var defPointId="defPointId";
	defPointX = (typeof(document.getElementById(defPointId).title)=="undefined") ? 0 : document.getElementById(defPointId).title ;

	bulletSrc = document.getElementById("iPoint"+pointX).src ;	
	if(state==true)
	{	
		document.getElementById("mapLegnd"+pointX).style.display="block";
		//document.getElementById("mapLegnd"+defPointX).style.display="none";
		document.getElementById("iPoint"+pointX).src = bulletSrc.replace("Off","On");
		if(defPointX>0)
		document.getElementById("iPoint"+defPointX).src = bulletSrc.replace("Off","On");
	}else{
		document.getElementById("mapLegnd"+pointX).style.display="none";
		//document.getElementById("mapLegnd"+defPointX).style.display="block";
		document.getElementById("iPoint"+pointX).src = bulletSrc.replace("On","Off");
		if(defPointX>0)
		document.getElementById("iPoint"+defPointX).src = bulletSrc.replace("Off","On");
	}
}


function get_random()
{
	var ranNum= Math.floor(Math.random()*4);
	return ranNum;
}
function getaQuote()
{
 var whichQuote=get_random();
var quote=new Array(4)
 quote[0]="http://www.etisalat.ae/assets/etisalat/global/images/bg_banner.jpg";
 quote[1]="http://www.etisalat.ae/assets/etisalat/global/images/bg_banner.jpg";
 quote[2]="http://www.etisalat.ae/assets/etisalat/global/images/bg_banner.jpg";
 quote[3]="http://www.etisalat.ae/assets/etisalat/global/images/bg_banner.jpg";
 document.getElementById("pagebgrandom").style.backgroundImage = "url(" + quote[whichQuote] + ")";
}
var t;
function homeNews1()
{
	clearTimeout(t);
	jQuery("#homeCsNewsConBlockCon").animate({marginLeft: "0px"}, 500);
	jQuery('img#Homenews1').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOn.png"); 
	jQuery('img#Homenews2').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOff.png"); 
	jQuery('img#Homenews3').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOff.png");		
	t=setTimeout("homeNews2()",10000);
}

function homeNews2()
{
	clearTimeout(t);
	jQuery("#homeCsNewsConBlockCon").animate({marginLeft: "-280px"}, 500);
	jQuery('img#Homenews1').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOff.png"); 
	jQuery('img#Homenews3').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOff.png"); 
	jQuery('img#Homenews2').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOn.png"); 
	t=setTimeout("homeNews3()",10000);
}

function homeNews3()
{
	clearTimeout(t);
	jQuery("#homeCsNewsConBlockCon").animate({marginLeft: "-560px"}, 500);
	jQuery('img#Homenews1').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOff.png");
	jQuery('img#Homenews2').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOff.png"); 
	jQuery('img#Homenews3').attr("src","http://www.etisalat.ae/assets/etisalat/global/images/dotGrayOn.png"); 
	t=setTimeout("homeNews1()",10000);
}

$(document).ready(function(){

	jQuery("#btnslide").click(function () {
	jQuery("#mydiv").slideToggle("medium");
    });
	jQuery("#mydiv").click(function () {
	 jQuery("#mydiv").slideUp("medium");
    });
	jQuery(".countrySelTextField").click(function () {
	 jQuery("#mydiv").slideToggle("medium");
    });
});
