var iScroll=0;
var step=2;
var dir="ltr";
var minWidth=0;
var downloaded="no";
var timer;

var deps=new Array("cars","computer","condition","filters","laptop","services","mobile","export","camera","electronic","nonitahiti");

window.onload=prepare;

function prepare(){
	var ThumbsMarq=document.getElementById("ThumbsMarq");
	tblThumb=document.getElementById("tblThumb1");
	ThumbsMarq.style.display='';
	if(dir=="ltr") {
		iScroll=tblThumb.offsetWidth-ThumbsMarq.offsetWidth;
		minWidth=iScroll;
		ThumbsMarq.scrollLeft=iScroll;
	}
	scrolling();
	for (x=0;x<deps.length;x++){
		document.getElementById('images').innerHTML+='<img src="images/'+deps[x]+'.gif" width="1" height="1" />';
	}
	downloaded="yes";
}

function scrolling(){
	var ThumbsMarq=document.getElementById("ThumbsMarq");
	if(dir=="ltr"){
		iScroll-=step; 
	}else{
		iScroll+=step; 
	}

	ThumbsMarq.scrollLeft=iScroll; 
	timer=setTimeout("scrolling()",15);
	if(iScroll<=0){
		iScroll=0;
		if(dir=="rtl") dir="ltr";else dir="rtl";
	}else if(iScroll>=minWidth){
		iScroll=minWidth;
		if(dir=="rtl") dir="ltr";else dir="rtl";
	}
}

function show(i){
	if(downloaded=="yes"){
		clearTimeout(timer);
		var pic=document.getElementById("contnt");
		if(deps[i]=="services")
		{
			pic.innerHTML='<img src="images/services.gif" width="777" height="315" border="0" usemap="#Map"><map name="Map"><area shape="rect" coords="655,175,776,211" href="mobinil/"><area shape="rect" coords="656,233,772,263" href="etisalat/"><area shape="rect" coords="651,289,778,317" href="vodafone/"><area shape="rect" coords="15,36,135,88" href="mobinil/"><area shape="rect" coords="40,103,119,176" href="etisalat/"><area shape="circle" coords="76,233,38" href="vodafone/"></map>';
		}else{
			pic.innerHTML='<img src="images/'+deps[i]+'.gif" width="776" height="315" />';
		}
	}
}

function zoomIn(i){
	var pic=new Image;
	alert(ctrl.id);
	pic.src=ctrl.style.backgroundImage.src;
	pic.width+=30;
	pic.width+=30;
	document.body.appendChild(pic);
}

function addArray(){

	var ThumbsMarq=document.getElementById("ThumbsMarq");
	HTML='<table id="tblThumb1" class="tblThumb"><tr>';
		for(i=0;i<=4;i++){
			for(j=0;j<deps.length;j++){
				HTML+='<td width="161" height="150">';
					HTML+='<a href="'+deps[j]+'"><div style="width:161px; vertical-align:middle; height:150px; cursor:pointer; background-image:url(images/thumb/'+deps[j]+'.gif)" onMouseOver="show('+j+'); " onMouseOut="scrolling()" ></div></a>';
				HTML+="</td>";

			}
		}
	HTML+="</tr></table>";
	ThumbsMarq.innerHTML=HTML;

}

function chngDirection(newDir){
	dir=newDir; 
}


function main()
{
	document.getElementById("cont").innerHTML="";
	document.getElementById("mainpage").style.display='';
}