//var dbPath='isa/isa.nsf';
var dbPath='';
function PageQuery(q)
{
	if(q.length > 1)
	{
		this.q = q.substring(1, q.length);
	}
	else
	{
		this.q = null;
	}
	this.keyValuePairs = new Array();
	if(q)
	{
		for(var i=0; i < this.q.split("&").length; i++)
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s)	{
						for(var j=0; j < this.keyValuePairs.length; j++)
						{
							if(this.keyValuePairs[j].split("=")[0] == s)
							return this.keyValuePairs[j].split("=")[1];
						}
						return false;
					}
	this.getParameters = function()	{
						var a = new Array(this.getLength());
						for(var j=0; j < this.keyValuePairs.length; j++)
							{
								a[j] = this.keyValuePairs[j].split("=")[0];
							}
							return a;
					}
	this.getLength = function()	{
						return this.keyValuePairs.length;
					}
}
function queryString(key)
{
	var page=new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}
function displayItem(key)
{
	if(queryString(key)=='false') 
	{
		return '';
	}
	else
	{
		 return queryString(key);
	}
}
function replaceSubstring(inputString, badString, goodString, caseSensitive)
{
	newStr= "";
	UI = inputString;
	UB = badString;
 	if(( caseSensitive != 1) && (caseSensitive != true))
	{
		UI = inputString.toUpperCase();
		UB = badString.toUpperCase();
	}
   	badEnd = -1;
   	badLoc = UI.indexOf(UB);
  	 if( badLoc != -1)
	{
      		for (x=1; (badLoc != -1); x++)
		{
         			newStr = newStr + inputString.substring((badEnd + 1), badLoc) + goodString;
         			badEnd = badLoc + UB.length - 1;
         			badLoc = UI.indexOf(UB, (badLoc + 1)); 
		}
      		newStr = newStr + inputString.substring((badEnd + 1), inputString.length); 
	} else
		newStr = inputString;  
	return( newStr);
}
function openLevel(idLevel)
{
	var itemMenu=window.document.getElementById(idLevel);
	if (itemMenu!='' && itemMenu!=null)
	{
		if (itemMenu.isOpen!=true)
		{
			var itemImg=window.document.getElementById(idLevel+'_img');
			if (itemImg!='' && itemImg!=null)
			{
				itemImg.src=imageOpenTable[idLevel.split('_').length-1];
			}
			var colItem=itemMenu.children;
			for(var x=0;x<colItem.length;x++)
			{
				var itemChild=colItem.item(x);
				if ( (idLevel==itemChild.id.substring(0,idLevel.length)) && (itemChild.tagName=='DIV') )
				{
					itemChild.style.display='block';
// FILTER UNACTIVATE					itemChild.filters[0].Apply();
// FILTER UNACTIVATE					itemChild.filters[0].Play();
				}
			}
			itemMenu.isOpen=true;
			// Close All Other Level
			var allMenu=window.document.getElementById(itemMenu.parentElement.id);
			if (allMenu!='' && allMenu!=null)
			{
				var colItem=allMenu.children;
				for(var x=0;x<colItem.length;x++)
				{
					var itemChild=colItem.item(x);
					if ( (idLevel!=itemChild.id) && (itemChild.tagName=='DIV') )
					{
						var itemImg=window.document.getElementById(itemChild.id+'_img');
						if (itemImg!='' && itemImg!=null)
						{
							itemImg.src=imageCloseTable[itemChild.id.split('_').length-1];
						}
						closeAllOtherLevel(itemChild.id);
					}
				}
			}
		}
		else
		{
			var itemImg=window.document.getElementById(idLevel+'_img');
			if (itemImg!='' && itemImg!=null)
			{
				itemImg.src=imageCloseTable[idLevel.split('_').length-1];
			}
			var colItem=itemMenu.children;
			for(var x=0;x<colItem.length;x++)
			{
				var itemChild=colItem.item(x);
				if ( (idLevel==itemChild.id.substring(0,idLevel.length)) && (itemChild.tagName=='DIV') )
				{
					itemChild.style.display='none';
				}
			}
			itemMenu.isOpen=false;
			// Close All Children
			closeAllChildrenLevel(itemMenu.id);
		}
	}
}
function closeAllChildrenLevel(idLevel)
{
	var itemMenu=window.document.getElementById(idLevel);
	if (itemMenu!='' && itemMenu!=null)
	{
		var colItem=itemMenu.children;
		for(var x=0;x<colItem.length;x++)
		{
			var itemChild=colItem.item(x);
			if ( (idLevel==itemChild.id.substring(0,idLevel.length)) && (itemChild.tagName=='DIV') )
			{
				itemChild.style.display='none';
				var itemImg=window.document.getElementById(itemChild.id+'_img');
				if (itemImg!='' && itemImg!=null)
				{
					itemImg.src=imageCloseTable[itemChild.id.split('_').length-1];
				}
				closeAllChildrenLevel(itemChild.id);
			}
		}
		itemMenu.isOpen=false;
	}
}
function closeAllOtherLevel(idLevel)
{
	var itemMenu=window.document.getElementById(idLevel);
	if (itemMenu!='' && itemMenu!=null)
	{
		var colItem=itemMenu.children;
		for(var x=0;x<colItem.length;x++)
		{
			var itemChild=colItem.item(x);
			if ( (idLevel==itemChild.id.substring(0,idLevel.length)) && (itemChild.tagName=='DIV') )
			{
				itemChild.style.display='none';
				var itemImg=window.document.getElementById(itemChild.id+'_img');
				if (itemImg!='' && itemImg!=null)
				{
					itemImg.src=imageCloseTable[itemChild.id.split('_').length-1];
				}
				closeAllOtherLevel(itemChild.id);
			}
		}
		itemMenu.isOpen=false;
	}
}
function openAtLevel(idLevel)
{
	var menuIndex=idLevel.split('_');
	var idElement=menuIndex[0];
	for(var i=1;i<menuIndex.length;i++)
	{
		idElement=idElement+'_'+menuIndex[i];
		openLevel(idElement);
	}
}
function openContent(idLevel, urlLevel, targetLevel, optionLevel)
{
	openLevel(idLevel);
	if (urlLevel!='' && urlLevel!=undefined)
	{
		targetLevel=(targetLevel=='' || targetLevel==undefined ? '_self' : targetLevel)
		if (optionLevel=='' || optionLevel==undefined)
		{
			window.open(urlLevel, targetLevel);
		}
		else
		{
			window.open(urlLevel, targetLevel, optionLevel);
		}
	}
}
function initMenu(urlXmlMenu)
{
	var xmlMenu=new ActiveXObject("Microsoft.XMLDOM");
	xmlMenu.async="false";
	xmlMenu.load(urlXmlMenu);
	// Get Images Url
	var colImage=xmlMenu.getElementsByTagName("IMAGESRC");
	imageCloseTable=new Array();
	imageOpenTable=new Array();
	for(var x=0;x<colImage.length;x++)
	{
		imageCloseTable[colImage.item(x).getAttribute("LEVEL")]=replaceSubstring(colImage.item(x).getAttribute("SRCCLOSE"),'<thisdbpath>',dbPath,false);
		imageOpenTable[colImage.item(x).getAttribute("LEVEL")]=replaceSubstring(colImage.item(x).getAttribute("SRCOPEN"),'<thisdbpath>',dbPath,false);
	}
	// Get Menu Data
	var colMenu=xmlMenu.getElementsByTagName("MENU");
	var itemMenu=colMenu.item(0);
	var colItem=itemMenu.childNodes;
	window.document.writeln('<DIV ID="menu">');
	for(var x=0;x<colItem.length;x++)
	{
		getChildItemMenu(colItem.item(x));
	}
	window.document.writeln('</DIV>');
	// Get item id for opening
	var opening=displayItem('opening');
	if (opening!='')
	{
		openAtLevel(opening);
	}
}
function getChildItemMenu(itemMenu)
{
	var itemType=itemMenu.getAttribute("TYPE");
	if (itemType!='0')
	{
		var itemId=itemMenu.getAttribute("ID");
		var itemLevel=itemId.split('_').length-1;
		var itemLabel=itemMenu.getAttribute("LABEL");
		var itemUrl=replaceSubstring(itemMenu.getAttribute("URL"),'<thisdbpath>',dbPath,false);
		var itemTarget=itemMenu.getAttribute("TARGET");
		var itemOptions=itemMenu.getAttribute("OPTION");
		window.document.writeln('<DIV ID="menu'+itemId+'" CLASS="menu_level_'+itemLevel+'">');
		window.document.writeln('<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS="menu_level_'+itemLevel+'">');
		window.document.writeln('<TR CLASS="menu_level_'+itemLevel+'">');
		window.document.writeln('<TD CLASS="menu_level_'+itemLevel+'_img">');
		window.document.writeln('<A HREF="javascript:openLevel(\'menu'+itemId+'\')">');
		window.document.writeln('<IMG ID="menu'+itemId+'_img" NAME="img_level_'+itemLevel+'" SRC="'+replaceSubstring(imageCloseTable[itemLevel],'<thisdbpath>',dbPath,false)+'" CLASS="menu_level_'+itemLevel+'_img">');
		window.document.writeln('</A>');
		window.document.writeln('</TD>');
		window.document.writeln('<TD CLASS="menu_level_'+itemLevel+'_title">');
		window.document.writeln('<A HREF="javascript:openContent(\'menu'+itemId+'\',\''+itemUrl+'\',\''+itemTarget+'\',\''+itemOptions+'\')" CLASS="menu_level_'+itemLevel+'_link">');
		window.document.writeln(itemLabel);
		window.document.writeln('</A>');
		window.document.writeln('</TD>');
		window.document.writeln('</TR>');
		window.document.writeln('</TABLE>');
	
		var colChildItem=itemMenu.childNodes;
		for(var x=0;x<colChildItem.length;x++)
		{
			getChildItemMenu(colChildItem.item(x));
		}
		window.document.writeln('</DIV>');
	}
}
