//*Items with children arrow style
var RightArrow = new String
var LeftArrow = new String 
var DownArrow = new String 

//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=3
var IsOpen

//Settings for offset of submenus
var offsetX = 0
var offsetY = -1
//Setting for menu layout [Vertical/Horizontal]
var Vertical = true
//Arrow settings
RightArrow = '<img src="/SiteSpecific/Includes/Menu/arrow-right.gif">'
DownArrow = '<img src="/SiteSpecific/Includes/Menu/arrow-right.gif">'

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++){
        document.getElementsByTagName('SELECT')[r].style.visibility = 'hidden'
        //document.getElementsByTagName('SELECT')[r].style.filter = 'revealTrans; height=50; width=100;'
        //document.getElementsByTagName('SELECT')[r].style.display = 'block'
    }

}


function ShowSelect(){

    for(r=0;r<=document.getElementsByTagName('SELECT').length-1;r++){
        document.getElementsByTagName('SELECT')[r].style.visibility = ''
    }

}

//*Create main menu table with main menus
function createMain(thisid){

	if(Vertical){
		tmpBody = "<table width=100% onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\" name=\"tblMain\" id=\"tblMain\"  class='BigMainMenuTable' cellspacing="+BigMainMenuTablePadding+" cellpadding="+BigMainMenuTableSpacing+"><tr>"
	}
	else{
		tmpBody = "<table  width=100% onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"  name=\"tblMain\" id=\"tblMain\"   class='BigMainMenuTable' cellspacing="+BigMainMenuTablePadding+" cellpadding="+BigMainMenuTableSpacing+">"
	}
	
	
	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, 9) == '/home.asp') {
     
        }
        else if (sURL.substr(0, 1) == '*' && sURL.search('toolid=') == '-1') {
            sURL = sURL.substr(1)
        }
        else {
            sURL = "home.asp?pid=" + tmpItem[0]
        }


        var tmpMainMouseover = new String

			if(MainMenu[maincount-1][2] > 0){
			
			
				tmpArrow = "<td  class='ArrowClass' width=1  style='vertical-align:middle'>"+ DownArrow +"</td>"
				tmpMainMouseover = "onmouseover='createSub(this,"+ MainMenu[maincount-1][0] +","+ MainMenu[maincount-1][2] +",0)'"
			}
			else{
				tmpArrow = "<td class='ArrowClass' width=1  style='vertical-align:middle'>&nbsp;</td>"
				tmpMainMouseover = "onmouseover='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 "+ AltTag +" oncontextmenu=\"ShowContextMenu(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 nowrap ><a href=\""+ sURL +"\" target=\""+ tmpItem[7] +"\">" + tmpItem[1] + "</a></td>"+ tmpArrow +"</tr></table></td>"
			
			
			if(Vertical){tmpBody += "</tr>"}
		}
	}
	
	if(Vertical){
		tmpBody += "<td width=100% ></td></tr></table>"
	}
	else{
		tmpBody += "</table>"
	}	

	document.writeln(tmpBody)
}


//*Create main menu table with main menus
function createParentMenu(thisid){
	var tmpBody
	if(Vertical){
		tmpBody = "<table width=100% onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"  cellpadding=0 cellspacing=0 name=\"tblMain\" id=\"tblMain\" class='BigMainMenuTable' ><tr>"
	}
	else{
		tmpBody = "<table  width=100% onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"  cellpadding=0 cellspacing=0 name=\"tblMain\" id=\"tblMain\" class='BigMainMenuTable' >"
	}
	
	
	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 tmpMainMouseover = new String
			
		        var sURL = new String
		        sURL = tmpItem[5]
			    //alert(sURL)

		        if (sURL.substr(0, 9) == '/home.asp') {

		        }        	
                else if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
                    sURL = sURL.substr(1)
                }            	
                else{
                    sURL = "home.asp?pid="+ tmpItem[0]
                }			
			
			
			
				if(tmpSubItem[maincount-1][2] > 0){
					tmpArrow = "<td  class='ArrowClass' width=1  style='vertical-align:middle'>"+ DownArrow +"</td>"
					//tmpMainMouseover = "  onmouseover='HideAll("+ sID +",this.id,"+lvl+");createSub(this,0,0,"+parseInt(lvl)+")' "
					tmpMainMouseover = "onmouseover='createSub(this,"+ tmpItem[0] +","+ tmpItem[2] +",0)'"

				}
				else{
					tmpArrow = "<td class='ArrowClass' width=1  style='vertical-align:middle'>&nbsp;</td>"
					//tmpMainMouseover = "   "
					tmpMainMouseover = "onmouseover='Hide();this.className=\"MainMenuOver\"'"

				}
				

	            if(tmpSubItem[maincount-1][6]!=tmpSubItem[maincount-1][1]){
	                AltTag = 'title = "'+ tmpSubItem[maincount-1][6] +'"'
	            }
	            else {
	                AltTag = ''
	            }	
				
				//tmpMainMouseover = ""
				//tmpArrow = ""
				
			//if(thisid==0 || thisid==tmpSubItem[maincount-1][2]){	
				if(Vertical){tmpBody += "<tr>"}
				
				tmpBody += 	"<td " +  AltTag + " oncontextmenu=\"ShowContextMenu(this,"+ tmpSubItem[maincount-1][0] +",1,"+ 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 nowrap ><a href=\""+ sURL +"\" target=\""+ tmpItem[7] +"\">" + tmpItem[1] + "</a></td>"+ tmpArrow +"</tr></table></td>"
				
				if(Vertical){tmpBody += "</tr>"}
			//}
		}
		
		if(Vertical){
			tmpBody += "<td width=100% ></td></tr></table>"
		}
		else{
			tmpBody += "</table>"
		}	

		document.writeln(tmpBody)
	}	
}


function HideMainPrevious(sID){

	if(sID!=undefined && !document.all['tbl' + sID]){
		sBody = ""
		document.all.subHTML.innerHTML = "<table cellpadding=0 cellspacing=0 height=0 style=\"position:absolute;left:1;top:1\"><tr><td></td></tr></table>"	
	}
}



function Hide(){

    try {
        if (event != null) {
            if (event.srcElement.tagName != 'IMG') {
                sBody = ""
                document.all.subHTML.innerHTML = "<table cellpadding=0 cellspacing=0 height=0 style=\"position:absolute;left:1;top:1\"><tr><td></td></tr></table>"
                document.all.contextmnu.style.display = 'none'
                DoNormalCSS()
                ShowSelect()
            }
        }
        else {
            if (IsOpen == 0) {
                sBody = ""
                document.all.subHTML.innerHTML = "<table cellpadding=0 cellspacing=0 height=0 style=\"position:absolute;left:1;top:1\"><tr><td></td></tr></table>"
                document.all.contextmnu.style.display = 'none'
                DoNormalCSS()
                ShowSelect()
            }
        }
    }
    catch (e) {
        sBody = ""
        document.all.subHTML.innerHTML = "<table cellpadding=0 cellspacing=0 height=0 style=\"position:absolute;left:1;top:1\"><tr><td></td></tr></table>"
        document.all.contextmnu.style.display = 'none'
        DoNormalCSS()
        ShowSelect()
    }
		
}

function createSubOnImage(obj,tmpID,level){

	var tmpSubArray = eval('SubMenu' + tmpID);
	//var tmpSubArray = document.all['SubMenu' + tmpID];
	if(tmpSubArray!=undefined){
		HideMainPrevious(tmpID)
		ShowSubMenusImage(obj,tmpID,level)
	}
	
}

//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)

            //if(sURL.substr(0,1)=='*' && sURL.search('toolid=')=='-1'){
            //    sURL = sURL.substr(1)
            //}            	
           // else{
            //    sURL = "home.asp?pid="+ tmpItem[0]
           // }	

					    
			    if(ThisArray[maincount-1][2] > 0){
				    tmpArrow = "<td  class='ArrowClass' width=1  style='vertical-align:middle'>"+ DownArrow +"</td>"
				    tmpMainMouseover = "onmouseover='createSub(this,"+ ThisArray[maincount-1][0] +","+ ThisArray[maincount-1][2] +",0)'"
			    }
			    else{
				    tmpArrow = "<td class='ArrowClass' width=1  style='vertical-align:middle'>&nbsp;</td>"
				    tmpMainMouseover = "onmouseover='Hide();this.className=\"MainMenuOver\"'"
			    }
    			
		    
			    if(Vertical){tmpBody += "<tr>"}
    			
			    tmpBody += 	"<td ><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 ><a href=\""+ sURL +"\" >" + tmpItem[1] + "</a></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='"+ lvl +"' id='tbl"+ sID +"' style=\"position:absolute;left:"+ parseInt(FindXY(obj).x+2) +";top:"+ parseInt(FindXY(obj).y+obj.clientHeight+1) +"\" 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]
        	
            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 = ''
			}
			
			if(tmptmpSubItem[2]>0){
				tmpSubMenus += "<tr "+ AltTag +" onclick=\"document.location.href = 'home.asp?pid="+ tmptmpSubItem[0] +"'\" style='cursor:hand'><td nowrap  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 +"\"  class=SubMenuDropDownA>"+ tmptmpSubItem[1] +"</a></td></tr></table></td></tr>"
			}
			else{
				tmpSubMenus += "<tr "+ AltTag +" title='"+ tmptmpSubItem[6] +"' onclick=\"document.location.href = 'home.asp?pid="+ tmptmpSubItem[0] +"'\"  style='cursor:hand'><td nowrap  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 +"\"  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(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'
		}
	}
	}
	

	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 createContextMenu(){
	var sContext
	
	if(!document.all.contextmnu){
	
		sContext = '<div class="skin0" onmouseover=\"IsOpen=1\" style="zIndex:99;z-Index:99;display:none;position: absolute;cursor:hand" name=contextmnu id=contextmnu onMouseover="highlightie5()" onMouseout="lowlightie5()"'
		sContext+=	'	>'
		sContext+= '		<!--<a href="#" class="menuitems" id="APA" style="border:0">Insert page above</a>-->'
		sContext+= '		<a href="#" class="menuitems" onclick="Add(\'after\')" id="APB" style="border:0">New page</a>'
		sContext+= '		<a href="#" class="menuitems" onclick="Add(\'sub\')" id="APS" style="border:0">New sub page</a>'
		sContext+= '		<!--hr>'
		sContext+= '		<a href="#" class="menuitems" id="MPU" style="border:0">Move page up</a>'
		sContext+= '		<a href="#" class="menuitems" id="MPD" style="border:0">Move page down</a-->'
		sContext+= '		<hr id="menuHR">'
		sContext+= '		<!--<div class="menuitems" id="Info" style="border:0">Page info</a>-->'
		sContext+='		<a href="#" class="menuitems" onclick="Prop()"  id="Prop" style="border:0">Properties</a>'
		sContext+= '</div>	'
		
	document.writeln(sContext)
	}
}

function createContextMenu2(){
	var sContext
	//alert('aa')
	if(!document.all.contextmnu){
		sContext = '<table name=contextmnu id=contextmnu style="visibility: hidden;display:none" width=0 height=0 ><tr></td></td></tr></table>'
		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(obj,deleteID,AddID,Priority){
	var sContext = new String
	sAddID = deleteID
	sParentID = AddID
	sPriority = Priority
	document.all.contextmnu.style.top = event.clientY + document.body.scrollTop
	document.all.contextmnu.style.left = event.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(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";
//    }


}



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) == undefined || document.getElementById('tbl' + sID) == null) {


	tmpSubMenus = "<table class='MainSub'  onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' id='tbl"+ sID +"' level='"+ lvl +"' style=\"z-Index:3;position:absolute;top:"+ parseInt(FindXY(obj).y+offsetY) +";left:"+ parseInt(FindXY(obj).x + obj.clientWidth+offsetX+2) +"\" cellpadding=0 cellspacing=0>"
	var tmpSubItem = eval("SubMenu" + sID)
	
    

	if(tmpSubItem !=undefined){
		for(tCount=1;tCount<=tmpSubItem.length;tCount++){
			var tmptmpSubItem = tmpSubItem[tCount-1]

            var sURL = new String
            sURL = tmptmpSubItem[5]

            if (sURL.substr(0, 9) == '/home.asp') {

            }
            else if(sURL.substr(0,1)=='*'){
                sURL = sURL.substr(1)
            }            	
            else{
                sURL = "home.asp?pid="+ tmptmpSubItem[0]
            }

			
			
			if(tmptmpSubItem[6]!=tmptmpSubItem[1]){
			    AltTag = 'title = "'+ tmptmpSubItem[6] +'"'
			}
			else{
			    AltTag = ''
			}


			if (tmptmpSubItem[2] > 0 && sID != tmptmpSubItem[0]) {
				tmpSubMenus += "<tr "+ AltTag +" oncontextmenu=\"ShowContextMenu(this,"+ tmptmpSubItem[0] +","+ sID +","+ tmptmpSubItem[4] +"); return false;\"><td nowrap ><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>&nbsp;<a href=\""+ sURL +"\" target=\""+ tmptmpSubItem[7] +"\">"+ tmptmpSubItem[1] +"</a></td><td width=1 class='ArrowClass'  style='vertical-align:middle'>"+RightArrow+"</td></tr></table></td></tr>"
			}
			else{
				tmpSubMenus += "<tr "+ AltTag +" oncontextmenu=\"ShowContextMenu(this,"+ tmptmpSubItem[0] +","+ sID +","+ tmptmpSubItem[4] +"); return false;\"><td nowrap ><table width=100% class='SubMenu'  level='"+ lvl +"' childcount='"+ tmptmpSubItem[2] +"' id='"+ tmptmpSubItem[0] +"' onmouseover='this.className = \"SubMenuOver\";HideAll("+ sID +",this.id,"+ lvl +");' cellpadding=1 cellspacing=0><tr><td nowrap>&nbsp;<a href=\""+ sURL +"\" target=\""+ tmptmpSubItem[7] +"\">"+ tmptmpSubItem[1] +"</a></td><td width=1 class='ArrowClass'  style='vertical-align:middle'>&nbsp;</td></tr></table></td></tr>"
			}
		}	
	}
	tmpSubMenus += "</table>"
	document.all.subHTML.innerHTML = document.all.subHTML.innerHTML + tmpSubMenus
	}
	else{
		if(document.getElementById('tbl' + sID).style.display=='none'){
			document.getElementById('tbl' + sID).style.visibility="hidden";
		}
		
		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 = (parseInt(tmpX)-parseInt(document.getElementById('tbl' + sID).clientWidth)-parseInt(offsetX)) + 'px'}

		FadeMakeObj(document.getElementById('tbl' + sID))
	
}


function isArray() 
{
  if (typeof arguments[0] == 'object')
  {  
    var criterion = arguments[0].constructor.toString().match(/array/i);
   return (criterion != null);  
  }
  return false;
}



function ShowSubMenus(obj,sID,lvl){
	var tmpSubMenus = new String
	var tmpMainx
	tmpMainx = FindXY(obj).x
	HideSelect()


	if(!document.getElementById('tbl'+ sID)){
		if(Vertical){
		tmpSubMenus = "<table class='MainSub' onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' level='"+ lvl +"' id='tbl"+ sID +"' style=\"position:absolute;left:"+ parseInt(FindXY(obj).x+obj.clientWidth+offsetX+3) +";top:"+ parseInt(FindXY(obj).y+offsetY) +"\" cellpadding=0 cellspacing=0>"
		}
		else{
		tmpSubMenus = "<table class='MainSub' onmouseover=\"IsOpen=1\" onmouseout=\"IsOpen=0;setTimeout('HideDelay()',TimeOut)\"   name='tbl"+ sID +"' level='"+ lvl +"' id='tbl"+ sID +"' style=\"position:absolute;left:"+ parseInt(FindXY(obj).x+offsetX) +";top:"+ parseInt(FindXY(obj).y+obj.clientHeight+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]


                var sURL = new String
                sURL = tmptmpSubItem[5]

                if (sURL.substr(0, 9) == '/home.asp') {

                }    	            
                else if(sURL.substr(0,1)=='*'){
                    sURL = sURL.substr(1)
                }            	
                else{
                    sURL = "home.asp?pid="+ tmptmpSubItem[0]
                }

			    if(tmptmpSubItem[6]!=tmptmpSubItem[1]){
			        AltTag = 'title = "'+ tmptmpSubItem[6] +'"'
			    }
			    else{
			        AltTag = ''
			    }				
				
				if(tmptmpSubItem[2]>0){
					tmpSubMenus += "<tr "+ AltTag +" oncontextmenu=\"ShowContextMenu(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>&nbsp;<a class='SubMenuItem' target=\""+ tmptmpSubItem[7] +"\" href=\""+ sURL +"\">"+ tmptmpSubItem[1] +"</a></td><td width=1 class='ArrowClass'  style='vertical-align:middle'>"+RightArrow+"</td></tr></table></td></tr>"
				}
				else{
					tmpSubMenus += "<tr "+ AltTag +" oncontextmenu=\"ShowContextMenu(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>&nbsp;<a class='SubMenuItem' target=\""+ tmptmpSubItem[7] +"\" href=\""+ sURL +"\">"+ tmptmpSubItem[1] +"</a></td><td width=1 class='ArrowClass'  style='vertical-align:middle'>&nbsp;</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=500, height=600, scrollbars=yes');}


//for(qwerty=1;qwerty<=document.getElementID;){


//}

//function openPropertiesWindow(pid){window.open('/dev/AddNewPage.asp?pid=' + pid + '&act=edit&priority=0&parentid=0', 'AddPage', 'width=301, height=615');}