﻿
function InitLeftMenu() {
    var i = 0;
    var item = document.getElementById("left-menu-parent-0");
    while (item) {
        var linkText = item.firstChild.innerHTML.replace("&amp;", "*AND*");
        var linkPath = item.firstChild.href;
        var flobj = new SWFObject("/gfx/left-menu-item.swf?linkText=" + linkText.toUpperCase() + "&linkPath=" + linkPath, "leftMenuItem_" + i, "150", "20", "8", "");
        flobj.addParam("quality", "high");
        flobj.addParam("menu", "false");
        flobj.addParam("wmode", "transparent");
        flobj.write("left-menu-parent-" + i);
        i++;
        item = document.getElementById("left-menu-parent-" + i);
    }
}
    

function SearchSite()
{
    var query = document.getElementById("search-query").value;
    if (query.length > 0) {
        for (var i = 0; i < query.length; i++) {
            query = query.replace("å", "_aring;").replace("ä", "_auml;").replace("ö", "_ouml;");
            query = query.replace("Å", "_Aring;").replace("Ä", "_Auml;").replace("Ö", "_Ouml;");
        }
        top.location.href = "/Page.aspx?path=sokresultat&query=" + query + "&ctrl=SearchResult";
    }
}

function SearchCheckKey(e)
{
    var code, character;
    if (!e)
        var e = window.event;
	if (e.keyCode)
	    code = e.keyCode;
	else if (e.which)
	    code = e.which;
	
	if (code == 13)
	{
	    SearchSite();
	    return false;
	}
}

function ShowFloatingMessage(msg) {
    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;
    }

    var box = document.getElementById("floatingMessageBox");
    box.style.left = (myWidth - 140) + "px";
    box.style.top = (myHeight - 120) + "px";
    box.firstChild.innerHTML = msg;
    
    box.style.opacity = "0";
    box.style.filter = "alpha(opacity=50);";
    box.style.display = "block";
    
    box.style.display = "block";
    FadeFloatingMessage(0, true);
}

function FadeFloatingMessage(op, fadeUp) {
    if ((fadeUp && op <= 1) || (!fadeUp && op > 0)) {
        var box = document.getElementById("floatingMessageBox");
        op = (fadeUp ? op + 0.05 : op - 0.05);
        box.style.opacity = op;
        box.style.filter = "alpha(opacity=" + (op * 100) + ");";
        setTimeout("FadeFloatingMessage(" + op + ", " + fadeUp + ")", 20);
    }
    else if (fadeUp) {
        setTimeout("FadeFloatingMessage(1, false)", 5000);
    }
}

function popWindow(url, id, width, height, resize) {
	if (parseInt(navigator.appVersion) >= 3) {
		if (navigator.userAgent.indexOf("Netscape") > -1 && parseInt(navigator.appVersion) < 5) {
			var tools = new Packages.java.awt.Toolkit.getDefaultToolkit();
			screen = tools.getScreenSize();
		}
	}
	var x = screen.width;
	var y = screen.height;
	window.open(url, id, "top=" + parseInt(y/2-height/2-16) + ",left=" + parseInt(x/2-width/2-5) + ",width=" + width + ",height=" + height + ",scrollbars=1, status=1, resizable=" + resize);
}

var PositionX = 100;
var PositionY = 100;
var defaultWidth  = 500;
var defaultHeight = 500;
var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}