function show_hide_div(adiv) {
    if (adiv.style.display == 'none') {
        adiv.style.display = 'block'; 
    } else {
        adiv.style.display = 'none'; 
    }
}

function overQuickLink(text) {
	document.all['link_hint'].innerHTML = text;
}

function outQuickLink() {
	document.all['link_hint'].innerHTML = 'Vælg en genvej';
}

function setCookie(name, value, expire) {
	if (value != null && value != '') {
		document.cookie = name + '=' + escape(value) + '; expires=' + expire.toGMTString();
	}
}

function getCookie(name) {
	var index = document.cookie.indexOf(name + '=');
	if (index == -1) {
		return null;
	}
	index = document.cookie.indexOf('=', index) + 1;
	var endstr = document.cookie.indexOf(';', index);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(index, endstr));
}

function setRowCookie(items_pr_row) {
	var today = new Date();
	var expire = new Date(today.getTime() + 100 * 24 * 60 * 60 * 1000); // plus 28 days

	setCookie('items_pr_row', items_pr_row, expire);
	if (getCookie('items_pr_row') != items_pr_row) {
		alert('Du har ikke slået cookies til og kan derfor ikke benytte denne funktion');
	} else {
		window.location.reload(true);
	}
}

function reportScrollPosition() {
	var x = document.body.scrollLeft;
	var y = document.body.scrollTop;
//	document.all['jump_to_top'].style.left = x;
//	document.all['jump_to_top'].style.top = y;
	return;
}


function findPosX(obj){
    var curleft = 0;
    if (document.getElementById || document.all){
        while (obj.offsetParent){
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (document.layers)
        curleft += obj.x;
    return curleft;
}


function findPosY(obj){
    var curtop = 0;
    if (document.getElementById || document.all){
        while (obj.offsetParent){
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (document.layers)
        curtop += obj.y;
    return curtop;
}

function setFade(objId, value){
    document.all[objId].style.filter = 'alpha(opacity=' + value + ')';
}

function fade(objId, start, end, steps, posi){
    if (posi == 0){
        document.all[objId].style.display = 'block';
    } 
    if (posi <= steps) {
        fadeVal = start + (posi * (end - start) / steps);
        setFade(objId, fadeVal);
        posi = posi + 1;
        setTimeout("fade('" + objId + "', " + start + ", " + end + ", " + steps + ", " + posi + ")", 10);
    }
}

function show_hint(text, obj){
    x = findPosX(obj);
    y = findPosY(obj);
    theHint = document.all["aHint"];

	theHint.innerHTML = text;
    theHint.style.left = x;
    theHint.style.top = y + 15;
    theHint.style.display = 'block';
    fade(theHint.id, 0, 85, 4, 0);
}

function hide_hint(){
    theHint = document.all["aHint"];
    theHint.style.display = 'none';
}
