	//# Columbus IT Partner A/S 
	//# DataPublish module scripts for DynamicWeb (ASP)
	
	//# DEBUGGING				20061020 cit/cfi.dk
	//# VALIDATION
	//# MULTIGRID
	//# EDITOR
	//# DATEPICKER
	//# DYNAMIC COMBOBOX/LOOKUP
	//# CHECKBOX
	//# MULTISELECT ENUM SUM
	//# FILEMANAGER


	//# > DEBUGGING
	//# - 20061020 cit/cfi.dk
	var DebugWindow;
	function fnDebugInit()
	{
		DebugWindow = window.open('files/templates/citdatapublish/shared/debug/debugwindow.htm',null,"status=yes,toolbar=no,menubar=no,location=no,resizable=yes,width=300,height=800,top=0,left=1300,scrollbars=yes");
	}
	
	function fnDebug(text)
	{
		if (DebugWindow == null || DebugWindow.closed == true)
			fnDebugInit();
	        
		DebugWindow.fnAddText(text);    
	}
	//# < DEBUGGING
	
	//# > CLIENT VALIDATION
	
	// 20051201 citp/cfi.dk
	function fnDateValidate()
	{
		// 20060220 citp/cfi.dk - Updated
		
		var daysOfMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		var caller = event.srcElement;
		var dateNow = new Date();
		var day;
		var month;
		var year;
		var buffer;
		
		var dateTest = new Date();
		
		if (caller.value == "")
			return;

		if (caller.value.toLowerCase() == "d")
			caller.value = dateNow.getDate() + "-" + (dateNow.getMonth()+1) + "-" + dateNow.getFullYear();

		buffer = caller.value.split("-");
		
		switch (buffer.length)
		{
			case 1:
				if (buffer[0].length > 0 && buffer[0].length < 3)
				{	// 1 or 2 digits entered
					year = dateNow.getFullYear();
					month = validateMonth(dateNow.getMonth()+1);
					day = validateDay(buffer[0]);
				}
				else if (buffer[0].length == 4)
				{	// 4 digits entered
					year = dateNow.getFullYear();
					month = validateMonth(buffer[0].substr(2,2));
					day = validateDay(buffer[0].substr(0,2));
				}
				else if (buffer[0].length == 6)
				{	// 6 digits entered
					year = validateYear(buffer[0].substr(4,2));
					month = validateMonth(buffer[0].substr(2,2));
					day = validateDay(buffer[0].substr(0,2));
				}
				else if (buffer[0].length == 8)
				{	// 8 digits entered
					year = validateYear(buffer[0].substr(4,4));
					month = validateMonth(buffer[0].substr(2,2));
					day = validateDay(buffer[0].substr(0,2));
				}
				break;
			case 2:
				year = dateNow.getFullYear();
				month = validateMonth(buffer[1]);
				day = validateDay(buffer[0]);
				break;
			case 3:
				year = validateYear(buffer[2]);
				month = validateMonth(buffer[1]);
				day = validateDay(buffer[0]);
				break;
		}

		if (day && month && year)
			caller.value = day + "-" + month + "-" + year;
		else
			caller.value = "";
			
		// inner function		
		function validateDay(_value) {
			var day;
			var tmpInt = parseInt(_value, 10);
			
			if (!isNaN(tmpInt))	{
				if (tmpInt < 1)
					tmpInt = 1;
				else if (isLeapYear(year) && parseInt(month, 10) == 2) {
					if (tmpInt > 29)
					tmpInt = 29;
				}	
				else if (tmpInt > daysOfMonth[parseInt(month, 10) - 1])
					tmpInt = daysOfMonth[parseInt(month, 10) - 1];
				day = String(tmpInt);
				if (day.length != 2)
					day = "0" + day;
			}
			else {
				return false;
			}
			return day;
		}
		// inner function		
		function validateMonth(_value) {
			var month;
			var tmpInt = parseInt(_value, 10);

			if (!isNaN(tmpInt))	{
				if (tmpInt < 1)
					tmpInt = 1;
				else if(tmpInt > 12)
					tmpInt = 12;
				month = String(tmpInt);
				if (month.length != 2)
					month = "0" + month;
			}
			else {
				return false;
			}
			return month;
		}
		// inner function
		function validateYear(_value) {
			var year;
			var tmpInt = parseInt(_value, 10);
			if (!isNaN(tmpInt) && tmpInt <= 9999 && tmpInt >= 0)
			{
				year = String(tmpInt);
				if (year.length == 3)
					year = String(dateNow.getFullYear()).substr(0,1) + year;
				else if (year.length == 2)
					year = String(dateNow.getFullYear()).substr(0,2) + year;
				else if (year.length == 1)
					year = String(dateNow.getFullYear()).substr(0,3) + year;
			}
			else {
				return false;
			}
			return year;
		}
		// inner function
		function isLeapYear(intYear)
		{
			if (intYear % 100 == 0)
			{
				if (intYear % 400 == 0)
				{
					return true;
				}
			}
			else
			{
				if ((intYear % 4) == 0)
				{
					return true;
				}
			}
			return false;
		}
	}

	function fnTime_onchange(_caller)
	{
		fnTimeValidate(_caller, 15); // nedrunding til nærmeste 15 minutter
	}

	function fnTime_onkeypress() 
	{
		if (event.keyCode < 47 || event.keyCode > 57)
			event.returnValue = false;
	}
	
	function fnTimeValidate(_caller, _unit)
	{
		var time   = 0;
		var minute = 0;
		_caller.value = _caller.value.replace(/:/g,"");
		
		if (_unit < 1)
			_unit = 1;
		
		switch(_caller.value.length)
		{
			case 1:
			case 2: time = _caller.value;
					break;
			case 3: time = _caller.value.substr(0,1);
					minute = _caller.value.substr(1,2); 
					break;
			case 4: time = _caller.value.substr(0,2);
					minute = _caller.value.substr(2,2); 
					break;
		}
		if (minute >= 60) minute = 0;
		if (time   >  24) time   = 0;
		if (time   == 24) minute = 0;
		time = parseFloat(time);
		minute = Math.floor(minute / _unit) * _unit;
		_caller.value = (time < 10 ? '0' + time : time) + ':' + (minute == 0 ? '00' : minute);
		if (_caller.value == '00:00')
			_caller.value = '';
	}	
	
	function fnDateBuild(_targetField, _dateField, _timeField)
	{
		var valDate;
		var valTime;
		
		if (_dateField != null && _dateField.value != '')
			valDate = _dateField.value;
		else
			valDate = '01-01-1900';
			
		if (_timeField != null && _timeField.value != '')
			valTime = _timeField.value;
		else
			valTime = '';
			
		if (valTime == '' && valDate == '01-01-1900')	
			_targetField.value = '';
		else
			_targetField.value = valDate + ' ' + valTime;
	}
	//# < CLIENT VALIDATION

	//# > DATAPUBLISH MULTIGRID SCRIPTS
	
	//# called when ever the value of a field is changed/manipulated
	function fnMGChanged(_caller) {
		var caller;

		//# the element that triggered the change-event
		if (_caller == null)
			caller = window.event.srcElement;
		else
			caller = _caller;
		
		//# the record identifier that is part of the calling elements name or id
		var recId = fnMGFindRecord(caller.name);
		if (! recId)
			recId = fnMGFindRecord(caller.id);
		
		//# set the changed-flag for the row to which the calling element belongs
		var changed;
		eval("changed = caller.form.changed_" + recId);
		if (changed)
			changed.value = 1;
		
		//# > 20060612 cit/cfi.dk - Call special method on form if it exists
		if (caller.form.fnFormFieldChanged)
			caller.form.fnFormFieldChanged(caller);
		//# < 20060612 cit/cfi.dk	
	}
	
	//# returns the record identifier from a string of the format xxx_4711_yyy (recId = 4711)
	function fnMGFindRecord(_identifier) { 
		var recId;
		
		recId = _identifier.substr(_identifier.indexOf("_")+1);
		recId = recId.substr(0, recId.indexOf("_"));

		return recId;
	}
	//# < MULTIGRID
	
	//# > DATAPUBLISH EDITOR SCRIPTS
	
	//# > 20070519 cit/cfi.dk
	var idEditorSourceValue = null;
	
	function fnEditorPopupFCK(_idEditorSource) {
	    idEditorSource = _idEditorSource;
	    var editor = window.open('files/templates/citdatapublish/shared/editor/popup.htm', 'editor', 'height=300,width=400,left=150,top=150,menubar=no,toolbar=no,titlebar=no,location=no,resizable=yes,scrollbars=no');
	}
	
	function fnEditorPopupFCKGetSource() {
	    return idEditorSource;
	    //return document.getElementById("");
	}
	
	//# < 20070519 cit/cfi.dk
		
	var editorSource;
	var editorFrameActive;

	function fnEditorPopupShow(sourcefield)	{
		editorSource = sourcefield;
		window.open('Files/Templates/citp_publish/editor/editorpopup.asp', 'editor', 'height=400,width=400,left=150,top=150,menubar=no,toolbar=no,titlebar=no,location=no,resizable=yes,scrollbars=no');
	}
	
	function fnEditorPopupGetText()	{
		return editorSource.value;	
	}
	
	function fnEditorPopupSetText(newValue)	{
		editorSource.value = newValue;
		//output.innerHTML = newValue;
		editorSource.fireEvent("onchange");
	}

	function fnEditorFrameOnLoad(_textSource) {
		var callerFrame = window.event.srcElement;
		var textSource = document.getElementById(_textSource.id);
		//var textSource = document.getElementById(_textSource);
		//alert(textSource);
		//sdfsdfsdf;
	//alert(_textSource + " : " + textSource.id + " : " + textSource.value); //DEBUG
		
		document.frames[callerFrame.id].document.body.innerHTML = textSource.value;
		document.frames[callerFrame.id].document.designMode = "on";		
		
		editorFrameActive = document.frames[callerFrame.id].document;
	}
	
	function fnEditorActive() {
		var callerFrame = window.event.srcElement;
		editorFrameActive = document.frames[callerFrame.id].document;
	}

	function fnEditorCommand(_command, _value) {
		switch (_command) {
			case 'Bold' :
				editorFrameActive.execCommand('Bold');		
				break;
			case 'Italic' :
				editorFrameActive.execCommand('Italic');
				break;
			case 'Underline' :
				editorFrameActive.execCommand('Underline');
				break;					
			case 'FontName' :
				editorFrameActive.execCommand('FontName',false,'Verdana,Arial');
				break;
			case 'ForeColor' :
				editorFrameActive.execCommand('ForeColor');
				break;
			case 'InsertImage' :
				editorFrameActive.execCommand('InsertImage', true);
				break;					
			case 'CreateLink' :
				editorFrameActive.execCommand('CreateLink');
				break;
			case 'InsertOrderedList' :
				editorFrameActive.execCommand('InsertOrderedList');
				break;	
			case 'InsertUnorderedList' :
				editorFrameActive.execCommand('InsertUnorderedList');	
				break;
			case 'FormatBlock' :
				editorFrameActive.execCommand('FormatBlock',false,_value);
				break;
			case 'RemoveFormat' :
				editorFrameActive.execCommand('RemoveFormat');
				break;
			default :
		}
		
		return true;
	}
	
	function fnEditorChangeFormat(_select) {
		if (_select.value != "") {
			if (_select.value == "Normal")
				fnEditorCommand('FormatBlock', '<p>');
			else
				fnEditorCommand('FormatBlock', '<' + _select.value + '>');				
		}
		_select.selectedIndex = 0;
	}	
	
	function fnEditorSaveChange() {
		var caller = window.event.srcElement;
		var frames = document.all.tags("iframe");
		var frame;
		var textSourceName;
		var textSource;

		for (idx = 0; idx < frames.length; idx++) {
			frame = frames(idx);

			if (frame.id.substr(0,10) == 'editorfld_') {
				// update multigrid
				textSourceName = 'fld_' + frame.id.substr(frame.id.indexOf("_")+1, frame.id.length)		
				eval("textSource = caller.form." + textSourceName);
				textSource.value = document.frames(frame.id).document.body.innerHTML;
				textSource.fireEvent("onchange");
			}
			
			if (frame.id.substr(0,13) == 'editorinsert_') {
				// update insert frame - 200606 cit/cfi.dk
				textSourceName = 'insert_' + frame.id.substr(frame.id.indexOf("_")+1, frame.id.length)		
				textSource = caller.form.all[textSourceName];
				textSource.value = document.frames[frame.id].document.body.innerHTML;
				textSource.fireEvent("onchange");
			}
		}
	}
	
	
/* NEW EDITOR OBJECT (XStandard) -->	
		var editorActive = null; // The currently active editor object (popup or embedded)

		// Returns the active editorobject
		function fnEditorGet() {
			return editorActive;
		}

		// > Popup Editor
		
		// Create and show the editor
		// Called when user clicks the editbutton
		function fnEditorCreatePopup(_contentSource, _editorPath) {
			editorActive =  new fnEditorObjectPopup(_contentSource, _editorPath);
			editorActive.Open();
		}
		
		// Editor handler object (Popup)
		function fnEditorObjectPopup(_contentSource, _editorPath)
		{
			//# >> defined constant values	
			filenamecss = 'format.css';
			filenamestyles = 'styles.xml';
			filenamecodebase = 'XStandard.cab#Version=1,7,1,0';
			
			editorPathWindow = 'Files/Templates/citp_publish/editor/xstandard/editorpopup_window.htm';
			windowWidth = 475;
			windowHeight = 400;

			//# >> parameters supplied and generated
			var contentSource = document.getElementById(_contentSource);
			var editorPathBase = _editorPath;
			var editorWindow = null;
			
			//# >> defined methods for object
			this.Open = Open;
			this.Close = Close;
			this.GetContentSource = GetContentSource;
			this.GetWindow = GetWindow;
			this.GetContent = GetContent;
			this.SetContent = SetContent;
			this.GetPathCSS = GetPathCSS;
			this.GetPathStyles = GetPathStyles;
			this.GetPathCodeBase = GetPathCodeBase;
			
			//# >> method implementation
			function Open()	{
				editorWindow = window.open(editorPathWindow, 'editor', 'height='+ windowHeight +',width='+ windowWidth +',left=150,top=150,menubar=no,toolbar=no,titlebar=no,location=no,resizable=yes,scrollbars=no');
			}
			
			function Close() {
				editorWindow.close();
			}

			function GetWindow() {
				return editorWindow;
			}
			
			function GetContentSource() {
				return contentSource;
			}

			function GetContent() {
				return contentSource.value;
			}

			function SetContent(_content) {
				_content = fnEditorRemoveTimeStamp(_content);
				
				if (contentSource.value != _content) {
					contentSource.value = _content;
					contentSource.fireEvent("onchange");
				}
			}
			
			function GetPathCSS() {
				return editorPathBase + filenamecss; 
			}
			
			function GetPathStyles() {
				return editorPathBase + filenamestyles;
			}
			
			function GetPathCodeBase() {
				return editorPathBase + filenamecodebase;
			}
		}
		// << Popup Editor
		
		// >> Embedded Editor

		// Create editor object handler for embedded editor.
		function fnEditorCreateEmbedded(_contentSourceId, _contentEditorId) {
			editorActive =  new fnEditorObjectEmbedded(_contentSourceId, _contentEditorId);
		}

		// Editor handler object (Embedded)
		function fnEditorObjectEmbedded(_contentSourceId, _contentEditorId)
		{
			var contentSource = document.getElementById(_contentSourceId);
			var editorObject = document.getElementById(_contentEditorId);

			this.SetContent = SetContent;

			function SetContent() {
				var content;
				content = fnEditorRemoveTimeStamp(editorObject.value);
				if (contentSource.value != content) {
					contentSource.value = content;
					contentSource.fireEvent("onchange");
				}
			}
		}
*/
/* PART OF OLD EDITOR -->	
		// Copies content of embedded editor control back to hidden formfield-
		// Must be called from submitbutton on form.
		function fnEditorSaveChange() {
			var caller = window.event.srcElement;
			var parentForm = caller.form;
			var editors = parentForm.all("editorcontrol");

			this.SaveSingle = SaveSingle;
			
			if (editors != null) {
				if (editors.length != null) {
					for (idx = 0; idx < editors.length; idx++) {
						this.SaveSingle(caller.form, editors[idx]);
					}
				}
				else {
					this.SaveSingle(caller.form, editors);
				}
			}
			
			function SaveSingle(_form, _source)
			{
				var target;
				target = _form.all['insert_' + _source.id.substr(_source.id.indexOf("_")+1, _source.id.length)];
				target.value = _source.value;
				target.fireEvent("onchange");
			}
		}
*/		
		// << Embedded Editor
		
		// >> Common functions
		
		// Removes the automatic timestamp comment created by XStandard
		function fnEditorRemoveTimeStamp(_content) {
			var content = null;
			
			if (_content.substr(0, 4) == '<!--') {
				lastPos = _content.indexOf('-->', 0) + 3;
				content = _content.slice(lastPos);
				return content;
			}
			else
				return _content;
		}
		
		// << Common functions
		
	//# < DATAPUBLISH EDITOR SCRIPTS

	//# > DATEPICKER (Julian Robichaux -- http://www.nsftools.com)
	
	var datePickerDivID = "datepicker";
	var iFrameDivID = "datepickeriframe";


	var dayArrayShort = new Array('S&oslash;', 'Ma', 'Ti', 'On', 'To', 'Fr', 'L&oslash;');
	var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
	var dayArrayLong = new Array('S&oslash;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&oslash;rdag');
	var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec');
	var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dec');
	var monthArrayLong = new Array('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December');


//	var dayArrayShort = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
//	var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
//	var dayArrayLong = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
//	var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
//	var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
//	var monthArrayLong = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
	  
	var defaultDateSeparator = "-";		// common values would be "/" or "."
	var defaultDateFormat = "dmy"	// valid values are "mdy", "dmy", and "ymd"
	var dateSeparator = defaultDateSeparator;
	var dateFormat = defaultDateFormat;

	var targetDateField; // 20051116 citp/cfi.dk

	function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep)
	{
		// > 20051116 citp/cfi.dk
		var callerDateImage = window.event.srcElement;
		var callerDateImageId = callerDateImage.id;  
		var targetDateFieldId = callerDateImageId.substr(callerDateImageId.indexOf("_")+1);
		
		if (document.all[callerDateImageId].length) {
			for (i = 0; i < document.all[callerDateImageId].length; i++) {
				if (document.all[callerDateImageId][i] == callerDateImage) {
					targetDateField = document.all[targetDateFieldId][i];
				}
			}
		}
		else {
			targetDateField = document.getElementsByName(dateFieldName).item(0);
		}		  
		// < 20051116 citp/cfi.dk
		  
		// if we weren't told what node to display the datepicker beneath, just display it
		// beneath the date field we're updating
		if (!displayBelowThisObject)
			displayBelowThisObject = targetDateField;
		  
		// if a date separator character was given, update the dateSeparator variable
		if (dtSep)
			dateSeparator = dtSep;
		else
			dateSeparator = defaultDateSeparator;
		  
		// if a date format was given, update the dateFormat variable
		if (dtFormat)
			dateFormat = dtFormat;
		else
			dateFormat = defaultDateFormat;
		  
		var x = displayBelowThisObject.offsetLeft;
		var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight;
		  
		// deal with elements inside tables and such
		var parent = displayBelowThisObject;
		while (parent.offsetParent) {
			parent = parent.offsetParent;
			x += parent.offsetLeft;
			y += parent.offsetTop;
		}
	  
		drawDatePicker(targetDateField, x, y);
	}
	function drawDatePicker(targetDateField, x, y)
	{
		var dt = getFieldDate(targetDateField.value);
	  
		// the datepicker table will be drawn inside of a <div> with an ID defined by the
		// global datePickerDivID variable. If such a div doesn't yet exist on the HTML
		// document we're working with, add one.
		if (!document.getElementById(datePickerDivID)) {
			// don't use innerHTML to update the body, because it can cause global variables
			// that are currently pointing to objects on the page to have bad references
			//document.body.innerHTML += "<div id='" + datePickerDivID + "' class='dpDiv'></div>";
			var newNode = document.createElement("div");
			newNode.setAttribute("id", datePickerDivID);
			newNode.setAttribute("class", "dpDiv");
			newNode.setAttribute("style", "visibility: hidden;");
			document.body.appendChild(newNode);
		}
		  
		// move the datepicker div to the proper x,y coordinate and toggle the visiblity
		var pickerDiv = document.getElementById(datePickerDivID);
		pickerDiv.style.position = "absolute";
		pickerDiv.style.left = x + "px";
		pickerDiv.style.top = y + "px";
		pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
		pickerDiv.style.zIndex = 10000;
		  
		// draw the datepicker table
		refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
	}

	/**
	This is the function that actually draws the datepicker calendar.
	*/
	function refreshDatePicker(dateFieldName, year, month, day)
	{
		// if no arguments are passed, use today's date; otherwise, month and year
		// are required (if a day is passed, it will be highlighted later)
		var thisDay = new Date();
		  
		if ((month >= 0) && (year > 0)) {
			thisDay = new Date(year, month, 1);
		} else {
			day = thisDay.getDate();
			thisDay.setDate(1);
		}
		  
		// the calendar will be drawn as a table
		// you can customize the table elements with a global CSS style sheet,
		// or by hardcoding style and formatting elements below
		var crlf = "\r\n";
		var TABLE = "<table cols=7 class='dpTable'>" + crlf;
		var xTABLE = "</table>" + crlf;
		var TR = "<tr class='dpTR'>";
		var TR_title = "<tr class='dpTitleTR'>";
		var TR_days = "<tr class='dpDayTR'>";
		var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
		var xTR = "</tr>" + crlf;
		var TD = "<td class='dpTD'";	// leave this tag open, because we'll be adding an onClick event
		var TD_title = "<td colspan=5 class='dpTitleTD'>";
		var TD_buttons = "<td class='dpButtonTD'>";
		var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
		var TD_days = "<td class='dpDayTD'>";
		var TD_selected = "<td class='dpDayHighlightTD'";	// leave this tag open, because we'll be adding an onClick event
		var xTD = "</td>" + crlf;
		var DIV_title = "<div class='dpTitleText'>";
		var DIV_selected = "<div class='dpDayHighlight'>";
		var xDIV = "</div>";
		  
		// start generating the code for the calendar table
		var html = TABLE;
		  
		// this is the title bar, which displays the month and the buttons to
		// go back to a previous month or forward to the next month
		html += TR_title;
		html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "&lt;") + xTD;
		html += TD_title + DIV_title + monthArrayLong[thisDay.getMonth()] + " " + thisDay.getFullYear() + xDIV + xTD;
		html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "&gt;") + xTD;
		html += xTR;
		
		// this is the row that indicates which day of the week we're on
		html += TR_days;
		for(i = 0; i < dayArrayShort.length; i++)
			html += TD_days + dayArrayShort[i] + xTD;
		html += xTR;
		//alert(html);  
		// now we'll start populating the table with days of the month
		html += TR;
		  
		// first, the leading blanks
		for (i = 0; i < thisDay.getDay(); i++)
			html += TD + "&nbsp;" + xTD;
		  
		// now, the days of the month
		do {
			dayNum = thisDay.getDate();
			TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";
		    
			if (dayNum == day)
			html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
			else
			html += TD + TD_onclick + dayNum + xTD;
		    
			// if this is a Saturday, start a new row
			if (thisDay.getDay() == 6)
			html += xTR + TR;
		    
			// increment the day
			thisDay.setDate(thisDay.getDate() + 1);
		} while (thisDay.getDate() > 1)
		  
		// fill in any trailing blanks
		if (thisDay.getDay() > 0) {
			for (i = 6; i > thisDay.getDay(); i--)
			html += TD + "&nbsp;" + xTD;
		}
		html += xTR;
		// add a button to allow the user to easily return to today, or close the calendar
		var today = new Date();
		var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[today.getMonth()] + " " + today.getDate();
		html += TR_todaybutton + TD_todaybutton;
//		html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>This month</button> ";
//		html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>Close</button>";
		html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>Denne mdr.</button> ";
		html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>Luk</button>";
		html += xTD + xTR;
		  
		// and finally, close the table
		html += xTABLE;
		  
		document.getElementById(datePickerDivID).innerHTML = html;
		// add an "iFrame shim" to allow the datepicker to display above selection lists
		
		adjustiFrame();
	}

	/**
	Convenience function for writing the code for the buttons that bring us back or forward
	a month.
	*/
	function getButtonCode(dateFieldName, dateVal, adjust, label) {
		var newMonth = (dateVal.getMonth() + adjust) % 12;
		var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
		if (newMonth < 0) {
			newMonth += 12;
			newYear += -1;
		}
	  
		return "<button class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</button>";
	}

	/**
	Convert a JavaScript Date object to a string, based on the dateFormat and dateSeparator
	variables at the beginning of this script library.
	*/
	function getDateString(dateVal)	{
		var dayString = "00" + dateVal.getDate();
		var monthString = "00" + (dateVal.getMonth()+1);
		dayString = dayString.substring(dayString.length - 2);
		monthString = monthString.substring(monthString.length - 2);
		  
		switch (dateFormat) {
			case "dmy" :
				return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
			case "ymd" :
				return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
			case "mdy" :
			default :
				return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
		}
	}

	/**
	Convert a string to a JavaScript Date object.
	*/
	function getFieldDate(dateString) {
		var dateVal;
		var dArray;
		var d, m, y;
		  
		try {
			dArray = splitDateString(dateString);
			if (dArray) {
				switch (dateFormat) {
					case "dmy" :
						d = parseInt(dArray[0], 10);
						m = parseInt(dArray[1], 10) - 1;
						y = parseInt(dArray[2], 10);
						break;
					case "ymd" :
						d = parseInt(dArray[2], 10);
						m = parseInt(dArray[1], 10) - 1;
						y = parseInt(dArray[0], 10);
						break;
					case "mdy" :
					default :
						d = parseInt(dArray[1], 10);
						m = parseInt(dArray[0], 10) - 1;
						y = parseInt(dArray[2], 10);
						break;
				}
				dateVal = new Date(y, m, d);
			}
			else {
				dateVal = new Date(dateString);
			}
		}
		catch(e) {
			dateVal = new Date();
		}
		  
		return dateVal;
	}

	/**
	Try to split a date string into an array of elements, using common date separators.
	If the date is split, an array is returned; otherwise, we just return false.
	*/
	function splitDateString(dateString) {
		var dArray;
		if (dateString.indexOf("/") >= 0)
			dArray = dateString.split("/");
		else if (dateString.indexOf(".") >= 0)
			dArray = dateString.split(".");
		else if (dateString.indexOf("-") >= 0)
			dArray = dateString.split("-");
		else if (dateString.indexOf("\\") >= 0)
			dArray = dateString.split("\\");
		else
			dArray = false;
		  
		return dArray;
	}

	/**
	Update the field with the given dateFieldName with the dateString that has been passed,
	and hide the datepicker. If no dateString is passed, just close the datepicker without
	changing the field value.

	Also, if the page developer has defined a function called datePickerClosed anywhere on
	the page or in an imported library, we will attempt to run that function with the updated
	field as a parameter. This can be used for such things as date validation, setting default
	values for related fields, etc. For example, you might have a function like this to validate
	a start date field:

	function datePickerClosed(dateField)
	{
	var dateObj = getFieldDate(dateField.value);
	var today = new Date();
	today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
	  
	if (dateField.name == "StartDate") {
		if (dateObj < today) {
		// if the date is before today, alert the user and display the datepicker again
		alert("Please enter a date that is today or later");
		dateField.value = "";
		document.getElementById(datePickerDivID).style.visibility = "visible";
		adjustiFrame();
		} else {
		// if the date is okay, set the EndDate field to 7 days after the StartDate
		dateObj.setTime(dateObj.getTime() + (7 * 24 * 60 * 60 * 1000));
		var endDateField = document.getElementsByName("EndDate").item(0);
		endDateField.value = getDateString(dateObj);
		}
	}
	}

	*/

	function updateDateField(dateFieldName, dateString)	{
		//var targetDateField = document.getElementsByName(dateFieldName).item(0); // 20051116 citp/cfi.dk - outcomment
		if (dateString)
			targetDateField.value = dateString;

		document.getElementById(datePickerDivID).style.visibility = "hidden";
		adjustiFrame();
		targetDateField.fireEvent("onchange"); //# 20050915 citp/cfi.dk
		targetDateField.focus();
	  
		// after the datepicker has closed, optionally run a user-defined function called
		// datePickerClosed, passing the field that was just updated as a parameter
		// (note that this will only run if the user actually selected a date from the datepicker)
		if ((dateString) && (typeof(datePickerClosed) == "function"))
			datePickerClosed(targetDateField);
	}

	/**
	Use an "iFrame shim" to deal with problems where the datepicker shows up behind
	selection list elements, if they're below the datepicker. The problem and solution are
	described at:

	http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx
	http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx
	*/
	function adjustiFrame(pickerDiv, iFrameDiv)	{
		if (!document.getElementById(iFrameDivID)) {
			// don't use innerHTML to update the body, because it can cause global variables
			// that are currently pointing to objects on the page to have bad references
			//document.body.innerHTML += "<iframe id='" + iFrameDivID + "' src='javascript:false;' scrolling='no' frameborder='0'>";
			var newNode = document.createElement("iFrame");
			newNode.setAttribute("id", iFrameDivID);
			//newNode.setAttribute("src", "javascript:false;");
			newNode.setAttribute("scrolling", "no");
			newNode.setAttribute("frameborder", "0");
			document.body.appendChild(newNode);
		}
		  
		if (!pickerDiv)
			pickerDiv = document.getElementById(datePickerDivID);
		if (!iFrameDiv)
			iFrameDiv = document.getElementById(iFrameDivID);
		  
		try {
			iFrameDiv.style.position = "absolute";
			iFrameDiv.style.width = pickerDiv.offsetWidth;
			iFrameDiv.style.height = pickerDiv.offsetHeight;
			iFrameDiv.style.top = pickerDiv.style.top;
			iFrameDiv.style.left = pickerDiv.style.left;
			iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
			iFrameDiv.style.visibility = pickerDiv.style.visibility;
		}
		catch(e) {
		}
	}
	
	//# < DATEPICKER
	
	//# > DYNAMIC COMBOBOX/LOOKUP
	//# 20051207 citp/cfi.dk

	// Position target element in relation to source element.
	// Below with same width.
	function fnPositionBelow(_source, _target)
	{
		// _source : the main object
		// _target : the object to position in relation to _source
		
		var debug;	
		var x = _source.offsetLeft;
		var y = _source.offsetTop + _source.offsetHeight;
		var w = _source.offsetWidth;

		while (_source.offsetParent) {
			_source = _source.offsetParent;
			if (_source.tagName != "DIV") //# This is a problem with relationg to DynamicWeb. This DIV offset's everything!!
			{
				x += _source.offsetLeft;
				y += _source.offsetTop;
			}
		}

		_target.style.position = "absolute";
		_target.style.zIndex = "10000";
		
		_target.style.top = y + "px";
		_target.style.left = x + "px";
		_target.style.width = w + "px";
	}

	function fnLookupHandleKey(_keyCode)
	{
		//fnDebug("fnLookupHandleKey: " + _keyCode); // DEBUG
		switch(_keyCode)
		{
			case 9:		// tab
			case 16:	// shift
			case 35:	// end
			case 36:	// home
			case 37:	// arrow left
			case 38:	// arrow up
			case 39:	// arrow right
			case 40:	// arrow down
			return false;
		}
		return true;
	}
	
	function fnLookupStartTimer(_handler)
	{
		if (_handler.isTimerStarted() == false)
		{
		    //fnDebug("fnLookupStartTimer"); // DEBUG	
			_handler.timerId = setTimeout("fnLookupSelectOpen('" + _handler.getSelect().id + "')", 1000);
			_handler.isTimerStarted(true);
		}	
	}
	
	//# 20061020 cit/cfi.dk
	function fnLookupCancelTimer(_handler)
	{
		if (_handler.isTimerStarted() == true)
		{
		    //fnDebug("fnLookupCancelTimer"); // DEBUG	
			clearTimeout(_handler.timerId);
			_handler.isTimerStarted(false);
		}	
	}
	
	// Eventhandler for INPUT 
	// If a normal key is pressed and the SELECT is hidden then start a timer that will make the SELECT visible.
	function fnLookupOnKeyPress()
	{
		//fnDebug("fnLookupOnKeyPress(): " + event.keyCode); // DEBUG
		
		var objInput = event.srcElement;
		var handler = objInput.lookupHandler;
		
		if (handler.isLookupOpen() == false)
			fnLookupStartTimer(handler);
	}
	
	// Eventhandler for INPUT
	// Handling of special keys.
	function fnLookupOnKeyDown()
	{
		var objInput = event.srcElement;
		var keyCode = event.keyCode;

		var handler = objInput.lookupHandler;
		var objSelect = handler.getSelect();

		var doStartTimer = true;

		//fnDebug("fnLookupOnKeyDown(): " + keyCode); // DEBUG

		switch(keyCode)
		{
			case 38 :	// UP ARROW
				if (objSelect.selectedIndex > 0) {
					objSelect.options(objSelect.selectedIndex - 1).selected = true;
					fnLookupSelectOnChange(objSelect);
				}
				break;
			case 40 :	// DOWN ARROW
				if (objSelect.options.length > objSelect.selectedIndex + 1) {
					objSelect.options(objSelect.selectedIndex + 1).selected = true;
					fnLookupSelectOnChange(objSelect);
				}
				break;
			case 13 :	// ENTER
				
				//# > 20061020 cit/cfi.dk 
				if (objSelect.selectedIndex >= 0) 
					objInput.value = objSelect.options(objSelect.selectedIndex).text;
				//# < 20061020 cit/cfi.dk

				if (handler.isLookupOpen())
				{
					fnLookupSelectClose(objSelect);
					return false;
				}	
			default :
				doStartTimer = false;
		}
		
		if (doStartTimer)
			fnLookupStartTimer(handler);
	}
	
	// Eventhandler for INPUT
	// When a 'normal' key is released, search the SELECT for corresponding item.
	function fnLookupOnKeyUp()
	{
		var objInput = event.srcElement;
		var handler = objInput.lookupHandler;
		var keyCode = event.keyCode;
				
		if (fnLookupHandleKey(keyCode) == true)
		{
			//fnDebug("fnLookupOnKeyUp(): " + event.keyCode); // DEBUG
			fnLookupSelectFindOption(handler.getSelect(), objInput.value);		
		}
	}
	
	// Eventhandler for INPUT
	// When the INPUT recieves focus.
	function fnLookupOnFocus()
	{
		var objInput = event.srcElement;
		var handler = objInput.lookupHandler;

		handler.hasFocus(true);
	}

/*	
	// Eventhandler for INPUT
	// When the INPUT looses focus, close the SELECT if it is open.
	function fnLookupOnBlur()
	{
		var objInput = event.srcElement;
		var handler = objInput.lookupHandler;
		var objSelect = handler.getSelect();

		handler.isTimerStarted(false);
		handler.hasFocus(false);
		
		if (handler.isLookupOpen())
			fnLookupSelectClose(objSelect);

		if (objSelect.selectedIndex >= 0)
			objInput.value = objSelect.options(objSelect.selectedIndex).text;
	}
*/	

	function fnLookupOnBlur()
	{
	    //fnDebug("fnLookupOnBlur"); // DEBUG

		var objInput = event.srcElement;
		var handler = objInput.lookupHandler;
		var objSelect = handler.getSelect();

		if (handler.isLookupOpen() &&
		    handler.isBlurTimerStarted() == false)
		{
			handler.timerOnBlur = setTimeout("fnLookupOnBlurTimerRun('" + handler.getSelect().id + "')", 100);
			handler.isBlurTimerStarted(true);
		}	
		else
			fnLookupCancelTimer(handler); //# 20061020 cit/cfi.dk
		
		//# > 20061020 cit/cfi.dk
		if (objSelect.selectedIndex >= 0)
			objInput.value = objSelect.options(objSelect.selectedIndex).text;
		//# < 20061020 cit/cfi.dk	
	}

	function fnLookupOnBlurTimerRun(_objSelectId)
    {
		var objSelect = document.getElementById(_objSelectId);
        var handler = objSelect.lookupHandler;
                
        if (handler.isBlurTimerStarted() == true)
        {                
    	    //fnDebug("fnLookupOnBlurTimerRun: " + handler.isBlurTimerStarted()); // DEBUG
    	    
   		    handler.isBlurTimerStarted(false);
		    handler.hasFocus(false);
    		
		    if (handler.isLookupOpen())
			    fnLookupSelectClose(objSelect);
        }
    }
	
	function fnLookupSelectOnFocus()
	{
		var objSelect = event.srcElement;
		var handler = objSelect.lookupHandler;

        if (handler.isBlurTimerStarted() == true)
        {
            //fnDebug("fnLookupSelectOnFocus: " + handler.isBlurTimerStarted()); // DEBUG	
            clearTimeout(handler.timerOnBlur);
            handler.isBlurTimerStarted(false);
        }            
	}
	
	function fnLookupSelectOnBlur()
	{
		var objSelect = event.srcElement;
		var handler = objSelect.lookupHandler;
		
		if (handler.isLookupOpen())
		    fnLookupSelectClose(objSelect);
	}

	// Eventhandler for SELECT
	// Event: If user makes a selection from the SELECT 
	// CalledFrom: If user uses up/down arrows in INPUT 
	function fnLookupSelectOnChange(_objSelect)
	{
		//fnDebug("fnLookupSelectChange()"); // DEBUG
		var objSelect;
		var isEvent = false;
		
		if (_objSelect == null)
		{	// triggered by event
			objSelect = event.srcElement;
			isEvent = true;
		}
		else
		{	// called from other method
			objSelect = _objSelect;
		}
		
		var handler = objSelect.lookupHandler;
		
		handler.getInput().value = objSelect.options(objSelect.selectedIndex).text;
		
		if (isEvent)
			fnLookupSelectClose(objSelect);		
		
		handler.getInput().focus();

		fnMGChanged(objSelect); // CALL to multigrid change management
	}

	// Make SELECT visible and find option that matches the value in INPUT.
	function fnLookupSelectOpen(_objSelect)
	{
		var objSelect = document.getElementById(_objSelect);
		var isEvent = false;
		var objInput;
		var handler;
		
		if (objSelect == null)
		{
			objSelect = event.srcElement.lookupHandler.getSelect();
			isEvent = true;
		}	

		handler = objSelect.lookupHandler;
		objInput = handler.getInput();

		handler.isTimerStarted(false);
		if (handler.hasFocus() || isEvent)
		{
			fnPositionBelow(objInput, objSelect);
			handler.isLookupOpen(true);
			objSelect.style.visibility = "visible";
			objInput.focus();
		}
		fnLookupSelectFindOption(objSelect, handler.getInput().value);
	}
	
	// Make SELECT hidden.
	function fnLookupSelectClose(_select)
	{
		_select.lookupHandler.isLookupOpen(false);
		_select.style.visibility = "hidden";
	}
	
	// Search SELECT for text matching criteria.
	function fnLookupSelectFindOption(_objSelect, _searchText)
	{
		var optionText;
		var searchText;
		var selectedIndex;
		
		var options = _objSelect.options;
		
		if (_objSelect.selectedIndex >= 0 && _objSelect.options(_objSelect.selectedIndex).text == _searchText)
			return true;
				
		for (i = 0; i < options.length; i++)
		{	// for each option in the select
		
			optionText = options(i).text;	
			searchText = _searchText;
			
			if (optionText.length > searchText.length)
				optionText = optionText.substr(0, searchText.length);
			else if (searchText.length > optionText.length)
				searchText.substr(0, optionText.length);

			if (searchText.toLowerCase() == optionText.toLowerCase())
			{
				selectedIndex = i;
				break;
			}
		}
		
		if (selectedIndex >= 0)
		{
			options(selectedIndex).selected = true;
			fnMGChanged(_objSelect); // CALL to multigrid change management
			return true;
		}	
		return false;
	}

	// Object LookupHandler
	function ObjLookupHandler(_mainElement)
	{
		// _input		: <INPUT> element
		// _img			: <IMG> element
		// _select		: <SELECT> element
		// _optional	:
		// _filled		: If TRUE, no server lookup will be done. All data is on client.
		
		/*
		if (_input == null || _input.tagName != "INPUT")
			alert("Error with input element!(" + _input + ") " + _optional);
		if (_img == null || _img.tagName != "IMG")
			alert("Error with img element!("+ _img + ") " + _optional);
		if (_select == null || _select.tagName != "SELECT")
			alert("Error with select element!("+_select+") " + _optional);
		*/
		/*	
		var objInput = _input;
		var objImg = _img;
		var objSelect = _select;
		*/
		var objInput = document.getElementById("input_" + _mainElement);
		var objImg = document.getElementById("img_" + _mainElement);
		var objSelect = document.getElementById(_mainElement);

		if (objInput == null || objInput.tagName != "INPUT")
		{
			alert("Error with input element!(" + _input + ") " + _optional);
			return;
		}
		if (objImg == null || objImg.tagName != "IMG")
		{
			alert("Error with img element!("+ _img + ") " + _optional);
			return;
		}
		if (objSelect == null || objSelect.tagName != "SELECT")
		{
			alert("Error with select element!("+_select+") " + _optional);
			return;
		}
		
		if (objSelect.selectedIndex < 0)
			objSelect.selectedIndex = 0;
			
		objInput.value = objSelect.options(objSelect.selectedIndex).text;
		
		var lookupHasFocus = false;
		var lookupTimerStarted = false;
		var lookupOpen = false;	
		var lookupFilled = false;	
		var valueTimerId = 0;

		var lookupBlurTimerStarted = false;
		var timerOnBlur = 0;
		
		this.getInput = function () {
			return objInput;
		}
		this.getImg = function () {
			return objImg;
		}
		this.getSelect = function () {
			return objSelect;
		}
		
		//# set/get timerId value - 20061020 cit/cfi.dk
		this.timerId = function (_value) {
			if (_value != null)
				valueTimerId = _value;
			return valueTimerId;
		}
		
		//# set/get hosFocus flag
		this.hasFocus = function (_flag) {
			if (_flag != null)
				lookupHasFocus = _flag;
			return lookupHasFocus;
		}
		
		//# set/get method for timer-flag
		this.isTimerStarted = function (_flag) {
			if (_flag != null)
				lookupTimerStarted = _flag;
			return lookupTimerStarted;
		}
		
		//# set/get method for blurtimer
		this.isBlurTimerStarted = function (_flag) {
		    if (_flag != null)
		        lookupBlurTimerStarted = _flag;
		    return lookupBlurTimerStarted;
		}
		
		//# set/get method for visibility-flag
		this.isLookupOpen = function (_flag) {
			if (_flag != null)
				lookupOpen = _flag;
			return lookupOpen;				
		}
		
		//# set/get method for filled-flag
		this.isLookupFilled = function (_flag) {
			if (_flag != null)
				lookupFilled = _flag;
			return lookupFilled;
		}
		
		//# objSelect functions
		//fnPositionBelow(objInput, objSelect);
		
		//# Event delegation
		// IMG events
		objImg.onclick = fnLookupSelectOpen;
		// INPUT events
		objInput.onfocus = fnLookupOnFocus;
		objInput.onkeydown = fnLookupOnKeyDown;
		objInput.onkeypress = fnLookupOnKeyPress;
		objInput.onkeyup = fnLookupOnKeyUp;
		objInput.onblur = fnLookupOnBlur;
		// SELECT events		
		objSelect.onchange = fnLookupSelectOnChange;
		objSelect.onfocus = fnLookupSelectOnFocus;
		objSelect.onblur = fnLookupSelectOnBlur;
				
		objInput.lookupHandler = this;
		objImg.lookupHandler = this;
		objSelect.lookupHandler = this;
	}

	//# < DYNAMIC COMBOBOX/LOOKUP
	
	//# > CHECKBOX (20051216 citp/cfi.dk)
	
	function fnCheckBoxClick(_oCaller, _idMainElement)
	{   // 20070516 cit/cfi.dk
	    var oMainElement = document.getElementById(_idMainElement);
	    oMainElement.value = _oCaller.checked ? "true" : "false";
	    oMainElement.fireEvent("onchange");
	}
	
	function fnCheckBoxClickImage(_mainElement)
	{
		var objInput = document.getElementById(_mainElement);
		var objImg = document.getElementById(_mainElement + "_img");
		
		if (objInput.value == "0")
		{
			objInput.value = "1";
			objImg.src = "Files/Templates/citp_publish/images/checkbox_on.gif";
		}
		else
		{
			objInput.value = "0";
			objImg.src = "Files/Templates/citp_publish/images/checkbox_off.gif";
		}
		
		objInput.fireEvent("onchange");
	}
	
	//# < CHECKBOX
	
	//# > MULTISELECT ENUM (20060321 citp/cfi.dk)
	function fnMultiSelectSum(target)
	{
		// Sums the selected values and returns a single integer value.
		// Only work with integer values of course...
		
		var caller = event.srcElement;
		var value = 0;
		
		for (idx = 0; idx < caller.options.length; idx++)
		{
			if (caller.options[idx].selected)
				value += parseInt(caller.options[idx].value, 10);
		}

		target.value = value;
	}
	
	function fnMultiSelectString(target)
	{
		// Builds a string from the selected values for use with an SQL 'IN' statement
		// Only works with string values
		// ('value1','value2','value3')
	
		var caller = event.srcElement;
		var value = "";
		var first = true;
		
		value += "(";
		for (idx = 0; idx < caller.options.length; idx++)
		{
			if (caller.options[idx].selected)
			{
				if (first)
					first = false;
				else
					value += ",";
					
				value += "'" + caller.options[idx].value + "'";
			}
		}
		value += ")";

		target.value = value;
	}

	function fnMultiSelectNumber(target)
	{
		// **NOT YET IN USE**
		// Builds a string from the selected values for use with an SQL 'IN' statement
		// Only works with integer values
		// (value1,value2,value3)

		var caller = event.srcElement;
		var value = "";
		var first = true;

		value += "(";
		for (idx = 0; idx < caller.options.length; idx++)
		{
			if (caller.options[idx].selected)
			{
				if (first)
					first = false;
				else
					value += ",";
					
				value += caller.options[idx].value;
			}
		}
		value += ")";
		
		target.value = value;
	}

	//# < MULTISELECT ENUM SUM
	
	//# > FILEMANAGER
	var hider = "";
	var activeDocument = null;
	var arrPermission = new Array;
	var activeMenu = "";
	
	function showMenu(ID, Top, Left){
		if (activeMenu != ""){
			hideMenu(activeMenu);
		}
		activeMenu = ID
		document.all[ID].style.pixelTop = Top-4;
		document.all[ID].style.pixelLeft = Left-13;
		document.all[ID].style.display = "";
		document.all[ID].focus();
	}
	
	function startHide(ID){
		if (hider == ""){
			hider = window.setInterval("hideMenu(\"" + ID + "\")", 1000);
		}
	}
	
	function stopHide(){
		if (hider != ""){
			window.clearInterval(hider);
			hider = "";
		}
	}
	
	function hideMenu(ID){
		if (hider != ""){
			window.clearInterval(hider);
		}
		if (document.all[ID]){
			document.all[ID].style.display = "none";
		}
		if (document.all.menuOption){
			document.all.menuOption.style.display = "none";
		}
		activeMenu = ""
		hider = "";
		activeDocument = null;
 	}
 	
 	function showOptions(objSrc, objParent){
 		arrTmp = arrPermission[activeDocument.GUID]
 		document.all.FileActionOpen.style.display = (arrTmp['open']) ? "" : "none";
 		//document.all.FileActionOpenWorkingCopy.style.display = (arrTmp['inwork']) ? "" : "none";//""//(arrTmp['checkin']) ? "" : "none";
 		//document.all.FileActionCheckOut.style.display = (arrTmp['checkout']) ? "" : "none";
 		document.all.FileActionUndoCheckOut.style.display = (arrTmp['checkin']) ? "" : "none";
 		//document.all.FileActionCheckIn.style.display = (arrTmp['checkin']) ? "" : "none";
 		document.all.FileActionRename.style.display = (arrTmp['rename']) ? "" : "none";
 		document.all.FileActionDelete.style.display = (arrTmp['delete']) ? "" : "none";
 		document.all.FileActionProperties.style.display = (arrTmp['open']) ? "" : "none";
 		document.all.FileActionVersionHistory.style.display = (arrTmp['open']) ? "" : "none";
 		//document.all.FileActionApprove.style.display = (arrTmp['approve']) ? "" : "none";
 		//document.all.FileActionRelease.style.display = (arrTmp['release']) ? "" : "none";
 		document.all.FileActionUpload.style.display = (arrTmp['checkin']) ? "" : "none";
 		document.all.FileActionNewVersion.style.display = (arrTmp['checkout']) ? "" : "none";
 		document.all.FileActionNoOptions.style.display = "";
 		for (var i in arrTmp){
 			if (arrTmp[i]==true){
 				document.all.FileActionNoOptions.style.display = "none";
 				break;
 			}
 		}
 		document.all.menuOption.style.pixelTop = objSrc.offsetTop+document.all[objParent].style.pixelTop-1;
 		document.all.menuOption.style.pixelLeft = objSrc.offsetLeft+document.all[objParent].style.pixelLeft+objSrc.offsetWidth-20;
 		document.all.menuOption.style.display = "";
 	}
 	
 	function setActiveDocument(GUID){
 		activeDocument = new Document(GUID)
 	}

 	function Document(ID){
 		this.Open = Open;
 		this.Edit = Edit;
 		this.OpenWorkingCopy = OpenWorkingCopy;
 		this.CheckOut = CheckOut;
 		this.Upload = Upload;
 		this.Approve = Approve;
 		this.Release = Release;
 		this.UndoCheckOut = UndoCheckOut;
 		this.CheckIn = CheckIn;
 		this.versionHistory = versionHistory;
 		this.Rename = Rename;
 		this.Delete = Delete;
 		this.Properties = Properties;
 		this.GUID = ID;
 		this.PID = 0;
 		function Open(){
 			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID);
 			newWin.focus();
 		}
 		function Edit(){
 			document.location.href = "CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=edit";
 			setTimeout("document.location.href = document.location.href;", 5000);
 		}
 		function OpenWorkingCopy(){
 			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=openworkingcopy");
 			newWin.focus();
 		}
 		function CheckOut(){
 			document.location.href = "CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=checkout&url="+document.location.href;
 		}
 		function Upload(){
 			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&mode=commit&FileGUID=" + this.GUID, 'upl', 'height=500 width=700 status=yes');
 			newWin.focus();
 		}
 		function Approve(){
 			document.location.href = "CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=approve&url="+document.location.href;
 		}
 		function Release(){
 			document.location.href = "CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=release&url="+document.location.href;
 		}
 		function UndoCheckOut(){
 			document.location.href = "CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=undocheckout&url="+document.location.href;
 		}
 		function CheckIn(){
			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=checkin", "CitpViever", "height=600 width=800 status=yes resize=yes scrollbars=yes");
 			newWin.focus();
 		}
 		function versionHistory(){
 			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=versionhistory", "asd", "height=600 width=800 status=yes resize=yes scrollbars=yes");
 		}
 		function Rename(){
 			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=rename", "asd", "height=600 width=800 status=yes resize=yes scrollbars=yes");
 		}
 		function Delete(){
 			arrTmp = arrPermission[this.GUID]
 			if (confirm("Denne handling vil slette filen \"" + arrTmp['filename'] + "\" og dens versionshistorik.\nØnsker du at fortsætte?")){
 				document.location.href = "CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=delete&url="+document.location.href;
 			}
 		}
 		function Properties(){
 			newWin = window.open("CustomModules/Citp_Publish/FileToolKit.asp?pid=" + this.PID + "&FileGUID=" + this.GUID + "&mode=properties", "asd", "height=500 width=400 status=yes resize=yes scrollbars=yes");
 		}
	}
	
	//# < FILEMANAGER



function PageQuery(q) 
{
	if(q.length > 1) 
		this.q = q.substring(1, q.length);
	else 
		this.q = null;

	this.keyValuePairs = new Array();
	if(q) 
	{
		for(var i=0; i < this.q.split("&").length; i++) 
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}

	this.getKeyValuePairs = function() { return this.keyValuePairs; }

	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}

	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
		a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}

	this.getLength = function() 
	{ 
		return this.keyValuePairs.length; 
	} 
}	
