//document.write("<script src=\"/htm-webaxy/javascript/jquery-1.2.3.js\"><\/script>");
//var myMenu;
var theDiv = new Array();
var theXmlPath;
var username = '', password = '', userAllowMenus = -1;		
var IEVersionNumber = 8;
var margTop = margLeft = 0;
var alowToEdit = 0;
var cid = '';
var speed = 6;
var objImgs;

mainLoad();
//runEventsOnDOMLoaded();
function mainLoad(){
//	if(window.objBody){return false;}
	minMargin=10;
	hide_delay=600;
	objHead = document.getElementsByTagName('head')[0];
	objBody = document.body;
	webaxyURL= document.getElementById('scriptRequire').attributes.getNamedItem('webaxyURL').value;
	PageLoaded=false;
	dateObj = new Date();
	dt=dateObj.getYear()+''+dateObj.getMonth()+''+dateObj.getDate();
	//------------- click Admin -----------------
	editAlow = '';
	clickadmin='';
	if (document.cookie.length > 0) { // if there are any cookies
		var search =  "clickadmin&";
		var search1 = "clickadmin=";
		offset = document.cookie.indexOf(search);
		if (offset == -1) offset = document.cookie.indexOf(search1);
		if (offset != -1) { // if cookie exists 
			offset += search.length ;  // set index of beginning of value
			end = document.cookie.indexOf("&", offset); // set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length;
			clickadmin= unescape(document.cookie.substring(offset, end));
			if (clickadmin != "" && clickadmin != '0' && clickadmin.search(/^0/) == -1 )
				alowToEdit = 1;
		}
		search =  "username&";
		search1 = "username=";
		offset = document.cookie.indexOf(search);
		if (offset == -1) offset = document.cookie.indexOf(search1);
		if (offset != -1) { // if cookie exists 
			offset += search.length ;  // set index of beginning of value
			end = document.cookie.indexOf("&", offset); // set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length;
			username = unescape(document.cookie.substring(offset, end));
		}
		var search =  "password&";
		var search1 = "password=";
		offset = document.cookie.indexOf(search);
		if (offset == -1) offset = document.cookie.indexOf(search1);
		if (offset != -1) { // if cookie exists 
			offset += search.length ;  // set index of beginning of value
			end = document.cookie.indexOf("&", offset); // set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length;
			password = unescape(document.cookie.substring(offset, end));
		}
		
		if (alowToEdit) {
				search = "webaxylogin_";
				offset = document.cookie.indexOf(search);
				end = document.cookie.indexOf("=", offset); // set index of end of cookie value
				offset += search.length ;  // set index of beginning of value
				id = unescape(document.cookie.substring(offset, end));
				var xmlHttp;
				try {  // Firefox, Opera 8.0+, Safari  
					xmlHttp=new XMLHttpRequest(); 
				}
				catch (e) {  // Internet Explorer  
					try {
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e) {   
						 try {
						 	   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						 }
				   	 catch (e)  {
				  		   alert("Your browser does not support AJAX!");  
				   		   return false;
						}
					}
				}
			  xmlHttp.onreadystatechange=function() {
			  			if(xmlHttp.readyState==4) {	  					
			  					userAllowMenus = xmlHttp.responseText;
			  			}
			  	}
			  		
			  xmlHttp.open("GET","/cgi-webaxy/xmlMenu/xmlMenu.pl?ID="+id+"&username="+username+"&password="+password+"&act=getUserAllowMenu",true);
			  xmlHttp.send(null);
		}
	}
	//---------------------------------------------------
	subMenuDivObj=document.createElement("div");
	subMenuDivObj.setAttribute('id', 'subMenu');
	subMenuDivObj.id= 'subMenu';
	
	//--------   add subMenuDivObj to body when DOM is loaded ----
	
	
//	preDOMonload = window.__onDOMLoad;
//	window.__onDOMLoad = function() {
//		preDOMonload();
		//itays//objBody.insertBefore(subMenuDivObj, objBody.firstChild);
		
		
//		//#--------------    for debaging    --------------------------
//		debagDiv=document.createElement("div");
//		debagDiv.setAttribute('id', 'debugDiv');
//		objBody.appendChild(debagDiv);
//		//#------------------------------------------------------------
	
	//}
	//-------------------------------------------------------------------------------------

}

//#------------------------------------------------------------
function initMenu(divID, xmlPath, verticalMenu, more, checkLogin, opensUp, map){
	
	try {
	if(document.all) {
		IEVersionNumber = getIEVersionNumber();
		if (IEVersionNumber == 7) {
			var bod;
			if (document.getElementById('body')) bod = document.getElementById('body');
			else if (document.body) bod = document.body;
			if (bod) {
				margTop = parseInt(bod.currentStyle.marginTop);
				margLeft = parseInt(bod.currentStyle.marginLeft);
			}
		}
	}
} catch (e){}
	
	if (typeof(msgLocation) != "undefined" && checkLogin) {
			if (!username || username == '' || !password || password == '') return;
	}
	if (typeof(map) == "undefined") map = '';
	objBody = document.body;
	if (!document.getElementById('subMenu')) objBody.insertBefore(subMenuDivObj, objBody.firstChild);
	objHead = document.getElementsByTagName('head')[0];
	
	var jsPath = xmlPath.replace(/\.xml/,'.js');
	var cssPath = xmlPath.replace(/\.xml/,'.css');
	
	var divObj=document.getElementById(divID);
	divObj.timer=divID;
	if(verticalMenu && (verticalMenu==1 || verticalMenu=='v' || verticalMenu=='vertical') ){divObj.verticalMenu=1;}
	if (verticalMenu > 1) {divObj.verticalMenu=verticalMenu;}
	if (verticalMenu == '0') {divObj.verticalMenu=verticalMenu;}
	//if(stylePath && stylePath.search(/\.css$/) !=-1){divObj.stylePath=stylePath;}
	if(more){divObj.more=1;}else{divObj.more=0;}
	
	/*objJS = document.createElement('script');
	objJS.id = 'xmlMenuJs';
	objJS.type = 'text/javascript';
	objJS.language = 'JavaScript';
	objJS.src = jsPath;
	objHead.appendChild(objJS);*/
	
	myRe = /\d+/;
  myArray = myRe.exec(divID);

	var id = myArray[0];
	theDiv[myArray[0]] = divObj;
	theXmlPath = xmlPath;
	
	LoadXMLobject(id,xmlPath,'','','',divID,more, opensUp, map);
	//setTimeout("LoadXMLobject("+id+",'"+xmlPath+"');", 300);
	/*objJS.onreadystatechange= function () {
      if (this.readyState == 'complete') setTimeout("LoadXMLobject("+id+",'"+xmlPath+"');", 700);
  }

	objJS.onload = setTimeout("LoadXMLobject("+id+",'"+xmlPath+"');", 700);*/
}
//#------------------------------------------------------------
function LoadXMLobject(id, filePath, postMode, postVars, async, divID, more, opensUp, map){
	
	objHead = document.getElementsByTagName('head')[0];
	div = theDiv[id];
	//filePath = theXmlPath;
	var jsPath = filePath.replace(/\.xml/,'.js');
	var cssPath = filePath.replace(/\.xml/,'.css');
	
	var myMenu;
	if (!map) {
		//myMenu = eval("getMenuM"+id+"();");
		myMenu = eval("getMenuM"+id+"();");
	}
	else {
		myMenu = eval("getMenuMAP"+id+"();");
		$(document).ready(function () {
  		pos = getPosition(document.getElementById('MAP_MENU'+id));
			eval("MAP"+id+"PosX="+pos[0]);
			eval("MAP"+id+"PosY="+pos[1]);
		});
	}
	
	if (typeof(myMenu.membersOnly) != "undefined" && myMenu.membersOnly == 'true') {
			if (typeof(username) == "undefined" || username == '' || typeof(password) == "undefined" || password == '') return;
	}
	if (typeof(myMenu.not4Member) != "undefined" && myMenu.not4Member == 'true') {
			if (typeof(username) != "undefined" && username != '' && typeof(password) != "undefined" && password != '') return;
	}
	if (typeof(username) == "undefined" || username == '' || typeof(password) == "undefined" || password == '') myMenu.IsMember = false;
	if (typeof(username) != "undefined" && username != '' && typeof(password) != "undefined" && password != '') myMenu.IsMember = true;
	
	myMenu.opensUp = opensUp;
		
	if (div.verticalMenu > 1) {
		if (alowToEdit) {
			if (userAllowMenus == -1) {
				setTimeout("LoadXMLobject('"+id+"', '"+filePath+"', '"+postMode+"', '"+postVars+"', '"+async+"', '"+divID+"', '"+more+"', '"+opensUp+"', '"+map+"');",100);
				return;
			}
			else {
				buildMenuV(div, myMenu);
			}
		}
		else {
			buildMenuV(div, myMenu);			
		}		
	}
	else {
		
		if (alowToEdit) {
			if (userAllowMenus == -1) {
				setTimeout("LoadXMLobject('"+id+"', '"+filePath+"', '"+postMode+"', '"+postVars+"', '"+async+"', '"+divID+"', '"+more+"', '"+opensUp+"', '"+map+"');",100);
				return;
			}
			else {
				buildMenu(div, myMenu,more, opensUp);
			}
		}
		else {
			buildMenu(div, myMenu,more, opensUp);
		}
	}
	setTimeout("MNav.init('"+divID+"');", 500);
		
}

//#------------------------------------------------------------
function buildMenu(div, myMenu,more, opensUp){
	
	var loginToDo = '';
	var toolTipToDo = [];
	var mID=myMenu.id;
	var moveBullets = '';
	var setBulletsDim = '';
	if (document.getElementById('surround'+mID)) return;
	div.setAttribute('cID', myMenu.cID);
	div.setAttribute('current_menu_item', '');
	var mID_original=mID;
	var allBorderR=myMenu.borderR;
	var allBorderL=myMenu.borderL;
	var allBullet=myMenu.bullet;
	
	var mainMenuBullet=myMenu.bulletBwMenu;
	var removeFirstBullet=myMenu.removeFirstBullet;
	
	var HTMLbefore=myMenu.HTMLbefore;
	var HTMLafter=myMenu.HTMLafter;
	
	var menuSurround = document.createElement('div');
	menuSurround.setAttribute('id', 'surround'+mID);
	menuSurround.className='surroundDIV';
	//menuSurround.innerHTML='<div id="'+mID+'htmlBefore">'+decodeXML(HTMLbefore)+'</div><XMLMENU></XMLMENU>'+'<div id="'+mID+'htmlAfter">'+decodeXML(HTMLafter)+'</div>';
	menuSurround.innerHTML = '';
	menuSurround.innerHTML=decodeXML(HTMLbefore)+'<XMLMENU/>'+decodeXML(HTMLafter);
	
	div.innerHTML='';
	div.dir=myMenu.dir;
	div.setAttribute('menuId', mID);
	div.setAttribute('style', '');
	div.className='menuDiv '+mID+'menuDiv';
	div.setAttribute('vertical',div.verticalMenu);
	
	var menuTable=document.createElement("table");
	menuTable.setAttribute('id', mID);
	
	if (typeof(myMenu.cid) != 'undefined' && myMenu.cid) {
		menuTable.setAttribute('cid', myMenu.cid);
		cid = myMenu.cid;
	}
	menuTable.setAttribute('cellSpacing', '0');
	menuTable.setAttribute('cellPadding', '0');
	//if (!div.verticalMenu) menuTable.setAttribute('style', 'display: none;');
	menuTable.dir=myMenu.dir;
	menuTable.previsible=mID;
	menuTable.timer='';
	menuTable.tStatus=0;
	menuTable.className='menuBar '+mID+'menuBar';
	if (1 || !div.verticalMenu) {
			newRow=menuTable.insertRow(-1);
			mainCell=newRow.insertCell(newRow.cells.length);
	}
	
	mID1 = mID;
	mID1 = mID1.replace(/M/,'');
	mID1 = mID1.replace(/MAP_MENU/,'');
	//if (alowToEdit == 1 && ((userAllowMenus  == 'admin' || userAllowMenus.indexOf(';'+mID1+';') >= 0)){
	try {
		if (userAllowMenus == 'admin' || userAllowMenus.indexOf(';'+mID1+';') >= 0){
			var imgA=document.createElement("img");
			imgA.setAttribute('menuId', mID_original);
			imgA.setAttribute('src', ""+webaxyURL+"/click/pagedit.gif");
			imgA.setAttribute('title', "Menu Administration");
			imgA.className='menuClickAdminImg';
			imgA.style.cursor='pointer';
			if (!div.verticalMenu) {
				var divCA=document.createElement("div");
				divCA.appendChild(imgA);
				divCA.className = mID+'divClass divClass';
				mainCell.appendChild(divCA);
			}
			else {
				/*newRow=menuTable.insertRow(-1);
				itemCell=newRow.insertCell(newRow.cells.length);
				itemCell.appendChild(imgA);
				*/
				var divCA=document.createElement("div");
				divCA.appendChild(imgA);
				divCA.className = mID+'divClass divClass';
				mainCell.appendChild(divCA);
				//alert(myMenu.name+':'+itemCell.innerHTML);
			}
		}
	} catch(e) {}
	
	if (myMenu.name && !div.verticalMenu) {
		var divTitle=document.createElement("div");
		divTitle.innerHTML = myMenu.name;
		divTitle.className = mID+'divClass divClass';
		mainCell.appendChild(divTitle);
	}
	else if (myMenu.name && div.verticalMenu) {
		/*newRow=menuTable.insertRow(-1);
		itemCell=newRow.insertCell(newRow.cells.length);
		itemCell.innerHTML = myMenu.name;*/
		var divTitle=document.createElement("div");
		divTitle.innerHTML = myMenu.name;
		divTitle.className = mID+'divVClass divVClass';
		mainCell.appendChild(divTitle);				
	}
	
	//for (var child = topMenuElement.firstChild; child != null && 1 == 0; child = child.nextSibling){
	var child;
	myMenu.objImgs = new Array(myMenu.mainItems.length);
	for (var i = 0 ; i < myMenu.mainItems.length ; i++) {
				child = myMenu.mainItems[i];
				if (child.hide && (child.hide == 'checked' ||
													 child.hide == 1) ||
													 (myMenu.IsMember && child.hide == 3) ||
													 (!myMenu.IsMember && child.hide == 2)
													 ) continue;
				//myMenu.IsMember
				var thisItemId=child.id;
				var thisItemCSSid=thisItemId.replace(/\./g,'_');
				var itemWrapTable;
				if(div.verticalMenu){
					//newRow=menuTable.insertRow(-1);
					//newRow = document.createElement('DIV');
					itemWrapTable=document.createElement("table");
					//itemWrapTable.setAttribute('id', mID);
					itemWrapTable.setAttribute('cellSpacing', '0');
					itemWrapTable.setAttribute('cellPadding', '0');
					itemWrapTable.dir=myMenu.dir;
					newRow=itemWrapTable.insertRow(0);
				}
				else {
					//alert(menuTable.innerHTML);
					itemWrapTable=document.createElement("table");
					//itemWrapTable.setAttribute('id', mID);
					itemWrapTable.setAttribute('cellSpacing', '0');
					itemWrapTable.setAttribute('cellPadding', '0');
					itemWrapTable.dir=myMenu.dir;
					newRow=itemWrapTable.insertRow(0);
				}
				
				
				if (!div.verticalMenu && mainMenuBullet && ((removeFirstBullet == 'false' && i == 0) || (i > 0))) {
					var itemCell1 = newRow.insertCell(newRow.cells.length);//add a cell at the end
					if( mainMenuBullet.search(/^http:/) !=-1 ){
							addText=document.createElement("img");
							addText.setAttribute('src', mainMenuBullet);
							addText.className = mID+'BulletBW';
							addText.id = mID+'_bullet_'+thisItemId;
							//addText.className='bullets';
					}
					else{
						addText=document.createTextNode(mainMenuBullet);
					}
					var mmbDiv=document.createElement("div");
					mmbDiv.className = mID+'divClass divClass '+mID+'divClassBullet';
					mmbDiv.appendChild(addText);
					mainCell.appendChild(mmbDiv);
				}
				else if (div.verticalMenu && mainMenuBullet && ((removeFirstBullet == 'false' && i == 0) || (i > 0))) {
					var itemCell1 = newRow.insertCell(0);//add a cell at the end
					if( mainMenuBullet.search(/^http:/) !=-1 ){
							addText=document.createElement("img");
							addText.setAttribute('src', mainMenuBullet);
							addText.id = mID+'_bullet_'+thisItemId;
							//addText.className='bullets';
					}
					else{
						addText=document.createTextNode(mainMenuBullet);
					}
					itemCell1.appendChild(addText);
					itemCell1.setAttribute('align', 'center');
					newRow=menuTable.insertRow(-1);
				}
				
					var itemCell = newRow.insertCell(newRow.cells.length);//add a cell at the end
					itemCell.align="center";
					var itemTable=document.createElement("table");
					if (typeof(child.padding) != 'undefined') {
						itemTable.setAttribute('padding', Math.abs(parseInt(child.padding)));
					}
				
					if (typeof(child.toolTip) != 'undefined' && child.toolTip == 'true') {
							itemTable.toolTip = 1;
							if (typeof(child.toolTipFile) != 'undefined' && child.toolTipFile != '') itemTable.toolTipFile = child.toolTipFile;
							if (typeof(child.toolTipFileCell) != 'undefined' && child.toolTipFileCell != '') itemTable.toolTipFileCell = child.toolTipFileCell;
							if (typeof(child.toolTipStyle) != 'undefined' && child.toolTipStyle != '') itemTable.toolTipStyle = child.toolTipStyle;
							if (typeof(child.toolTipTitle) != 'undefined' && child.toolTipTitle != '') itemTable.toolTipTitle = child.toolTipTitle;
							if (typeof(child.toolTipTitleStyle) != 'undefined' && child.toolTipTitleStyle != '') itemTable.toolTipTitleStyle = child.toolTipTitleStyle;
							if (typeof(child.toolTipContactCat) != 'undefined' && child.toolTipContactCat != '') itemTable.toolTipContactCat = child.toolTipContactCat;
							if (typeof(child.toolTipContactAppearence) != 'undefined' && child.toolTipContactAppearence != '') itemTable.toolTipContactAppearence = child.toolTipContactAppearence;
							if (typeof(child.toolTipContactSelect) != 'undefined' && child.toolTipContactSelect != '') itemTable.toolTipContactSelect = child.toolTipContactSelect;
							if (typeof(child.toolTipDrag) != 'undefined' && child.toolTipDrag == 'true') itemTable.dragabble = 1;
							if (typeof(child.toolTipCloseButton) != 'undefined' && child.toolTipCloseButton!= '') itemTable.toolTipCloseButton = child.toolTipCloseButton;
							if (typeof(child.toolTipSource) != 'undefined' && child.toolTipSource!= '') itemTable.toolTipSource = child.toolTipSource;
							if (child.toolTipContactAppearence && (child.toolTipContactCat || child.toolTipContactSelect)) {
								telAppearence = child.toolTipContactAppearence;
								telCat = child.toolTipContactCat;
				  			contactID = child.toolTipContactSelect;
					  		if (telAppearence) insertFileElement("/Contact/tel"+telAppearence+".css","css");
					  		//alert('tel'+contactID);
					  		thisItemId1 = thisItemId.replace(/\./g,'_');
					  		if (child.toolTipContactCat && child.toolTipContactSelect) {
					  			get_ajax_popup('', '','ID='+cid+'&telID='+telAppearence+'&recordID='+contactID+'&cat='+child.toolTipContactCat+'&only_data=1', '', 'tel'+thisItemId1,'popupRecord');
					  		}
					  		else {
					  			get_ajax_popup('', '','ID='+cid+'&telID='+telAppearence+'&cat='+child.toolTipContactCat+'&only_data=1', '', 'tel'+thisItemId1,'getCat');
					  		}
					  	}
							itemTable.onclick = function() {preGetPageCell(this, mID);};
					}
					
					itemTable.setAttribute('menuId', mID);
					itemTable.setAttribute('id', mID+'_item_'+thisItemId);
					itemTable.setAttribute('itemId', thisItemId);
					itemTable.setAttribute('menuLevel', '0');
					if(div.verticalMenu){itemTable.setAttribute('vertical', div.verticalMenu);}
					itemTable.setAttribute('cellSpacing', '0');
					//if (location.href.indexOf('cmi='+thisItemId) != -1) {
					var loc = location.href, child_link = child.link?child.link:'';
					/*var index = child_link.indexOf('?');
					if (index >= 0) child_link = child_link.substring(0,index);
					index = loc.indexOf('?');
					if (index >= 0) loc = loc.substring(0,index);
					*/
					
					var cmiCSS = '';
					//if (child_link && (loc.indexOf(child_link) != -1)) {
					try {
						if (child_link && encodeURIComponent(decodeURIComponent(loc)) == encodeURIComponent(decodeURIComponent(child_link))) {
								cmiCSS = mID+'current_menu_item ';
						}
					} catch (e) {
					}
					itemTable.className=cmiCSS+'menuBar '+mID+'menuBar allItems '+mID+'allItems '+mID+'item'+thisItemCSSid;
					itemTable.setAttribute('itemClass', cmiCSS+'menuBar '+mID+'menuBar allItems '+mID+'allItems '+mID+'item'+thisItemCSSid);
					itemTable.setAttribute('itemOverClass', "menuBar "+mID+"menuBar allItems "+mID+"allItems allItemsOver "+mID+"allItemsOver "+mID+"item"+thisItemCSSid+"Over");

						var tr;//=itemTable.insertRow(0);
						//var newCell = tr.insertCell(0);
						if(!child.borderL){
							child.borderL = myMenu.borderL;
						}
						borderL=child.borderL;
						if(!child.borderR){
							child.borderR = myMenu.borderR;
						}
						borderR=child.borderR;
						if(!child.bullet){
							child.bullet = myMenu.bullet;
						}
						bullet=child.bullet;
						if(!child.recursive){
							child.recursive = false;
						}
						upperbullet = child.upperbullet;
						recursive = child.recursive;
						var newBulletCell, trBullet = '';
						if (upperbullet) {
							itemTable.setAttribute('upperbullet', 1);
							/*trBullet = itemTable.insertRow(-1);
							newBulletCell = trBullet.insertCell(-1);
							newBulletCell.colSpan = 4;
							*/
							//newBulletCell.align = 'center';
							
							if (0) {
								newBulletCell.id = mID+'_bulletCell_'+thisItemId;
								newBulletCell.style.zIndex = -1;
								if( upperbullet.search(/^http:/) !=-1 ){
									addUpperText=document.createElement("img");
									addUpperText.setAttribute('src', upperbullet);
									addUpperText.className='bullets';
									addUpperText.id = mID+'_bullet_'+thisItemId;
									myMenu.objImgs[i] = new Image();
									myMenu.objImgs[i].src = upperbullet;
								}
								else{addUpperText=document.createTextNode(upperbullet);}
								//alert('upperbullet:'+upperbullet );
								myMenu.objImgs[i].onload = function() {
									//alert('debug'+ i + '::' + myMenu.objImgs[i].src + ':' + myMenu.objImgs[i].width + 'x' + myMenu.objImgs[i].height);
								}
	
								if (child.upperbulleteffect == 'true' || child.upperbulletover == 'true') {
									addUpperText.style.height = '0px';
									addUpperText.style.position = 'relative';
									addUpperText.style.zIndex = 1;
									addUpperText.style.top = myMenu.objImgs[i].height+'px';
									addUpperText.setAttribute('myWidth', myMenu.objImgs[i].width);
									addUpperText.setAttribute('myHeight', myMenu.objImgs[i].height);
								}
								newBulletCell.style.height = myMenu.objImgs[i].height+'px';
								newBulletCell.appendChild(addUpperText);								
								if (child.upperbulleteffect== 'true' && child.upperbulletover != 'true') {
									var inc = myMenu.objImgs[i].height/speed;
									moveBullets += "moveBullet('"+mID+"', "+inc+", "+speed+" , '"+addUpperText.id+"');";
								}
							}
							else {
								var bulletDiv = document.createElement('DIV');
								bulletDiv.id = mID+'_bulletCell_'+thisItemId;
								bulletDiv.style.zIndex = -1;
								bulletDiv.style.position = 'absolute';
								if( upperbullet.search(/^http:/) !=-1 ){
									addUpperText=document.createElement("img");
									addUpperText.setAttribute('src', upperbullet);
									addUpperText.className='bullets';
									addUpperText.id = mID+'_bullet_'+thisItemId;
									myMenu.objImgs[i] = new Image();
									myMenu.objImgs[i].src = upperbullet;
									eval(bulletDiv.id+"=new Image()");
									eval(bulletDiv.id+".src='"+upperbullet+"'");
								}
								else{addUpperText=document.createTextNode(upperbullet);}
								//alert('upperbullet:'+upperbullet );
								myMenu.objImgs[i].onload = function() {
									//alert('img load:'+i + '::' + myMenu.objImgs[i].src + ':' + myMenu.objImgs[i].width + 'x' + myMenu.objImgs[i].height);
									//alert(document.getElementById(mID+'_bulletCell_'+thisItemId).id);
									//eval("alert('"+mID+"_bulletCell_"+thisItemId+"')");
								}
								setBulletsDim += 'setBulletDim("'+bulletDiv.id+'", "'+mID+'");';
								if (!child.upperbulletalign) child.upperbulletalign = 'center';
								addUpperText.setAttribute('upperbulletalign', child.upperbulletalign);
									
								if (child.upperbulleteffect == 'true' || child.upperbulletover == 'true') {
									addUpperText.style.height = '0px';
									addUpperText.style.position = 'relative';
									addUpperText.style.zIndex = 1;
									addUpperText.style.top = myMenu.objImgs[i].height+'px';
									addUpperText.setAttribute('myWidth', myMenu.objImgs[i].width);
									addUpperText.setAttribute('myHeight', myMenu.objImgs[i].height);
								}
								bulletDiv.style.height = myMenu.objImgs[i].height+'px';
								bulletDiv.appendChild(addUpperText);
								moveBullets += 'positionedBullet("'+bulletDiv.id+'", "'+itemTable.id+'");';
								if (child.upperbulleteffect== 'true' && child.upperbulletover != 'true') {
									var inc = myMenu.objImgs[i].height/speed;
									moveBullets += "moveBullet('"+mID+"', "+inc+", "+speed+" , '"+addUpperText.id+"');";
								}
								document.getElementById('subMenu').appendChild(bulletDiv);
							}
							
						}
						// if bullet to put onover
						if (child.upperbulletover == 'true') {
							itemTable.setAttribute('bulletOver', 1);
						}
						if (child.upperbulleteffect == 'true' && child.upperbulletover == 'true') {
							itemTable.setAttribute('bulletEffect', 1);
						}
						var tr=itemTable.insertRow(-1);
						//if (borderL) {
							var newCell = tr.insertCell(0);
							if( borderL.search(/^http:/) !=-1 ){
								addText=document.createElement("img");
								addText.setAttribute('src', borderL);
							}
							else{addText=document.createTextNode(borderL);}
							newCell.appendChild(addText);
						//}
						
						//if (bullet) {
							newCell = tr.insertCell(-1);
							if( bullet.search(/^http:/) !=-1 ){
								addText=document.createElement("img");
								addText.setAttribute('src', bullet);
								addText.className='bullets';
								addText.id = mID+'_bullet_'+thisItemId;
								img = new Image();
								img.src = bullet;
							}
							else{addText=document.createTextNode(bullet);}															
							newCell.appendChild(addText);
						//}
						
						newCell = tr.insertCell(-1);
						newCell.style.width='100%';
						if(child.name){
							if(child.name.search(/^http:/) !=-1){
								addText=document.createElement("img");
								addText.setAttribute('src', child.name);
							}
							else{
								addText=document.createTextNode(child.name);
							}
						}
						else{addText=document.createTextNode('');}
						tr.setAttribute('data', tr.cells.length-1);
						newCell.appendChild(addText);
						
						//if (borderR) {
							newCell = tr.insertCell(-1);
							if( borderR.search(/^http:/) !=-1 ){
								addText=document.createElement("img");
								addText.setAttribute('src', borderR);
							}
							else{addText=document.createTextNode(borderR);}
							newCell.appendChild(addText);
						//}
				
					var link='#';
					if(child.link){//build click on menu item
						link=child.link;
						if (link.search(/@/) > 0 && link.search(/mailto/) != 0) {
							link = 'mailto:'+link;
						}
						else if (link.search(/^Login:(\d+)/) >= 0) {
							id = RegExp.$1;
							loginID = 'login'+id;
							var divLogin = document.getElementById(loginID);
							var hide = document.getElementById('hideAllDiv');
							if (!hide) {
								getSize();
								hide = document.createElement('DIV');
								hide.id = 'hideAllDiv';
								hide.style.zIndex = 1111;
								hide.style.backgroundColor = '#000000';
								hide.style.display = 'none';
								hide.style.position = 'absolute';
								hide.style.left = '0px';
								hide.style.top = '0px';
								hide.style.width = '100%';
								if (navigator.appVersion.indexOf("MSIE")!=-1) {
									hide.style.filter = "alpha(opacity=85)";
								}
								else {
									hide.style.opacity = 0.85;
								}
								document.getElementById('subMenu').appendChild( hide);
							}
							if (!divLogin) {
								var divLogin = document.createElement('DIV');
								divLogin.id = loginID;
								//alert(hide+':'+hide.parent);
								hide.parentNode.insertBefore( divLogin, hide );
								loadjscssfile("/htm-webaxy/cookies.js", "js");
								loadjscssfile("/LoGin/"+loginID+".css", "css");
								loadjscssfile("/LoGin/"+loginID+".js", "js", loginID+".js");
								loadjscssfile("/htm-webaxy/login/login1.js", "js");
								loginToDo += 'copyLoginBtn("'+mID+'_item_'+thisItemId+'_a'+'", "login'+id+'b");';
							}
							link = 'javascript:loginCenter("", "'+id+'","'+div.getAttribute('cID')+'","'+div.getAttribute('dir')+'");';
							//link = 'http://ynet.co.il';
						}
					}
					var target=child.target?child.target:'_self';
					var itemLink=document.createElement("a");
					itemLink.setAttribute('href', link);
					itemLink.setAttribute('target', target);
					itemLink.setAttribute('id', mID+'_item_'+thisItemId+'_a');
					itemTable=insertLinksInTable(itemLink,itemTable);
				
				itemCell.appendChild(itemTable);
				
				if(!div.verticalMenu){
					var divSround = document.createElement('div');
					divSround.appendChild(itemWrapTable);
					divSround.id = mID+'_d_'+thisItemId;
					var divStyle = '';
					divSround.className = mID+'divClass divClass';
					//divSround.setAttribute('style', child.addCode);
					//alert(child.addCode);
					//divSround.style.position = 'relative';
					//divSround.style.top = '140px';
					if (typeof(child.toolTip) != 'undefined' && child.toolTip == 'true') {
							divSround.toolTip = 1;
							divTT = document.createElement('DIV');
							divTT.id = mID+'_d_'+thisItemId+'_tt';
							divSround.appendChild(divTT);
					}
					if (child.addCode) {
							var addCodeA = child.addCode.split(';');
							var ttLeft = 0;
							for (var myIndex = 0 ; myIndex < addCodeA.length ; myIndex++) {
									addCodeA[myIndex] = addCodeA[myIndex].replace(/^\s+/, '');
									addCodeA[myIndex] = addCodeA[myIndex].replace(/\s+$/, '');
									if (addCodeA[myIndex] == '') continue;
									var values = addCodeA[myIndex].split(':');
									var key = values[0];
									var value = values[1];
									if (key.search(/-/) > 0) {
											var loc = key.indexOf('-');
											var part1 = key.substring(0, loc);
											var part2 = key.substring(loc+1,loc+2).toUpperCase();
											var part3 = key.substring(loc+2);
											key = part1+part2+part3;
									}
									key = key.replace(/^\s+/, '');
									key = key.replace(/\s+$/, '');
									value = value.replace(/^\s+/, '');
									value = value.replace(/\s+$/, '');
									if (key == 'left') {
										ttLeft = value.replace(/px/,'');										
									}
									eval("divSround.style['"+key+"']= '"+value+"'");
							}
							if (divSround.toolTip == 1 || child.coords == 1) {
								toolTipToDo.push(divSround.id+'%%'+ttLeft+'%%'+child.bulletWidth);
							}
					}
					mainCell.appendChild(divSround);
					///div.appendChild(divSround);
				}
				else {
					var divSround = document.createElement('div');
					divSround.appendChild(itemTable);
					divSround.id = mID+'_d_'+thisItemId;
					var divStyle = '';
					divSround.className = mID+'divVClass divVClass';
					mainCell.appendChild(divSround);
				}
				if(child.items && child.items.length > 0 || (typeof(child.toolTip) != 'undefined' && child.toolTip == 'true')){// create submenu
							createSubMenu(child, mID, child.id, 1, recursive, mID + 'item' + thisItemCSSid, mID + 'item' + thisItemCSSid+ 'Over',myMenu,thisItemCSSid, div.id);
				}
						
	}
	if (div.verticalMenu) {
		var wrapDiv = document.createElement('DIV');
		wrapDiv.id = mID;
		wrapDiv.innerHTML = mainCell.innerHTML;
		wrapDiv.dir=myMenu.dir;
		wrapDiv.setAttribute('menuId', mID);
		wrapDiv.setAttribute('style', '');
		wrapDiv.className='menuDiv '+mID+'menuDiv';
		wrapDiv.setAttribute('vertical',div.verticalMenu);	
		div.appendChild(wrapDiv);
	}
	else {
		div.appendChild(menuTable);
	}
	
	menuParent=div.parentNode;
	menuParent.appendChild(insertInTo(menuSurround, div, 0))
	
	var items = div.getAttribute('current_menu_item').split(" ");
	for (var i = 0 ; i < items.length ; i++) {
			if (items[i]) {
				document.getElementById(items[i]).className += ' '+mID+'current_menu_item';
				document.getElementById(items[i]+'_a').className += ' '+mID+'current_menu_item';
				document.getElementById(items[i]).setAttribute('itemClass',document.getElementById(items[i]).getAttribute('itemClass')+' '+mID+'current_menu_item');	
				//document.getElementById(items[i]).setAttribute('itemOverClass', document.getElementById(items[i]).getAttribute('itemOverClass'));
			}
	}
	
	if (document.getElementById(mID) && more == 'sp') {
			document.getElementById(mID).setAttribute('sp', 1);
	}
	if (document.getElementById(mID) && more == 'sp2') {
			document.getElementById(mID).setAttribute('sp', 2);
	}
	if (document.getElementById(mID) && myMenu.opensUp == 1) {
			document.getElementById(mID).setAttribute('opensUp', 1);
	}
	
	if (myMenu.dir.toLowerCase() == 'rtl' && toolTipToDo.length > 0) {
		$(document).ready(function () {
  		for (var i = 0 ; i < toolTipToDo.length ; i++) {
				arr = toolTipToDo[i].split(/%%/);
				id = arr[0];
				ttLeft = arr[1];
				bulletWidth = arr[2];
				//alert(id+':'+ttLeft);
				try {
					//alert(id+':'+document.getElementById(id).clientWidth);
					document.getElementById(id).style.left = parseFloat(document.getElementById(id).style.left)-document.getElementById(id).clientWidth+'px';
				} catch (e) {
				}
			}
	 });	
	}
	
	if (setBulletsDim != '') {
		var menuOldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = function() {eval(setBulletsDim);}
	  } else {
	    window.onload = function() {
	      if (menuOldonload) {
	        menuOldonload();
	      }
	      eval(setBulletsDim);
	    }
	  }	
	}
	
	if (moveBullets != '') {
		var menuOldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = function() {eval(moveBullets);}
	  } else {
	    window.onload = function() {
	      if (menuOldonload) {
	        menuOldonload();
	      }
	      eval(moveBullets);
	    }
	  }	
	}
	
	if (loginToDo != '') eval(loginToDo);
		
}

function setBulletDim(div, mID) {
	
	img = document.getElementById(div.replace(/Cell/, ''));
	//div = document.getElementById(div);
	var img;
	//alert(eval("img="+div));
	img.setAttribute('myHeight', eval(div+".height"));
	img.setAttribute('myWidth', eval(div+".width"));
	
}
function buildMenuV(div, myMenu){
	
	div.setAttribute('current_menu_item', '');
	var mID=myMenu.id;
	var mID_original=mID;
	// have to check this mID=mID+(div.verticalMenu?'v':'');
	//topMenuElement.setAttribute('id', mID);
	var allBorderR=myMenu.borderR;
	var allBorderL=myMenu.borderL;
	var allBullet=myMenu.bullet;
	
	var mainMenuBullet=myMenu.bulletBwMenu;
	var removeFirstBullet=myMenu.removeFirstBullet;
	
	var HTMLbefore=myMenu.HTMLbefore;
	var HTMLafter=myMenu.HTMLafter;
	
	var menuSurround = document.createElement('div');
	menuSurround.setAttribute('id', 'surround'+mID);
	menuSurround.className='surroundDIV';
	menuSurround.innerHTML=decodeXML(HTMLbefore)+'<XMLMENU></XMLMENU>'+decodeXML(HTMLafter);
	
	div.innerHTML='';
	div.dir=myMenu.dir;
	div.setAttribute('menuId', mID);
//	div.style.height='auto';
	div.setAttribute('style', '');
	div.className='menuDiv '+mID+'menuDiv';
	div.setAttribute('vertical',div.verticalMenu);
	
	var menuTable=document.createElement("table");
	menuTable.setAttribute('id', mID);
	menuTable.setAttribute('indent', myMenu.menuPadding );
	menuTable.setAttribute('cellSpacing', '0');
	menuTable.setAttribute('cellPadding', '0');
	menuTable.setAttribute('display', 'hidden');
	menuTable.dir=myMenu.dir;
	menuTable.previsible=mID
	menuTable.timer='';
	menuTable.tStatus=0;
	menuTable.className='menuBar '+mID+'menuBar';
	
	if ( 1 ){
	//for (var child = topMenuElement.firstChild; child != null && 1 == 0; child = child.nextSibling){
	var child;
	
	/*var indent = document.createElement('input');
	indent.setAttribute('type', 'hidden');
	indent.setAttribute('id', 'indent');
	indent.setAttribute('value', myMenu.menuPadding);
	var wa1 = document.createElement('input');
	wa1.setAttribute('type', 'hidden');
	wa1.setAttribute('id', 'wa1');
	wa1.setAttribute('value', '');
	var wa2 = document.createElement('input');
	wa2.setAttribute('type', 'hidden');
	wa2.setAttribute('id', 'wa2');
	wa2.setAttribute('value', '');*/
	
	/*previsible.setAttribute('type', 'hidden');
	previsible.setAttribute('id', 'previsible');
	previsible.setAttribute('value', mID);*/
	
	//document.getElementsByTagName("body")[0].appendChild(indent);
	//document.getElementsByTagName("body")[0].appendChild(wa1);
	//document.getElementsByTagName("body")[0].appendChild(wa2);
	newRow=menuTable.insertRow(-1);
	indent = myMenu.menuPadding;
	var spacing = myMenu.menuSpacing;
	var mainCell = newRow.insertCell(-1);
	
	var menuDir;
	if (myMenu.dir == 'RTL' || myMenu.dir == 'rtl') {
		menuDir = 'right';
	}
	else {
		menuDir = 'left';
	}
	
	mID1 = mID;
	mID1 = mID1.replace(/M/,'');
	mID1 = mID1.replace(/MAP_MENU/,'');
	try {
		if (userAllowMenus == 'admin' || userAllowMenus.indexOf(';'+mID1+';') >= 0){
			var itemUl=document.createElement("ul");
			itemUl.setAttribute('menuId', mID);
			itemUl.setAttribute('vertical', div.verticalMenu);
			
			var itemLi=document.createElement("li");
			itemLi.setAttribute('menuId', mID);
			
			if (indent) itemLi.setAttribute('style', 'padding-'+menuDir+': '+indent+'px;');
			
			var imgA=document.createElement("img");
			imgA.setAttribute('menuId', mID_original);
			imgA.setAttribute('src', ""+webaxyURL+"/click/pagedit.gif");
			imgA.setAttribute('title', "Menu Administration");
			imgA.className='menuClickAdminImg';
			imgA.style.cursor='pointer';
			
			itemLi.appendChild(imgA);
			itemLi.dir=myMenu.dir;
			itemUl.appendChild(itemLi);
			div.appendChild(itemUl);
		}
	} catch (e) {}
		
	if (myMenu.name) {
		var itemUl=document.createElement("ul");
		itemUl.setAttribute('menuId', mID);
		itemUl.setAttribute('vertical', div.verticalMenu);
		
		var itemLi=document.createElement("li");
		itemLi.setAttribute('menuId', mID);
		
		if (indent) itemLi.setAttribute('style', 'padding-'+menuDir+': '+indent+'px;');
		itemLi.innerHTML = myMenu.name;
		itemLi.dir=myMenu.dir;
		itemUl.appendChild(itemLi);
		div.appendChild(itemUl);
	}
	var currentItem = '';						
	for (i = 0 ; i < myMenu.mainItems.length ; i++) {
			if(1){
				child = myMenu.mainItems[i];
				if (child.hide && (child.hide == 'checked' ||
													 child.hide == 1) ||
													 (myMenu.IsMember && child.hide == 3) ||
													 (!myMenu.IsMember && child.hide == 2)
													 ) continue;
				
				var thisItemId=child.id;
				var thisItemCSSid=thisItemId.replace(/\./g,'_');
					/////newRow=menuTable.insertRow(-1);
				if (mainMenuBullet && ((removeFirstBullet == 'false' && i == 0) || (i > 0))) {
					//var itemCell1 = newRow.insertCell(newRow.cells.length);//add a cell at the end
					var itemUl=document.createElement("ul");
					itemUl.setAttribute('menuId', mID);
					itemUl.setAttribute('vertical', div.verticalMenu);
					
					var itemLi=document.createElement("li");
					itemLi.setAttribute('menuId', mID);
					itemLi.setAttribute('vertical', div.verticalMenu);
					if (indent) itemLi.setAttribute('style', 'padding-'+menuDir+': '+indent+'px;');
					if( mainMenuBullet.search(/^http:/) !=-1 ){
							addText=document.createElement("img");
							addText.setAttribute('src', mainMenuBullet);
					}
					else{
						addText=document.createTextNode(mainMenuBullet);
					}
					itemLi.appendChild(addText);
					itemLi.dir=myMenu.dir;
					itemUl.appendChild(itemLi);
					div.appendChild(itemUl);
				}				
				
				/////var itemCell = newRow.insertCell(newRow.cells.length);//add a cell at the end
				/////itemCell.align="center";
				var itemTable=document.createElement("table");
				itemTable.setAttribute('menuId', mID);
				itemTable.setAttribute('itemId', thisItemId);
				itemTable.setAttribute('menuLevel', '0');
				itemTable.setAttribute('autoClose', myMenu.autoClose);
				if(div.verticalMenu){itemTable.setAttribute('vertical', div.verticalMenu);}
				itemTable.setAttribute('cellSpacing', '0');
				itemTable.setAttribute('cellPadding', '0');
				itemTable.dir=myMenu.dir;
				var loc = location.href, child_link = child.link?child.link:'';
				/*var index = child_link.indexOf('?');
				if (index >= 0) child_link = child_link.substring(0,index);
				index = loc.indexOf('?');
				if (index >= 0) loc = loc.substring(0,index);
				*/
				cmiCSS = '';
				try {
					if (child_link && encodeURIComponent(decodeURIComponent(loc)) == encodeURIComponent(decodeURIComponent(child_link))) {
						cmiCSS = mID+'current_menu_item ';
						currentItem = thisItemId;
					}
				} catch (e) {
				}
				itemTable.className=cmiCSS+'menuBar '+mID+'menuBar allItems '+mID+'allItems '+mID+'item'+thisItemCSSid;
				itemTable.setAttribute('itemClass', cmiCSS+'menuBar '+mID+'menuBar allItems '+mID+'allItems '+mID+'item'+thisItemCSSid);
				itemTable.setAttribute('itemOverClass', "menuBar "+mID+"menuBar allItems "+mID+"allItems allItemsOver "+mID+"allItemsOver "+mID+"item"+thisItemCSSid+"Over");
					
				var tr=itemTable.insertRow(0);						
				var indent = '';
						if (myMenu.menuPadding != ''){indent=myMenu.menuPadding;}
						/*if (indent != '') {
							var indentCell = tr.insertCell(-1);
							indentCell.innerHTML  = '<img src="/htm-webaxy/multimedia/r1.gif" width="'+indent+'">';
						}*/
						if(!child.borderL){
							child.borderL = myMenu.borderL;
						}
						borderL=child.borderL;
						if(!child.borderR){
							child.borderR = myMenu.borderR;
						}
						borderR=child.borderR;
						if(!child.bullet){
							child.bullet = myMenu.bullet;
						}
						bullet=child.bullet;
						if(!child.recursive){
							child.recursive = false;
						}
						recursive = child.recursive;
						
						if (borderL) {
							var newCell = tr.insertCell(-1);
							if( borderL.search(/^http:/) !=-1 ){
								addText=document.createElement("img");
								addText.setAttribute('src', borderL);
								addText.setAttribute('noOnClick', true);
								//addText.onclick=function() {noBubble1(window.event);};
							}
							else{addText=document.createTextNode(borderL);newCell.setAttribute('noOnClick',true);}							
							newCell.appendChild(addText);
						}
						
						if (bullet) {
							newCell = tr.insertCell(-1);
							if( bullet.search(/^http:/) !=-1 ){
								addText=document.createElement("img");
								addText.setAttribute('src', bullet);
								addText.setAttribute('noOnClick', true);
								addText.className='bullets';
								addText.id = mID+'_bullet_'+thisItemId;
								newCell.style.verticalAlign = 'top';								
							}
							else{addText=document.createTextNode(bullet);newCell.setAttribute('noOnClick',true);}
							newCell.appendChild(addText);							
						}
						
						newCell = tr.insertCell(-1);
						newCell.style.width='100%';
						if(child.name){
							if(child.name.search(/^http:/) !=-1){
								addText=document.createElement("img");
								addText.setAttribute('src', child.name);
							}
							else{
								addText=document.createTextNode(child.name);
							}
						}
						else{addText=document.createTextNode('');}
						tr.setAttribute('data', tr.cells.length-1);
						newCell.appendChild(addText);
						
						if (borderR) {
							newCell = tr.insertCell(-1);
							if( borderR.search(/^http:/) !=-1 ){
								addText=document.createElement("img");
								addText.setAttribute('src', borderR);
								addText.setAttribute('noOnClick', true);
								//addText.onclick=function() {noBubble1(window.event);};
							}
							else{addText=document.createTextNode(borderR);newCell.setAttribute('noOnClick',true);}
							newCell.appendChild(addText);
						}
				
					var link='javascript:void(0);';
					if(child.link){	//build click on menu item
						link=child.link;
						if (link.search(/@/) > 0 && link.search(/mailto/) != 0) link = 'mailto:'+link;
						/*if (link.search(/\?/) != -1) {
							link = link + '&cmi='+thisItemId+'m';
						}
						else {
							link = link + '?cmi='+thisItemId+'m';
						}*/
					}
					var target=child.target?child.target:'_self';
					var itemLink=document.createElement("a");
					itemLink.setAttribute('href', link);
					itemLink.setAttribute('target', target);
					itemLink.setAttribute('id', mID+'_item_'+thisItemId+'_a');
					itemTable=insertLinksInTable(itemLink,itemTable);					
				
				var itemDiv=document.createElement("div");
				itemDiv.setAttribute('id', mID + '.' + thisItemId);
				itemDiv.setAttribute('menuId', mID);
				itemDiv.setAttribute('vertical', div.verticalMenu);
				itemDiv.className = 'mainMenuDiv';
				
				itemDiv.appendChild(itemTable);
				/////itemCell.appendChild(itemDiv);
				
				var itemUl=document.createElement("ul");
				//itemDiv.setAttribute('id', mID + '.' + thisItemId);
				itemUl.setAttribute('menuId', mID);
				itemUl.setAttribute('vertical', div.verticalMenu);
				//itemUl.className = mID+'menuPad '+mID+'mainMenuPad ';
				//itemDiv.className = 'mainMenuDiv';
				
				var itemLi=document.createElement("li");
				itemLi.setAttribute('menuId', mID);
				itemLi.setAttribute('vertical', div.verticalMenu);
				if (indent) itemDiv.setAttribute('style', 'margin-'+menuDir+': '+indent+'px;');
				//if (indent) itemLi.setAttribute('style', 'padding-'+menuDir+': '+indent+'px;');
				if (spacing) 	itemUl.style['paddingBottom'] = spacing+'px';
				//itemUl.setAttribute('style', 'padding-bottom: '+spacing+'px;');
			
				itemLi.appendChild(itemDiv);
				itemUl.appendChild(itemLi);
				///mainCell.appendChild(itemUl);
				div.appendChild(itemUl);
				
				/////itemCell.appendChild(itemDiv);
				
				if(child.items && child.items.length > 0){// create submenu
					createSubMenuV(child, mID, child.id, 1, recursive, mID + 'item' + thisItemCSSid, mID + 'item' + thisItemCSSid+ 'Over', div.verticalMenu, menuTable, myMenu, itemUl, thisItemCSSid, div.id);
				}
			}
		}
	}
	div.appendChild(menuTable);
	
//	newMenuView=insertInTo(menuSurround, div); // insert menu in to surround html
//	div.appendChild(newMenuView);
	
	menuParent=div.parentNode;
	menuParent.appendChild(insertInTo(menuSurround, div))
	
	if (myMenu.currOpen == 'true') {
			if (currentItem) {
					myMenu.currOpenID = currentItem;
					myMenu.currOrigOpenID = currentItem;
					myMenu.currOpenIDLevel = 0;
			}
			mID1 = mID.replace(/M/,'Menu');
			var els = document.getElementById(mID1).getElementsByTagName('div');
			var cur_el_id = mID + '.' + myMenu.currOpenID + '.';
			var curcur_el_id = mID + '.' + myMenu.currOrigOpenID;
			//check if one of my child is open, so I close myself.
			var found = false;
			var index;
			for(var i=0; i<els.length; i++){
				index = els[i].id.indexOf(cur_el_id);
				index1 = els[i].id.indexOf(curcur_el_id);
				if ((index == 0 && els[i].id != cur_el_id && els[i].firstChild.getAttribute('menulevel') && els[i].firstChild.getAttribute('menulevel') <= myMenu.currOpenIDLevel) ||
						(index1 == 0 && els[i].id != cur_el_id && els[i].firstChild.getAttribute('menulevel') && els[i].firstChild.getAttribute('menulevel') > myMenu.currOpenIDLevel)
						) { 
						//alert(els[i].id+':'+cur_el_id+':'+index);				
						els[i].style['display'] = 'block';
						els[i].parentNode.style['display'] = 'block';
						els[i].parentNode.parentNode.style['display'] = 'block';
				}
			}
	}
	
	var items = div.getAttribute('current_menu_item').split(" ");
	for (i = 0 ; i < items.length ; i++) {
			if (items[i]) {
				document.getElementById(items[i]).className += ' '+mID+'current_menu_item';
				itemID = items[i].split('.',2)[1];
				document.getElementById(mID+'_item_'+itemID+'_a').className += ' '+mID+'current_menu_item';
				document.getElementById(items[i]).setAttribute('itemClass',document.getElementById(items[i]).getAttribute('itemClass')+' '+mID+'current_menu_item');	
				if (document.getElementById(items[i]).firstChild && document.getElementById(items[i]).firstChild.getAttribute('itemid') == itemID) {
						document.getElementById(items[i]).firstChild.className += ' '+mID+'current_menu_item';
						document.getElementById(items[i]).firstChild.setAttribute('itemClass',document.getElementById(items[i]).firstChild.getAttribute('itemClass')+' '+mID+'current_menu_item');
						//alert(tbItem.getAttribute('itemClass'));					
						//tbItem.setAttribute('itemoverclass',document.getElementById(items[i]).firstChild.getAttribute('itemoverclass')+' '+mID+'current_menu_item');
				}
			}
	}
	
}

//#------------------------------------------------------------
function insertLinksInTable(linkObj, tableObj){
	//if (tableObj.rows[0].cells[1].firstChild.nodeName == 'IMG') return tableObj;
	var tableClass=tableObj.getAttribute('itemClass');
	var rowIndex = 0;
	/*if (tableObj.getAttribute('upperbullet') == 1 && tableObj.rows[1]) rowIndex = 1;
	else rowIndex = 0;		*/
	var data = tableObj.rows[rowIndex].getAttribute('data');
	for (var c=0; c<tableObj.rows[rowIndex].cells.length; c++){
		//if (tableObj.rows[0].cells[c].firstChild.nodeName == 'IMG') continue;
		//var newLink=linkObj.cloneNode(true);
		var newLink = document.createElement("a");
		newLink.href = linkObj.href;
		newLink.target = linkObj.target;
		if (linkObj.id && data == c) newLink.id = linkObj.id;
		newLink.className=tableClass;
		newLink.style.border='0px';
		newLink.style.backgroundImage='none';
		//if (newLink.href == 'javascript:void(0);' && tableObj.rows[0].cells[c].firstChild.nodeName == 'IMG') continue;
     tableObj.rows[rowIndex].cells[c].appendChild(newLink);
     newLink.appendChild(tableObj.rows[rowIndex].cells[c].firstChild);
  }
	return tableObj;
}
//#------------------------------------------------------------
function insertInTo(node, menuDiv) {
	for (var child = node.firstChild; child != null; child = child.nextSibling){
		if(child.nodeName =='XMLMENU') {
	//			child.parentNode.replaceChild(menuDiv.firstChild, child);
				child.parentNode.replaceChild(menuDiv, child);
		}
		else if(child.hasChildNodes()){insertInTo(child, menuDiv);}
	}
	return node;
}
//#------------------------------------------------------------
function decodeXML(txt){
	var txt= new String(txt);
    txt = txt.replace(/&amp;/g, '&');
    txt = txt.replace(/&lt;/g, '<');
    txt = txt.replace(/&gt;/g, '>');
    txt = txt.replace(/&apos;/g, "'");
    txt = txt.replace(/&quot;/g, '"');
return txt;
}
//#------------------------------------------------------------
function createSubMenu(xmlObj, menuID, submenuID, submenuLevel, recursive, recursiveMenuID, recursiveMenuIDOver, myMenu, theFatherId, mainDivID){
	var submenuLevel = submenuLevel;
	var submenuSCCid=submenuID.replace(/\./g,'_');
	var div=document.createElement("div");
	div.setAttribute('menuId', menuID);
	div.setAttribute('id', menuID+"."+submenuID);
	div.className='subMenuDiv';
	div.ttLoad = 0;
	if (typeof(xmlObj.subMenuCoordsX) != 'undefined' && xmlObj.subMenuCoordsX != '') div.subMenuCoordsX = xmlObj.subMenuCoordsX;
	if (typeof(xmlObj.subMenuCoordsY) != 'undefined' && xmlObj.subMenuCoordsY != '') div.subMenuCoordsY = xmlObj.subMenuCoordsY;							
				
	if (typeof(xmlObj.toolTip) != 'undefined' && xmlObj.toolTip == 'true') {
		if (typeof(xmlObj.toolTipCoordX) != 'undefined' && xmlObj.toolTipCoordX) {
			div.toolTipCoordX = xmlObj.toolTipCoordX;
		}
		if (typeof(xmlObj.toolTipCoordY) != 'undefined' && xmlObj.toolTipCoordY) {
			div.toolTipCoordY = xmlObj.toolTipCoordY;
		}
	}
	var submenuTable=document.createElement("table");
	submenuTable.setAttribute('cellSpacing', '0');
	submenuTable.setAttribute('cellPadding', '0');
	submenuTable.className='subMenu '+menuID+'subMenu subMenu'+submenuLevel+' '+menuID+'subMenu'+submenuLevel+'';
	//alert(xmlObj.id+':'+xmlObj.toolTip);
	if (typeof(xmlObj.toolTip) == 'undefined' || xmlObj.toolTip != 'true') {
		for (var i = 0 ; xmlObj.items && i < xmlObj.items.length ; i++){
			//if( 1 ){
				child = xmlObj.items[i];
				if (child.hide && (child.hide == 'checked' ||
													 child.hide == 1) ||
													 (myMenu.IsMember && child.hide == 3) ||
													 (!myMenu.IsMember && child.hide == 2)
													 ) continue;
				
				var thisItemId=child.id;
				var thisItemCSSid=thisItemId.replace(/\./g,'_');
				
				var itemCell;
				if (myMenu.opensUp == 1) {
					itemCell=submenuTable.insertRow(0).insertCell(0);
				}
				else {
					itemCell=submenuTable.insertRow(-1).insertCell(0);
				}
	//			itemCell.align="center";
				var itemTable=document.createElement("table");
				if (typeof(child.toolTip) != 'undefined' && child.toolTip == 'true') {
					itemTable.toolTip = 1;
					itemTable.ttLoad = 0;
					itemTable.onclick = function() {preGetPageCell(this, menuID);};
					if (typeof(child.toolTipFile) != 'undefined' && child.toolTipFile != '') itemTable.toolTipFile = child.toolTipFile;
					if (typeof(child.toolTipFileCell) != 'undefined' && child.toolTipFileCell != '') itemTable.toolTipFileCell = child.toolTipFileCell;
					if (typeof(child.toolTipStyle) != 'undefined' && child.toolTipStyle != '') itemTable.toolTipStyle = child.toolTipStyle;
					if (typeof(child.toolTipTitle) != 'undefined' && child.toolTipTitle != '') itemTable.toolTipTitle = child.toolTipTitle;
					if (typeof(child.toolTipTitleStyle) != 'undefined' && child.toolTipTitleStyle != '') itemTable.toolTipTitleStyle = child.toolTipTitleStyle;
					if (typeof(child.toolTipContactCat) != 'undefined' && child.toolTipContactCat != '') itemTable.toolTipContactCat = child.toolTipContactCat;
					if (typeof(child.toolTipContactAppearence) != 'undefined' && child.toolTipContactAppearence != '') itemTable.toolTipContactAppearence = child.toolTipContactAppearence;
					if (typeof(child.toolTipContactSelect) != 'undefined' && child.toolTipContactSelect != '') itemTable.toolTipContactSelect = child.toolTipContactSelect;
					if (typeof(child.toolTipDrag) != 'undefined' && child.toolTipDrag == 'true') itemTable.dragabble = 1;
					if (typeof(child.toolTipCloseButton) != 'undefined' && child.toolTipCloseButton!= '') itemTable.toolTipCloseButton = child.toolTipCloseButton;
					if (typeof(child.toolTipSource) != 'undefined' && child.toolTipSource!= '') itemTable.toolTipSource = child.toolTipSource;
					if (child.toolTipContactAppearence && (child.toolTipContactCat || child.toolTipContactSelect)) {
						telAppearence = child.toolTipContactAppearence;
						telCat = child.toolTipContactCat;
			  		contactID = child.toolTipContactSelect;
			  		if (telAppearence) insertFileElement("/Contact/tel"+telAppearence+".css","css");
			  		//alert('tel'+contactID);
			  		thisItemId1 = thisItemId.replace(/\./g,'_');
			  		if (child.toolTipContactCat && child.toolTipContactSelect) {
			  			get_ajax_popup('', '','ID='+cid+'&telID='+telAppearence+'&recordID='+contactID+'&cat='+child.toolTipContactCat+'&only_data=1', '', 'tel'+thisItemId1,'popupRecord');
			  		}
			  		else {
			  			get_ajax_popup('', '','ID='+cid+'&telID='+telAppearence+'&cat='+child.toolTipContactCat+'&only_data=1', '', 'tel'+thisItemId1,'getCat');
			  		}
			  	}
				}
				itemTable.setAttribute('menuId', menuID);
				itemTable.setAttribute('itemId', thisItemId);
				itemTable.setAttribute('menuLevel', submenuLevel);
				itemTable.setAttribute('cellSpacing', '0');
				var recursiveMenuIDSCC = '';
				var recursiveMenuIDSCCOver = '';
				if (recursive == 'true') {
						recursiveMenuIDSCC = recursiveMenuID.replace(/\./g,'_');
						recursiveMenuIDSCCOver = recursiveMenuIDOver.replace(/\./g,'_');
						recursiveMenuIDSCCOver = recursiveMenuIDSCC + ' ' + recursiveMenuIDSCCOver;
				}
				
				var loc = location.href, child_link = child.link?child.link:'';
				/*var index = child_link.indexOf('?');
				if (index >= 0) child_link = child_link.substring(0,index);
				index = loc.indexOf('?');
				if (index >= 0) loc = loc.substring(0,index);
					*/
					
				var cmiCSS = '';
				try {
					if (child_link && encodeURIComponent(decodeURIComponent(loc)) == encodeURIComponent(decodeURIComponent(child_link))) {
						cmiCSS += menuID+'current_menu_item ';
						for (mLevel = 1 ; mLevel <= submenuLevel && mLevel <= 3; mLevel++) {
							cmiCSS += menuID+'subMenuCMI'+mLevel+' ';
						}
						document.getElementById(mainDivID).setAttribute('current_menu_item', document.getElementById(mainDivID).getAttribute('current_menu_item') + menuID+'_item_'+theFatherId + ' ');
					}
				} catch (e) {
				}
				
				var mLevelsCss = '',mLevelsCssOver = '';
				var firstLastChildCss = '';
				if (i == 0) {
					firstLastChildCss += menuID+'firstItem_'+thisItemId+' ';
				}
				if ( i == (xmlObj.items.length - 1) ){
					firstLastChildCss += menuID+'lastItem_'+thisItemId+' ';
				}	
				for (mLevel = 1 ; mLevel <= submenuLevel && mLevel <= 3; mLevel++) {
						mLevelsCss += 'subMenu'+mLevel+' '+menuID+'subMenu'+mLevel+' ';
						mLevelsCssOver += 'subMenuOver'+mLevel+' '+menuID+'subMenuOver'+mLevel+' ';
						//first child
						if (i == 0) {
							firstLastChildCss += menuID+'firstItem'+mLevel+' ';
						}
						if ( i == (xmlObj.items.length - 1) ){
							firstLastChildCss += menuID+'lastItem'+mLevel+' ';
						}		
				}
				
				// for taking care all child together
				/*
				var allTog = menuID+'item'+theFatherId+'_family ';
				allTog += menuID+'item'+theFatherId+'_family_sub'+submenuLevel;
				var allTogOver = menuID+'item'+theFatherId+'_familyOver ';
				allTogOver += menuID+'item'+theFatherId+'_family_sub'+submenuLevel+'Over';			
				allTogOver = allTog+' '+allTogOver;
				*/
				itemTable.id = menuID+'_item_'+thisItemCSSid;
				itemTable.className=firstLastChildCss+mLevelsCss+cmiCSS+' subMenu allItems '+menuID+'allItems '+recursiveMenuIDSCC+' '+menuID+'item'+thisItemCSSid;
				itemTable.setAttribute('itemClass',firstLastChildCss+mLevelsCss+cmiCSS+' subMenu allItems '+menuID+'allItems '+recursiveMenuIDSCC+' '+menuID+'item'+thisItemCSSid);	
				itemTable.setAttribute('itemOverClass', firstLastChildCss+mLevelsCssOver+mLevelsCss+menuID+"subMenuOver subMenu "+menuID+"subMenu allItems "+menuID+"allItems allItemsOver "+menuID+"allItemsOver "+menuID+"item"+thisItemCSSid+"Over "+recursiveMenuIDSCCOver);
	
				if(!child.borderL){
						if (recursive == 'true') {
							child.borderL = xmlObj.borderL?xmlObj.borderL:'';
						}
						else {
							for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
									child.borderL = eval("myMenu.subMenuBorderL"+mLevel);	
									if (child.borderL != undefined && child.borderL != '') break;
							}
							if ((child.borderL == undefined || child.borderL == '') && myMenu.borderL) child.borderL = myMenu.borderL;
						}
				}
				borderL=child.borderL;
				if(!child.borderR){
						if (recursive == 'true') {
							child.borderR = xmlObj.borderR?xmlObj.borderR:'';
						}
						else {
							for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
									child.borderR = eval("myMenu.subMenuBorderR"+mLevel);	
									if (child.borderR != undefined && child.borderR != '') break;
							}
							if ((child.borderR == undefined || child.borderR == '') && myMenu.borderR) child.borderR = myMenu.borderR;
						}
				}
				borderR=child.borderR;
					if(! child.bullet){
						if (recursive == 'true') {
							child.bullet = xmlObj.bullet?xmlObj.bullet:'';
						}
						else {
							for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
									child.bullet = eval("myMenu.subMenuBullet"+mLevel);	
									if (child.bullet != undefined && child.bullet != '') break;
							}
							if ((child.bullet == undefined || child.bullet == '') && myMenu.bullet) child.bullet = myMenu.bullet;
						}
					}
					/*
					upperbullet = child.upperbullet;
					var newBulletCell, trBullet = '';
					if (upperbullet) {
						trBullet = itemTable.insertRow(-1);
						newBulletCell = trBullet.insertCell(-1);
						newBulletCell.colSpan = 3;
						//newBulletCell.align = 'center';
						newBulletCell.id = menuID+'_bulletCell_'+thisItemId;
						if( upperbullet.search(/^http:/) !=-1 ){
							addUpperText=document.createElement("img");
							addUpperText.setAttribute('src', upperbullet);
							addUpperText.className='bullets';
							addUpperText.id = menuID+'_bullet_'+thisItemId;
							img = new Image();
							img.src = upperbullet;
						}
						else{addUpperText=document.createTextNode(upperbullet);}
						if (child.upperbulleteffect == 'true' || child.upperbulletover == 'true') {
							addUpperText.style.height = '0px';
							addUpperText.style.position = 'relative';
							addUpperText.style.zIndex = -1;
							addUpperText.style.top = img.height+'px';
							addUpperText.setAttribute('myHeight', img.height);
						}
						newBulletCell.style.height = img.height+'px';
						newBulletCell.appendChild(addUpperText);								
						if (child.upperbulleteffect== 'true' && child.upperbulletover != 'true') {
							var inc = img.height/speed;
							moveBullets += "moveBullet('"+menuID+"', "+inc+", "+speed+" , '"+addUpperText.id+"');";
						}
					}
					// if bullet to put onover
					if (child.upperbulletover == 'true') {
						itemTable.setAttribute('bulletOver', 1);
					}
					if (child.upperbulleteffect == 'true' && child.upperbulletover == 'true') {
						itemTable.setAttribute('bulletEffect', 1);
					}
					*/
					bullet=child.bullet;
					if(! child.recursive){
						child.recursive = false;
					}
					else if (child.recursive == 'true') {
							recursive=child.recursive;
							recursiveMenuID = recursiveMenuID + ' ' + menuID+'item'+thisItemId;
							recursiveMenuIDSCCOver = recursiveMenuIDSCCOver + ' ' + menuID+'item'+thisItemId+'Over ' + menuID+'subMenuOver'+submenuLevel;
					}
						
					var tr=itemTable.insertRow(0);
					
					//if (borderL) {
						if (borderL == undefined) borderL = '';
						var newCell = tr.insertCell(0);
						if( borderL.search(/^http:/) !=-1 ){
							addText=document.createElement("img");
							addText.setAttribute('src', borderL);
						}
						else{	addText=document.createTextNode(borderL);}
						newCell.appendChild(addText);
					//}
					
					//if (bullet) {
						newCell = tr.insertCell(-1);
						if (bullet == undefined) bullet = '';
						if( bullet.search(/^http:/) !=-1 ){
							addText=document.createElement("img");
							addText.setAttribute('src', bullet);
							addText.className='bullets';
							addText.id = menuID+'_bullet_'+thisItemId;
						}
						else{
							addText=document.createTextNode(bullet);
						}
						newCell.appendChild(addText);
					//}
					
					newCell = tr.insertCell(-1);
					newCell.style.width='100%';
					if(child.name){
						if(child.name.search(/^http:/) !=-1){
							addText=document.createElement("img");
							addText.setAttribute('src', child.name);
						}
						else{
							addText=document.createTextNode(child.name);
						}
					}
					else{
						addText=document.createTextNode('');
					}
					newCell.appendChild(addText);
					tr.setAttribute('data', tr.cells.length-1);
					
					//if (borderR) {
						if (borderR == undefined) borderR = '';
						newCell = tr.insertCell(-1);
						if( borderR.search(/^http:/) !=-1 ){
							addText=document.createElement("img");
							addText.setAttribute('src', borderR);
						}
						else{	addText=document.createTextNode(borderR);}
						newCell.appendChild(addText);
					//}
				
				var link='#';
				if(child.link){//build click on menu item
					link=child.link;
					if (link.search(/@/) > 0 && link.search(/mailto/) != 0) link = 'mailto:'+link;
					/*if (link.search(/\?/) != -1) {
							link = link + '&cmi='+thisItemId+'m';
					}
					else {
							link = link + '?cmi='+thisItemId+'m';
					}*/
				}
				var target=child.target?child.target:'_self';
				var itemLink=document.createElement("a");
				itemLink.className='itemLink';
				itemLink.setAttribute('href', link);
				itemLink.setAttribute('target', target);
				itemTable=insertLinksInTable(itemLink,itemTable);
				if (typeof(child.toolTip) != 'undefined' && child.toolTip == 'true') {	
					divTT = document.createElement('DIV');
					divTT.id = menuID+'_d_'+thisItemCSSid+'_tt';
					newCell = tr.insertCell(-1);
					//newCell.appendChild(divTT);
					//alert(myMenu.id+'.'+theFatherId);
					//alert(myMenu+':'+myMenu.id);
					//div.appendChild(divTT);
				}
				itemCell.appendChild(itemTable);
				if(child.items && child.items.length > 0 || (typeof(child.toolTip) != 'undefined' && child.toolTip == 'true')) {
					createSubMenu(child, menuID, child.id, submenuLevel+1, recursive, recursiveMenuID, recursiveMenuIDSCCOver, myMenu, theFatherId, mainDivID);
				}
			//}
		}
	}
	else {
		//divSround.toolTip = 1;
		divTT = document.createElement('DIV');
		divTT.id = menuID+'_d_'+submenuID+'_tt';
		divTT.id = divTT.id.replace(/\./g,'_');
		div.appendChild(divTT);				
	}
	
	var itemCell=submenuTable.insertRow(-1).insertCell(0);
	itemCell.className = menuID + 'lastLine '+menuID + 'lastLine_Item_'+xmlObj.id+' '+menuID + 'lastLinesub'+submenuLevel;
	//alert(div.id);
	div.appendChild(submenuTable);
	document.getElementById('subMenu').appendChild(document.createTextNode("\n"));
	document.getElementById('subMenu').appendChild(div);
}

function createSubMenuV(xmlObj, menuID, submenuID, submenuLevel, recursive, recursiveMenuID, recursiveMenuIDOver, vertical, menuTable, myMenu, itemUl, theFatherId, mainDivID){
	var submenuLevel = submenuLevel;
	var submenuSCCid=submenuID.replace(/\./g,'_');
	var div=document.createElement("div");
	div.setAttribute('menuId', menuID);
	div.setAttribute('id', menuID+"."+submenuID);
	div.className='subMenuDivV';
	div.setAttribute('vertical', vertical);
		
	var submenuTable=document.createElement("table");
	submenuTable.setAttribute('cellSpacing', '0');
	submenuTable.setAttribute('cellPadding', '0');
	submenuTable.className='menuBar subMenu '+menuID+'subMenu subMenu'+submenuLevel+' '+menuID+'subMenu'+submenuLevel+'';
				
	for (var i = 0 ; xmlObj.items && i < xmlObj.items.length ; i++){
		//if( 1 ){
			child = xmlObj.items[i];
			if (child.hide && (child.hide == 'checked' ||
													 child.hide == 1) ||
													 (myMenu.IsMember && child.hide == 3) ||
													 (!myMenu.IsMember && child.hide == 2)
													 ) continue;
				
			var thisItemId=child.id;
			var thisItemCSSid=thisItemId.replace(/\./g,'_');
			
			var divS=document.createElement("div");
			divS.setAttribute('menuId', menuID);
			divS.setAttribute('id', menuID + "." + child.id);
			divS.className='subMenuDivV';
			divS.setAttribute('vertical', vertical);
			
			// changed // var itemCell=submenuTable.insertRow(-1).insertCell(0);
			var itemTable=document.createElement("table");
			itemTable.setAttribute('menuId', menuID);
			itemTable.setAttribute('itemId', thisItemId);
			itemTable.setAttribute('autoClose', myMenu.autoClose);
			itemTable.setAttribute('menuLevel', submenuLevel);
			itemTable.setAttribute('cellSpacing', '0');
			itemTable.setAttribute('cellPadding', '0');
			itemTable.dir=myMenu.dir;
			var recursiveMenuIDSCC = '';
			var recursiveMenuIDSCCOver = '';
			if (recursive == 'true') {
					recursiveMenuIDSCC = recursiveMenuID.replace(/\./g,'_');
					recursiveMenuIDSCCOver = recursiveMenuIDOver.replace(/\./g,'_');
					recursiveMenuIDSCCOver = recursiveMenuIDSCC + ' ' + recursiveMenuIDSCCOver;
			}
			
			var loc = location.href, child_link = child.link?child.link:'';
			/*var index = child_link.indexOf('?');
			if (index >= 0) child_link = child_link.substring(0,index);
			index = loc.indexOf('?');
			if (index >= 0) loc = loc.substring(0,index);
			*/
			
			var cmiCSS = '';
			try {
				if (child_link && encodeURIComponent(decodeURIComponent(loc)) == encodeURIComponent(decodeURIComponent(child_link))) {
					cmiCSS += menuID+'current_menu_item ';
					for (mLevel = 1 ; mLevel <= submenuLevel && mLevel <= 3; mLevel++) {
						cmiCSS += menuID+'subMenuCMI'+mLevel+' ';
					}
					document.getElementById(mainDivID).setAttribute('current_menu_item', document.getElementById(mainDivID).getAttribute('current_menu_item') + menuID+'.'+theFatherId + ' ');
				}
			} catch (e) {
			}
			
			var mLevelsCss = '',mLevelsCssOver = '';
			for (mLevel = 1 ; mLevel <= submenuLevel && mLevel <= 3; mLevel++) {
					mLevelsCss += 'subMenu'+mLevel+' '+menuID+'subMenu'+mLevel+' ';
					mLevelsCssOver += 'subMenuOver'+mLevel+' '+menuID+'subMenuOver'+mLevel+' ';					
			}
			
			// for taking care all child together
			/*var allTog = menuID+'item'+theFatherId+'_family          ';
			allTog = allTog+'      '+menuID+'item'+theFatherId+'_family_sub'+submenuLevel;
			var allTogOver = menuID+'item'+theFatherId+'_familyOver ';
			allTogOver = allTogOver+' '+menuID+'item'+theFatherId+'_family_sub'+submenuLevel+'Over';			
			allTogOver = allTog+' '+allTogOver;
			*/
			itemTable.className=mLevelsCss+cmiCSS+'menuBar '+menuID+'menuBar subMenu allItems '+menuID+'allItems '+recursiveMenuIDSCC+' '+menuID+'item'+thisItemCSSid;
			itemTable.setAttribute('itemClass',mLevelsCss+cmiCSS+'menuBar '+menuID+'menuBar subMenu allItems '+menuID+'allItems '+recursiveMenuIDSCC+' '+menuID+'item'+thisItemCSSid);	
			itemTable.setAttribute('itemOverClass', mLevelsCssOver+mLevelsCss+menuID+"subMenuOver menuBar "+menuID+"menuBar subMenu "+menuID+"subMenu allItems "+menuID+"allItems allItemsOver "+menuID+"allItemsOver "+menuID+"item"+thisItemCSSid+"Over "+recursiveMenuIDSCCOver);
			
			if(!child.borderL){
					if (recursive == 'true') {
						child.borderL = xmlObj.borderL?xmlObj.borderL:'';
					}
					else {
						for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
								child.borderL = eval("myMenu.subMenuBorderL"+mLevel);	
								if (child.borderL != undefined && child.borderL != '') break;
						}
						if ((child.borderL == undefined || child.borderL == '') && myMenu.borderL) child.borderL = myMenu.borderL;
					}
			}
			borderL=child.borderL;
			if(!child.borderR){
					if (recursive == 'true') {
						child.borderR = xmlObj.borderR?xmlObj.borderR:'';
					}
					else {
						for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
								child.borderR = eval("myMenu.subMenuBorderR"+mLevel);	
								if (child.borderR != undefined && child.borderR != '') break;
						}
						if ((child.borderR == undefined || child.borderR == '') && myMenu.borderR) child.borderR = myMenu.borderR;
					}
			}
			borderR=child.borderR;
			if(! child.bullet){
					if (recursive == 'true') {
						child.bullet = xmlObj.bullet?xmlObj.bullet:'';
					}
					else {
						for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
								child.bullet = eval("myMenu.subMenuBullet"+mLevel);	
								if (child.bullet != undefined && child.bullet != '') break;
						}
						if ((child.bullet == undefined || child.bullet == '') && myMenu.bullet) child.bullet = myMenu.bullet;
					}
			}
			bullet=child.bullet;
				if(! child.recursive){
					child.recursive = false;
				}
				else if (child.recursive == 'true') {
						recursive=child.recursive;
						recursiveMenuID = recursiveMenuID + ' ' + menuID+'item'+thisItemId;
						recursiveMenuIDSCCOver = recursiveMenuIDSCCOver + ' ' + menuID+'item'+thisItemId+'Over ' + menuID+'subMenuOver'+submenuLevel;
				}
				
				var tr=itemTable.insertRow(0);						
				var indent, spacing;
				for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
						indent = eval("myMenu.subMenuPadding"+mLevel);	
						if (indent != undefined && indent != '') break;
				}				
				if (indent == undefined || indent == '') {
						if (myMenu.menuPadding != ''){
								indent = myMenu.menuPadding;	
						}
				}				
				
				for (mLevel = submenuLevel ; mLevel > 0 ; mLevel--) {
						spacing = eval("myMenu.subMenuSpacing"+mLevel);	
						if (spacing != undefined && spacing != '') break;
				}				
				if (spacing == undefined || spacing == '') {
						if (myMenu.menuSpacing != ''){
								spacing = myMenu.menuSpacing;	
						}
				}
				/*if (indent != undefined && indent != '') {
						var indentCell = tr.insertCell(-1);
						indentCell.innerHTML  = '<img src="/htm-webaxy/multimedia/r1.gif" height="1" width="'+indent+'">';
				}*/
				
				if (borderL) {
					var newCell = tr.insertCell(-1);
					if( borderL.search(/^http:/) !=-1 ){
						addText=document.createElement("img");
						addText.setAttribute('src', borderL);
						addText.setAttribute('noOnClick', true);
					}
					else{	addText=document.createTextNode(borderL);newCell.setAttribute('noOnClick',true);}
					newCell.appendChild(addText);
				}
				
				if (bullet) {
					newCell = tr.insertCell(-1);
					if( bullet.search(/^http:/) !=-1 ){
						addText=document.createElement("img");
						addText.setAttribute('src', bullet);
						addText.setAttribute('noOnClick', true);
						addText.className='bullets';
						newCell.style.verticalAlign = 'top';
					}
					else{
						addText=document.createTextNode(bullet);
						newCell.setAttribute('noOnClick',true);
					}
					newCell.appendChild(addText);
				}
				
				newCell = tr.insertCell(-1);
				newCell.style.width='100%';
				if(child.name){
					if(child.name.search(/^http:/) !=-1){
						addText=document.createElement("img");
						addText.setAttribute('src', child.name);
					}
					else{
						addText=document.createTextNode(child.name);
					}
				}
				else{
					addText=document.createTextNode('');
				}
				newCell.appendChild(addText);
				tr.setAttribute('data', tr.cells.length-1);
				
				if (borderR) {
					newCell = tr.insertCell(-1);
					if( borderR.search(/^http:/) !=-1 ){
						addText=document.createElement("img");
						addText.setAttribute('src', borderR);
						addText.setAttribute('noOnClick', true);
					}
					else{	addText=document.createTextNode(borderR);newCell.setAttribute('noOnClick',true);}
					newCell.appendChild(addText);
				}
				
			var link='javascript:void(0);';
			if(child.link) {//build click on menu item
				link=child.link;
				if (link.search(/@/) > 0 && link.search(/mailto/) != 0) link = 'mailto:'+link;
				/*if (link.search(/\?/) != -1) {
					link = link + '&cmi='+thisItemId+'m';
				}
				else {
					link = link + '?cmi='+thisItemId+'m';
				}*/
			}
			var target=child.target?child.target:'_self';
			var itemLink=document.createElement("a");
			itemLink.className='itemLink';
			itemLink.setAttribute('href', link);
			itemLink.setAttribute('target', target);
			itemTable=insertLinksInTable(itemLink,itemTable);
			
			//itemCell.appendChild(itemTable);
			
			divS.appendChild(itemTable);
			/////var itemCell2=menuTable.insertRow(-1).insertCell(0);
			/////itemCell2.appendChild(divS);
			
			var curItemUl=document.createElement("ul");
			//itemDiv.setAttribute('id', mID + '.' + thisItemId);
			curItemUl.setAttribute('menuId', menuID);
			curItemUl.setAttribute('vertical', vertical);
			curItemUl.style['display'] = 'none';
			//curItemUl.setAttribute('style', 'display: none;');
				
			//curItemUl.className = menuID+'menuPad '+menuID+'subMenuPad '+menuID+'subMenuPad'+submenuLevel;
			//itemDiv.className = 'mainMenuDiv';
				
			var itemLi=document.createElement("li");
			itemLi.setAttribute('menuId', menuID);
			itemLi.setAttribute('vertical', vertical);
			var menuDir;
			if (myMenu.dir == 'RTL' || myMenu.dir == 'rtl') {
				menuDir = 'Right';
			}
			else {
				menuDir = 'Left';
			}
			itemLi.style['display'] = 'none';
			//itemLi.style.display = 'none';
			if (indent) eval("divS.style.margin"+menuDir+" = '"+indent+"px'");
			//if (indent) eval("itemLi.style.padding"+menuDir+" = '"+indent+"px'");
			if (spacing) eval("curItemUl.style.paddingTop = '"+spacing+"px'");
				
			itemLi.appendChild(divS);
			curItemUl.appendChild(itemLi);
			itemUl.firstChild.appendChild(curItemUl);
			
			if (myMenu.currOpen == 'true' && cmiCSS) {
						//showMenuV(itemTable, menuID, theFatherId, '', false);
						//showByMenuLevel(menuID, 1, theFatherId, true);
						myMenu.currOpenID = theFatherId;
						myMenu.currOrigOpenID = thisItemId;
						myMenu.currOpenIDLevel = submenuLevel;
			}			
			
			if(child.items && child.items.length > 0){
				createSubMenuV(child, menuID, child.id, submenuLevel+1, recursive, recursiveMenuID, recursiveMenuIDSCCOver, vertical, menuTable, myMenu, curItemUl, theFatherId ,mainDivID);
			}
		//}
	}
	
	div.appendChild(submenuTable);
	myRe = /\d+/;
  myArray = myRe.exec(menuID);

	var id = myArray[0];
	
	//menuTable.appendChild(document.createTextNode("\n"));
	if (submenuLevel < 0) {
		var itemCell1=menuTable.insertRow(-1).insertCell(0);
		itemCell1.appendChild(div);
	}
	
}

//#--------------------------------------------------------------------------------------------------------------------------------------------------
function showElement(el,bolVisible){
	var updateBullet = 0;
	objStyle=document.getElementById(el).style;
	if(bolVisible){
		objStyle.visibility = "visible";
		el = el.replace(/\./, '_item_');
		cur_el = document.getElementById(el);
		if (cur_el && cur_el.getAttribute('bulletOver')) {
			bulletID = cur_el.id.replace(/item/, 'bullet');
			var previousVisible=getPreviousBulletVisible(cur_el.getAttribute('menuID'));
			var cur = bulletID;
			if(previousVisible == cur){return;}
			
			bullet = document.getElementById(bulletID);
			bullet.style.top = bullet.getAttribute('myHeight')+'px';
			bullet.style.height = '0px';
			var nySpeed;
			if (cur_el.getAttribute('bulletEffect') == 1) mySpeed = speed;
			else mySpeed = 1;
			inc = parseInt(parseInt(bullet.getAttribute('myHeight'))/mySpeed);
			//alert(inc);
			if (document.getElementById(menuID).getAttribute('bulletRunning') != 1 && (bullet.getAttribute('up') == 0 || !bullet.getAttribute('up') || (inc > 0 && parseFloat(bullet.style.height) == 0))) {
				document.getElementById(menuID).setAttribute('bulletRunning', 1);
				updateBullet = moveBullet(cur_el.getAttribute('menuID'), inc, mySpeed, bulletID);			
			}
			else if (!document.getElementById(menuID).getAttribute('bulletWaiting')) {
				document.getElementById(menuID).setAttribute('bulletWaiting', bulletID);
			}
		}
		else {
			//hidePreviousBullet(menuID, el, 1);
			//setPreviousBulletVisible(menuID, el);
		}
	}
	else{	
		/*
		tbID = el.replace(/\./, '_item_');
		cur_el = document.getElementById(tbID);
		if (cur_el && cur_el.getAttribute('bulletOver')) {
			var bulletID = cur_el.id.replace(/item/, 'bullet');
			var bullet = document.getElementById(bulletID);
			bullet.style.height = bullet.getAttribute('myHeight')+'px';
			bullet.style.top = '0px';
			inc = parseInt(bullet.getAttribute('myHeight'))/speed;
			var menuID = cur_el.getAttribute('menuID');
			if (bullet.getAttribute('up') == 1) moveBullet(menuID, -1*inc, speed, bulletID);
		}
		*/
		objStyle.visibility = "hidden";
	}
	return updateBullet;
}
//#------------------------------------------------------------

function getBounds(el, zero){ // return absolute left top width height of object
	
	var Left;
	var Top;
	if (zero) {Left = 0; Top = 0;}
	else {Left = el.offsetLeft;Top = el.offsetTop;}
	var myTarget = el;
	//while (parent = parent.offsetParent){
	while(myTarget!= document.body && myTarget != null) { 
		//alert(myTarget+':'+myTarget.id+':'+myTarget.offsetLeft+':'+Left);
		//alert(parent+':'+parent.id+':'+parent.offsetLeft+':'+Left);
		Left += myTarget.offsetLeft;
		Top += myTarget.offsetTop;
		myTarget = myTarget.offsetParent;
	}
	return {left: Left, top: Top, width: el.offsetWidth, height: el.offsetHeight};
}
//-----------------------------------------------------------

function hidePrevious(menuID, m){
	var previousVisible=getPreviousVisible(menuID);
	var cur =menuID+'.'+m;
	if(previousVisible == cur || !previousVisible){return;}
	
	if(previousVisible == menuID){return;}
	while((eval("cur.search(/^"+previousVisible+"\\D/)") ==-1) && previousVisible != cur){
		try{
			showElement(previousVisible, 0);
		}
		catch(e){;}
		lastD=previousVisible.match(/\d+$/);
		lastIDX=previousVisible.lastIndexOf(lastD);
		if(lastIDX > 0) lastIDX--;
		previousVisible=previousVisible.substring(0,lastIDX);
	}
}

function hidePreviousBullet(menuID, m, resetBullet) {
	
	var previousVisible=getPreviousBulletVisible(menuID);
	
	var cur =menuID+'_bullet_'+m;
	if(previousVisible == cur || !previousVisible){return;}
	var mySpeed;
	tbID = previousVisible.replace(/bullet/, 'item');
	tb = document.getElementById(tbID);
	if (tb.getAttribute('bulletEffect') == 1) mySpeed = speed;
	else mySpeed = 1;
	inc = parseInt(parseInt(bullet.getAttribute('myHeight'))/mySpeed);
	if (document.getElementById(previousVisible).getAttribute('bulletRunning') == 1) {// && !document.getElementById(previousVisible).getAttribute('up') == 1) {
		var prevElem = document.getElementById(previousVisible);
		if (prevElem.getAttribute('up') == 1 && parseFloat(prevElem.style.height) == parseFloat(prevElem.getAttribute('myHeight'))) {
			;
		}
		else {
		//if (previousVisible && document.getElementById(previousVisible)) document.getElementById(previousVisible).setAttribute('up', 0);
			return;		
		}
	}
	
	
	//itay//document.getElementById(menuID).setAttribute('bulletRunning', 1);
	if (document.getElementById(previousVisible)) document.getElementById(previousVisible).setAttribute('bulletRunning', 1);
	moveBullet(menuID, -1*inc, mySpeed, previousVisible, resetBullet);
	/*
	tbID = el.replace(/\./, '_item_');
		cur_el = document.getElementById(tbID);
		if (cur_el && cur_el.getAttribute('bulletOver')) {
			var bulletID = cur_el.id.replace(/item/, 'bullet');
			var bullet = document.getElementById(bulletID);
			bullet.style.height = bullet.getAttribute('myHeight')+'px';
			bullet.style.top = '0px';
			inc = parseInt(bullet.getAttribute('myHeight'))/speed;
			var menuID = cur_el.getAttribute('menuID');
			if (bullet.getAttribute('up') == 1) moveBullet(menuID, -1*inc, speed, bulletID);
		}
		*/
		
	
			
}

function getPreviousVisible(menuID){
	if(menuID){
		return document.getElementById(menuID).getAttribute('previsible');
		//if (document.getElementById(menuID)) return document.getElementById(menuID).getAttribute('previsible');
		//else return document.getElementById('previsible').value;
	}
	else{return 0;}
}

function getPreviousBulletVisible(menuID) {
	
	if(menuID){
		return document.getElementById(menuID).getAttribute('currentBulletRunning');
	}
	else{return 0;}
	
}

function setPreviousVisible(menuID, m){
	document.getElementById(menuID).setAttribute('previsible', menuID+'.'+m);
	//if (document.getElementById(menuID)) document.getElementById(menuID).setAttribute('previsible', menuID.toLowerCase()lse document.getElementById('previsible').value = menuID+'.'+m;
}

function setPreviousBulletVisible(menuID, m) {
	var id = menuID+'.'+m;
	id = id.replace(/\./, '_item_');
	var bulletID = id.replace(/item/, 'bullet');
	document.getElementById(menuID).setAttribute('currentBulletRunning', bulletID);
}
function fadeBullet(inc, index, id) {
		
		var next = 0;
		bullet = document.getElementById(id)
		var curOpacity;
		index--;
		if (index >= 0) {
				if (navigator.appVersion.indexOf("MSIE")!=-1) {
					curOpacity = curOpacity + inc*100;
					if (curOpacity < 0.1) curOpacity = 0;
					bullet.style.filter = "alpha(opacity=" + curOpacity + ")";
				}
				else {
					curOpacity = curOpacity + inc;
					if (curOpacity < 0.001) curOpacity = 0;
					bullet.style.opacity = curOpacity;
				}
				window.setTimeout("fadeBullet("+inc+", "+index+", '"+id+"')",30);
		}
		else {
			if (inc < 0) {
				bullet.style.top = bullet.getAttribute('myHeight')+'px';
				bullet.style.height = '0px';
			}
			else {
				if (navigator.appVersion.indexOf("MSIE")!=-1) {
					try { 
						if (bullet.style.filter == 'alpha(opacity=100)')
							bullet.style.filter = '';
					} catch (e) {
						
					}
				}
			}
		}
	}

function moveBullet(menuID, inc, index, id, resetBullet) {
		
		var bullet = document.getElementById(id);
		if (typeof(resetBullet) == 'undefined') resetBullet = 0;
		// first time
		if (index == speed) {
			divID = id.replace(/bullet/, 'bulletCell');
			document.getElementById(divID).style.zIndex = 100;
			// avoid duplicate moveBullet calls
			//if (bullet.getAttribute('up') == 1 && inc > 0 && parseFloat(bullet.style.height) != 0) {
			if ((bullet.getAttribute('up') == 1 && inc > 0 && parseFloat(bullet.style.height) != 0) || ((!bullet.getAttribute('up') || bullet.getAttribute('up') == 0) && inc < 0 && parseFloat(bullet.style.height) != parseFloat(bullet.getAttribute('myHeight')) )) {
				return;
			}
		}
		index--;
		if (index >= 0) {
				newHeight = parseFloat(bullet.style.height)+inc;
				if (newHeight < -1) {
					bullet.setAttribute('up', 0);
					return 0;
				}
				bullet.style.height = newHeight+'px';
				newTop = parseFloat(bullet.style.top)-inc;
				if (newTop < 0) newTop = 0;
				bullet.style.top = newTop+'px';
				window.setTimeout("moveBullet('"+menuID+"',"+inc+", "+index+", '"+id+"', "+resetBullet+")",30);
		}
		else {
			if (inc < 0) {
				//alert('move down bullet');
				bullet.style.top = bullet.getAttribute('myHeight')+'px';
				bullet.style.height = '0px';			
				bullet.setAttribute('up', 0);
				divID = id.replace(/bullet/, 'bulletCell');
				document.getElementById(divID).style.zIndex = -1;
				if (resetBullet == 1) {
					document.getElementById(menuID).setAttribute('currentBulletRunning', '');
				}
				else {
					;
				}
			}
			else {
				bullet.style.height = bullet.getAttribute('myHeight')+'px';
				bullet.setAttribute('up', 1);
				document.getElementById(menuID).setAttribute('bulletRunning', 0);
				if (document.getElementById(menuID).getAttribute('bulletWaiting')) {
					 var waitingBullet = document.getElementById(menuID).getAttribute('bulletWaiting');
					 if  (waitingBullet == id) {
					 		document.getElementById(menuID).setAttribute('bulletWaiting', ''); 	
					 }
					 else {
					 	 // calls the waiting bullet
					 	 	var mySpeed;
					 	 	var cur_el = document.getElementById(waitingBullet.replace(/bullet/, 'item'));
					 	 	var waitingBulletElem = document.getElementById(waitingBullet);
							if (cur_el.getAttribute('bulletEffect') == 1) mySpeed = speed;
							else mySpeed = 1;
							inc = parseInt(waitingBulletElem.getAttribute('myHeight'))/mySpeed;
							if (document.getElementById(menuID).getAttribute('bulletRunning') != 1 && (waitingBulletElem.getAttribute('up') == 0 || !waitingBulletElem.getAttribute('up') || (inc > 0 && parseFloat(waitingBulletElem.style.height) == 0))) {
								document.getElementById(menuID).setAttribute('bulletRunning', 1);
								updateBullet = moveBullet(menuID, inc, mySpeed, waitingBullet);			
								if (typeof(updateBullet) != 'undefined' && updateBullet) {
									//alert(waitingBullet.replace(/.+_bullet_/,''));
									hidePreviousBullet(menuID, waitingBullet.replace(/.+_bullet_/,''));
									setPreviousBulletVisible(menuID, waitingBullet.replace(/.+_bullet_/,''));
								}
							}
							else {
								document.getElementById(menuID).setAttribute('bulletWaiting', ''); 	
							}
								
							
					}
					 
				}
			}
			//itay//document.getElementById(menuID).setAttribute('bulletRunning', 0);
			bullet.setAttribute('bulletRunning', 0);
		}
		return 1;
	}

function showMenu(cur_el, menuID, m) { // cur_el -> curient element object, m ->menu for view
	var updateBullet = 0;
	try{		
		divObj=document.getElementById(''+menuID+'.'+m);
		var thisObjBounds, thisObjBound1;
		/*
		thisObjBounds=getBounds(cur_el)
		var cur_el_div = document.getElementById(cur_el.id.replace(/item/,'d'));
		if (cur_el_div) thisObjBounds1=getBounds(document.getElementById(cur_el.id.replace(/item/,'d')));
		if (!cur_el_div || (thisObjBounds.left == thisObjBounds1.left && thisObjBounds.top == thisObjBounds1.top)) ;//thisObjBounds=getBounds(cur_el);
		else {
			thisObjBounds=getBounds(cur_el_div,1);
			thisObjBounds.left = thisObjBounds.left - cur_el.clientWidth; 
		}
		*/
		 // IE
		//var margTop = margLeft = 0;
		/*
		if(document.all && IEVersionNumber == 7) {
			//alert(document.getElementById('body').currentStyle.marginTop);
			margTop = parseInt(document.getElementById('body').currentStyle.marginTop);
			margLeft = parseInt(document.getElementById('body').currentStyle.marginLeft);
		}
		else {
			//alert(document.defaultView.getComputedStyle(document.getElementById('body'),'').getPropertyValue('margin-top'));
			//marg = parseInt(document.defaultView.getComputedStyle(document.getElementById('body'),'').getPropertyValue('margin-top'));
		}
		*/		
		var sp = 0;
		
		if (document.getElementById(menuID).dir.toLowerCase() =='rtl' && document.getElementById(menuID) && document.getElementById(menuID).getAttribute('sp') > 0) {
			sp = document.getElementById(menuID).getAttribute('sp');
			var cur_el_div = document.getElementById(cur_el.id.replace(/item/,'d'));
			
			if(sp == 2 || IEVersionNumber > 7 || navigator.appVersion.indexOf("MSIE")==-1) {
				thisObjBounds=getBounds(cur_el_div,1);
				thisObjBounds.left = thisObjBounds.left + margLeft - divObj.clientWidth;
			}
			else {
				thisObjBounds=getBounds(cur_el_div,1);
				thisObjBounds.left = thisObjBounds.left + margLeft - parseFloat(cur_el_div.style.right)-divObj.clientWidth+thisObjBounds.width;
			}			
		}
		else {
			thisObjBounds=getBounds(cur_el);
		}
		
		if( (document.getElementById(menuID).dir.toLowerCase() =='rtl') && (thisObjBounds.left-divObj.offsetWidth+thisObjBounds.width > minMargin) ){
				divObj.style.left = thisObjBounds.left+margLeft+'px';
				if (sp == 0) divObj.style.left = thisObjBounds.left+margLeft-divObj.offsetWidth+thisObjBounds.width+"px";
				var idd = cur_el.parentNode.parentNode.parentNode.parentNode.parentNode.id;
				idd = idd.replace(/_d/,'');
				idd = idd.replace(/_/g,'.');				
				if (idd && document.getElementById(idd).getAttribute('dcd') != 1) divObj.dir ='rtl';
				divObj.firstChild.style.left = divObj.style.left;
		}
		else{
			divObj.style.left = thisObjBounds.left+margLeft+"px";
			divObj.dir ='ltr';
		}
		//alert(thisObjBounds);
		if (document.getElementById(menuID).getAttribute('opensUp') == 1) {
			divObj.style.top =  thisObjBounds.top-divObj.clientHeight+margTop+"px";
		}
		else {
			if (IEVersionNumber < 8 && navigator.appVersion.indexOf("MSIE") >= 0 && document.getElementById(menuID).dir.toLowerCase() =='rtl' && document.getElementById(menuID) && document.getElementById(menuID).getAttribute('sp') == 1) {
				divObj.style.top =  thisObjBounds.top+0+margTop+"px";	
			}
			else {
				divObj.style.top =  thisObjBounds.top+thisObjBounds.height+0+margTop+"px";	
			}			
			
		}
		//if (typeof(divObj.toolTip) != 'defined' && divObj.toolTip == 'true') {
			/*if (typeof(divObj.toolTipCoordX) != 'undefined' && divObj.toolTipCoordX)
				divObj.style.left = divObj.toolTipCoordX+'px';
			if (typeof(divObj.toolTipCoordY) != 'undefined' && divObj.toolTipCoordY)
				divObj.style.top = divObj.toolTipCoordY+'px';
			*/
			try {
				if (typeof(divObj.subMenuCoordsX) != 'undefined' && divObj.subMenuCoordsX) {
				var posX = parseInt(eval(menuID+"PosX"));
				var posY = parseInt(eval(menuID+"PosY"));
				if (document.getElementById(menuID).dir.toLowerCase() =='rtl')
					divObj.style.left = posX+parseInt(divObj.subMenuCoordsX)-divObj.clientWidth+'px';
				else
					divObj.style.left = posX+parseInt(divObj.subMenuCoordsX)+'px';
				divObj.style.zIndex = divObj.id.replace(/\D+/g,'');
			}
			if (typeof(divObj.subMenuCoordsY) != 'undefined' && divObj.subMenuCoordsY) {
				divObj.style.top = posY+parseInt(divObj.subMenuCoordsY)+'px';
				divObj.style.zIndex = divObj.id.replace(/\D+/g,'');
			}
		} catch(e) {}
		//}
		
		updateBullet = showElement(menuID+'.'+m, true);
	}catch(e){
		//alert(e);
		el = menuID+'.'+m;
		el = el.replace(/\./, '_item_');
		cur_el = document.getElementById(el);
		if (cur_el && cur_el.getAttribute('bulletOver')) {
			bulletID = cur_el.id.replace(/item/, 'bullet');
			var previousVisible=getPreviousBulletVisible(cur_el.getAttribute('menuID'));
			var cur = bulletID;
			if(previousVisible == cur){return;}
			
			bullet = document.getElementById(bulletID);
			bullet.style.top = bullet.getAttribute('myHeight')+'px';
			bullet.style.height = '0px';
			var mySpeed;
			if (cur_el.getAttribute('bulletEffect') == 1) mySpeed = speed;
			else mySpeed = 1;
			inc = parseInt(bullet.getAttribute('myHeight'))/mySpeed;
			//if ((bullet.getAttribute('up') == 1 && inc > 0 && parseFloat(bullet.style.height) != 0) || ((!bullet.getAttribute('up') || bullet.getAttribute('up') == 0) && inc < 0 && parseFloat(bullet.style.height) != parseFloat(bullet.getAttribute('myHeight')) )) {
			if (document.getElementById(menuID).getAttribute('bulletRunning') != 1 && (bullet.getAttribute('up') == 0 || !bullet.getAttribute('up') || (inc > 0 && parseFloat(bullet.style.height) == 0))) {
				document.getElementById(menuID).setAttribute('bulletRunning', 1);
				updateBullet = moveBullet(cur_el.getAttribute('menuID'), inc, mySpeed, bulletID);			
			}
			else if (!document.getElementById(menuID).getAttribute('bulletWaiting')) {
				document.getElementById(menuID).setAttribute('bulletWaiting', bulletID);
			}
		}
	}
	hidePrevious(menuID, m);
	setPreviousVisible(menuID, m);
	// take care of bullet
	if (typeof(updateBullet) != 'undefined' && updateBullet) {
		hidePreviousBullet(menuID, m);
		setPreviousBulletVisible(menuID, m);
	}
}

function showMenuV(cur_el, menuID, m, origNode, noOnClick) { // cur_el -> curient element object, m ->menu for view
	if ((origNode == 'IMG' || origNode == 'TD' || noOnClick) && navigator.appVersion.indexOf("MSIE")!=-1) return;
	try{
		var prev = getPreviousVisible(menuID);
		var cur_el_id = menuID + '.' + m;
		var cur_level = cur_el.getAttribute('menulevel');
		if (cur_el_id == prev) {
			setPreviousVisible(menuID, '');
			showByMenuLevel(menuID, parseInt(cur_el.getAttribute('menulevel'))+1, m, false);
		}
		else {
			var mID = menuID.replace(/M/,'Menu');
			var els = document.getElementById(mID).getElementsByTagName('div');
			//check if one of my child is open, so I close myself.
			var found = false;
			for(var i=0; i<els.length; i++){
				index = els[i].id.indexOf(cur_el_id+'.');						
				if (index == 0 && els[i].id != cur_el_id && els[i].style.display == 'block') { 
						found = true;
						break;
				}
			}
			if (found) {
				showByMenuLevel(menuID, parseInt(cur_level)+1, m, false);
				m = '';
			}
			else {
				showByMenuLevel(menuID, parseInt(cur_el.getAttribute('menulevel'))+1, m, true);
				var emptyEl = menuID + '.';    // check current not prev child
				if (prev && prev != emptyEl && cur_el_id.indexOf(prev+'.') != 0) {
					var prev_id = prev.split(menuID+'.',2)[1];
					var prev_level = document.getElementById(prev).firstChild.getAttribute('menulevel');
					// if current father of prev
					if (prev.indexOf(cur_el_id) == 0) {
						showByMenuLevel(menuID, parseInt(cur_level)+1, m, false);
						m = '';
					}
					else {
						for(var i=0; i<els.length; i++){
							if (prev.indexOf(els[i].id) == 0 && els[i].firstChild.getAttribute('menulevel') == cur_level) {
									prev_id = els[i].id.split(menuID+'.',2)[1];
									prev_level = cur_level;
							}
						}
						showByMenuLevel(menuID, parseInt(prev_level)+1, prev_id, false);
					}
				}
			}
			setPreviousVisible(menuID, m);			
		}
		if (waIndex == 1) {wa1.value = '';}
		else {wa2.value = '';}
	}catch(e){;}
	
}

function showMenuV2(cur_el, menuID, m, origNode, noOnClick) { // cur_el -> curient element object, m ->menu for view
	if ((origNode == 'IMG' || origNode == 'TD' || noOnClick) && navigator.appVersion.indexOf("MSIE")!=-1) return;
	try{
		var prev = '';//getPreviousVisible(menuID);
		var cur_el_id = menuID + '.' + m;
		var cur_level = cur_el.getAttribute('menulevel');
		if (cur_el_id == prev) {
			setPreviousVisible(menuID, '');
			showByMenuLevel(menuID, parseInt(cur_el.getAttribute('menulevel'))+1, m, false);
		}
		else {
			var mID = menuID.replace(/M/,'Menu');
			var els = document.getElementById(mID).getElementsByTagName('div');
			//check if one of my child is open, so I close myself.
			var found = false;
			var index;
			for(var i=0; i<els.length; i++){
				index = els[i].id.indexOf(cur_el_id+'.');						
				if (index == 0 && els[i].id != cur_el_id && els[i].style.display == 'block') { 
						found = true;
						break;
				}
			}
			
			if (found) {
				showByMenuLevel(menuID, parseInt(cur_level)+1, m, false);
				m = '';
			}
			else {
				showByMenuLevel(menuID, parseInt(cur_el.getAttribute('menulevel'))+1, m, true, 'yes');
				var emptyEl = menuID + '.';    // check current not prev child
				if (prev && prev != emptyEl && cur_el_id.indexOf(prev+'.') != 0) {
					var prev_id = prev.split(menuID+'.',2)[1];
					var prev_level = document.getElementById(prev).firstChild.getAttribute('menulevel');
					// if current father of prev
					if (prev.indexOf(cur_el_id) == 0) {
						showByMenuLevel(menuID, parseInt(cur_level)+1, m, false);
						m = '';
					}
					else {
						for(var i=0; i<els.length; i++){
							if (prev.indexOf(els[i].id) == 0 && els[i].firstChild.getAttribute('menulevel') == cur_level) {
									prev_id = els[i].id.split(menuID+'.',2)[1];
									prev_level = cur_level;
							}
						}
						showByMenuLevel(menuID, parseInt(prev_level)+1, prev_id, false);
					}
				}
			}
			setPreviousVisible(menuID, m);			
		}
		if (waIndex == 1) {wa1.value = '';}
		else {wa2.value = '';}
	}catch(e){;}
	
}

function showByMenuLevel(menuID, level, m, open, keepOpen) {
	
	var cur_id = menuID+'.'+m;
	var mID = menuID.replace(/M/,'Menu');
	var els = document.getElementById(mID).getElementsByTagName('div');
	for(var i=0; i<els.length; i++){
		index = els[i].id.indexOf(menuID+'.'+m+'.');
		if (open) {
				if (index == 0 && els[i].firstChild && els[i].firstChild.getAttribute('menulevel') && els[i].firstChild.getAttribute('menulevel') == level) {
					els[i].style['display'] = 'block';
					els[i].parentNode.style['display'] = 'inline';
					var attrs = els[i].parentNode.parentNode.attributes;
					var myStyle = '';
					for (j=0;j<attrs.length;j++) {
							if (attrs[j].name == 'style') {
									myStyle = attrs[j].value;
									break;
							}
					}
					els[i].parentNode.parentNode.style['display'] = 'block';
				}
				else if (els[i].id != cur_id && els[i].firstChild.getAttribute('menulevel') >= level && level > 1 && !keepOpen){
					els[i].style['display'] = 'none';
					els[i].parentNode.style['display'] = 'none';
					els[i].parentNode.parentNode.style['display'] = 'none';
				}
		}
		else {
				if (index == 0 && els[i].firstChild && els[i].firstChild.getAttribute('menulevel') && els[i].firstChild.getAttribute('menulevel') >= level) {
					els[i].style['display'] = 'none';
					els[i].parentNode.style['display'] = 'none';
					els[i].parentNode.parentNode.style['display'] = 'none';
				}
		}
	}
}

//--------------
function showSubMenu(cur_el, menuID, m) {
	divObj=document.getElementById(''+menuID+'.'+m);
	if(divObj){
		padding = 0;
		if (cur_el.getAttribute('padding')) {
			padding = parseInt(cur_el.getAttribute('padding'));
		}
		//cur_el = 'M2_d_2';
		var thisObjBounds=getBounds(cur_el, 1);
		//alert(thisObjBounds.left+'::'+thisObjBounds.top);
		//var parentDir=cur_el.parentNode.parentNode.parentNode.parentNode.parentNode.dir.toLowerCase();
		var parentDir=cur_el.parentNode.parentNode.dir.toLowerCase();			
		
		if(parentDir !='rtl' && parentDir !='ltr'){
			if( (document.getElementById(menuID).dir.toLowerCase() =='rtl') && (thisObjBounds.left-divObj.offsetWidth+thisObjBounds.width > minMargin) ){
				divObj.dir ='rtl'; parentDir ='rtl';
			}
			else{
				divObj.dir ='ltr'; parentDir ='ltr';
			}
		}
		
		padding = 0;
		//if( parentDir == 'rtl' && (cur_el.dir == '' || cur_el.dir == 'rtl')){
		if( parentDir == 'rtl' ){
			if (thisObjBounds.left-divObj.offsetWidth < 0) {
				cur_el.dir = 'ltr';
				//cur_el.parentNode.parentNode.parentNode.parentNode.parentNode.dir = 'ltr';
				cur_el.parentNode.parentNode.dir = 'ltr';
				parentDir = 'ltr';
				//cur_el.parentNode.parentNode.parentNode.parentNode.parentNode.setAttribute('dcd', '1'); //donot change dir
				cur_el.parentNode.parentNode.setAttribute('dcd', '1'); //donot change dir
			}
			divObj.style.left = thisObjBounds.left-divObj.offsetWidth+padding+"px";
		}
		else{
			//alert(thisObjBounds.left+'::'+thisObjBounds.width);		
			divObj.style.left = thisObjBounds.left+thisObjBounds.width-padding+0+"px";
		}
		divObj.dir=parentDir;
		if (document.getElementById(menuID).getAttribute('opensUp') == 1) {
			divObj.style.top =  thisObjBounds.top+thisObjBounds.height-divObj.clientHeight+"px";
		}
		else {
			divObj.style.top =  thisObjBounds.top+"px";
		}
		if (typeof(divObj.subMenuCoordsX) != 'undefined' && divObj.subMenuCoordsX) {
			if (document.getElementById(menuID).dir.toLowerCase() =='rtl')
				divObj.style.left = divObj.subMenuCoordsX-divObj.clientWidth+'px';
			else
				divObj.style.left = divObj.subMenuCoordsX+'px';
			divObj.style.zIndex = divObj.id.replace(/\D+/g,'');
		}
		if (typeof(divObj.subMenuCoordsY) != 'undefined' && divObj.subMenuCoordsY) {
			divObj.style.top = divObj.subMenuCoordsY+'px';
			divObj.style.zIndex = divObj.id.replace(/\D+/g,'');
		}
				
		updateBullet = showElement(menuID+'.'+m, true);
	}
	hidePrevious(menuID, m);
	setPreviousVisible(menuID, m);
}

//----------------------------------------------------
function hideMenu(mID, resetBullet){ //Hide menu with delay
	if (typeof(resetBullet) == 'undefined') resetBullet = 0;
	var menu=document.getElementById(mID);
	if (menu.getAttribute('hide') == 0) return;
	if(menu.tStatus==1){// hide menu
		hidePrevious(mID, '');
		hidePreviousBullet(mID, '', resetBullet);
	}
	else{ // Start timer for hide menu
		menu.timer=setTimeout("hideMenu('"+mID+"', "+resetBullet+")",hide_delay);
		menu.tStatus=1; // Timer is work
	}
}
function unhideMenu(mID) { // Stop timer and don't hide menu 
	var menu=document.getElementById(mID);
	if (menu.tStatus==1) { // If timer working
		clearTimeout(menu.timer);
		menu.tStatus=0;
	}
}
//#------------------------------------------------------------
function buildCSS(CSS_xmlNODE, mID){
	var styles = document.createElement('style');
	styles.setAttribute('type', 'text/css');
	objHead.appendChild(styles);
	var thisStyleSheet = document.styleSheets[document.styleSheets.length-1];

	var StyleRule=CSS_xmlNODE.firstChild;
	while (StyleRule){
		if(StyleRule.nodeType==1){
			var ruleName=mID+''+StyleRule.attributes.getNamedItem('name').value;
			ruleName='.'+ruleName.replace(/\./g,'_');
			var ruleValues='';
			if(StyleRule.hasChildNodes()){
				for(var rulesNod=StyleRule.firstChild; rulesNod != null; rulesNod=rulesNod.nextSibling){
					if(rulesNod.nodeType==1){ruleValues +=rulesNod.attributes.getNamedItem('name').value+': '+rulesNod.attributes.getNamedItem('value').value+';';}
				}
			}
			if( thisStyleSheet.insertRule ){//Mozilla & Opera add rule to the end of style
				thisStyleSheet.insertRule( ruleName+' { '+ruleValues+' }', thisStyleSheet.cssRules.length);
			}
			else if( thisStyleSheet.addRule ){// IE add rule to the end of style
				thisStyleSheet.addRule(ruleName, ruleValues);
			}
			//---------------   FIX for A styles in page --------
			if( (ruleName.search(/over/i) !=-1) || (ruleName.search(/item/i) !=-1) || (ruleName.search(/menuBar/i) !=-1) || (ruleName.search(/subMenu/i) !=-1) ){
				if( thisStyleSheet.insertRule ){//Mozilla & Opera add rule to the end of style
					thisStyleSheet.insertRule( ruleName+':link { '+ruleValues+' }', thisStyleSheet.cssRules.length);
					thisStyleSheet.insertRule( ruleName+':hover { '+ruleValues+' }', thisStyleSheet.cssRules.length);
					thisStyleSheet.insertRule( ruleName+':visited { '+ruleValues+' }', thisStyleSheet.cssRules.length);
					
				}
				else if( thisStyleSheet.addRule ){// IE add rule to the end of style
					thisStyleSheet.addRule(ruleName+':link', ruleValues);
					thisStyleSheet.addRule(ruleName+':hover', ruleValues);
					thisStyleSheet.addRule(ruleName+':visited', ruleValues);
					
				}
			}
			/*else if(ruleName.search(/item/i) !=-1){
				if( thisStyleSheet.insertRule ){//Mozilla & Opera add rule to the end of style
					thisStyleSheet.insertRule( ruleName+':link { '+ruleValues+' }', thisStyleSheet.cssRules.length);
					thisStyleSheet.insertRule( ruleName+':hover { '+ruleValues+' }', thisStyleSheet.cssRules.length);
					thisStyleSheet.insertRule( ruleName+':visited { '+ruleValues+' }', thisStyleSheet.cssRules.length);
				}
				else if( thisStyleSheet.addRule ){// IE add rule to the end of style
					thisStyleSheet.addRule(ruleName+':link', ruleValues);
					thisStyleSheet.addRule(ruleName+':hover', ruleValues);
					thisStyleSheet.addRule(ruleName+':visited', ruleValues);
				}
			}*/
			//------------------------------------------------
		}StyleRule=StyleRule.nextSibling;
	}
}
//---------------------------------------------------------------------------------------------
function __onDOMLoad(){;}

//#------------------------------------------------------------
function checkDOMandRun(){
	var preDOMonload = window.__onDOMLoad;
	window.__onDOMLoad = function() {
		preDOMonload();
		if(navigator.appVersion.indexOf("MSIE")!=-1 && window.noMenuTrick!=1){
			setTimeout("document.body.innerHTML+='';", 500);
		}
		setTimeout("MNav.init();", 700);
	}
/* for Mozilla/Firefox/Opera 9 */
if (document.addEventListener) {
   try{ document.addEventListener("DOMContentLoaded", __onDOMLoad(), false);}
   catch(e){}
//	return ;
}
//#------------------------------------------------------------
/* for Internet Explorer */
else if(navigator.appVersion.indexOf("MSIE")!=-1 && window == top ){// If IE is used and is not in a frame	
	//based on http://javascript.nwbox.com/IEContentLoaded/
	var d = window.document, done = false,
	// only fire once
	init = function () {
		if (!done) {
			done = true;
			__onDOMLoad();
		}
	};
	// polling for no errors
	(function () {
		try {
			// throws errors until after ondocumentready
			d.documentElement.doScroll('left');
		} catch (e) {
			setTimeout(arguments.callee, 50);
			return;
		}
		// no errors, fire
		init();
	})();
	// trying to always fire before onload
	d.onreadystatechange = function() {
		if (d.readyState == 'complete') {
			d.onreadystatechange = null;
			init();
		}
	};
//return;
}
//#------------------------------------------------------------

/* for Safari */
else if (/WebKit/i.test(navigator.userAgent)) {
    var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
		    clearInterval(_timer);
		    __onDOMLoad(); // call to init
		}
    }, 10);
//    return;
}
//#------------------------------------------------------------
else{
/* for all other browsers */
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = function(){
			__onDOMLoad();
		}
	}
	else {
		window.onload = function(){
			if (oldonload) {oldonload();}
			__onDOMLoad();
		}
	}
}
//#------------------------------------------------------------
}


function onMenuItemClickV1(e) {
		var itemTable=getEventTarget(e);
		var origNode = itemTable.nodeName;
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
//		debugView('CLICK:e'+itemTable.nodeName +'; menuId='+itemTable.getAttribute('menuId')+'; itemId='+itemTable.getAttribute('itemId'));
		if(itemTable.getAttribute('menuId')){
			var td=itemTable.rows[0].cells[itemTable.rows[0].getAttribute('data')];
			for (var c = 0;c < td.childNodes.length; c++) {
				if (td.childNodes[c].tagName && (td.childNodes[c].tagName.toLowerCase() == 'a')) {
					if (td.childNodes[c].click) {	// IE
						td.childNodes[c].click();
					}
					//else {//FF
					var mID=itemTable.getAttribute('menuId');
					var itemId=itemTable.getAttribute('itemId');
					showMenuV(itemTable, mID, itemId, itemTable);
					//}
				}
			}
		}
		return true;
}

//#------------------------------------------------------------
var MNav = {
	
	init: function(id){
		
		//alert(id+':'+document.getElementById(id));
		if (!document.getElementById(id)) {
				setTimeout("MNav.init('"+id+"');", 100);
				return;
		}
		//var allMenuDivs=getElementsByClassNameAndTagName('menuDiv', 'div');
		var allMenuDivs = [];
		allMenuDivs.push(document.getElementById(id));			
		//alert('init:'+allMenuDivs.length);
		for(var i=0; i<allMenuDivs.length; i++){
			//for clickAdmin
				var allMenuClickAdminImg=getElementsByClassNameAndTagName('menuClickAdminImg', 'img', allMenuDivs[i]);
				if(allMenuClickAdminImg.length){allMenuClickAdminImg[0].onclick=new Function("openMenuAdmin('"+allMenuClickAdminImg[0].getAttribute('menuId')+"');");}
			//--------------------------------
			var vertical = allMenuDivs[i].getAttribute('vertical');
			if (vertical > 1) {
				//allMenuDivs[i].firstChild.onclick=this.onMenuItemClickV;
				//allMenuDivs[i].firstChild.onclick=this.onMenuItemClickV;
			}
			else if (vertical == 1) {
				allMenuDivs[i].onmouseout=this.onMenuDivOut;
				allMenuDivs[i].onmouseover=this.onMenuDivOver;
				allMenuDivs[i].firstChild.onmouseover=this.onMenuOver;
				allMenuDivs[i].firstChild.onmouseout=this.onMenuOut;
				allMenuDivs[i].firstChild.onclick=this.onMenuItemClick;
			}
			else {
				allMenuDivs[i].onmouseout=this.onMenuDivOut;
				allMenuDivs[i].onmouseover=this.onMenuDivOver;
				
				allMenuDivs[i].firstChild.onmouseover=this.onMenuOver;
				allMenuDivs[i].firstChild.onmouseout=this.onMenuOut;
				allMenuDivs[i].firstChild.onclick=this.onMenuItemClick;
				
				/*for (var j = 0 ; j < allMenuDivs[i].childNodes.length ; j++) {
					if (allMenuDivs[i].childNodes[j].childNodes[0] && allMenuDivs[i].childNodes[j].childNodes[0].nodeName == 'TABLE') {
						allMenuDivs[i].childNodes[j].onmouseover=this.onMenuOver;
						allMenuDivs[i].childNodes[j].onmouseout=this.onMenuOut;
						allMenuDivs[i].childNodes[j].onclick=this.onMenuItemClick;
					}
				}*/
			}
		}
		var allMainMenuDiv=getElementsByClassNameAndTagName('mainMenuDiv', 'div');
		for(var i=0; i<allMainMenuDiv.length; i++){
			var vertical = allMainMenuDiv[i].getAttribute('vertical');
			if (vertical > 1) {
				/*allMainMenuDiv[i].firstChild.onclick=function() {
						this.noBubble;
						this.onMenuItemClickV;
					};*/
				allMainMenuDiv[i].firstChild.onclick=this.onMenuItemClickV;
				allMainMenuDiv[i].firstChild.onmouseover=this.onMenuOverV;
				allMainMenuDiv[i].firstChild.onmouseout=this.onMenuOutV;
			}			
		}
		var allSubMenuDiv=getElementsByClassNameAndTagName('subMenuDivV', 'div');
		for(var i=0; i<allSubMenuDiv.length; i++){
			allSubMenuDiv[i].firstChild.onclick=this.onMenuItemClickV;
			allSubMenuDiv[i].firstChild.onmouseover=this.onMenuOverV;
			allSubMenuDiv[i].firstChild.onmouseout=this.onMenuOutV;
		}
		var allSubMenuDiv=getElementsByClassNameAndTagName('subMenuDiv', 'div');	
		for(var i=0; i<allSubMenuDiv.length; i++){
				allSubMenuDiv[i].onmouseout=this.onMenuDivOut;
				allSubMenuDiv[i].onmouseover=this.onMenuDivOver;
				allSubMenuDiv[i].firstChild.onmouseover=this.onMenuOver;
				allSubMenuDiv[i].firstChild.onmouseout=this.onMenuOut;
				allSubMenuDiv[i].firstChild.onclick=this.onMenuItemClick;
		}
	},
	noBubble: function(event) {
			  
			  event = event || window.event;
			  if (!event) {
                return;
        }
        
       if (event.stopPropagation) {
			     event.stopPropagation();
        }
        else {
                try {
                        event.cancelBubble = true;
                }
                catch(e) {}
        }
	},
	onMenuDivOut: function(e) {
		var menuDiv=getEventTarget(e);
		while(menuDiv.nodeName.toLowerCase() != 'div' || (menuDiv.nodeType == 3) ){
			//alert(menuDiv.id+':'+menuDiv.nodeNa+':'+menuDiv.nodeType);
			menuDiv=menuDiv.parentNode;
		}
		var idToHide = '';
		//alert(menuDiv.id+':'+menuDiv.nodeType+':'+targ+':'+document.getElementById('M110').getAttribute('previsible'));
		if (menuDiv.getAttribute('menuId')) { 
			idToHide = menuDiv.getAttribute('menuId');
		}
		else if (menuDiv.nodeName.toLowerCase() == 'div' && menuDiv.id.search(/M\d+_d_\d+/) != -1) {
			idToHide = menuDiv.id.replace(/_d_\d+/,'');
		}
			
		//alert('onMenuDivOut:'+menuDiv+':'+menuDiv.id+':'+idToHide);
		
//		debugView('hideMenu '+menuDiv.getAttribute('menuId')+';');
		if(idToHide){
			document.getElementById(idToHide).setAttribute('hide', 1);
			setTimeout("hideMenu('"+idToHide+"', 1);", 200);
		}
		return true;
	},
	onMenuDivOver: function(e) {
		var menuDiv=getEventTarget(e);
		while(menuDiv.nodeName.toLowerCase() != 'div' || (menuDiv.nodeType == 3) ){
			menuDiv=menuDiv.parentNode;
		}
		var idToShow = '';
		if (menuDiv.getAttribute('menuId')) { 
			idToShow = menuDiv.getAttribute('menuId');
		}
		else if (menuDiv.nodeName.toLowerCase() == 'div' && menuDiv.id.search(/M\d+_d_\d+/) != -1) {
			idToShow = menuDiv.id.replace(/_d_\d+/,'');
		}
		
		//alert('omdo:'+menuDiv+':'+menuDiv.id+':'+idToShow+':'+document.getElementById(idToShow).getAttribute('hide'));
//		debugView('unhideMenu '+menuDiv.getAttribute('menuId')+';');

		////if(menuDiv.getAttribute('menuId')){unhideMenu(menuDiv.getAttribute('menuId'));}
		if(idToShow){
				document.getElementById(idToShow).setAttribute('hide', 0);
				unhideMenu(idToShow);
		}
		
		return true;
	},
	onMenuOver: function(e) {
		var itemTable=getEventTarget(e);
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
//		debugView('IN: '+itemTable.nodeName +'; HTML=<code>'+itemTable.innerHTML+'</code>; menuId='+itemTable.getAttribute('menuId')+'; itemId='+itemTable.getAttribute('itemId'));
		//alert(itemTable.getAttribute('itemId'));
		if(itemTable.getAttribute('menuId')){
				var mID=itemTable.getAttribute('menuId');
				var itemId=itemTable.getAttribute('itemId');
				var thisItemCSSid=itemId.replace(/\./g,'_');
	//			setItemClassName(itemTable, "menuBar "+mID+"menuBar allItems "+mID+"allItems "+mID+"item"+thisItemCSSid+" allItemsOver "+mID+"allItemsOver "+mID+"item"+thisItemCSSid+"Over", "allItems "+mID+"allItems "+mID+"item"+thisItemCSSid+" allItemsOver "+mID+"allItemsOver "+mID+"item"+thisItemCSSid+"Over");
				setItemClassName(itemTable, itemTable.getAttribute('itemOverClass'), "allItems "+mID+"allItems "+mID+"item"+thisItemCSSid+" allItemsOver "+mID+"allItemsOver "+mID+"item"+thisItemCSSid+"Over");
				//alert(itemId+':'+itemTable.toolTip);
				if (typeof(itemTable.toolTip) != 'undefined' && itemTable.toolTip == 1) {
						if (typeof(itemTable.toolTipFile) != 'undefined' && typeof(itemTable.toolTipFileCell) != 'undefined') {
								//alert('bring '+itemTable.toolTipFile+': cell'+itemTable.toolTipFileCell);
								//getPageCell(itemTable, mID, itemId);
						}
				}
				else {
					if( itemTable.getAttribute('vertical') || (itemTable.getAttribute('menuLevel') >0)){
						showSubMenu(itemTable, mID, itemId);
					}
					else{
						showMenu(itemTable, mID, itemId);
					}
				}
		}
		return true;
	},
	onMenuOverV: function(e) {
		var itemTable=getEventTarget(e);
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
		if(itemTable.getAttribute('menuId')){
			var mID=itemTable.getAttribute('menuId');
			var itemId=itemTable.getAttribute('itemId');
			var thisItemCSSid=itemId.replace(/\./g,'_');
			setItemClassName(itemTable, itemTable.getAttribute('itemOverClass'), "allItems "+mID+"allItems "+mID+"item"+thisItemCSSid+" allItemsOver "+mID+"allItemsOver "+mID+"item"+thisItemCSSid+"Over");			
		}
		return true;
	},
	onMenuOut: function(e) {
		var itemTable=getEventTarget(e);
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
//		debugView('OUT: '+itemTable.nodeName +'; menuId='+itemTable.getAttribute('menuId')+'; itemId='+itemTable.getAttribute('itemId'));
		if(itemTable.getAttribute('menuId')){
			var mID=itemTable.getAttribute('menuId');
			var itemId=itemTable.getAttribute('itemId');
			var thisItemCSSid=itemId.replace(/\./g,'_');
//			setItemClassName(itemTable, "menuBar "+mID+"menuBar allItems "+mID+"allItems "+mID+"item"+thisItemCSSid, "allItems "+mID+"allItems "+mID+"item"+thisItemCSSid);
			setItemClassName(itemTable, itemTable.getAttribute('itemClass'), "allItems "+mID+"allItems "+mID+"item"+thisItemCSSid);
		}
		return true;
	},
	onMenuOutV: function(e) {
		var itemTable=getEventTarget(e);
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
		if(itemTable.getAttribute('menuId')){
			var mID=itemTable.getAttribute('menuId');
			var itemId=itemTable.getAttribute('itemId');
			var thisItemCSSid=itemId.replace(/\./g,'_');
			setItemClassName(itemTable, itemTable.getAttribute('itemClass'), "allItems "+mID+"allItems "+mID+"item"+thisItemCSSid);
		}
		return true;
	},
	onMenuItemClick: function(e) {
		var itemTable=getEventTarget(e);
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
//		debugView('CLICK: '+itemTable.nodeName +'; menuId='+itemTable.getAttribute('menuId')+'; itemId='+itemTable.getAttribute('itemId'));
		if(itemTable.getAttribute('menuId')){
			var rowIndex = 0;
			/*if (itemTable.getAttribute('upperbullet') == 1 && itemTable.rows[1]) rowIndex = 1;
			else rowIndex = 0;	*/
			var td=itemTable.rows[rowIndex].cells[2];
			//alert(itemTable.rows[rowIndex].id);
			//alert(td.childNodes.length);
			for (var c = 0;c < td.childNodes.length; c++) {
				//alert(c+'::'+td.childNodes[c].tagName.toLowerCase()+'::');
				if (td.childNodes[c].tagName && (td.childNodes[c].tagName.toLowerCase() == 'a')) {
					if (td.childNodes[c].click) {	// IE
						td.childNodes[c].click();
					}
					else {//FF
					}
				}
			}
		}
		return true;
	},
	onMenuItemClickV: function(e) {
		//MNav.noBubble(e);
		//alert('pre nb'+window.event.cancelBubble);
		var itemTable=getEventTarget(e);
		//alert(itemTable+':'+itemTable.nodeName+':'+itemTable.id);
		var origItem = itemTable;
		var flag = 0;
		var origNode = itemTable.nodeName;
		var noOnClick = false;
		//alert(origItem.parentNode.nodeName+':'+origItem.parentNode.getAttribute('noOnClick'));
		if (origNode == 'A' && origItem.parentNode.getAttribute('noOnClick')) noOnClick = true;
		while(itemTable.nodeName.toLowerCase() != 'table' || (itemTable.nodeType == 3) ){
			itemTable=itemTable.parentNode;
		}
		if(!flag && itemTable.getAttribute('menuId')){
			var td=itemTable.rows[0].cells[itemTable.rows[0].getAttribute('data')];
			for (var c = 0;c < td.childNodes.length; c++) {
				if (td.childNodes[c].tagName && (td.childNodes[c].tagName.toLowerCase() == 'a')) {
					//alert(td.childNodes[c]);
					if (td.childNodes[c].click) {	// IE
						td.childNodes[c].click();
					}
					else {
						//alert(td.childNodes[c].href+':'+td.childNodes[c].target)
						window.open(td.childNodes[c].href, td.childNodes[c].target? td.childNodes[c].target : '_self');
					}
					var mID=itemTable.getAttribute('menuId');
					var itemId=itemTable.getAttribute('itemId');
					if (itemTable.getAttribute('autoclose') == 'true') {
						showMenuV(itemTable, mID, itemId, origNode, noOnClick);
					}
					else {
						showMenuV2(itemTable, mID, itemId, origNode, noOnClick);
					}
				}
			}
		}
		return true;
	}
	
}

//#------------------------------------------------------------
function setItemClassName(itemTable, itemClassName, linksClassName){
//	debugView('setItemClassName:'+itemTable.outerHTML+', '+itemClassName+', '+linksClassName);
	itemTable.className=itemClassName;
	var rowIndex = 0;
	/*if (itemTable.getAttribute('upperbullet') == 1 && itemTable.rows[1]) rowIndex = 1;
	else rowIndex = 0;*/
	for (var c=0; c<itemTable.rows[rowIndex].cells.length; c++){
		if(itemTable.rows[rowIndex].cells[c].hasChildNodes() && itemTable.rows[rowIndex].cells[c].firstChild.nodeName.toLowerCase() == 'a'){
//			itemTable.rows[0].cells[c].firstChild.className=linksClassName;
			itemTable.rows[rowIndex].cells[c].firstChild.className=itemClassName;
		}
	}
}
//function setItemClassName(obj, itemClassName, linksClassName){
//	if (obj.tagName == "TABLE") {
//			obj.className = itemClassName;
//			for (var r = 0; r < obj.rows.length; r++) {
//				for (var c = 0; c < obj.rows[r].cells.length; c++) {
//					setItemClassName(obj.rows[r].cells[c], itemClassName, linksClassName);
//				}
//			}
//		}
//		else if (obj.tagName == "TD") {
//			for (var c = 0;c < obj.childNodes.length; c++) {
////				if (obj.childNodes[c].className && (obj.childNodes[c].className == (on ? classOff : classOn))) {
//					obj.childNodes[c].className = linksClassName;
////				}
//			}
//		}
//}
//#------------------------------------------------------------
function getEventTarget(e) {
	var e = e || window.event;
	targ = e.target || e.srcElement;
	while (targ.nodeType == 3) { // for  Safari 
		targ = targ.parentNode;
	}
	return targ;
}
//#------------------------------------------------------------
function getElementsByClassNameAndTagName(classname, tag, node){
	//alert('start geat:'+classname);
	if(!node){node = document.getElementsByTagName("body")[0];}
	if(!tag){tag="*";}
	var a = [];
	//var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName(tag);
	//alert('get:'+classname+':'+els.length);
	for(var i=0; i<els.length; i++){
		var index = els[i].className.search(classname);
		var cn = els[i].className;
		if (index >= 0) {
			var endClassname = index + classname.length;
			//alert(classname+':'+cn+':'+endClassname+':'+cn.charAt(endClassname));
			if (endClassname == els[i].className.length || els[i].className.charAt(endClassname) == ' ') a.push(els[i]);			
		}
		//if(re.test(els[i].className)){a.push(els[i]);}
//		if(els[i].className==classname){a.push(els[i]);}
	}
	return a;
}
//#------------------------------------------------------------
function debugView(str){
	document.getElementById('debugDiv').innerHTML=str.replace(/</g,'&lt;').replace(/\n/g,'<br>')+'<br>'+document.getElementById('debugDiv').innerHTML;
}

function noBubble1(event) {
			  
			  event = event || window.event;
       if (!event) {
                return;
        }
       if (event.stopPropagation) {
			     event.stopPropagation();
        }
        else {
                try {
										//alert('event1:'+event);
							    	window.event.cancelBubble = true;
							    	//alert('event2:'+event);
                }
                catch(e) {}
        }
}


function getIEVersionNumber() {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}

function preGetPageCell(itemTable, mID) {
	
	getPageCell(itemTable, mID, itemTable.getAttribute('itemId'));
	
}

function preGetPageCell2(itemTableID, menuID, m) {
	
	getPageCell(document.getElementById(itemTableID), menuID, m);
	
}

function getPageCell(cur_el,menuID, m) {
	
		var fileLoc = cur_el.toolTipFile;
		var cell = cur_el.toolTipFileCell;
		var cur_el_div_tt = cur_el.id.replace(/item/,'d');							  
		cur_el_div_tt += '_tt';
		//alert(menuID);
		//alert(cur_el.id);
		//alert(cur_el_div_tt );
		//alert(menuID+'.'+m);
		var firstTime = 0;
		if( cur_el.getAttribute('vertical') || (cur_el.getAttribute('menuLevel') >0)){
			if (document.getElementById(cur_el.id).ttLoad == 0) firstTime = 1;
		}
		else {
			if (document.getElementById(menuID+'.'+m).ttLoad == 0) firstTime = 1;
		}
		if (firstTime == 1) {
				var contact = 0;
				var itemId = '';
				if (typeof(cur_el.toolTipSource) != 'undefined' && cur_el.toolTipSource == 'contact') {
					try {
						arr = cur_el.id.split(/_item_/);
						itemId = arr[1];
						itemId = 'tel'+arr[1];
						htm = eval(itemId);										
						contact = 1;
					} catch (e) {
						setTimeout("preGetPageCell2('"+cur_el.id+"', '"+menuID+"', '"+m+"')", 200);
						return;
					}	
				}
				else {
					contact = 0;
				}
				
				var xmlHttp;
				try {  // Firefox, Opera 8.0+, Safari  
					xmlHttp=new XMLHttpRequest(); 
				}
				catch (e) {  // Internet Explorer  
					try {
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e) {   
						 try {
						 	   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						 }
				   	 catch (e)  {
				  		   alert("Your browser does not support AJAX!");  
				   		   return false;
						}
					}
				}
			  xmlHttp.onreadystatechange=function() {
			  			if(xmlHttp.readyState==4) {	 
								  var resp = xmlHttp.responseText;		
								  var arr = prepareOL(cur_el, menuID);
									caption = arr[0];
									height = arr[1];
									width = arr[2];
									style = arr[3];
									
									if (contact) {
										//htm = eval(itemId);										
									}
									else {
										//htm = resp;
										//else {
										 var first = resp.search(/<!-- cells -->/);
									  var second = resp.indexOf('<!-- cells -->', first+10);
									  arr = resp.substring(first,second).split(/<!-- cell \d+ -->/);						  
									  cell++;
									  if (!arr[cell]) {
									  	setTimeout("preGetPageCell2('"+cur_el.id+"', '"+menuID+"', '"+m+"')", 200);
									  	return;
									  }
									  arr[cell] = arr[cell].replace(/^\s*<tr>\s*<td[^>]*>/, '');
										arr[cell].search(/^<div id=\"c(\d+)\"/);
										arr[cell] = arr[cell].replace(/^<div id=\"c\d+\"/, '<div '+style+' id="c'+RegExp.$1+'" class="map'+m+'-c'+RegExp.$1+'"');
									}
									if( cur_el.getAttribute('vertical') || (cur_el.getAttribute('menuLevel') >0)){
										//alert(cur_el_div_tt);
										if (contact) {
											document.getElementById(cur_el_div_tt).innerHTML = htm;
											document.getElementById(cur_el.id).ttLoad = 1;										
											FixDoar(cur_el_div_tt);
											htm = document.getElementById(cur_el_div_tt).innerHTML;
										}
										else {
											document.getElementById(cur_el_div_tt).innerHTML = arr[cell];
											document.getElementById(cur_el.id).ttLoad = 1;										
											htm = arr[cell];
										}
										//showSubMenu(cur_el, menuID, m);
										refID = cur_el.id;
									}
									else{
										if (contact) {
											document.getElementById(cur_el_div_tt).innerHTML = htm;
											document.getElementById(cur_el.id).ttLoad = 1;										
											FixDoar(cur_el_div_tt);
											htm = document.getElementById(cur_el_div_tt).innerHTML;
										}
										else {
											document.getElementById(menuID+'.'+m).innerHTML = arr[cell];
											document.getElementById(menuID+'.'+m).ttLoad = 1;
											htm = document.getElementById(menuID+'.'+m).innerHTML;
											refID = menuID+'_d_'+m;
										}
										refID = menuID+'_d_'+m;
									}
									BgColor = '#FFFFFF';
									if (cur_el.dragabble == 1) {
										overlib(htm, DRAGGABLE, TEXTPADDING , 0, CAPTIONPADDING, 0, NOCLOSE, CAPTION, caption, STICKY, MOUSEOFF, OFFDELAY, 100000, REF, refID, WIDTH, width, HEIGHT, height, FGCOLOR, BgColor);										
									}
									else {
										overlib(htm, TEXTPADDING , 0, CAPTIONPADDING, 0, NOCLOSE, CAPTION, caption, STICKY, MOUSEOFF, OFFDELAY, 100000, REF, refID, WIDTH, width, HEIGHT, height, FGCOLOR, BgColor);
									}
									try {
										ttX = document.getElementById(menuID+'.'+m).toolTipCoordX;
										ttY = document.getElementById(menuID+'.'+m).toolTipCoordY;
										if (typeof(ttX) != 'undefined' && ttX != '') document.getElementById('overDiv').style.left = ttX+'px';
										if (typeof(ttY) != 'undefined' && ttY != '') document.getElementById('overDiv').style.top = ttY+'px';
										document.getElementById('overDiv').firstChild.cellPadding = 0;
										document.getElementById('overDiv').firstChild.bgColor = '';
										document.getElementById('overCap').bgColor = '';
									} catch (e){}
									
			  			}
			  	}
			  var sid=Math.random()*10000000000;
			  if (contact) {
			  	//telAppearence = cur_el.toolTipContactAppearence;
			  	//contactID = cur_el.toolTipContactSelect;
			  	//x = get_ajax_popup('', '','ID='+document.getElementById(menuID).getAttribute('cid')+'&telID='+telAppearence+'&recordID='+contactID+'&only_data=1', '', 'tel'+contactID,'popupRecord');
			  	//fileLoc = '/cgi-webaxy/tel/mig-tel.pl?ID='+document.getElementById(menuID).getAttribute('cid')+'&act=getCat&cat='+cur_el.toolTipContactCat+'&telID='+telAppearence+'&noheader=1&only_data=1';
			  	//fileLoc = '/cgi-webaxy/tel/mig-tel.pl?ID='+document.getElementById(menuID).getAttribute('cid')+'&act=popupRecord&recordID='+contactID+'&telID='+telAppearence+'&noheader=1&only_data=1';			  	
			  	fileLoc = '/htm-webaxy/mapMenu/blankMenu.xml';
			  }
			  if (!fileLoc) return;
			  if (fileLoc && fileLoc.search(/\?/) >= 0) fileLoc += '&sid='+sid;
			  else fileLoc += '?sid='+sid;
			  xmlHttp.open("GET",fileLoc,true);
			  xmlHttp.send(null);	
			}
			else {
				//alert(cur_el.id);
				var arr = prepareOL(cur_el, menuID);
				caption = arr[0];
				height = arr[1];
				width = arr[2];
				style = arr[3];
									
				if (cur_el.getAttribute('vertical') || (cur_el.getAttribute('menuLevel') >0)){
					 ref = cur_el.id;
					 htm = document.getElementById(cur_el_div_tt).innerHTML;					 
				}
				else {
					ref = menuID+'_d_'+m;
					htm = document.getElementById(menuID+'.'+m).innerHTML;
				}
				BgColor = '#FFFFFF';
				if (cur_el.dragabble == 1) overlib(htm, DRAGGABLE, TEXTPADDING , 0, CAPTIONPADDING, 0, NOCLOSE, CAPTION, caption, STICKY, MOUSEOFF, OFFDELAY, 100000, REF, refID, WIDTH, width, HEIGHT, height, FGCOLOR, BgColor);
				else overlib(htm, TEXTPADDING , 0, CAPTIONPADDING, 0, NOCLOSE, CAPTION, caption, STICKY, MOUSEOFF, OFFDELAY, 100000, REF, refID, WIDTH, width, HEIGHT, height, FGCOLOR, BgColor);
				try {
					ttX = document.getElementById(menuID+'.'+m).toolTipCoordX;
					ttY = document.getElementById(menuID+'.'+m).toolTipCoordY;
					if (typeof(ttX) != 'undefined' && ttX != '') document.getElementById('overDiv').style.left = ttX+'px';
					if (typeof(ttY) != 'undefined' && ttY != '') document.getElementById('overDiv').style.top = ttY+'px';
					document.getElementById('overDiv').firstChild.cellPadding = 0;
					document.getElementById('overDiv').firstChild.bgColor = '';					
					document.getElementById('overCap').bgColor = '';
				} catch (e){}																		
				
			}
			  
}

function prepareOL(cur_el, menuID) {
	
	var style = '';
									if (typeof(cur_el.toolTipStyle) != 'undefined' && cur_el.toolTipStyle != '') {
										style = cur_el.toolTipStyle;
									}
									if (style) style = 'style="'+style+'"';
									caption = '<table';
									width = height = widthHeight = '';
									if (typeof(cur_el.toolTipStyle) != 'undefined' && cur_el.toolTipStyle != '') {
										if (cur_el.toolTipStyle.search(/width\s*:\s*(\d+)px;/) >= 0) {
												widthHeight += 'WIDTH , '+RegExp.$1+',';
												width = RegExp.$1;
										}
										if (cur_el.toolTipStyle.search(/height\s*:\s*(\d+)px;/) >= 0) {
												widthHeight += 'HEIGHT, '+RegExp.$1;
												height = RegExp.$1;
										}
									}
									if (typeof(cur_el.toolTipTitle) != 'undefined' && cur_el.toolTipTitle != '') {
										captionStyle = 'white-space:nowrap;';
										if (typeof(cur_el.toolTipTitleStyle) != 'undefined' && cur_el.toolTipTitleStyle != '') {
											captionStyle += cur_el.toolTipTitleStyle;												
										}												
										if (document.getElementById(menuID).dir.toLowerCase() =='rtl') {
												captionStyle += 'direction:RTL;';
										}
										captionStyle = 'style="'+captionStyle+'"';
										if (document.getElementById(menuID).dir.toLowerCase() =='rtl') 
											caption += ' '+captionStyle+'><tr><td width="99%" style="padding-right: 10px;">'+cur_el.toolTipTitle+'</td>';
										else
											caption += ' '+captionStyle+'><tr><td width="99%" style="padding-left: 10px;">'+cur_el.toolTipTitle+'</td>';
									}
									else caption += ' style="background-color: #FFFFFF;"><tr>';
									if (cur_el.toolTipCloseButton) closeBut = cur_el.toolTipCloseButton;
									else closeBut = '/htm-webaxy/icons/close.png';
									if (document.getElementById(menuID).dir.toLowerCase() =='rtl') 
										caption += '<td id="overlib-closeBtnTd"><img id="overlib-closeBtn" src="'+closeBut+'" border="0" style="cursor: pointer; aalign: left; ppadding-right:5px;" onClick="return cClick();"></td>';
									else
										caption += '<td id="overlib-closeBtnTd"><img id="overlib-closeBtn" src="'+closeBut+'" border="0" style="cursor: pointer; aalign: right; ppadding-left:5px;" onClick="return cClick();"></td>';
									caption += '</tr></table>';
									
		return new Array(caption, height, width, style);
		
}

//===================================================================
//  
//  insertFileElement: insert css or js file ref into page header 
//  
//===================================================================
function insertFileElement(path,ext) {
	try {
		var headerTag = document.getElementsByTagName("head")[0];
	}
	catch(no_header) {
		return;
	}
	var fileObject = null;
	if (ext == "css") {
		fileObject = document.createElement("link");
		fileObject.setAttribute("rel", "stylesheet");
		fileObject.setAttribute("type", "text/css");
		fileObject.setAttribute("href",path);
	}
	else if (ext == "js") {
		fileObject = document.createElement("script");
		fileObject.setAttribute("type","text/javascript");
		fileObject.setAttribute("src",path);
	}
	if (fileObject) {
		headerTag.appendChild(fileObject);
	}

}

function getSize() {
			// Window Size
			if (self.innerHeight) { // Everyone but IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
				myScroll = window.pageYOffset;
			} else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				myScroll = document.documentElement.scrollTop;
			} else if (document.body) { // Other IE, such as IE7
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
				myScroll = document.body.scrollTop;
			}
			// Page size w/offscreen areas
		
			if (window.innerHeight && window.scrollMaxY) {	
				myScrollWidth = document.body.scrollWidth;
				myScrollHeight = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac
				myScrollWidth = document.body.scrollWidth;
				myScrollHeight = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				myScrollWidth = document.body.offsetWidth;
				myScrollHeight = document.body.offsetHeight;
			}
		}
		
function loadjscssfile(filename, filetype, setID){
			 
			 if (!setID) setID = '';
			 if (filetype=="js"){ //if filename is a external JavaScript file
			  if (setID != '' && document.getElementById(setID)) return;
			  var fileref=document.createElement('script');
			  fileref.setAttribute("type","text/javascript");
			  fileref.setAttribute("src", filename);
			  if (setID != '') fileref.id = setID;
			 }
			 else if (filetype=="css"){ //if filename is an external CSS file
			  if (setID != '' && document.getElementById(setID)) return;
			  var fileref=document.createElement("link");
			  fileref.setAttribute("rel", "stylesheet");
			  fileref.setAttribute("type", "text/css");
			  fileref.setAttribute("href", filename);
			  if (setID != '') fileref.id = setID;
			 }
			 if (typeof fileref!="undefined")
			  document.getElementsByTagName("head")[0].appendChild(fileref);
		
}

function copyLoginBtn(to, from) {
	
	fromDiv = document.getElementById(from);
	if (!fromDiv) {
		window.setTimeout("copyLoginBtn('"+to+"', '"+from+"')",50);
		return;
	}
	toDiv = document.getElementById(to);
	d = document.createElement('DIV');
	d.innerHTML = fromDiv.innerHTML;
	d.className = fromDiv.className;
	d.onclick = fromDiv.onclick;
	fromDiv.style.display = 'none';
	toDiv.innerHTML = '';
	toDiv.appendChild(d);
	
}		

function positionedBullet(bulletId, tableID) {
	
	try {
		tb = document.getElementById(tableID);
		bulletDiv = document.getElementById(bulletId);
		bullet = document.getElementById(bulletId.replace('Cell', ''));
		var tbBounds=getBounds(tb);
		bulletDiv.style.width = tb.clientWidth+'px';
		bulletDiv.style.textAlign = bullet.getAttribute('upperbulletalign');
		//alert('bulletId:'+bulletId+':: tableID'+tableID+'::Top'+tbBounds.top+'::Left:'+tbBounds.left);
		if (tbBounds.top == 0 && tbBounds.left == 0) {
			window.setTimeout("positionedBullet('"+bulletId+"', '"+tableID+"')", 50); 
			return;
		}
		bulletDiv.style.top = tbBounds.top-bullet.getAttribute('myHeight')+margTop+'px';
		//alert(tbBounds.top+'::'+bullet.getAttribute('myHeight')+'::'+margTop);
		if (0 && document.getElementById(tb.getAttribute('menuID')).dir.toLowerCase() =='rtl') {// && (tbBounds.left-bullet.getAttribute('myWidth')+tb.offsetWidth > minMargin) ){
			//bulletDiv.style.left = tbBounds.left+'px';
			bulletDiv.style.left = tbBounds.left-bullet.getAttribute('myWidth')+tb.offsetWidth+'px';
		}
		else {
			bulletDiv.style.left = tbBounds.left+'px';			
		}		
		//alert(bulletDiv.style.left+'::'+bulletDiv.style.top);
	} catch (e) {
		alert(e);
	}
	
}
				
	