activateMenu = function(nav) {

    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}

var popWin = window.createPopup();
var subPopWin = popWin.document.parentWindow.createPopup();
var Xpos = 0;
var Ypos = 0;
var timerId;
function createPopWindow(content,Height){
  popWin.document.body.innerHTML = "<div style=\"position:absolute; width:100%; height:"+Height+"px; display:block;\" onmouseover='parent.stopTime()' onmouseout='parent.delayClose()'>"+content.innerHTML+"</div>";
}
function createSubPopWindow(content,Height){
  subPopWin.document.body.innerHTML = "<div style=\"position:absolute; width:100%; height:"+Height+"px; display:block;\">"+content.innerHTML+"</div>";
  var div = subPopWin.document.getElementsByTagName('div')[0];
  div.attachEvent("onmouseover", stopTime);
  div.attachEvent("onmouseout", delayClose);
}

function showPopWindow(contentid,Yp,Height,width){
  stopTime();
  var content = document.getElementById(contentid);
  createPopWindow(content,Height);
  Xpos = document.documentElement.scrollLeft + event.clientX - event.offsetX -3;
  Ypos = document.documentElement.scrollTop + event.clientY - event.offsetY + Yp;
  popWin.show(Xpos,Ypos,width,Height,document.body);
  subPopWin.hide();
}

function showSubPopWindow(contentid,Xp,Yp,Height,width){
  stopTime();
  var content = document.getElementById(contentid);
  createSubPopWindow(content,Height);
  SubXpos = Xpos + Xp;
  SubYpos = Ypos + Yp;
  subPopWin.show(SubXpos,SubYpos,width,Height,document.body);
}

function getposOffset(what, offsettype){ 
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
var parentEl=what.offsetParent; 
while (parentEl!=null){ 
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
parentEl=parentEl.offsetParent; 
}
return totaloffset; 
} 

function delayClose(){
  timerId = setTimeout(closePop,600);
}

function closePop(){
  
  popWin.hide();
}

function stopTime(){
  clearTimeout(timerId);
}

function jumpUrl(url){
  window.top.location.replace(url);
}
