function openWindow(url,width,height) {
	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;
	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();
}