function zoomImage(url, width, height) {
    if(!url || !width || !height) return;
    width += 20;
    height += 10;
    var win = window.open('', 'zoomimg', 'width='+width+',height='+height+'resizable=0,scrollbars=0,directories=0,location=0,menubar=0,status=0,toolbar=0');
    if(win) {
        win.document.open();
        win.document.write('<html><head><title>Skiforeningen.no</title></head><body style="margin:0;padding:0;" onclick="self.close();">' +
            '<div align="center"><img src="'+url+'" border="0" alt="" title="klikk på bilder for å lukke"></div>' +
            '</body></html>');
        win.document.close();
        win.focus();
    }
}


/* scripts for the area map (including image preloading) */

function newImage(arg) {
	if (document.images) {
		var rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
	return null;
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<arguments.length; i+=2) {
			document[arguments[i]].src = arguments[i+1];
		}
	}
}

var preloadFlag = false;

var preloadImageList=Array();
var preloadedImages=Array();

function addPreloadImage(imgsrc) {
	preloadImageList.push(imgsrc);
}

function preloadImages() {
	if (document.images) {
		while(preloadImageList.length>0) {
			var imgsrc=preloadImageList.shift();
			preloadedImages.push(newImage(imgsrc));
		}
		preloadFlag=true;
	}
}

/* scripts for the foremelding arkiv */

function foremeldingResult_ShowMore(event) {
	if (!event) event=window.event;
	var target=event.target;
	if (!target) target=event.srcElement;
	var kids=target.parentNode.childNodes;
	var i;
	for(i=0;i<kids.length;i++) {
		if (kids[i].nodeType==1 && kids[i].className=="foremelding_arkiv_result_more") {
			if (kids[i].style.display=='block') {
				kids[i].style.display='none';
				target.firstChild.data="mer...";
			} else {
				kids[i].style.display='block';
				target.firstChild.data="mindre...";
			}
			break;
		}
	}
}

/** Scripts for the content rotator - used on the front page, maybe elsewhere.
 * use:
 * 1. make sure all the elements to be rotated have unique IDs,
 * 2. find an unused (for this page) shuffler number,
 * 3. call addRotated(shufflernum,elemid) for each element to be rotated.
 * 4. after all elements are added, call startRotation(shufflernum).
 *
 * On the front page, numbers 0 and 1 are already used.
 */
var shuffle=Array();
function addRotated(shufflernum,elemid) {
	if (undefined==window.shuffle[shufflernum] || undefined==window.shuffle[shufflernum].push) {
		window.shuffle[shufflernum]=Array();
	}
	window.shuffle[shufflernum].push(elemid);
}
function rotate(shufflernum,show) {
	var hide = show + 1;
	if(hide >= window.shuffle[shufflernum].length) hide = 0;
	document.getElementById(window.shuffle[shufflernum][hide]).className = 'hide';
	document.getElementById(window.shuffle[shufflernum][show]).className = '';
	setTimeout('rotate('+shufflernum+','+hide+');',20000);
}
function startRotation(shufflernum) {
	rotate(shufflernum,0);
}
/** End content rotator (shuffler) script. */

