var p_Menu_Dir = 'ltr';
var ArrowIcon = new Image();
ArrowIcon.src = 'http://www.israeline.com/images-cms/icon-arrow_ltr.gif';

		function fPopulateMenu(nMenuID, nSourceWidth){
			fHideMenu();
			if(nMenuID==3 || nMenuID==4 )
				return " ";
				
			var sContent = new String();
			var intTableWidth = document.all.tableMainMenuItems.offsetWidth;
			sContent = '<table width='+intTableWidth+'px cellspacing=0 cellpadding=0>';
			sContent +='<tr><td width="1px" bgcolor="#003366"><img width="1px" src="'+strImagePath+'nothing.gif"></td>'
			
			for(var a = 0; a < aMenu[nMenuID].length; a++){
				sContent += '<td class="oMenuTd" onmouseout="this.className=\'oMenuTd\'" onmouseover="this.className=\'oMenuTdOnMouseOver\'" '
				if(aMenu[nMenuID][a][0].length!=0){
					sContent += ' onClick="location.href=\'' + aMenu[nMenuID][a][0] + '\'" '
				}
				if(aMenu[nMenuID][a][2]){
					sContent += 'onmouseover="g_bSubMenuOn = true; fShowSubMenu(this, ' + nMenuID + ', ' + a + ')" ' +
						' nowrap>' + 
						aMenu[nMenuID][a][1] + '</td>\n';
				}else{
					sContent += 'nowrap>' + 
						aMenu[nMenuID][a][1] + '</td>\n';
				}
				
				sContent += '<td style="width:1px;background-color:#215C9E;background-repeat:repeat-y;background-image : url('+strImagePath+'navLineHorizontal.gif);">'
				sContent += '<img border="0"  width="1px" src="../media.images/nothing.gif"></td>'
			}
			sContent +='<td width=100% class="oMenuTd"></td>'
			sContent += '</tr></table>';
			return sContent;
		}
		
		function fPopulateSubMenu(oSource, nMenuID, nOptionID){
			fHideMenu();
			var sContent = new String();
			sContent = '<table width="100" dir="'+p_Menu_Dir+'" cellpadding=0 cellspacing=0>';
			sContent +='<tr>'
			
			if(aMenu[nMenuID][nOptionID][2]){
				for(var a = 0; a < aMenu[nMenuID][nOptionID][2].length; a++){
					sContent += '<td  style="padding-left:8px;" class="oMenuTd" '
						if(aMenu[nMenuID][nOptionID][2][a][1].length!=0){
							sContent += ' onClick="location.href=\'' + aMenu[nMenuID][nOptionID][2][a][1] + '\'" ' +
										' onmouseover="this.className=\'oMenuTdOnMouseOver\'" ' +
										' onmouseout="this.className=\'oMenuTd\'"'							
						}
						sContent +=' nowrap>' + 
						aMenu[nMenuID][nOptionID][2][a][0] + '</td>\n';
				}
			}
			sContent += '</tr></table>';
			return sContent;
		}
		
		function fShowMenu(oSource, nMenuID){
			
			if(nMenuID==3 || nMenuID==4 )
				return;
			
			var intLeftStart = fGetLeft(document.all.tableMainMenuItems)
			g_bMenuOn = true;
			g_bSubMenuOn = false;
			var oElement = eval('document.all.oMenu');
			oElement.style.visibility = 'hidden';
			oElement.innerHTML = fPopulateMenu(nMenuID, oSource.offsetWidth);
			//oElement.style.left = fGetLeft(oSource) + oSource.offsetWidth - oElement.offsetWidth;
			var FitToWindow = (oElement.offsetWidth+(fGetLeft(oSource)))-window.document.body.offsetWidth;
			if(FitToWindow>0){
				oElement.style.left = intLeftStart;   //(fGetLeft(oSource)+oSource.offsetWidth);-oElement.offsetWidth;
			}else{
				oElement.style.left = intLeftStart;   //fGetLeft(oSource)+1;
			}
			
			oElement.style.top = fGetTop(oSource) + oSource.offsetHeight+1;

			if(aMenu[nMenuID].length > 0){
				oElement.style.visibility = 'visible';
			}
		}
		
		function fShowSubMenu(oSource, nMenuID, nOptionID){
			g_bMenuOn = true;
			var oElement = eval('document.all.oSubMenu');
			oElement.style.visibility = 'hidden';
			oElement.innerHTML = fPopulateSubMenu(oSource, nMenuID, nOptionID);

			oElement.style.left = fGetLeft(oSource)+oSource.offsetWidth;
			//oElement.style.left = fGetLeft(oSource)+1;
			oElement.style.top = fGetTop(oSource)+1;
			if(aMenu[nMenuID].length > 0){
				oElement.style.visibility = 'visible';
			}
		}
		
		function fHideMenu(){
			if(!g_bMenuOn){
				var oElement = eval('document.all.oMenu');
				oElement.style.visibility = 'hidden';
				oElement.innerHtml = '';
			}
			
			if(!g_bSubMenuOn){
				var oElement = eval('document.all.oSubMenu');
				oElement.style.visibility = 'hidden';
				oElement.innerHtml = '';
			}
		}
		
		function fDelayedHide(){
			setTimeout('fHideMenu()', 1000);
		}
		
		function fGetLeft(obj){
		   return(obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+fGetLeft(obj.offsetParent));
		}

		function fGetTop(obj){
		   return(obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+fGetTop(obj.offsetParent));
		}


	document.write('<div id="oMenu" style="z-index:1;VISIBILITY: hidden; POSITION: absolute;" onmouseover="g_bMenuOn = true;" onmouseout="g_bMenuOn = false; g_bSubMenuOn = false; fDelayedHide();"></div>')
	document.write('<div id="oSubMenu" style="z-index:101;VISIBILITY: hidden; POSITION: absolute;" onmouseover="g_bMenuOn = true; g_bSubMenuOn = true;" onmouseout="g_bMenuOn = false; g_bSubMenuOn = false; fDelayedHide();"></div>')