// JavaScript login page Document
function checkEmail(value){
	if(value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)==-1) return true;
	else return false;
	}
	
function changeColor(value){
	document.getElementById(value).style.backgroundColor="#FF6633";
	}

function resetColor(f){
 for (var i=0; i<f.elements.length; i++) {
  curObj = f.elements[i];
  if (curObj.tagName == 'INPUT' && curObj.type == 'text' && curObj.id != '') {
   document.getElementById(curObj.id).style.backgroundColor="";
  }
 }
}
	
function loginCheck(f){
	resetColor(f)
	if(f.user.value == ""){
		alert("Inserire lo username.");
		changeColor("user");
		return false;
		}
	if(f.pass.value == ""){
		alert("Inserire la password");
		changeColor("pass");
		return false;
		}
	}
	
function forgot(f){
	resetColor(f);
	if(f.email.value == "" || checkEmail(f.email.value) == true){
		alert("E' obbligatorio inserire un indirizzo email VALIDO");
		changeColor("email");
		return false;
		}
	}
