//################################################
//############## FIELD FORM FOCUS ################
	function fieldFocus(){	
		var url = location.pathname;
		var lunghezza = url.length;
		var trova = url.lastIndexOf("juice", url, lunghezza);
		var pagina = url.substr(trova+6, lunghezza);
			if (pagina == "testimonials/index.php"){
				document.form.TxtSDate.focus();
			} 
			
			if (pagina == "links/index.php"){
				document.form.TxtSUrl.focus();
			} 
			
			if (pagina == "courses/"){
				document.form.TxtNCode.focus();
			}
			
			if (pagina == "properties/new.php"){
				document.form.SelSCategory.focus();
			}
			
			if (pagina == "courses/update.php"){
				document.form.TxtSCode.focus();
			}
			
			if (pagina == "conferences/"){
				document.form.TxtNCode.focus();
			}
			
			if (pagina == "conferences/new.php"){
				document.form.TxtSCode.focus();
			}
			
			if (pagina == "conferences/update.php"){
				document.form.TxtSCode.focus();
			}
			
			if (pagina == "news/index.php"){
				document.form.TxtSTitle.focus();
			}
			
			if (pagina == "resources/index.php"){
				document.form.TxtSDescription.focus();
			}
			
			if (pagina == "venues/index.php"){
				document.form.TxtSName.focus();
			}
	}
//############## FIELD FORM FOCUS ################
//################################################



//###############################################
//########### FUNCTION CONFIRM DELETE ###########
function del(){
		conferma = window.confirm ("MESSAGE: The record will be deleted!!");
	return conferma;
}
//########### FUNCTION CONFIRM DELETE ########### 
//###############################################


//###############################################
//########### FUNCTION CONFIRM UPDATE ###########
function conferma_update(){
		conferma = window.confirm ("MESSAGE: The record will be updated!!");
	return conferma;
}
//########### FUNCTION CONFIRM UPDATE ###########
//###############################################


//##############################################################
//########### CHECK CONFIRM PASSWORD (User Register) ###########
function confirmPass(){
	if(document.form.TxtSNewPassword.value != document.form.TxtSConfirm_Password.value){
		alert ("Error: The fields Password and Confirm password are different!");
		document.form.TxtSConfirm_Password.focus;
		return false;
	}
}
//########### CHECK CONFIRM PASSWORD (User Register) ###########
//##############################################################


//####################################################
//########### FUNCTION CHECK EMAIL ADDRESS ###########
function checkEmail() {
	mail = document.form.TxtNEmail.value;
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	if (Filtro.test(mail)==false){
		alert("Email address is not valid, please try again!");
		document.form.TxtNEmail.focus();
		document.form.TxtNEmail.style.background='#E4E4E4';
		return false;
	}
}
//########### FUNCTION CHECK EMAIL ADDRESS ###########
//####################################################



//##################################################################
//########### FUNCTION CHECK EMAIL ADDRESS (USER UPDATE) ###########
function checkEmailUpdate() {
	mail = document.form.TxtNEmailUpdate.value;
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	if (Filtro.test(mail)==false){
		alert("Email address is not valid, please try again!");
		document.form.TxtNEmailUpdate.focus();
		document.form.TxtNEmailUpdate.style.background='#E4E4E4';
		return false;
	}
}
//########### FUNCTION CHECK EMAIL ADDRESS (USER UPDATE) ###########
//##################################################################


//############################################################
//########### FUNCTION CHECK EMAIL ADDRESS (LOGIN) ###########
function checkEmailLogin() {
	mail = document.formLogin.TxtNLogEmail.value;
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	if (Filtro.test(mail)==false){
		alert("Email address is not valid, please try again!");
		document.formLogin.TxtNLogEmail.focus();
		document.formLogin.TxtNLogEmail.style.background='#E4E4E4';
		return false;
	}
}
//########### FUNCTION CHECK EMAIL ADDRESS (LOGIN) ###########
//############################################################


//#######################################################
//########### FUNCTION CHECK CONFIRM PASSWORD ###########
function confirmPass(){
	if (!(document.form.TxtSPassword.value == document.form.TxtSConfirm_Password.value )){
		alert("Please confrim your password correctly!!");
		document.form.TxtSConfirm_Password.focus();
		document.form.TxtSConfirm_Password.style.background='#E4E4E4';
		return false;
	}
}
//########### FUNCTION CHECK CONFIRM PASSWORD ###########
//#######################################################


//######################################################
//########### CHANGE PAGE FROM DROPDOWN LIST ###########
function view(targ,selObj,restore){ 
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
}
//########### CHANGE PAGE FROM DROPDOWN LIST ###########
//######################################################


//#############################################################################
//########### FUNCTION USER AND PASSWORD LENGHT (user_register.php) ###########
function stringsUserLenght(){
	if(document.form.TxtSUsername.value.length < 6){
		alert("Error: the Username field can't be shorter then 6 chars!");
		document.form.TxtSUsername.style.background='#E4E4E4';
		document.form.TxtSUsername.focus;
		return false;
	}
}

function stringsPassLenght(){
	if(document.form.TxtSPassword.value.length < 6){
		alert("Error: the Password field can't be shorter then 6 chars!");
		document.form.TxtSPassword.style.background='#E4E4E4';
		document.form.TxtSPassword.focus;
		return false;
	}
}
//########### FUNCTION USER AND PASSWORD LENGHT (user_register.php) ###########
//#############################################################################
	

//################################################################
//########### FUNCTION CHECK SEARCH IN JUICE LOGS PAGE ###########
	function checkSearch(){
		//Month and Year empty
		if(document.form.SelNDay.value != ""  && document.form.SelNMonth.value == "" && document.form.SelNYear.value == ""){
			alert ("Please Month and Year are required fields.");
			document.form.SelNMonth.focus();
			return false;
		}
		
		//Day and Year empty
		if(document.form.SelNDay.value == ""  && document.form.SelNMonth.value != "" && document.form.SelNYear.value == ""){
			alert ("Please Day and Year are required fields.");
			document.form.SelNDay.focus();
			return false;
		}
		
		//Day and Month empty
		if(document.form.SelNDay.value == ""  && document.form.SelNMonth.value == "" && document.form.SelNYear.value != ""){
			alert ("Please Day and Month are required fields.");
			document.form.SelNDay.focus();
			return false;
		}
		
		//Year empty
		if(document.form.SelNDay.value != ""  && document.form.SelNMonth.value != "" && document.form.SelNYear.value == ""){
			alert ("Please Year is a required field.");
			document.form.SelNYear.focus();
			return false;
		}
		
		//Day empty
		if(document.form.SelNDay.value == ""  && document.form.SelNMonth.value != "" && document.form.SelNYear.value != ""){
			alert ("Please Day is a required field.");
			document.form.SelNDay.focus();
			return false;
		}	
		
		//Month empty
		if(document.form.SelNDay.value != ""  && document.form.SelNMonth.value == "" && document.form.SelNYear.value != ""){
			alert ("Please Month is a required field.");
			document.form.SelNMonth.focus();
			return false;
		}	
		
		//When everything is empty you must select the Area
		if(document.form.SelNDay.value == ""  && document.form.SelNMonth.value == "" && document.form.SelNYear.value == "" &&  document.form.SelNArea.value == ""){
			alert ("Please Area is a required field.");
			document.form.SelNArea.focus();
			return false;
		}	
	}
//########### FUNCTION CHECK SEARCH IN JUICE LOGS PAGE ###########
//################################################################
