//*Items with children arrow style
var RightArrow = new String
var LeftArrow = new String 
var DownArrow = new String 
var t
//Settings for fade or not fade
var bFade=true 
//Fade duration
var FadeDur=0.47
//Is used on the mouseout event, how many second delay
var TimeOut=2
var IsOpen
var Blend = false
//Settings for offset of submenus
var offsetX = 0
var offsetY = 1
//Setting for menu layout [Vertical/Horizontal]
var Vertical = true
//Arrow settings
RightArrow = '...'
DownArrow = '...'

var AltTag



//[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[No need to edit beyond this point]]]]]]]]]]]]]]]]]]]]]]]]]]]]]




//used by contextmenu
var sAddID = 0
var sPriority = 0
var sParentID = 0
var DeleteID = 0
TimeOut = TimeOut*1000

//*Big table with main menu items
var BigMainMenuTablePadding = '0'
var BigMainMenuTableSpacing = '0'
var objFil
var Previous
LeftArrow = '3'

//*Main menu body
var tmpBody = new String

function HideSelect(){

    for(r=0;r<=document.getElementsByTagName('SELECT').length-1;r++){
        if(document.getElementsByTagName('SELECT')[r].style.visibility != 'hidden'){
            document.getElementsByTagName('SELECT')[r].style.visibility = 'hidden'
        }
    }

}


function ShowSelect(){

    for(r=0;r<=document.getElementsByTagName('SELECT').length-1;r++){
        if(document.getElementsByTagName('SELECT')[r].style.visibility != ''){
            document.getElementsByTagName('SELECT')[r].style.visibility = ''
        }
    }

}


function isArray(a) {
    return isObject(a) && a.constructor == Array;
}



//*Create main menu table with main menus
function createMain(thisid){
//    
//    try{
//    

	if(Vertical){
		tmpBody = "<table  width=100% onmousemove=\"clearTimeout(t);IsOpen=1\"  onmouseover=\"clearTimeout(t);IsOpen=1\" onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\" name=\"tblMain\" id=\"tblMain\"  class='BigMainMenuTable' cellspacing="+BigMainMenuTablePadding+" cellpadding="+BigMainMenuTableSpacing+"><tr>"
	}
	else{
		tmpBody = "<table width=100%  onmousemove=\"clearTimeout(t);IsOpen=1\" onmouseover=\"clearTimeout(t);IsOpen=1\" onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\"  name=\"tblMain\" id=\"tblMain\"   class='BigMainMenuTable' cellspacing="+BigMainMenuTablePadding+" cellpadding="+BigMainMenuTableSpacing+">"
	}
    
    
	//if(undefined==Menu2){
	//alert('aa')
	//}
	for(maincount=1;maincount<=MainMenu.length;maincount++){
		var tmpItem = MainMenu[maincount-1]	
		var tmpArrow = MainMenu[maincount-1]	
		
        var sURL = new String
        sURL = tmpItem[5]
	


        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
            sURL = sURL.substr(1)
        }            	
        else{
            sURL = "home.asp?pid="+ tmpItem[0]
        }
					
		if(tmpItem[6]!=tmpItem[1]){
		    AltTag = 'title = "'+ tmpItem[6] +'"'
		}
		else{
		    AltTag = ''
		}		
		
		var swindowURL
		
        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){

            swindowURL = 'onclick="window.open(\''+ sURL.substr(1) + '\')"'           
        }            	
        else{
            if(tmpItem[7]=='_blank'){
                swindowURL = 'onclick="window.open(\''+ sURL + '\')"'            
            }
            else{
                swindowURL = 'onclick="window.location = \''+ sURL + '\'"'
            }
        }		
		

		var tmpMainMouseover = new String
			if(MainMenu[maincount-1][2] > 0){
				tmpArrow = DownArrow
				tmpMainMouseover = "onmouseover='createSub(this,"+ MainMenu[maincount-1][0] +","+ MainMenu[maincount-1][2] +",0)'"
			}
			else{
				tmpArrow = ""
				tmpMainMouseover = "onmouseover='DoNormalCSS();HideAll(0,0,0);Hide();this.className=\"MainMenuOver\"'"
			}

	    if(MainMenu[maincount-1][6]!=MainMenu[maincount-1][1]){
	        AltTag = 'title = "'+ MainMenu[maincount-1][6] +'"'
	    }
	    else{
	        AltTag = ''
	    }	
	
		if(thisid==0 || thisid==MainMenu[maincount-1][0]){	
			if(Vertical){tmpBody += "<tr>"}
			
			tmpBody += 	"<td "+ swindowURL +"   "+ AltTag +" oncontextmenu=\"ShowContextMenu(event,this,"+ MainMenu[maincount-1][0] +",1,"+ MainMenu[maincount-1][4] +"); return false;\"><table  width=100% "+ tmpMainMouseover +" cellpadding=1 border=0 cellspacing=0 name=mainmenu"+tmpItem[0]+" id=mainmenu"+tmpItem[0]+" class='MainMenu' height=100%><tr><td  >" + tmpItem[1] + tmpArrow +"</td></tr></table></td>"
			
			if(Vertical){tmpBody += "</tr>"}
		}
	}
	
	if(Vertical){
		tmpBody += "</table>"
	}
	else{
		tmpBody += "<td width=30%></td></table>"
	}	
   
	document.writeln(tmpBody)
//	}
//	catch(e){
//	
//	}
}

function HideThis(){

    HideAll(0,0,0)
    if(document.all["contextmnu"]){
    document.all["contextmnu"].style.display = 'none'
    }
}
//*Create main menu table with main menus
function createParentMenu(thisid){
    try{

	var tmpBody
	if(Vertical){
		tmpBody = "<table  width=100% onmousemove=\"clearTimeout(t);IsOpen=1\"  onmouseover=\"clearTimeout(t);IsOpen=1\" onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\" name=\"tblMain\" id=\"tblMain\"  class='BigMainMenuTable' cellspacing="+BigMainMenuTablePadding+" cellpadding="+BigMainMenuTableSpacing+"><tr>"
	}
	else{
		tmpBody = "<table width=100%  onmousemove=\"clearTimeout(t);IsOpen=1\" onmouseover=\"clearTimeout(t);IsOpen=1\" onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\"  name=\"tblMain\" id=\"tblMain\"   class='BigMainMenuTable' cellspacing="+BigMainMenuTablePadding+" cellpadding="+BigMainMenuTableSpacing+">"
	}
	
	if(eval("SubMenu" + thisid)!=undefined){
		
		var tmpSubItem = eval("SubMenu" + thisid)	
	
	
	
		var sID = thisid
		var lvl=2
		for(maincount=1;maincount<=tmpSubItem.length;maincount++){
			var tmpItem = tmpSubItem[maincount-1]	
			var tmpArrow = tmpSubItem[maincount-1]	
			
		var sURL = new String
        sURL = tmpItem[5]	

        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
            sURL = sURL.substr(1)
        }            	
        else{
            sURL = "home.asp?pid="+ tmpItem[0]
        }
        
		if(tmpItem[6]!=tmpItem[1]){
		    AltTag = 'title = "'+ tmpItem[6] +'"'
		}
		else{
		    AltTag = ''
		}								

		var swindowURL
		
        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){

            swindowURL = 'onclick="window.open(\''+ sURL.substr(1) + '\')"'           
        }            	
        else{
            if(tmpItem[7]=='_blank'){
                swindowURL = 'onclick="window.open(\''+ sURL + '\')"'            
            }
            else{
                swindowURL = 'onclick="window.location = \''+ sURL + '\'"'
            }
        }		
			
			var tmpMainMouseover = new String
			
				if(tmpSubItem[maincount-1][2] > 0){
					tmpArrow = DownArrow
					tmpMainMouseover = "onmouseover='createSub(this,"+ tmpItem[0] +","+ tmpItem[2] +",122)'"

				}
				else{
					tmpArrow = ""
					tmpMainMouseover = "onmouseover='DoNormalCSS();HideAll(0,0,0);Hide();this.className=\"MainMenuOver\"'"

				}
				

			    if(Vertical){tmpBody += "<tr>"}
    			
			    tmpBody += 	"<td "+ swindowURL +"   "+ AltTag +" oncontextmenu=\"ShowContextMenu(event,this,"+ tmpSubItem[maincount-1][0] +",2,"+ tmpSubItem[maincount-1][4] +"); return false;\"><table  width=100% "+ tmpMainMouseover +" cellpadding=1 border=0 cellspacing=0 name=mainmenu"+tmpItem[0]+" id=mainmenu"+tmpItem[0]+" class='MainMenu' height=100%><tr><td  ><a href=\""+ sURL +"\" target=\""+ tmpItem[7] +"\" onclick='return false;'>" + tmpItem[1] + tmpArrow + "</a></td></tr></table></td>"
    			
			    if(Vertical){tmpBody += "</tr>"}

		}
		
		if(Vertical){
			tmpBody += "</table>"
		}
		else{
			tmpBody += "</table>"
		}	

		document.writeln(tmpBody)
	}	
	}
	catch(e){
	
	}
}


function HideMainPrevious(sID){

    
    HideAll(sID,sID,0)
    //alert(document.all['tbl' + sID])


}

function Hide(){
//   
//    
//	if(event!=null){
//		if(event.srcElement.tagName!='IMG'){
//		
//		    if(IsOpen==0){
//			    sBody = ""
//			    ShowSelect()
//			    document.all["subHTML"].setAttribute("innerHTML","")
//			    if(document.all["contextmnu"]){
//			        document.all["contextmnu"].style.display = 'none'
//                }
//                			
//			    DoNormalCSS()
//			}
//		}
//	}
//	else{
		if(IsOpen==0){
			sBody = ""
			
			ShowSelect()
			document.all["subHTML"].innerHTML = ''
			
			document.all["subHTML"].setAttribute("innerHTML","")
			
			if(document.all["contextmnu"]){
			    document.all["contextmnu"].style.display = 'none'
            }
           
			DoNormalCSS()
			
		}	
//	}
	
		
}

function createSubOnImage(obj,tmpID,level){
    try{
    
	    var tmpSubArray = eval('SubMenu' + tmpID);
	    //var tmpSubArray = document.all['SubMenu' + tmpID];
	    if(tmpSubArray!=undefined){
		    HideMainPrevious(tmpID)
		    ShowSubMenusImage(obj,tmpID,level)
	    }
	}
	catch(e){
	
	}
	
}

//for use of custom main menus only, the arr is parsed
function createSubMain(ThisArray){
        var tmpArrow = ''
        var tmpMainMouseover= ''
        var tmpSubMain = ''
        var tmpBody = ''
		tmpSubMain = "<table   width=100%  cellpadding=0 cellspacing=0  class='BigMainMenuTable' >"

        
	    for(maincount=1;maincount<=ThisArray.length;maincount++){
		    var tmpItem = ThisArray[maincount-1]	
		    var tmpArrow = ThisArray[maincount-1]	
		    var tmpMainMouseover = new String
		    var sURL = new String
		    sURL = tmpItem[3]
			//alert(sURL)
			
			
	        sURL = "onclick=\"window.location = '"+ tmpItem[3] +"'\""
			
			
		    var swindowURL
    
			   
			    tmpArrow = "<td  width=1  style='vertical-align:middle'>&nbsp;</td>"
			    tmpMainMouseover = "onmouseover='DoNormalCSS();Hide();this.className=\"MainMenuOver\"'"
		 
			
	    
			    if(Vertical){tmpBody += "<tr>"}
    			
			    tmpBody += 	"<td  "+ sURL +"><table width=100%  "+ tmpMainMouseover +" onmouseout=\"this.className='MainMenu'\" cellpadding=1 border=0 cellspacing=0 name=mainmenu"+tmpItem[0]+" id=mainmenu"+tmpItem[0]+" class='MainMenu' height=100%><tr><td nowrap >" + tmpItem[1] + "</td>"+ tmpArrow +"</tr></table></td>"
    			
			    if(Vertical){tmpBody += "</tr>"}
		   
	    }
	    tmpSubMain = tmpSubMain + tmpBody + "</table>"
	    

		document.writeln(tmpSubMain)
}



function ShowSubMenusImage(obj,sID,lvl){

	var tmpSubMenus = new String
	var tmpMainx
	tmpMainx = FindXY(obj).x
	IsOpen=1
	tmpSubMenus = ""
	tmpSubMenus = "<table class='MainSubDropDown' onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' level='0' id='tbl"+ sID +"' style=\"position:absolute;left:"+ parseInt(FindXY(obj).x) +";top:"+ parseInt(FindXY(obj).y+parseInt(obj.clientHeight)) +"\" cellpadding=0 cellspacing=0>"
	
	
	var tmpSubItem = eval("SubMenu" + sID)
	//var tmpSubItem = document.all["SubMenu" + sID]
	if(tmpSubItem !=undefined){
		for(tCount=1;tCount<=tmpSubItem.length;tCount++){
			var tmptmpSubItem = tmpSubItem[tCount-1]

		    var sURL = new String
            sURL = tmptmpSubItem[5]	
			    //alert(sURL)
            if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
                sURL = sURL.substr(1)
            }            	
            else{
                sURL = "home.asp?pid="+ tmptmpSubItem[0]
            }
				

			if(tmptmpSubItem[6]!=tmptmpSubItem[1]){
			    AltTag = 'title = "'+ tmptmpSubItem[6] +'"'
			}
			else{
			    AltTag = ''
			}


		    var swindowURL
    		
            if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){

                swindowURL = 'onclick="window.open(\''+ sURL.substr(1) + '\')"'           
            }            	
            else{
                if(tmptmpSubItem[7]=='_blank'){
                    swindowURL = 'onclick="window.open(\''+ sURL + '\')"'            
                }
                else{
                    swindowURL = 'onclick="window.location = \''+ sURL + '\'"'
                }
            }	

			
			if(tmptmpSubItem[2]>0){
				tmpSubMenus += "<tr "+ AltTag +"  style='cursor:hand'><td nowrap "+ swindowURL +" class=SubMenuDropDownTD  onmouseover='createSubSubImage(this,0,0,"+parseInt(lvl)+")'><table width=100% level='"+ lvl +"'  childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' ><tr><td nowrap><a  href=\""+ sURL +"\" onclick='return false;' target=\""+ tmptmpSubItem[7] +"\" class=SubMenuDropDownA>"+ tmptmpSubItem[1] +"</a></td></tr></table></td></tr>"
			}
			else{
				tmpSubMenus += "<tr "+ AltTag +"   style='cursor:hand'><td nowrap  "+ swindowURL +"  class=SubMenuDropDownTD onmouseover='createSubSubImage(this,0,0,"+parseInt(lvl)+")'><table width=100% level='"+ lvl +"'   childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' ><tr><td  nowrap><a  href=\""+ sURL +"\" onclick='return false;' target=\""+ tmptmpSubItem[7] +"\" class=SubMenuDropDownA>"+ tmptmpSubItem[1] +"</a></td></tr></table></td></tr>"
			}
		}	
	}
	tmpSubMenus += "</table>"
	
	document.all.subHTML.innerHTML = document.all.subHTML.innerHTML + tmpSubMenus

	//if(parseInt(document.getElementById('tbl' + sID).style.left)+parseInt(document.getElementById('tbl' + sID).clientWidth+25)>=screen.availWidth){document.getElementById('tbl' + sID).style.left = tmpMainx-document.getElementById('tbl' + sID).clientWidth-offsetX}
	
}





function HideAll(sID,currentid,Level){
	var templ = document.all['tbl' + sID]
	var Collection1
	Collection1 = document.all.subHTML.getElementsByTagName('TABLE')
	for(ptmp=1;ptmp<=Collection1.length;ptmp++){
	if(templ!=undefined){
		if(Collection1[ptmp-1].getAttribute("level")!=undefined && Collection1[ptmp-1].getAttribute("level")>=templ.getAttribute("level")){
			
			if(Collection1[ptmp-1].id!='tbl'+currentid && Collection1[ptmp-1].className !='SubMenu' && Collection1[ptmp-1].className !='MainSub'){

			
			Collection1[ptmp-1].className ='SubMenu'
			}
		}
		}
	}
	var Collection2
	Collection2 = document.all.subHTML.childNodes	
	for(yyy=1;yyy<=Collection2.length;yyy++){
	
		if(Collection2[yyy-1].getAttribute("level")>Level){
			
			if(Collection2[yyy-1].id!='tbl'+currentid && Collection2[yyy-1].style.display != 'none' && Collection2[yyy-1].id!='tbl'+sID){
			
			
			Collection2[yyy-1].style.display = 'none'

			
			}
		}
	}
	

}
function DoNormalCSS(){
	for(yyy=1;yyy<=MainMenu.length;yyy++){
	if(document.all['mainmenu' + MainMenu[yyy-1][0]]!=undefined){
		if(document.all['mainmenu' + MainMenu[yyy-1][0]].className != 'MainMenu'){
			document.all['mainmenu' + MainMenu[yyy-1][0]].className = 'MainMenu'
		}
	}
	}
	
    if(document.all["tblMain"]){
	    for(po=1;po<=tblMain.getElementsByTagName("TABLE").length;po++){
		    if(tblMain.getElementsByTagName("TABLE")[po-1].className != 'MainMenu'){
			    tblMain.getElementsByTagName("TABLE")[po-1].className = 'MainMenu'
		    }
	    }	
	}
	
}
function createSub(obj,tmpID,childcount,level){

	DoNormalCSS()
	
	obj.className = 'MainMenuOver'
	
	if(childcount>0){
        
	    try
	    {   
		    var tmpSubArray = eval('SubMenu' + tmpID);
           
		    if(tmpSubArray!=undefined){
			    HideMainPrevious(tmpID)
			    ShowSubMenus(obj,tmpID,level+1)
		    }		    
		}
		catch(e){
		
		}
		

	}
}

function mover(obj){
    
    obj.style.background=''
    obj.style.color=''
    
}

function mout(obj){

    obj.style.background='#316AC5'
    obj.style.color='#FFFFFF'

}

function createContextMenu(){
	var sContext
	
	if(!document.all.contextmnu){
	
		sContext = '<span   style="filter: Shadow(color=#000000, Direction=135, Strength=8);" class="skin0" onmouseover=\"IsOpen=1\" style="padding: 2 2 2 2;zIndex:99;z-Index:99;display:none;position: absolute;cursor:hand" name=contextmnu id=contextmnu onMouseover="highlightie5()" onMouseout="lowlightie5();clearTimeout(t);IsOpen=0;t=setTimeout(\'HideDelay()\',TimeOut)"'
		sContext+=	'	>'
		sContext+= '		<div class="menuitems" url="" onmouseover="Javascript:mout(this)" onmouseover="Javascript:mover(this)" onclick="Javascript:void(Add(\'after\'))" id="APB" style="border:0">New page</div>'
		sContext+= '		<div class="menuitems" url="" onmouseover="Javascript:mout(this)" onmouseover="Javascript:mover(this)" onclick="Javascript:void(Add(\'sub\'))" id="APS" style="border:0">New sub page</div>'
		sContext+= '		<hr id="menuHR">'
		sContext+='		<div class="menuitems" url="" onmouseover="Javascript:mout(this)" onmouseover="Javascript:mover(this)" onclick="Javascript:void(Prop())"  id="Prop" style="border:0">Properties</div>'
		sContext+= '</span>	'
		
	document.writeln(sContext)
	}
}

function createContextMenu2(){
	var sContext
	if(!document.all.contextmnu){
		sContext = ''
		document.writeln(sContext)
	}
}
function Add(spos){
	//alert('Add to id ' + sAddID)
	
	//openAddWindow(sAddID, priority, parentid, userName, pos)	
	openAddWindow(sAddID,sPriority,sParentID,document.all.t_username.value,spos)	
	
}

function Prop(){openPropertiesWindow(sAddID)}

function highlightie5() {
	if (event.srcElement.className == "menuitems") {
		event.srcElement.style.backgroundColor = "highlight";
		event.srcElement.style.color = "white";
		//if (display_url){window.status = event.srcElement.url;}
	}
}

function lowlightie5() {
	if (event.srcElement.className == "menuitems") {
		event.srcElement.style.backgroundColor = "";
		event.srcElement.style.color = "black";
		window.status = "";
	}
}

function ShowContextMenu(e,obj,deleteID,AddID,Priority){
	var sContext = new String
	sAddID = deleteID
	sParentID = AddID
	sPriority = Priority

	if(document.all["contextmnu"]){
	    document.all.contextmnu.style.top = e.clientY + document.body.scrollTop
	    document.all.contextmnu.style.left = e.clientX+ document.body.scrollLeft
	    document.all.contextmnu.style.display = ''
	    document.all.contextmnu.style.zIndex = '99'
	    //document.all.contextmnu.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=20);'
	    FadeMakeObj(document.all.contextmnu)
	}
}

function FadeMakeObj(obj){
	if(Blend){ 
	    try{
	    if(bFade){
		    obj.style.filter="blendTrans(duration="+ FadeDur+")";
		    if (obj.style.visibility!='visible'){
			    obj.style.visibility="hidden";
			    obj.filters.blendTrans.apply();
			    obj.style.visibility="hidden";
            }
		    if (obj.filters.blendTrans.status != 2) {
			    obj.filters.blendTrans.apply();
			    obj.style.visibility="visible";
			    obj.filters.blendTrans.play();
		    }
	    }	
	    else{
		    obj.style.visibility="visible";
	    }
	    }
	    catch(e){
	        obj.style.visibility="visible";
	    }
	}
	else
	{
	    obj.style.visibility="visible";
	}
	
}



function createSubSubImage(obj,tmpID,childcount,level){

	
	
	for(q=1;q<=obj.offsetParent.getElementsByTagName('TD').length;q++){
		if(obj.offsetParent.getElementsByTagName('TD')[q-1].className=='SubMenuDropDownTDOver'){
			obj.offsetParent.getElementsByTagName('TD')[q-1].className='SubMenuDropDownTD'
		}
	}
	
	obj.className = 'SubMenuDropDownTDOver'
	
	if(obj.getAttribute("childcount")>0){
		var tmpSubArray = eval('SubMenu' + obj.id);
		if(tmpSubArray!=undefined){
			
			ShowSubSubMenus(obj,obj.id,level+1)
		}
	}
}

function createSubSub(obj,tmpID,childcount,level){
    
	obj.className = 'SubMenuOver'
	
	if(obj.getAttribute("childcount")>0){
		var tmpSubArray = eval('SubMenu' + obj.id);
		if(tmpSubArray!=undefined){
			
			ShowSubSubMenus(obj,obj.id,level+1)
		}
	}
}

function ShowSubSubMenus(obj,sID,lvl){
	var tmpSubMenus = new String
	var tmpX
	 
	HideSelect()
	
	tmpX = FindXY(obj).x
	if(!document.getElementById('tbl' + sID)){

	tmpSubMenus = "<table class='MainSub' onmousemove=\"clearTimeout(t);IsOpen=1\" onmouseover=\"clearTimeout(t);IsOpen=1\"  onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' id='tbl"+ sID +"' level='"+ lvl +"' style=\"position:absolute;top:"+ parseInt(FindXY(obj).y+parseInt(offsetY)-2) +";left:"+ parseInt(FindXY(obj).x + parseInt(obj.clientWidth)) +"\" cellpadding=0 cellspacing=0>"
	var tmpSubItem = eval("SubMenu" + sID)

	if(tmpSubItem !=undefined){
		for(tCount=1;tCount<=tmpSubItem.length;tCount++){
			var tmptmpSubItem = tmpSubItem[tCount-1]
			
			if(tmptmpSubItem[6]!=tmptmpSubItem[1]){
			    AltTag = 'title = "'+ tmptmpSubItem[6] +'"'
			}
			else{
			    AltTag = ''
			}


		var sURL = new String
        sURL = tmptmpSubItem[5]	
			//alert(sURL)
        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
            sURL = sURL.substr(1)
        }            	
        else{
            sURL = "home.asp?pid="+ tmptmpSubItem[0]
        }


	    var swindowURL
		
        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){

            swindowURL = 'onclick="window.open(\''+ sURL.substr(1) + '\')"'           
        }            	
        else{
            if(tmptmpSubItem[7]=='_blank'){
                swindowURL = 'onclick="window.open(\''+ sURL + '\')"'            
            }
            else{
                swindowURL = 'onclick="window.location = \''+ sURL + '\'"'
            }
        }	
					
			
			if(tmptmpSubItem[2]>0){
				tmpSubMenus += "<tr "+ swindowURL +"  "+ AltTag +" oncontextmenu=\"ShowContextMenu(event,this,"+ tmptmpSubItem[0] +","+ sID +","+ tmptmpSubItem[4] +"); return false;\"><td nowrap style=\"vertical-align: middle\"><table width=100% class='SubMenu'  level='"+ lvl +"' childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' onmouseover='this.className = \"SubMenuOver\";HideAll("+ sID +",this.id,"+ lvl +");createSubSub(this,0,0,"+ parseInt(lvl) +")'  cellpadding=1 cellspacing=0><tr><td nowrap style=\"vertical-align: middle\">"+ tmptmpSubItem[1] + RightArrow+"</td></tr></table></td></tr>"
			}
			else{
				tmpSubMenus += "<tr "+ swindowURL +" "+ AltTag +" oncontextmenu=\"ShowContextMenu(event,this,"+ tmptmpSubItem[0] +","+ sID +","+ tmptmpSubItem[4] +"); return false;\"><td nowrap style=\"vertical-align: middle\"><table width=100% class='SubMenu'  level='"+ lvl +"' childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' onmouseover='this.className = \"SubMenuOver\";HideAll("+ sID +",this.id,"+ lvl +");createSubSub(this,0,0,"+ parseInt(lvl) +")' cellpadding=1 cellspacing=0><tr><td nowrap  style=\"vertical-align: middle\">"+ tmptmpSubItem[1] +"</td></tr></table></td></tr>"
			}
		}	
	}
	tmpSubMenus += "</table>"
	
	document.all.subHTML.innerHTML = document.all.subHTML.innerHTML + tmpSubMenus

    
	
	}
	else{

		
		document.all['tbl' + sID].style.display = ''

		
	}


	if(parseInt(document.getElementById('tbl' + sID).style.left)+parseInt(document.getElementById('tbl' + sID).clientWidth+25)>=document.body.clientWidth){document.getElementById('tbl' + sID).style.left = tmpX-document.getElementById('tbl' + sID).clientWidth-offsetX}
	
		FadeMakeObj(document.getElementById('tbl' + sID))
		
	    
}

function ShowSubMenus(obj,sID,lvl){
	var tmpSubMenus = new String
	var tmpMainx
	tmpMainx = FindXY(obj).x
	var sNewID=  new String
	sNewID = "tbl"+ sID
    
    HideSelect()
    
	if(!document.getElementById('tbl'+ sID)){
		if(Vertical){
		tmpSubMenus = "<table id=\""+ sNewID +"\" class='MainSub' onmousemove=\"clearTimeout(t);IsOpen=1\" onmouseover=\"clearTimeout(t);IsOpen=1\"  onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' level='"+ lvl +"'  style=\"position:absolute;left:"+ parseInt(FindXY(obj).x+parseInt(obj.clientWidth)) +";top:"+ parseInt(FindXY(obj).y) +"\" cellpadding=0 cellspacing=0>"
		}
		else{
		tmpSubMenus = "<table id=\""+ sNewID +"\" class='MainSub' onmousemove=\"clearTimeout(t);IsOpen=1\" onmouseover=\"clearTimeout(t);IsOpen=1\" onmouseout=\"clearTimeout(t);IsOpen=0;t=setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' level='"+ lvl +"'  style=\"position:absolute;left:"+ parseInt(FindXY(obj).x) +";top:"+ parseInt(FindXY(obj).y+parseInt(obj.clientHeight)+parseInt(offsetY)) +"\" cellpadding=0 cellspacing=0>"
		}
		
		var tmpSubItem = eval("SubMenu" + sID)
		if(tmpSubItem !=undefined){
			for(tCount=1;tCount<=tmpSubItem.length;tCount++){
				var tmptmpSubItem = tmpSubItem[tCount-1]
				
			    if(tmptmpSubItem[6]!=tmptmpSubItem[1]){
			        AltTag = 'title = "'+ tmptmpSubItem[6] +'"'
			    }
			    else{
			        AltTag = ''
			    }				



		var sURL = new String
        sURL = tmptmpSubItem[5]	
			//alert(sURL)
        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
            sURL = sURL.substr(1)
        }            	
        else{
            sURL = "home.asp?pid="+ tmptmpSubItem[0]
        }



	    var swindowURL
		
        if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){

            swindowURL = 'onclick="window.open(\''+ sURL.substr(1) + '\')"'           
        }            	
        else{
            if(tmptmpSubItem[7]=='_blank'){
                swindowURL = 'onclick="window.open(\''+ sURL + '\')"'            
            }
            else{
                swindowURL = 'onclick="window.location = \''+ sURL + '\'"'
            }
        }	
				
				if(tmptmpSubItem[2]>0){
					tmpSubMenus += "<tr "+ swindowURL +" "+ AltTag +" oncontextmenu=\"ShowContextMenu(event,this,"+ tmptmpSubItem[0] +","+ sID +","+ tmptmpSubItem[4] +"); return false;\"><td nowrap  ><table width=100% level='"+ lvl +"' class='SubMenu' childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' onmouseover='HideAll("+ sID +",this.id,"+lvl+");createSubSub(this,0,0,"+parseInt(lvl)+")' cellspacing=0 cellpadding=0><tr><td nowrap>"+ tmptmpSubItem[1] + RightArrow+"</td></tr></table></td></tr>"
				}
				else{
					tmpSubMenus += "<tr "+ swindowURL +"  "+ AltTag +" oncontextmenu=\"ShowContextMenu(event,this,"+ tmptmpSubItem[0] +","+ sID +","+ tmptmpSubItem[4] +"); return false;\"><td nowrap  ><table width=100% level='"+ lvl +"' class='SubMenu'  childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' onmouseover='HideAll("+ sID +",this.id,"+lvl+");createSubSub(this,0,0,"+parseInt(lvl)+")' cellspacing=0 cellpadding=0><tr><td nowrap>"+ tmptmpSubItem[1] +"</td></tr></table></td></tr>"
				}
			}	
		}
		tmpSubMenus += "</table>"
		
		document.all.subHTML.innerHTML = document.all.subHTML.innerHTML + tmpSubMenus
	
		
	}
	else{
	   
		document.getElementById('tbl' + sID).style.display=''

		
	}



		
	if(parseInt(document.getElementById('tbl' + sID).style.left)+parseInt(document.getElementById('tbl' + sID).clientWidth+25)>=document.body.clientWidth){document.getElementById('tbl' + sID).style.left = tmpMainx-document.getElementById('tbl' + sID).clientWidth-offsetX}



	FadeMakeObj(document.getElementById('tbl' + sID))
	
}

function FindXY(obj){
	if ( document.layers ) {
		return { x:obj.x, y:obj.y };
	}
	var res = { x:0,y:0 }; 
	while ( obj ) {
		res.x += parseInt( obj.offsetLeft, 0 );
		res.y += parseInt( obj.offsetTop, 0 );
		obj = obj.offsetParent;
	}
	
	
	return res;
}

function HideDelay(){
    
	Hide()
	
}

function openAddWindow(pid, priority, parentid, userName, pos){window.open('/dev/AddNewPage.asp?pid=' + pid + '&priority=' + priority + '&parentid=' + parentid + '&userName=' + userName + '&pos=' + pos , 'AddPage', 'width=301, height=615');}

function openPropertiesWindow(pid){window.open('/Tools/PageProperties/AdvancedPropertiesEdit.asp?id=' + pid + '&advanced=false', 'AddPage', 'width=490, height=615');}
