function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=500');");
}


var timerID = Array();
var menuItems = Array();
var showSpeed = 200; //milliseconds
var hideSpeed = 400; // milliseconds
var hideDelay = 800; //milliseconds

function getMenuIndex(element)
{
// Find this menu in the list
for (idx in menuItems)
if(menuItems[idx] == element)
return idx;
// Indicate not found
return null;
}

function isSameTree(checkElement, referenceElement)
{
// Check if it's a parent
var parentElement = referenceElement;
while(null != parentElement)
{
if(parentElement == checkElement)
return true;
parentElement = parentElement.parentNode;
}

// Check if it's a child
var childList = referenceElement.getElementsByTagName("ul");
for(idx in childList)
if(childList[idx] == checkElement)
return true;
// Not in same tree
return false;
}

function cancelTimer(idx)
{
// If there's no timer running for this menu then bail
if(timerID[idx] == null)
return;
// Cancel and clear the timer
clearTimeout(timerID[idx]);
timerID[idx] = null;
}

function showMenu(idx)
{
// Kill the timer for this menu if it was running (i.e. about to hide)
cancelTimer(idx);
// Clear any sub menus that aren't in the tree being shown
for(clearIdx in menuItems)
if(!isSameTree(menuItems[clearIdx], menuItems[idx]))
clearMenu(clearIdx);
// Show the menu (with snazzy effect)
$(menuItems[idx]).stop(true, true).animate({height: "show", opacity: "show", fontSize: "show"}, showSpeed );
}

function hideMenu(idx)
{
// Clear the timer and fade out the menu
timerID[idx] = null;
$(menuItems[idx]).animate({height: "hide", opacity: "hide", fontSize: "hide"}, hideSpeed );
}

function clearMenu(idx)
{
// Immediately kill any timer and hide the menu (with no effect)
cancelTimer(idx);
$(menuItems[idx]).stop(true, true).hide();
}
//Nested Side Bar Menu (Mar 20th, 09)
//By Dynamic Drive: http://www.dynamicdrive.com/style/
 
var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
 
function initsidebarmenu()
{
for (var i=0; i<menuids.length; i++)
{
   var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
     for (var t=0; t<ultags.length; t++)
{
// Add to menu and timer lists
menuItems[t] = ultags[t];
timerID[t] = null;    

ultags[t].parentNode.getElementsByTagName("a")[0].className+=" subfolderstyle"
   if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
   {//dynamically position first level menuItems to be width of main menu item
ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" 
}
   else //else if this is a sub level submenu (ul)
     {//position menu to the right of menu item that activated it
ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" 
}
     ultags[t].parentNode.onmouseover=function()
{
showMenu(getMenuIndex(this.getElementsByTagName("ul")[0]));
     }
     ultags[t].parentNode.onmouseout=function()
{
var menuIdx = getMenuIndex(this.getElementsByTagName("ul")[0]);
     timerID[menuIdx] = setTimeout("hideMenu(" + menuIdx + ")", hideDelay);
     }
     }
   for (var t=ultags.length-1; t>-1; t--)
{ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
   ultags[t].style.visibility="visible"
   ultags[t].style.display="none"
   }
   }
}
 
if (window.addEventListener)
window.addEventListener("load", initsidebarmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", initsidebarmenu)

