function openWindow(url,w,h) {
    var width=780;
    var height=660;
    if(w && w>0)
        width=w;
    if(h && h>0)
        height=h;
     var availheight=((screen.availHeight-height)/2);
	 var availwidth=((screen.availWidth-width)/2);
    winStats='resizable=yes,toolbar=no,status=no,location=no,directories=no,menubar=no,';
	winStats+='scrollbars=yes,width='+width+',height='+height;
	winStats+=',left='+availwidth+',top='+availheight;
	if (navigator.appName.indexOf("Microsoft")>=0) {
		winStats+=',left='+availwidth+',top='+availheight;
	}else{
		winStats+=',screenX='+availwidth+',screenY='+availheight;
	}
	floater=window.open(url,"",winStats)
}

function openWindowNoResize(url,width,height) {
	 var availheight=((screen.availHeight-660)/2);
	 var availwidth=((screen.availWidth-780)/2);
	winStats='resizable=no,toolbar=no,status=no,location=no,directories=no,menubar=no,';
	winStats+='scrollbars=no,width='+width+',height='+height;
	if (navigator.appName.indexOf("Microsoft")>=0) {
		winStats+=',left='+availwidth+',top='+availheight;
	}else{
		winStats+=',screenX='+availwidth+',screenY='+availheight;
	}
	floater=window.open(url,"",winStats)
}

function confirmMessage(url, msg){
	if (confirm(msg)){
		document.location.href=url;
	}
}

function mergeDates(formName) {
	if (document.forms[formName].startDayDisplay.value == '' || document.forms[formName].endDayDisplay.value == '') {
		return false;
	}
	document.forms[formName].startDate.value = document.forms[formName].startDay.value+' '+document.forms[formName].startHour.value+':'+document.forms[formName].startMinute.value+':00';
	document.forms[formName].endDate.value = document.forms[formName].endDay.value+' '+document.forms[formName].endHour.value+':'+document.forms[formName].endMinute.value+':00';
	if (document.forms[formName].assignmentDeadline && document.forms[formName].assignmentDay.value != '')
		document.forms[formName].assignmentDeadline.value = document.forms[formName].assignmentDay.value+' '+document.forms[formName].assignmentHour.value+':'+document.forms[formName].assignmentMinute.value+':00';

}

function submitCSForm(formName){
	alert("Checking form.");
	if(checkFormFields(formName)){
		document.forms[formName].createCollaborationSpace.value='true';

		document.forms[formName].submit();
	}

}

function checkFormFields(formName) {
	if(document.forms[formName].name.value == ''){
		alert('A name must be given.');
		return false;
	}
	else if(document.forms[formName].subjectId.value < 1){
		alert('Choose a subject.');
		return false;
	}
	else if(document.forms[formName].targetGroupId.value < 1){
		alert('Choose a target group.');
		return false;
	}
	else if(document.forms[formName].studyTermId.value < 1){
		alert('Choose a term.');
		return false;
	}
	else if(document.forms[formName].selectedLanguageId.value < 1){
		alert('Choose a language.');
		return false;
	}
	else return true;
}	


function termSearch(formName,letter) {
	document.forms[formName].searchText.value = letter+'*';
	document.forms[formName].submit();
}

function checkSw(form) {
 	sw = form.searchWord.value;
	if (sw.length < 1) {
	alert ('<xsl:if test="$languageId = \'1\'">Vennligst skriv et ord.</xsl:if><xsl:if test="$languageId = \'2\'">Please write a word.</xsl:if>')
	return false;
	}
 }

function checkToDate(){
	todate=document.getElementById('toDate');
	alert(todate);
	alert(todate.value);
}

<!--
/*function replace (data,find,replace)  {
	var flen = find.length;
	var dlen = data.length;
	for (i=0; i<dlen; i++) {
		var j = i + flen;
		if (data.substring(i,j) == find)  {
			data = data.substring(0,i) + replace + data.substring(j,dlen);
		}
	}
	return data
}

function uescape(str)
{
	var a = escape(str);

	a = replace(a, '%E6', '%C3%A6');
	a = replace(a, '%F8', '%C3%B8');
	a = replace(a, '%E5', '%C3%A5');

	a = replace(a, '%C6', '%C3%86');
	a = replace(a, '%D8', '%C3%98');
	a = replace(a, '%C5', '%C3%85');
	
	a = replace(a, '%20', ' ');

	return a;
}*/
-->