    var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
                      && typeof(document.createElement) != 'undefined')
                   ? 1 : 0;
    var isIE4      = (typeof(document.all) != 'undefined'
                      && parseInt(navigator.appVersion) >= 4)
                   ? 1 : 0;
    var isNS4      = (typeof(document.layers) != 'undefined')
                   ? 1 : 0;
    var capable    = (isDOM || isIE4 || isNS4)
                   ? 1 : 0;
    // Ugly fix for Opera and Konqueror 2.2 that are half DOM compliant
    if (capable) {
        if (typeof(window.opera) != 'undefined') {
            var browserName = ' ' + navigator.userAgent.toLowerCase();
            if ((browserName.indexOf('konqueror 7') == 0)) {
                capable = 0;
            }
        } else if (typeof(navigator.userAgent) != 'undefined') {
            var browserName = ' ' + navigator.userAgent.toLowerCase();
            if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) {
                capable = 0;
            }
        } // end if... else if...
    } // end if



//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}



function kamprapp_vis() {
	var isIE = navigator.appName.indexOf("Microsoft") != -1 
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2)-150;
	var lightboxLeft = ((arrayPageSize[0] - 20) / 2)-230;
	var overlayer = document.getElementById("overlay");
	var kampdiv=document.getElementById("kamprapp");
	
	
	
	kampdiv.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	kampdiv.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
	
	
	// La oss dimme bakgrunnen først
	
		overlayer.style.height = (arrayPageSize[1] + 'px');
		if(isIE) { // Jævla Microsoft
			document.all.overlay.style.visibility = "visible";
			document.all.overlay.style.display = "block";
		}else{
			overlayer.style.visibility = 'visible'
			overlayer.style.display = 'block';
		}
	

		var kampdiv=document.getElementById("kamprapp");
		if(isIE) {
			document.all.kamprapp.style.visibility = "visible";
			document.all.kamprapp.style.display = "block";
		}else{
			kampdiv.style.visibility = "visible";
			kampdiv.style.display = 'block';
		}
		var felt=document.getElementById("kampnr");
		felt.focus();
				
}

function kamprapp_lukk() {
	// La oss dimme bakgrunnen først
	var isIE = navigator.appName.indexOf("Microsoft") != -1 
		var overlay = document.getElementById("overlay");
		overlay.style.height = (arrayPageSize[1] + 'px');
		if(isIE) {
			document.all.overlay.style.visibility = "hidden";
			document.all.overlay.style.display = "none";
		}else{
			overlay.style.visibility = 'invisible';
			overlay.style.display = 'none';
		}

		var kampdiv=document.getElementById("kamprapp");
		var kamp = document.getElementById("kampnr");
		var tekst = document.getElementById("sok_kamp");
		tekst.innerHTML = '';
		kamp.value = '';
		if(isIE) {
			document.all.kamprapp.style.visibility = "hidden";
			document.all.kamprapp.style.display = "none";
		}else{
			kampdiv.style.visibility = "invisible";
			kampdiv.style.display = 'none';
		}
}


function submit_form(formen)
{
  document.formen.submit();
}

function hentsesong(formen)
{
	alert(formen);
  document.formen.submit();
}


function legg_til_epost_felt(epost,felt) {
	var input=document.getElementById(felt);
	var tekst=input.value;
	var ny_tekst=tekst + ',' + epost;
	var sjekk=ny_tekst.substring(0,1);
	if(sjekk==',') {
		ny_tekst=ny_tekst.substring(1);
	}
		input.value=ny_tekst;
}

function toggle_liste(tdid,imgId) {
	var currElem = document.getElementById(tdid);
	var img = document.getElementById(imgId);
		var c = currElem.className;
		var eid = currElem.id;
		if(c.indexOf("collapsed") != -1) {
			
					currElem.className = c.replace("collapsed", "");
					img.src = "images/collapse.gif";
					img.alt = "-";
					
		}else{

					currElem.className = c + "collapsed";
					img.src = "images/expand.gif";
					img.alt = "-";

		}
}


function vis_progress(){
	var isIE = navigator.appName.indexOf("Microsoft") != -1 
		progress.style.visibility="visible"
	}
function skjul_progress(){
		progress.style.visibility="hidden"
	}


// Funksjon for å sette datoen på menyefelter

function setDate(id, year, month, day) {
	document.getElementById(id + "_" + "year").value = year;
	document.getElementById(id + "_" + "month").value = month;
	document.getElementById(id + "_" + "day").value = day;
	document.getElementById(id + "_" + "year").focus();
}


/**
Funksjon for å utvide vinduet
*/


function utvid_vindu()
{
	if (document.all || document.layers) {
			self.moveTo(0,0);
			self.resizeTo(screen.availWidth,screen.availHeight);
	}                         	
}


/**
Funksjon for å fargelegge TD tagene
*/

var marked_row = new Array;


function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    if (theAction == "over" || theAction == "click") {
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }

    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } 

    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    }

    if (newColor) {
        var c = null;
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    }

    return true;
}

var offsetxpoint=-60;
var offsetypoint=20;



var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
if (ie||ns6) { var tipobj=document.all? document.all["eventDetails"] : document.getElementById? document.getElementById("eventDetails") : "" }

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function eventDetailsBox(theText){
	if (ns6||ie){
		tipobj.innerHTML=theText;
		enabletip=true;
				alert("ok");

		return false;
		}
	}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

		if (rightedge<tipobj.offsetWidth)
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else
			tipobj.style.left=curX+offsetxpoint+"px"

		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
			tipobj.style.top=curY+offsetypoint+"px"
			tipobj.style.visibility="visible"
			}
	}

function hideEventDetailsBox(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
		}
	}

document.onmousemove=positiontip

