    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

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


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(){
		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();
}


function finnpostnr() {
        var url = "http://gunstead.no/kreator/finn_postadresse.php";
        var postnr = window.open(url, "Finn postadresse", "width=400,height=200,scrollbars=no,resizable=no");
        postnr.focus();
 }
function prosjekt_notat(unikid) {
        var url = "http://gunstead.no/kreator/prosjekt_notater.php?unikid=" + unikid;
        var postnr = window.open(url, "Legg til notat", "width=400,height=180,scrollbars=no,resizable=no");
        postnr.focus();
}

function vis_bronnoy(sok) {
        var url = "http://gunstead.no/kreator/bronnoysund.php?sok=" + sok;
        var sporsmal = window.open(url, "Brønnøysund", "width=400,height=320,scrollbars=no,resizable=no");
        sporsmal.focus();
 }
function hjelp(id) {
        var url = "http://gunstead.no/kreator/hjelp.php?id=" + id;
        var sporsmal = window.open(url, "Hjelp", "width=400,height=320,scrollbars=no,resizable=no");
        sporsmal.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, medlem_id, bilde_id, navn, album)
{
	if(theAction=="click") {
		marker_bilde(medlem_id,bilde_id,'get',navn,album);
	}
    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

