﻿// JScript File
<!--
    // code for the left menu -----------------------------
	function colourOn(obj){
	    document.getElementById(obj).style.color="#ffff99"
	}
    function colourOff(obj){
	    document.getElementById(obj).style.color=""
	}
	var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
	var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

	// Keep all the submenus hidden when load the page
	if (document.getElementById){
		document.write('<style type="text/css">\n')
		document.write('.leftSubMenu{display: none;}\n')
		document.write('</style>\n')
	}
	
	function SwitchMenu(obj)
	{
		if(document.getElementById){
		    // Save the menu to switch in a variable
		    var el = document.getElementById(obj);
		    // get all the span tags
		    var spanArray = document.getElementById("leftMenuContainer").getElementsByTagName("span");
			// If the menu is closed...
			if(el.style.display != "block")
			{
			    // close all the other menus
				for (var i=0; i<spanArray.length; i++){
					if (spanArray[i].className == "leftSubMenu")
					    spanArray[i].style.display = "none";
				}
				// Open the menu
				el.style.display = "block";
			}
			// To close/hide the submenu when is open
//			else{
//				el.style.display = "none";
//			}
		}
	}
	
	function get_cookie(Name) { 
		var search = Name + "="
		var returnvalue = "";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			if (offset != -1) { 
				offset += search.length
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				returnvalue=unescape(document.cookie.substring(offset, end))
			}
		}
		return returnvalue;
	}
	
	function onloadfunction()
	{
		if (persistmenu=="yes"){
			var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
			var cookievalue=get_cookie(cookiename)
			if (cookievalue!="")
				document.getElementById(cookievalue).style.display="block"
		}
	}
	
	function savemenustate()
	{
		var inc=1, blockid=""
		while (document.getElementById("sub"+inc)){
			if (document.getElementById("sub"+inc).style.display=="block"){
				blockid="sub"+inc
				break
			}
			inc++
		}
		var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
		var cookievalue=(persisttype=="sitewide")? blockid + ";path=/" : blockid
		document.cookie=cookiename + "=" + cookievalue
	}
	
	if (window.addEventListener)
		window.addEventListener("load", onloadfunction, false)
	else if (window.attachEvent)
		window.attachEvent("onload", onloadfunction)
	else if (document.getElementById)
		window.onload=onloadfunction

	if (persistmenu=="yes" && document.getElementById)
		window.onunload=savemenustate


/*******************************************************************************************************/
function NewWindow2_2(mypage, myname, w, h, scroll)
{
	// distances of the window from top and left border
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	// OBS! ingen radbrytning i texten nedan
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
	//slut på område utan radbrytning
	win = window.open(mypage, myname, winprops);
	
	if (parseInt(navigator.appVersion) >= 4)
	{ 
	    win.window.focus();
	}
}

function NewWindow2_3(mypage, myname, w, h, scroll)
{
	// distances of the window from top and left border
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 3;
	// OBS! ingen radbrytning i texten nedan
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
	//slut på område utan radbrytning
	win = window.open(mypage, myname, winprops);
	
	if (parseInt(navigator.appVersion) >= 4)
	{
	    win.window.focus();
	}
}

/* to login when pressing "Enter" button. Check even the code behind in the login page ***********************************************/
var __defaultFired = false;

function WebForm_FireDefaultButton(event, target)
{
    // 13 is the code for Enter Key
    if (!__defaultFired && event.keyCode == 13 && !(event.srcElement && (event.srcElement.tagName.toLowerCase() == "textarea")))
    {
        var defaultButton;
        if (__nonMSDOMBrowser) {
            defaultButton = document.getElementById(target);
        }
        else {
            defaultButton = document.all[target];
        }
        if (defaultButton && typeof(defaultButton.click) != "undefined")
        {
            __defaultFired = true;
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
        }
    }
    return true;
}

//-->