function openwindow(url, windowname, width, height) {
	if(arguments.length==4)
		extravariable=arguments[4]  //not used
	result = url.search(/event_show/gi)
	if (result >= 0) {
		scrollbars = "yes"
	} else {
		scrollbars = "no"
	}
	if (scrollbars == "yes") {
		width = width + 16  //add space for the vertical scrollbar
	}
	window.open(url, windowname, "width="+width+",height="+height+",left=150,top=100,scrollbars="+scrollbars)
}

function getele(n, d){  //NOTE: Denne skal bruges i stedet for GetElement()
  //source: MM_findObj(n, d) { //v4.01
  //argument 'n' is the name of the object you want to get
  //argument 'd' is the document object, it is not required
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function explodeArray(item,delimiter) {
  //function for explode a string into an array by the given seperator
  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);
  while (tempString.indexOf(delimiter)>0) {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }
  tempArray[Count]=tempString;
  return tempArray;
}

function transfer_standard_selection(transfer_from, transfer_to, form_name) {
	if (transfer_from.selectedIndex != 0) {  //first selection in dropdown is not a value
		transfer_value = transfer_from.options[transfer_from.selectedIndex].text;  //take label instead of value
	} else {
		transfer_value = '';
	}
	document.forms[form_name].elements[transfer_to].value = transfer_value;
	if (transfer_value != '') {
		document.forms[form_name].elements[transfer_to].disabled = true;
	} else {
		document.forms[form_name].elements[transfer_to].disabled = false;
	}
}

function set_opener_field(field_in_parent_window, myvalue, add_seperator) {
	/*
	NOTES:
	- copy a value to a field in the parent window
	INPUT:
	- add_seperator : whether or not the existing value should be overwritten or the new value should just be added
		- set to true if value should be added without any seperator
		- write a seperator string if value should be added with a seperator
		- omit parameter (or set to false) to have new value overwrite any current value
	*/
	obj = getele(field_in_parent_window, opener.document);  //get the field
	currvalue = obj.value;  //get current value
	if (currvalue.length > 0 && add_seperator) {
		if (add_seperator === true) add_seperator = '';
		newvalue  = currvalue + add_seperator + myvalue;
	} else {
		newvalue  = myvalue;
	}
	obj.value = newvalue;  //set new value
}

function refresh_parent_window(url) {
	if (url) {
		opener.document.location = url;
	} else {
		opener.document.location.reload();
	}
}

function confirm_link(url, popup_question) {
	if (!popup_question) {
		popup_question = 'Are you sure?';
	}
	if (confirm(popup_question)) {
		window.location=url;
	}
}

function dropdown_add(obj, thevalue, thelabel, is_selected) {
	next_index = obj.options.length;
	obj.options[next_index] = new Option(thelabel, thevalue, is_selected, is_selected); //it will only be selected if both arguments are set to true!! (but IE 5.0 does not even correctly set the default value!)
	if (is_selected) {  //IE does not correctly display the selected value by setting it when the item is added to the dropdown, therefore also set the selected here (this is at least what I experienced)
		obj.options[next_index].selected = true
	}
	return next_index;  //return the index number of this new option
}

function dropdown_value(select_obj) {
	if (select_obj.options.length > 0) {  //check if the dropdown has any values
		if (typeof select_obj == 'object') {
			myvalue = select_obj.options[select_obj.selectedIndex].value;
			return myvalue;
		} else {
			alert("Error occured in getting value from dropdown. Please contact system administrator.");
		}
	} else {
		return "";
	}
}

/* Toggle nyheder START */

var boolNS4 = navigator.appVersion.indexOf("Nav") > 0 && parseInt(navigator.appVersion) == 4;

function GetElement(strElement){  //NOTE: getele() skal bruges i stedet for denne!
	if (document.getElementById){// IE5+, Netscape 6, Mozilla
		return (document.getElementById(strElement));
	}else if (document.all)	{	// IE4
		return (eval("document.all." + strElement));
	}else if (document.layers){// Netscape 4
		return (eval("document." + strElement));
	}else{	// Crap!
		return (null);
	}
}

function toggleDesc(strProgramID){
  //if(boolNS4) return false;	
   objCurrentShort = GetElement("Desc"+strProgramID+"Short");
   objCurrentShort.style.display = (objCurrentShort.style.display=="none" ? "block" : "none");

   objCurrentLong = GetElement("Desc"+strProgramID+"Long");
   objCurrentLong.style.display = (objCurrentLong.style.display=="none" ? "block" : "none");
}

/* Toggle nyheder END */

function get_cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function set_cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function delete_cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}