function openLink(url, target) {
  var link=window.open(url,target);
  link.focus();
}

//////////////////////////////
// RESIZE
/////////////////////////////
function resizeMain() {
  var height = getScreenSize("height");
 
  document.getElementById('contentFrame').style.height = (height-absTopPosition(document.getElementById('contentFrame')))+"px";
  document.getElementById("content").style.height=height+"px";
  document.getElementById("borderleft").style.height=height+"px";
  document.getElementById("borderright").style.height=height+"px";
}
  
function getScreenSize(type) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == "number" ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in "standards compliant mode"
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  if(type=="width")
    return myWidth;
  else
    return myHeight;  
}

/////////////////////////////////////
// Diverse Funktionen
////////////////////////////////////
function absTopPosition(el) {
  return (el.offsetParent)? 
  el.offsetTop+absTopPosition(el.offsetParent) : el.offsetTop;
}

function absLeftPosition(el) {
  return (el.offsetParent)? 
  el.offsetLeft+absLeftPosition(el.offsetParent) : el.offsetLeft;
}

/////////////////////////////////
// FUNKTION für das dyn. Menu
////////////////////////////////
function showMenu(menu) {
  var menunode = document.getElementById(menu).cloneNode(true);
  var hovermenu = document.getElementById('hoverMenu');
  while(hovermenu.hasChildNodes()) {
    hovermenu.removeChild(hovermenu.firstChild);
  }
  hovermenu.appendChild(menunode);
  hovermenu.firstChild.style.display = 'block'; 
}

function closeSubMenu(s_node) {
  if(s_node==null)
    return;
  for(var i=0; i<s_node.childNodes.length; i++)
  {
    var cnode = s_node.childNodes[i];
    if(cnode.className=="contextmenu")
    {
      closeSubMenu(cnode);
      for(var j=0; j<cnode.childNodes.length; j++)
      {
        if(cnode.childNodes[j].className=='cm_entry cm_entry_hover')
          cnode.childNodes[j].className='cm_entry';
      }
      cnode.style.display = "none";
    }    
  }
}

function closeMenuTimeOut(menu) {
  eval('var bool = bool_cmenu_'+menu+';')
  eval('time_cmenu_'+menu+'--; var time = time_cmenu_'+menu+';');
  
  if(bool==false && time==0)
  {
    closeMenu(menu);
    eval('click_cmenu_'+menu+'=false;');
  }
}

function closeMenu(menu) {
  eval('click_cmenu_'+menu+'=true;');
  eval('bool_cmenu_'+menu+'=false;');
  var cm_node = document.getElementById("cmenu_"+menu);
  if(cm_node!=null)
  {
    closeSubMenu(cm_node);
    for(var j=0; j<cm_node.childNodes.length; j++)
    {
     if(cm_node.childNodes[j].className=='cm_entry cm_entry_hover')
       cm_node.childNodes[j].className='cm_entry';
    }
    cm_node.style.display='none';
  }
}

function hoverEntry(entry) {
  var sibs = entry.parentNode.childNodes;
  for(var i=0; i<sibs.length; i++)
  {
    if (sibs[i].className=='cm_entry cm_entry_hover')
      sibs[i].className='cm_entry';
  }
  entry.className='cm_entry cm_entry_hover';
  var parent = entry.parentNode.previousSibling;
  if(parent!=null && parent.className=='cm_entry')
    hoverEntry(entry.parentNode.previousSibling);
}
