
//---------------- DropDown Top Menu Functions --------------------

function ShowDropDownMenu(elm,IsVisible) {
  window.event.cancelBubble = true;
  var str = new String(elm.href);
  var lastslash = str.lastIndexOf("/");
  var sel = "div_"+str.substr(lastslash+1).toUpperCase();
  var dropBlock = document.all(sel);
  if(dropBlock == null) return;
  if(IsVisible) { //alert(elm.href);
    dropBlock.style.visibility = "visible";
    dropBlock.style.display = "block";
    dropBlock.style.left= TopMenu.offsetLeft + elm.offsetLeft - 7; //TopMenu is ID of top menu TD
    dropBlock.style.top= TopMenu.offsetTop+elm.offsetTop+elm.offsetHeight; //TopMenu is ID of top menu TD    
  } else {
    dropBlock.style.display = "none";
    dropBlock.style.visibility = "hidden";
  }
}

function OutTopMenu(elm){
  window.event.cancelBubble = true;
  var str = new String(elm.href);
  var lastslash = str.lastIndexOf("/");
  var sel = "div_"+str.substr(lastslash+1).toUpperCase();
  if(window.event.toElement == null || window.event.toElement.id != sel){
    ShowDropDownMenu(elm,false);
  }else {
    ShowDropDownMenu(elm,true);
  }
}

function vmHasParent(who, parent) {
  if (who != null) {
    var p = who.parentElement;
    while (p != null) {
      if (p == parent) {
        return true;
      }
      p = p.parentElement;
    }
  }
  return false;
}

function OutDropBlockMenu(elm){
  window.event.cancelBubble = true;
  var dropBlock = elm;
  var coll = document.links;
  var parentLink = null;
  if (coll!=null) {
    for (var i=0; i<coll.length; i++){
     //alert(coll.item(i).href)
      var itl = coll.item(i);
      var lastslash = itl.href.toString().lastIndexOf("/");
      var sel = null;
      if(lastslash != -1)
        sel = "div_"+itl.href.toString().substr(lastslash+1).toUpperCase();
      if(sel != null && sel == elm.id) {
        parentLink = itl;//alert(parentLink.href);
        break;
      }
    }
  }
  if(window.event.toElement != parentLink && window.event.toElement != elm && !vmHasParent(window.event.toElement, elm)){
      dropBlock.style.display = "none";
      dropBlock.style.visibility = "hidden";
  }else {
      dropBlock.style.display = "block";
      dropBlock.style.visibility = "visible";
  }
}

function printVersion(){
  var board=window.open("","printVer");
  var str = new String(EDodescr.innerHTML);
  var re = /<SPAN class=floatframeRight title=.* onclick=printVersion\(\)><IMG hspace=10 src="\/img\/imgsuper\/printVer.gif" border=0><BR>Printable version<\/SPAN>/ig;
  str=str.replace(re,'');  //Corrects text for printable version
  board.document.open();
  board.document.write("<html>");
  board.document.write('<head><title>Printable version</title><link REL="stylesheet" TYPE="text/css" HREF="/CSS/super.css"></head>');
  board.document.write("<body>");
  board.document.write(str);
  board.document.write("</body>");
  board.document.write("</html>");
  board.document.close();
}


/* -------------- Click on text near controls can be handled as a clcik on the control (if the control is a child of course).
                   Click on TD can be handled as a clcik on a link inside TD. -----  */

function clickOnParent(obj){
  if(obj != null){
    var coll=obj.children;
    if(coll != null){
      for(var i=0;i<coll.length;i++){
        coll.item(i).click();
      }
    }
  }
}

