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

//this function changes the topbar banner
function chgBanner()	{

	return;
	//insert banners in this array and they will be displayd randomly (4 banners)
	//@@@@@@@@@@@@@@@@@@@@@@@ banners@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	var imgArr = new Array("../images/banner/Loan_Baner_r.gif","../images/banner/rehev_banner_r.gif","../images/banner/25.gif","../images/banner/Bann_YoterMishtalem_r.gif");   
	//@@@@@@@@@@@@@@@@@@@@@@@@@end of banners @@@@@@@@@@@@@@@@@@@@@

	
	var origNum = Math.random();
	if(origNum <= 0.25) {
		imgNum = 0;
	} 
	else {
		if(origNum > 0.25 && origNum <= 0.5) {
		imgNum = 1;
		}
		else {
			if(origNum > 0.5 && origNum <= 0.75) {
			imgNum = 2;
			}
			else {
				if(origNum > 0.75 && origNum <= 1) {
				imgNum = 3;
				}
			}
		}
	}
	
	
	if(document.layers){setImage=document.TopBar.document}else{setImage=document};
	setImage.banner.src="images/"+imgArr[imgNum];
}
//end of banner change

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



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 += 341 + 50;
		if (index==2)  newLeft += 384 + 50;
		if (index==3)  newLeft += 434 + 50;		
		return newLeft;
	}
	 
	function getWindowWidth()
	{
		return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
	}
function HideTopAd()
{
 var dv = 	document.all['TopAd'];
 if (dv)
 {
 	dv.style.visibility='hidden';		
 }
}
function WriteLog(msg)
{
 var dv = 	document.all['Elog'];
 if (dv)
 {
// 	dv.innerText = dv.innerText + msg;
// 	dv.innerText =  msg;
 }
}
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 show specific popup
function ShowLayer(index)
{
 WriteLog('SL:'+index);
if (index > 0)
{
	
}
//	first close the open layer
document.all['ActiveMenu'+index].style.left=getMenuY(index);;
document.all['ActiveMenu0'].style.left=getMenuY(0);;

HideLayer();
//ShowTopAd();
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(){
// WriteLog('HL :');
	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/fp/banner/banner_08.png';
top_bar1a=new Image;				top_bar1a.src='images/fp/banner/banner_08_red.png';
top_bar2=new Image;					top_bar2.src='images/fp/banner/banner_10.png';
top_bar2a=new Image;				top_bar2a.src='images/fp/banner/banner_10_red.png';
top_bar3=new Image;					top_bar3.src='images/fp/banner/banner_12.png';
top_bar3a=new Image;				top_bar3a.src='images/fp/banner/banner_12_red.png';
}

function resetmenus()
{
WriteLog('Reset');
	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	
	}
}



