// MAIN MENU FUNCTIONS
var highlightedMenu = null;

function capevoMainmenuMouseOver(menubutton)
{
    if ((menubutton.className != "capevomenuButtonHover") && (menubutton.className != "capevomenuButtonLeftHover"))  //only hightlight menuitem if it is not highlighted by default
    {
        if (menubutton.className == "capevomenuButtonLeft")
        {
            menucorner = document.getElementById("capevomainmenuLeftcorner");
            menucorner.setAttribute("className", "capevomainmenuLeftcornerHover");
	menucorner.setAttribute("class", "capevomainmenuLeftcornerHover");
            menubutton.className = "capevomenuButtonLeftHover";
        }
        else
        {
            menubutton.className = "capevomenuButtonHover";
        }
    }
    else
    {
        highlightedMenu = menubutton;
    }
}

function capevoMainmenuMouseOut(menubutton)
{
    if (menubutton != highlightedMenu) //only remove hightlight from menuitem if it is not highlighted by default
    {
        if (menubutton.className == "capevomenuButtonLeftHover")
        {
            menucorner = document.getElementById("capevomainmenuLeftcorner");
            menucorner.setAttribute("className", "capevomainmenuLeftcorner");
	menucorner.setAttribute("class", "capevomainmenuLeftcorner");
            menubutton.className = "capevomenuButtonLeft";
        }
        else
        {
            menubutton.className = "capevomenuButton";
        }
    }
}

function gotoChildLink(ahrefObject)
{
	if (ahrefObject.childNodes[0].target != "_blank")
	{
	    document.location.href = ahrefObject.childNodes[0].href;
	}
	else
	{
		ahrefObject.childNodes[0].click();
		//window.open(ahrefObject.childNodes[0].href);	
	}
}

var printContentHTML = null;
var iframePrint = null;
var ifWin = null;

function printContent(nodeID)
{
    var id = "printframe";
    iframePrint = document.frames ? document.frames[id] : document.getElementById(id);
    ifWin = iframePrint.contentWindow || iframePrint;
    ifWin.location.href = "/print.aspx?NodeID=" + nodeID;
}

function printFrame()
{
    var id = "printframe";
    var iframe = document.frames ? document.frames[id] : document.getElementById(id);
    var ifWinX = iframe.contentWindow || iframe ;
//alert(ifWinX.document.getElementById('printHTMLContent'));
    ifWinX.document.getElementById('printHTMLContent').innerHTML = document.getElementById("mainText").innerHTML;
    ifWinX.focus();
    ifWinX.print();
}	

//FRONTPAGE SEARCH FUNCTIONS

function searchButtonHover(hoverbutton, imagepath)
{
    hoverbutton.src=imagepath;
    shadowElement = document.getElementById("searchButtonShadowImage");
    shadowElement.setAttribute("class","searchButtonShadowHover"); //Mozilla
    shadowElement.setAttribute("className","searchButtonShadowHover"); //IE
}

function searchButtonOut(hoverbutton, imagepath)
{
    hoverbutton.src=imagepath;
    shadowElement = document.getElementById("searchButtonShadowImage");
    shadowElement.setAttribute("class","searchButtonShadow"); //Mozilla
    shadowElement.setAttribute("className","searchButtonShadow"); //IE
}

// FRONTPAGE LOGIN FUNCTIONS

function loginButtonHover(hoverbutton, imagepath)
{
    hoverbutton.src=imagepath;
    shadowElement = document.getElementById("loginButtonShadowImage");
    shadowElement.setAttribute("class","loginButtonShadowHover"); //Mozilla
    shadowElement.setAttribute("className","loginButtonShadowHover"); //IE
}

function loginButtonOut(hoverbutton, imagepath)
{
    hoverbutton.src=imagepath;
    shadowElement = document.getElementById("loginButtonShadowImage");
    shadowElement.setAttribute("class","loginButtonShadow"); //Mozilla
    shadowElement.setAttribute("className","loginButtonShadow"); //IE
}


// FRONTPAGE PANEL FUNCTIONS

function selectPanel(panel)
{

    document.getElementById("PB1").className = "panelbar";
    document.getElementById("PB2").className = "panelbar";
    document.getElementById("PB3").className = "panelbar";
    document.getElementById("PB4").className = "panelbar";
    panel.className = "panelbarActive";
}


//FRONTPAGE TABPANEL FUNCTIONS

var activeTab = 1;

function openTab(tabId) {
    // reset old tab and content
    document.getElementById("tabLink"+activeTab).className = "boxmnuinactive";
    document.getElementById("tabContent"+activeTab).className = "tabContent";

    // set new tab and content
    document.getElementById("tabLink"+tabId).className = "boxmnuactive";
    document.getElementById("tabContent"+tabId).className = "tabContentActive";
    activeTab = tabId;
    setCookie('activeContentTabID',activeTab,365);
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function checkTabpanelCookie()
{
username=getCookie('activeContentTabID');
if (username!=null && username!="")
  {
    openTab(username);
  }
}

function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
     window.onload = function() {   
       if (oldonload) {   
         oldonload();   
       }   
       func();   
     }   
   }   
}   

function addUnloadEvent(func) {   
   var oldonload = window.onunload;   
   if (typeof window.onunload != 'function') {   
     window.onunload = func;   
   } else {   
     window.onunload = function() {   
       if (oldonload) {   
         oldonload();   
       }   
       func();   
     }   
   }   
}   


var Browser = {  
Version: function() {
    var version = 999; // we assume a sane browser
    if (navigator.appVersion.indexOf("MSIE") != -1)
      // IE, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }}

function hightlightmenu(menuitem)
{
	if (Browser.Version() >= 7) {menuitem.style.backgroundColor = '#ffffff'; menuitem.style.cursor = 'pointer';}
}

function downlightmenu(menuitem)
{
	if (Browser.Version() >= 7) {menuitem.style.backgroundColor = ''}
}

function checkLogout()
{
	if (document.location.href.indexOf("websitelogout=true") < 0)
	{
		document.location.href = document.location.href + "?websitelogout=true";
	}
}