var imgNum;      //  handle to banner [image,URL]

//this function changes the topbar banner

var index=0;
var IE=document.all;
var NS=document.layers;
var numOfLayers=4;

function getMenuY(index)
	{
		var windowWidth = getWindowWidth();
		if (windowWidth <= 750) {
			return 0;
		}
		var newLeft = (getWindowWidth() / 2)-(770/2)-10;
		if (newLeft < 0)
			newLeft =0;
		if (index==0)  newLeft += 0;			
		if (index==1)  newLeft += 155;
		if (index==2)  newLeft += 210;
		if (index==3)  newLeft += 252;		
		if (index==4)  newLeft += 295;		
		return newLeft;
	}
	 
	function getWindowWidth()
	{
		return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
	}


//		Function show specific popup
function ShowLayer(index){

//	first close the open layer
document.all['ActiveMenu'+index].style.left=getMenuY(index);;
document.all['ActiveMenu0'].style.left=getMenuY(0);;

HideLayer();
HideTopAd();

	if(IE){		//	Explorer
		document.all["ActiveMenu"+index].style.visibility='visible';
		document.all.ActiveMenu0.style.visibility='visible';		
	}
	
	if(NS){		// Netscape
		document.layers["ActiveMenu"+index].visibility='show';
		document.layers.ActiveMenu0.visibility='show';
	}
}


//	function close all popups
function HideLayer(){
	if(IE){		//	Explorer
		for(index=1;index<=numOfLayers;index++){
		document.all["ActiveMenu"+index].style.visibility='hidden';
	document.all.ActiveMenu0.style.visibility='hidden';
		}	// End loop	
	}
	
	if(NS){		// Netscape
		for(index=1;index<=numOfLayers;index++){
		document.layers["ActiveMenu"+index].visibility='hide';
		document.layers.ActiveMenu0.visibility='hide';
		}	// End loop	
	}
	
		ShowTopAd();
					//   kill frames
			if(top.location != self.location)
			{
			top.location=self.location;
			}	
}


function ChangeSearch(param1,param2){
	if(IE){
	document.all["Layer"+param1].style.visibility='visible';
	document.all["Layer"+param2].style.visibility='hidden';	
	}
	
	if(NS){
	document.layers["Layer"+param1].visibility='show';
	document.layers["Layer"+param2].visibility='hide';		
	}
}

//	Preload images
if(document.images){
top_bar1=new Image;					top_bar1.src='images/new/home/images/but1.gif';
top_bar1a=new Image;				top_bar1a.src='images/new/home/images/but1a.gif';
top_bar2=new Image;					top_bar2.src='images/new/home/images/but2.gif';
top_bar2a=new Image;				top_bar2a.src='images/new/home/images/but2a.gif';
top_bar3=new Image;					top_bar3.src='images/new/home/images/but3.gif';
top_bar3a=new Image;				top_bar3a.src='images/new/home/images/but3a.gif';
top_bar4=new Image;					top_bar4.src='images/new/home/images/but4.gif';
top_bar4a=new Image;				top_bar4a.src='images/new/home/images/but4a.gif';
top_bar5=new Image;					top_bar5.src='images/new/home/images/but5.gif';
top_bar5a=new Image;				top_bar5a.src='images/new/home/images/but5a.gif';


}


function resetmenus()
{
	if(IE){		//	Explorer
		for(index=0;index<=numOfLayers;index++){
			document.all["ActiveMenu"+index].style.top=document.all['but1'].style.top;
		}	// End loop	
	}
	
	if(NS){		// Netscape
		for(index=0;index<=numOfLayers;index++){
			//document.layers["ActiveMenu"+index].visibility='hide';
			//document.layers.ActiveMenu0.visibility='hide';
		}	// End loop	
	}
}

function HideTopAd()
{
 var dv = 	document.all['TopAd'];
 if (dv)
 {
 	dv.style.visibility='hidden';		
 }
}
function ShowTopAd()
{
//document.write('Show call');
 var dv = 	document.all['TopAd'];
 WriteLog('STA:');
// WriteLog( document.all["ActiveMenu"+1].style.visibility);
//  WriteLog( document.all["ActiveMenu"+2].style.visibility);
 //  WriteLog( document.all["ActiveMenu"+3].style.visibility);
 if(IE)
 {		//	Explorer
		if ( (document.all["ActiveMenu"+1].style.visibility == 'hidden') &&
	   		 (document.all["ActiveMenu"+2].style.visibility == 'hidden') &&
			 (document.all["ActiveMenu"+3].style.visibility == 'hidden'))
			 {
			  if (dv)
		       {
     			dv.style.visibility='visible';		
				 WriteLog( ' MadeVisible');
                } // div exists
	       }
		   else
		   {
		    if (dv)
		       {
     			dv.style.visibility='hidden';		
				 WriteLog( ' MadeHidden');
                } // div exists
		   }
	} // IE*/
}//function


function WriteLog(msg)
{
 var dv = 	document.all['Elog'];
 if (dv)
 {
// 	dv.innerText = dv.innerText + msg;
// 	dv.innerText =  msg;
 }
}

