
var nn = (navigator.appName == "Netscape");
var win = (navigator.userAgent.indexOf("Win")!=-1)
var browserversion = navigator.appVersion.substring(0,3)


var currActive = null;
function none(){}

function setAMonLight(o){if(currActive != o){o.className = 'actMenuRollover';}}
function setAMonDark(o){if(currActive != o){o.className = 'actMenuRollover';}}
function setAMoffLight(o){if(currActive != o){o.className = 'actMenuLight';}}
function setAMoffDark(o){if(currActive != o){o.className = 'actMenuDark';}}

function swapImg(imgDocID,imgObjName) {document.images[imgDocID].src = eval(imgObjName + ".src");}
function newImage(arg){if (document.images) {rslt = new Image();rslt.src = arg;return rslt;}}

function validateNr(formin,fieldin) {
var field = eval('document.'+formin+'.'+fieldin+'.value');
var valid = "0123456789";

if (field == ''){return false;}
else{

for (var i=0; i < field.length; i++) {
	temp = "" + field.substring(i, i+1);
	if (valid.indexOf(temp) == "-1") {
	eval('document.'+formin+'.'+fieldin+'.value = ""');
	return false;
	}
}}}

function cc_calcPos(topmenu, i, x_adjust){

	var coords = getXYcoord(topmenu);
	var y_adjust = 0;
	
	if(nn){this.ele=document.getElementById(i);this.ele.style.left=(coords.x-x_adjust);this.ele.style.top=(coords.y+y_adjust);}
	else{eval(i+'.style.pixelLeft = '+(coords.x-x_adjust));eval(i+'.style.pixelTop = '+(coords.y+y_adjust));}
}  

function popUpAll(cUrl,width,height,x,y,scrollbars,toolbar){

	if (x == 0){x = ((window.screen.width - width)/2);}
	if (y == 0){y = ((window.screen.height - height)/2);}
	if (scrollbars == ''){scrollbars = 'yes';}
	if (toolbar == ''){toolbar= 'yes';}

	var popUpA = window.open(cUrl, 'popupA', 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar='+toolbar+',location=no,status=yes,scrollbars='+scrollbars+',noresize,menubar=no');
	popUpA.focus();
}

function popInfo(cUrl){

	var popUpI = window.open(cUrl, 'popupI', 'width=340,height=260,left=10,top=10,toolbar=no,location=no,status=no,scrollbars=yes,noresize,menubar=no');
	popUpI.focus();
}

function window_open(url, name, attributes){
   var w;
   if (attributes == null) w = window.open(url, name);
   else w = window.open(url, name, attributes);
   if (!ie4) w.focus(); // w.focus() giver sikkerhedsfejl i ie4.
}        
function CustSearchGoogle()
{
	SearchqueryString = document.SearchFrame.txtSearch.value;
	if (document.SearchFrame.CustSearchType[0].checked==true){
	  document.SearchFrame.submit();
	}else if (document.SearchFrame.CustSearchType[1].checked==true){
	  window_open('http://www.google.com/search?q='+SearchqueryString+'&hl=da&btnG=Google-s%F8gning&lr=','newwindow',null);
	  document.SearchFrame.submit();
	}
}

var currmenu = -1;

function cc_show(object) {
    if(currmenu != -1){cc_hide(currmenu);}
    if (document.getElementById && document.getElementById(object) != null){node = document.getElementById(object).style.visibility='visible';}
    else if (document.layers && document.layers[object] != null){document.layers[object].visibility = 'visible';}
    else if (document.all){document.all[object].style.visibility = 'visible';}
    currmenu = object;	
}

function cc_hide(object) {
    if (document.getElementById && document.getElementById(object) != null){node = document.getElementById(object).style.visibility='hidden';}
    else if (document.layers && document.layers[object] != null){document.layers[object].visibility = 'hidden';}
    else if (document.all){document.all[object].style.visibility = 'hidden';}
}

//-- calc right positions for menu offset
function getXYcoord (nvn) {
    var rd = { x:0 ,y:0 };
	
    if (nn && document.getElementById && document.getElementById(nvn) != null){var elm = document.getElementById( nvn );}
    else if (document.layers && document.layers){var elm = document.layers[nvn];}
    else if (!nn && document.all){var elm = document.all[ nvn ];}   

    else {return rd}
	
    do {rd.x += parseInt( elm.offsetLeft );
        rd.y += parseInt( elm.offsetTop );
        elm = elm.offsetParent;} 
    while ( elm );
	//-- rd.x += 580;
	//-- rd.y += 92;
    return rd
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

// Fixes visible dropdownarrow on hiddenpages
function csFixDWDropdownMenus() {
	var aTables = document.getElementsByTagName("table");
	var oTable, t=0;
	while (oTable = aTables[t++]) {
		if (oTable.rows.length == 0) {
			csKillDropdownArrow(oTable.parentNode.id);
		}
	}
}

function csKillDropdownArrow(sID) {
	var oTR = document.getElementById(sID.replace("submenu", ""));
	if (oTR) {
		oTR.cells[2].getElementsByTagName("img")[0].style.visibility = "hidden";
	}
}
