function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


//======================== W3C compliant Popup script
function popupLauncher()
{
  if( document && document.body && document.getElementById && document.getElementsByTagName )
   {
     var alinks = document.getElementsByTagName('A');

     for( i=0; i < alinks.length; i++ )
     {
      if( alinks[i].rel == "external" )
       {
         try
         {
          alinks[i].target = "_blank";
         }
         catch(e)
          {}
//         alinks[i].onclick = function tmp() { window.open(this.href,'_blank'); return false; }
       }
     }
   }
}

 // jQuery function to collapse menu, jQuery library must be loaded first!
function collapseMenu( level, index  )
{
  if( index <= 1 )
  {
    $(document).ready(function()
    {			
      var sId = "#submenu-"+level; 
      try
      {
        $(sId).hide();
        $(sId ).slideDown( "slow" );
      }
      catch(e) {}
    });
  }
}

function videopopup(elem) {
        url=elem.getAttribute('href');
	newwindow=window.open(url,'name','height=400,width=641');
	if (window.focus) {newwindow.focus()}
	return false;
}


//======================== IE6 antiflicker
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


addLoadEvent(popupLauncher);

