
function notification(type,url,formname) {
	// alert(type);
	
	if (type == 'asend') {
		// aSend('notificationarea',url);
		open_layer('notifactionlayer');
	} else if (type == 'submit') {
		// mysubmit('notificationarea',url,formname);
		open_layer('notifactionlayer');
	} else {
		open_layer('notifactionlayer');
		// document.getElementById('notificationarea').innerHTML=formname+''+url;
		return false;
	}
	
	// window.load=startCountdown();
	// window.load=setTimeout("close_layer('notifactionlayer')", 9000);
	
}


function open_layer(layername) {
	// alert(layername);
	// alert(g_iCount);
	e=document.getElementById(layername);

	if (g_iCount == 0) {
		var g_iCount = new Number();
		var g_iCount = 10;
	}
	
	new opacity(layername, 0, 100, 500);

	if (layername == 'loginmenu') e.style.zIndex = 5;
	
	if (document.getElementById('MouseXl').value == 0) var height = '50%';
	else var height = (document.getElementById('MouseXl').value-90);
	
	e.style.top = height;
	// document.getElementById(layername).style.left = (parseInt(document.getElementById('MouseYl').value)+140);
	// document.getElementById(layername).style.left = '45%';
	
	setTimeout("e.style.display = 'block'", 50);
	
	// return g_iCount;
}


function close_layer(layername) {
	opacity(layername, 100, 0, 500);
	e = document.getElementById(layername);
	setTimeout("e.style.display='none'", 300);
	if (layername == 'loginmenu') setTimeout("document.getElementById('loginmenu').style.zIndex = 0", 300);
}


// Fade out div
// http://brainerror.net/scripts/javascript/blendtrans/
function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}



nereidFadeObjects = new Object();
nereidFadeTimers = new Object();

function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}



/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    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;
        }
    }
    // 4.1.3 Current color is the marker one
    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;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

/*
 * Sets/unsets the pointer and marker in vertical browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 *
 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
 */
function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theDefaultColor2, thePointerColor, theMarkColor) {
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        domDetect    = false;
    } // end 3

    var c = null;
    // 5.1 ... with DOM compatible browsers except Opera
    for (c = 0; c < rowCellsCnt; c++) {
        if (domDetect) {
            currentColor = theCells[c].getAttribute('bgcolor');
        } else {
            currentColor = theCells[c].style.backgroundColor;
        }

        // 4. Defines the new color
        // 4.1 Current color is the default one
        if (currentColor == ''
            || currentColor.toLowerCase() == theDefaultColor1.toLowerCase()
            || currentColor.toLowerCase() == theDefaultColor2.toLowerCase()) {
            if (theAction == 'over' && thePointerColor != '') {
                newColor              = thePointerColor;
            } else if (theAction == 'click' && theMarkColor != '') {
                newColor              = theMarkColor;
                marked_row[theRowNum] = true;
            }
        }
        // 4.1.2 Current color is the pointer one
        else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
                 && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
            if (theAction == 'out') {
                if (c % 2) {
                    newColor              = theDefaultColor1;
                } else {
                    newColor              = theDefaultColor2;
                }
            }
            else if (theAction == 'click' && theMarkColor != '') {
                newColor              = theMarkColor;
                marked_row[theRowNum] = true;
            }
        }
        // 4.1.3 Current color is the marker one
        else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
            if (theAction == 'click') {
                newColor              = (thePointerColor != '')
                                      ? thePointerColor
                                      : ((c % 2) ? theDefaultColor1 : theDefaultColor2);
                marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                      ? true
                                      : null;
            }
        } // end 4

        // 5. Sets the new color...
        if (newColor) {
            if (domDetect) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            }
            // 5.2 ... with other browsers
            else {
                theCells[c].style.backgroundColor = newColor;
            }
        } // end 5
    } // end for

     return true;
 } // end of the 'setVerticalPointer()' function


 
// header clock
var dayarray=new Array("Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag")
var montharray=new Array("januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december")

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentYear = currentTime.getFullYear ( );
  var currentMonth = currentTime.getMonth ( );
  var currentDay = currentTime.getDay ( );
  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Compose the string for display
  var currentTimeString = dayarray[currentDay]+" "+currentDay+" "+montharray[currentMonth] + " " + currentYear + " " + currentHours + ":" + currentMinutes + ":" + currentSeconds;

  // Update the time display
  document.getElementById("clock").innerHTML = currentTimeString;
}



// generel showlayer funktion
function ShowLayer(LayerName) {
	// document.getElementById(layername).style.position = "absolute";
	if (document.getElementById(LayerName).style.display == "none") document.getElementById(LayerName).style.display = "block";
	else document.getElementById(LayerName).style.display = "none";
}

// BeskedCenter vis gem longversion og shortversion
function ShowOtherVersion(LayerName) {

	if (document.getElementById('ShortVersion'+LayerName).style.display == "none") document.getElementById('ShortVersion'+LayerName).style.display = "block";
	else document.getElementById('ShortVersion'+LayerName).style.display = "none";

	if (document.getElementById('LongVersion'+LayerName).style.display == "block") document.getElementById('LongVersion'+LayerName).style.display = "none";
	else document.getElementById('LongVersion'+LayerName).style.display = "block";
}

// Indryk efterlysning vis hvilken kategori
function ShowNewCategoryLayer(LayerNumber) {
// alert(LayerNumber);
	
	ajax_get('indrykningskategori.php?Type='+LayerNumber, 'contentdiv');
/*
		if (LayerNumber == "NewCategoryLayer") {
			document.getElementById('GerningsstedLayer').style.display = "none";
			document.getElementById(LayerNumber).style.display = "block";
			document.getElementById('Action').value = "NewCategory";
		} else {
			document.getElementById('GerningsstedLayer').style.display = "block";
			document.getElementById('layer'+LayerNumber).style.display = "block";
			document.getElementById('Action').value = "IndrykEfterlysning";
			document.getElementById('IndrykCategory').value = LayerNumber;
		}
*/
}

// Indryk efterlysning - NewCategory
function AddNewCategory(ValueID) {
	document.getElementById('tempVarHolder').value = ValueID;
	if (ValueID == "NewCategory") {
		document.getElementById('NewCategoryLayer').style.display = "block";
		document.getElementById('NewCategory').focus();
	} else {
		document.getElementById('NewCategoryLayer').style.display = "none";
	}
}


function setvalidate(arg1) {
	document.getElementById('validatethis').value = arg1;
	// alert(document.getElementById('validatethis').value);
}

// text counter
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
	else cntfield.value = maxlimit - field.value.length;
}

// clearform
function clearform(arg1,arg2) {
	if (document.getElementById(arg1).value == arg2) {
		document.getElementById(arg1).value = '';
	}
}
	
// kan ik lige huske hvad det er for en
function changediv(layername) {
	document.getElementById(layername).innerHTML='';
}

// Confirm box
function confirmbox(arg1){
	question = confirm(arg1);
	if (question != "0"){
		return true ;
	} else {
		return false ;
	}
}

function confirmdeletemsg() {
	var answer = checkforempty('en besked');
	if (answer) return confirm('Er du sikker på du vil slette disse objekter?');
}

// check for empty (besked center)
function checkforempty(arg) {

    var i=0; 
    while(document.getElementById('item'+i)!=null){ 
        if (document.getElementById('item'+i).checked==true) {
			var runit = "1"
		}
        i++; 
    }
	if (runit != "1") {
		alert('Du skal vælge '+arg);
		return false;
	} else {
		return true;
	}
}



// select all besked center
function select_all(checkboxID) {
	if (document.getElementById('launch').checked == true) {
		state = true;
	} else {
		state = false;
	}
    var i=0; 
    while(document.getElementById(checkboxID+i)!=null){ 
        document.getElementById(checkboxID+i).checked=state; 
        i++; 
    } 
}














