// JavaScript Document

function doSomething(x) {
	if (x=="meny_kontakt") c="aktiv_kontakt"; 
	else if (x=="meny_startsidan") c="aktiv_startsidan";
	else c="aktiv";
	var y=document.getElementById('meny').className;
	if (y)	document.getElementById(y).className="meny";
	document.getElementById(x).className=c;
	document.getElementById('meny').className=x;
}











function toggleVisibility(id, NNtype, IEtype, WC3type) {
    if (document.getElementById) {
        eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
            }
        }
    }
}

function move_box(an, box)
{
    var cleft = 0;
    var ctop = 10;
    var obj = an;

    while (obj.offsetParent)
    {
        cleft += obj.offsetLeft;
        ctop += obj.offsetTop;
        obj = obj.offsetParent;
    }

    cleft += an.offsetLeft - 88;

    box.style.left = cleft + 'px';

    //box.style.left = 250 + 'px';

    ctop += an.offsetHeight + 8;

    // Handle Internet Explorer body margins,
    // which affect normal document, but not
    // absolute-positioned stuff.
    if (document.body.currentStyle &&
        document.body.currentStyle['marginTop'])
    {
        ctop += parseInt(
            document.body.currentStyle['marginTop']);
    }

    //box.style.top = ctop + 'px';
    box.style.top = 150 + 'px';
}

// Shows a box if it wasn't shown yet or is hidden
// or hides it if it is curre
function show_hide_box(an, width, height, borderStyle)
{
    var href = an.href;
    var boxdiv = document.getElementById(href);

    if (boxdiv != null)
    {
        if (boxdiv.style.display=='none')
        {
            // Show existing box, move it
            // if document changed layout
            move_box(an, boxdiv);
            boxdiv.style.display='block';
        }
        else
            // Hide currently shown box.
            boxdiv.style.display='none';
        return false;
    }

    // Create box object through DOM
    boxdiv = document.createElement('div');

    // Assign id equalling to the document it will show
    boxdiv.setAttribute('id', href);

    
    boxdiv.style.display = 'block';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = width + 'px';
    //boxdiv.style.height = height + 'px';
    boxdiv.style.height = 'auto';
    boxdiv.style.border = borderStyle;
    boxdiv.style.textAlign = 'right';
    boxdiv.style.padding = '4px';
    boxdiv.style.background = '#ffffff';
	boxdiv.style.font = 'normal bold 10pt Trebuchet MS'
	boxdiv.style.color = '#666666'
    document.body.appendChild(boxdiv);

    var offset = 0;

    // Remove the following code if 'Close' hyperlink
    // is not needed.
    var close_href = document.createElement('a');
    close_href.href = 'javascript:void(0);';
    close_href.onclick = function()
       { show_hide_box(an, width, height, borderStyle); }
    close_href.appendChild(document.createElement('<img src="/KAKELNATET_2007/images/knapp_stang.gif" />'));
    boxdiv.appendChild(close_href);
    offset = close_href.offsetHeight;
    // End of 'Close' hyperlink code.

    var contents = document.createElement('iframe');
    contents.scrolling = 'no';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = (height - offset) + 'px';
    //contents.style.height = 'auto';

    boxdiv.appendChild(contents);

    move_box(an, boxdiv);

    if (contents.contentWindow)
        contents.contentWindow.document.location.replace(
            href);
    else
        contents.src = href;

    // The script has successfully shown the box,
    // prevent hyperlink navigation.
    return false;
}



