////////// START BODY LOAD EVENTS //////////
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(init);
function init() {
	// Do These things once when page loads:
	checkUitklapTekst();
	initHomeLogos();
	restorePulldownMenuVisibility();
}

function restorePulldownMenuVisibility() {
	if (document.getElementById("MenuControl_pnlMenuContainer")) {
		var me = document.getElementById("MenuControl_pnlMenuContainer");
		var ch = me.getElementsByTagName("UL");
		for (var i=0; i<ch.length; i++) {
			ch[i].style.visibility = "visible";
		}
	}
}

/* CUSTOM EXPANDABLE BOXES */
function checkUitklapTekst() {
	if (top.location.href.indexOf("siteexplorer.aspx") < 0) {
		var ps = document.getElementsByTagName("P");
		for (var i=0; i<ps.length; i++) {
			if (ps[i].className.indexOf("pVariant3") > -1) {
				ps[i].className = "pVariant3_inactive";
				ps[i].onclick = function() {
					toggleUitklapTekst(this);
				}
			}
		}
	}
}
function toggleUitklapTekst(element) {
	var ukt = element;
	if (ukt.className == "pVariant3_active") {
		ukt.className = "pVariant3_inactive";
	} else {
		ukt.className = "pVariant3_active";	
	}
	window.focus();
}


/* FONTSIZE FUNCTIONALITY */
function setActiveStyleSheet(title) {
   var i, a;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
function getActiveStyleSheet() {
   var i, a, strStyleTitle;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && !a.disabled) {
         try {
             strStyleTitle = a.getAttribute("title").toString();
             return strStyleTitle;
         } catch (err) {
            //alert(err);
         }
     }
   }
}
function increaseFontSize() {
	if (getActiveStyleSheet() == 'Tekst Size 1') {
		setActiveStyleSheet('Default');
	} else if (getActiveStyleSheet() == 'Default') {
		setActiveStyleSheet('Tekst Size 2');
	} else if (getActiveStyleSheet() == 'Tekst Size 2') {
		setActiveStyleSheet('Tekst Size 3');
	} else {
		//do nothing
	}
}
function decreaseFontSize() {
	if (getActiveStyleSheet() == 'Tekst Size 3') {
		setActiveStyleSheet('Tekst Size 2');
	} else if (getActiveStyleSheet() == 'Tekst Size 2') {
		setActiveStyleSheet('Default');
	} else if (getActiveStyleSheet() == 'Default') {
		setActiveStyleSheet('Tekst Size 1');
	} else {
		//do nothing
	}
}

/* HOMELOGOS */
function initHomeLogos() {
	if (top.location.href.indexOf("siteexplorer.aspx") < 0) {
		if (document.getElementById("logoslideshow")) {
			document.getElementById("logoslideshow").style.display = "block";
		}
	}
}

/* END */