function fjerntekst(){
    document.getElementById("sokeboks").value = "";
}

var open=function(hash){
    hash.w.fadeIn(200);
    hash.o.fadeIn(200);
};
var close=function(hash) {
    hash.w.fadeOut(200);
    hash.o.fadeOut(200,function(){ hash.o.remove(); });
};


$(document).ready(function() {
    var dialogWidth = $('#imagedialog').width();
    var dialogOffsetWidth = document.getElementById('imagedialog').offsetWidth;
    var dialogLeft = (document.body.offsetWidth - dialogOffsetWidth)/2 - dialogWidth/2 + "px";
    $('#imagedialog').css("left", dialogLeft);
    $('#imagedialog').jqm({
        onShow: open,
        onHide: close
    });
});



function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}


function windowWidthAndHeight() {
    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;
    }
    return [myWidth,myHeight]
}


// Justering av bunn-elementer
function justerElementer(){
    var footerRoof = document.getElementById("FooterRoof");
    var footerRoofPos = findPos(footerRoof);
    var footer = document.getElementById("Bunn");
    var histlogo = document.getElementById("Histlogo");
    var ramme = document.getElementById("Ramme");
    var windowSize = windowWidthAndHeight();
    var footerRoofHeight = windowSize[1]-(footerRoofPos[1] + 65);
    if(footerRoofHeight < 1){
        footerRoofHeight = 1;
    }
    footerRoof.style.height = footerRoofHeight+'px';
    var footerPos=findPos(footer);
    var rammePos=findPos(ramme);
    histlogo.style.top=footerPos[1]+'px';
    histlogo.style.left=(rammePos[0]+951)+'px';
}

window.onresize = justerElementer;