function win_open(href, width, height)
{
	if (width == '' && height == '')  
	{
		window.open(href, '_blank', 'toolbar=no,location=no,status=yes,menubar=no,personalbar=no,scrollbars=yes,resizable=yes,screenx=50,left=50,screenY=50,top=50');
	} 
	else
	{
		window.open(href, '_blank', 'toolbar=no,location=no,status=yes,menubar=no,personalbar=no,scrollbars=yes,width=' + width + ',height=' + height + ',resizable=yes,screenx=50,left=50,screenY=50,top=50')
	}
}

function openPage(href) {
	if(href!=""){
		window.open(href, '_blank', 'width="800",height="600",toolbar=yes,location=yes,status=yes,menubar=yes,personalbar=yes,scrollbars=yes,resizable=yes,screenx=50,left=50,screenY=50,top=50');
	}
}

function openFullPage(href) {
	if(href!=""){
		var wOptions = "toolbar=yes,location=yes,status=yes,menubar=yes,personalbar=yes," +
			"scrollbars=yes,resizable=yes,outerHeight=" + screen.availHeight + ",outerWidth=" +
			screen.availWidth + ",screenX=0,screenY=0,height=" + screen.availHeight + ",width=" +
			screen.availWidth + ",left=0,top=0";
		window.open(href, '_blank', wOptions);
	}
}

function checkDelete() {

	if (confirm("Do you want to delete this entry?")) {
		return true;
	}
	else {
		return false;
	}
}

function CheckMandatoryFields(oForm) {

	var i, j, sElementName, sElementType, bCheck, sAlertText;
	var bError = 0;
	
	for (i = 0; i < oForm.elements.length; i++) {
		
		oElement = oForm.elements[i];
		sElementName = oElement.name;
		sElementType = oElement.type;

		if (sElementName != "") {
			
			if (sElementName.length > 3) {

				if (sElementName.substr(sElementName.length - 3, 3) == "_mf") {
					
					switch (sElementType) {
					
						case "text":
						
							if (oElement.value == "") {
								bError = 1;
							}
							
							break;
							
						case "checkbox":
						
							if (oElement.checked == false) {
								bError = 1;
							}
							
							break;
							
						case "file":
						
							if (oElement.value != "" && oElement.value.substr(oElement.value.length-3,3) != "doc" && oElement.value.substr(oElement.value.length-3,3) != "pdf") {
								bError = 2;
							}
							
							if (oElement.value == "") {
								bError = 1;
							}
							
							break;
							
						case "select-one":
						
							if (oElement[oElement.selectedIndex].value == "" || oElement[oElement.selectedIndex].value == "null") {
								bError = 1;
							}
							
							break;
							
						case "select-multiple":

							bCheck = 0;

							for (j = 0; j < oElement.options.length; j++) {
								if (oElement.options[j].selected) {
									bCheck++;
								}
							}

							if (bCheck == 0) {
								bError = 1;
							}
							
							break;
					}
				}
			}
		}
		
		if (bError == 0 && oElement.type == "checkbox" && oElement.name == "authorization" && oElement.checked == false){
			bError = 3;
		}
		
		
	}

	if (bError == 0) {
		oForm.submit();
	}
	else {
		
		switch (bError) {
		
			case 1:
				sAlertText="Please fill in all mandatory fields!";
				break;
				
			case 2:
				sAlertText="Only .doc and .pdf attachments are allowed";
				break;
				
			case 3:
				sAlertText="Please check the authorization-box";
				break;
		}
					
		alert(sAlertText);
	}
}
