function windowOpen(href, width, height, scrollbar)
{
	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 if (scrollbar != '') {
		window.open(href, '_blank', 'toolbar=no,location=no,status=no,menubar=no,personalbar=no,scrollbars=' + scrollbar + ',width=' + width + ',height=' + height + ',resizable=yes,screenx=50,left=50,screenY=50,top=50')
	}
	else {
		window.open(href, '_blank', 'toolbar=no,location=no,status=no,menubar=no,personalbar=no,scrollbars=no,width=' + width + ',height=' + height + ',resizable=yes,screenx=50,left=50,screenY=50,top=50')
	}
}

function del_confirm(msg, url) {
  if(confirm(msg)) {
  	location.href = url;
  }
}

function loginFocus() {
if (document.forms[0].name.value.length > 0)
	document.forms[0].password.focus();
else
	document.forms[0].name.focus();
}



function CheckMandatoryFields(oForm) {


	var i, j, sElementName, sElementType, bCheck;
	var bError = 0;
	var bOr = 0;
	var flag = 0;
	var checkboxG1 = 0;
	var flag2 = 0;
	var checkboxG2 = 0;
	var bgColor = "#EFEFEF";
	
	
	if (oForm.contact_password_mf) {
		
		var pw1 = oForm.contact_password_mf.value;
		var pw2 = oForm.contact_password_confirm_mf.value;
		
		if (pw1 != pw2) {
			//alert("")
			//document.registrationform.contact_password_mf.style.backgroundColor = bgColor
			//document.registrationform.contact_password_confirm_mf.style.backgroundColor = bgColor
			return false;
		}
	}
	
	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;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							break;
							
							
						case "password":
							if (oElement.value == "") {
								bError = 1;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							break;
						
																			
						case "textarea":
						
							if (oElement.value == "") {
								bError = 1;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							break;

						case "checkbox":
						
							if (oElement.checked == false) {
								bError = 3;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							break;
							
						
						case "radio":
												
							
				            bCheck = 0;
				             
							for (j = 0; j < oForm[sElementName].length; j++) {  
							 	
								if (oForm[sElementName][j].checked == true) bCheck = 1;
							}         
							  
			                  
			             	if (bCheck == 0) {
								bError = 1;
								oElement.style.border = "2px solid #ffffff";
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							
							break;
							
													
						case "select-one":
						
							if (oElement[oElement.selectedIndex].value == "" || oElement[oElement.selectedIndex].value == "null") {
								bError = 1;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							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;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							break;
						
						case "file":
							if (oElement.value == "") {
								bError = 1;
								oElement.style.backgroundColor = bgColor;
							}
							else {
								oElement.style.backgroundColor = "";
							}
							break;
					}
				}
				else {
				
					if (sElementName.substr(sElementName.length - 3, 3) == "_or") {
						
						switch (sElementType) {
							case "text":
								if (oElement.value == "") {
									bOr++;
									oElement.style.backgroundColor = bgColor;
								}
								else {
									oElement.style.backgroundColor = "";
								}
							break;
								
						}
						
						
						if (bOr > 1) {
							bOr = 1;
						}
					}
				}
				
				if (sElementName.indexOf('contact_checkboxG1') != -1) {
					
					checkboxG1 = 1;
						
						if (oElement.checked == true) {
							
							flag = 1;
		
						}				
				
				}
				
				if (sElementName.indexOf('contact_checkboxG2') != -1) {
					
					checkboxG2 = 1;
						
						if (oElement.checked == true) {
							
							flag2 = 1;
		
						}				
				
				}
				
				if (sElementName.indexOf('contact_checkboxG3') != -1) {
					
					checkboxG2 = 1;
						
						if (oElement.checked == true) {
							
							flag2 = 1;
		
						}				
				
				}
				
				
				if (sElementName.indexOf('mail_') != -1 && oElement.value != "") {
					
					if(checkEmail(oElement.value) == false){
						bError = 2;
						oElement.style.backgroundColor = bgColor;
					}
					else {
						oElement.style.backgroundColor = "#ffffff";
					}
				}
				
				if (sElementName.substr(sElementName.length - 3, 3) == "_ch") {
					
					switch (sElementType) {
							case "checkbox":
								if (oElement.checked == false) {
								bError = 3;
								oElement.style.backgroundColor = bgColor;
							}
							break;
					}
				}
				
								
			}
		}
	}

	
	if (checkboxG2 == 1 && flag2 == 0){
	
		bError = 1;
		oElement.style.backgroundColor = bgColor;

	}
	
	if (checkboxG1 == 1 && flag == 0){
	
		bError = 1;
		oElement.style.backgroundColor = bgColor;

	}
	
	if (bError == 0 && bOr == 0) {
		return true;
	}
	if (bError == 1) {
		alert("");
		return false;
	}
	if (bError == 2) {
		alert("Digitare E-mail...");
		return false;
	}
	if (bError == 3) {
		alert("");
		return false;
	}
	if (bOr == 1) {
		alert("");
		return false;
	}
	
	
	
}


function checkEmail(emailAddress) {
	
	var re = /^(([^<>()[\]\\.,;:@\"]+(\.[^<>()[\]\\.,;:@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return re.test(emailAddress);
}


function applyLoginMode(sFormName) {
	var aRadio=document.forms[sFormName].elements["login_mode"];
	for (var i=0; i<aRadio.length; i++) {
		if(aRadio[i].checked) {
			document.forms[sFormName].elements["name"].value = aRadio[i].value+"\\"+
				document.forms[sFormName].elements["uid"].value;
			
		}
	}
	return true;
}

function openNoteLine(nbr) {
	var contentStyle = document.getElementById(nbr).style;
	if(contentStyle.display == 'none') {
		contentStyle.display = 'block';
	} else {
		contentStyle.display = 'none';
	}
}
