
//========================================================================0
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0
//========================================================================0
/*					JAVASCRIPT  FUNCTIONS
#01- function trim(string)
#02- function hidelayer(lay)
#03- function showlayer(lay)
#04- function Error_Style(dom_Ele)
#05- function checkDate()

#07- function Validate_InsArtist(page)
#08- function Validate_UpdArtist()
#09- function Validate_UpdProfile($page)
#10- function contatore(val)
#11- function Validate_Register()
#12- function Validate_Sendpa()
#14- function Validate_NewPassword()
*/
//========================================================================0
//#01-                function trim(string)                  xxxxxxxxxxxx0
//========================================================================0
function trim(stringa){
	while (stringa.substring(0,1) == ' '){
		stringa = stringa.substring(1, stringa.length);
		}    
		while (stringa.substring(stringa.length-1, stringa.length) == ' '){
			stringa = stringa.substring(0,stringa.length-1);    
			}    
			return stringa;
			}
//========================================================================0
//#02-                function hidelayer(lay)                 xxxxxxxxxxxx0
//========================================================================0
// function used to show and hide layers passed as paramenters....
function hidelayer(lay) {
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
if (my_bros.ie5) {document.getElementById([lay]).style.display = "none";}
if (my_bros.ie6) {document.getElementById([lay]).style.display = "none";}
}

//========================================================================0
//#03-                function showlayer(lay)                 xxxxxxxxxxxx0
//========================================================================0
function showlayer(lay) {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
if (ie5) {document.getElementById([lay]).style.display = "block";}
if (ie6) {document.getElementById([lay]).style.display = "block";}
}

//========================================================================0
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0
//========================================================================0
//                      VALIDATION  SCRIPTS






//========================================================================0
//#04-                function Error_Style(dom_Ele)           xxxxxxxxxxxx0
//========================================================================0
  function Error_Style(dom_Ele) {
	// the variable dom_Ele must contain the DOM object name
	//document.getElementById("cella").className="errtext";
	dom_Ele.className="errtext_php";

  }
//========================================================================0
//#05-                function checkDate()                    xxxxxxxxxxxx0
//========================================================================0
// #05-
function checkDate() {
var myDayStr = document.mainForm.birth_day.value;
var myMonthStr = document.mainForm.birth_month.value;
var myYearStr = document.mainForm.birth_year.value;
var myMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 
var myDateStr = myDayStr + ' ' + myMonth[myMonthStr] + ' ' + myYearStr;

if ( myDayStr == "" || myMonthStr == "" || myYearStr == "" ) {
	alert( 'Date of birth: wrong format' );
	return;
}

/* Using form values, create a new date object
using the setFullYear function */
var myDate = new Date();
myDate.setFullYear( myYearStr, myMonthStr, myDayStr );

if ( myDate.getMonth() != myMonthStr ) {
  alert( 'I\'m sorry, but "' + myDateStr + '" is NOT a valid date.' );
} else {
  alert( 'Congratulations! "' + myDateStr + '" IS a valid date.' );
}
}

//========================================================================0
//#07-                function Validate_InsArtist(page)           xxxxxxxxxxxx0
//========================================================================0
// #07-
  function Validate_InsArtist(page) {
     // variables definition
	var artistname = document.mainForm.artistname.value;
	var description = document.mainForm.description.value;
	var homepage = document.mainForm.homepage.value;
	var channel_1 = document.mainForm.channel_1.value;
	var email = document.mainForm.email.value;
	var country = document.mainForm.country.value;
	var town = document.mainForm.town.value;
	//
	var tabdiag = document.getElementById("id_tabdiag");
	var cella1 = document.getElementById("id_cella1");
	var cella2 = document.getElementById("id_cella2");
	var msg = "";
	var submsg = "";
	var filter = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var filterEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	var filterTown = /^[a-zA-Z]+([^0-9]+)$/; //start with one or more letters
	//var filterHomepage = /^([a-zA-Z0-9]{1})+([a-zA-Z0-9\-])+([a-zA-Z0-9]{1})+$/; //low and uppercases, numbers and dashes in the middle
	var filterHomepage = /^([a-z0-9]{1})+([a-z0-9\-])+([a-z0-9]{1})+$/; //lowercases, numbers and dashes in the middle
        //------------------check the username------------------------------------
        if ((artistname == "") || (artistname == "undefined")) {
			document.getElementById("id_name").className="errlabel";
			if (msg == "") {
				document.mainForm.artistname.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Artistname</b> is required" + "</li>";
        }
        //-------------------check the description----------------------------------
        if ((description == "") || (description == "undefined")) {
			document.getElementById("id_description").className="errlabel";
			if (msg == "") {
				document.mainForm.description.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>About the artist</b> is required" + "</li>";
        }
        //-------------------check the music channel----------------------------------
        if ((channel_1 == "") || (channel_1 == "undefined") || (channel_1 == "XX")) {
			document.getElementById("id_channel").className="errlabel";
			if (msg == "") {
				document.mainForm.channel_1.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Main Music Channel</b> is required" + "</li>";
        }
        //-------------------check the home page----------------------------------
		//homepage = homepage.replace(/\s/g, ""); //strip blanks
        if ((homepage == "") || (homepage == "undefined")) {
			document.getElementById("id_homepage").className="errlabel";
			if (msg == "") {
				document.mainForm.homepage.focus();
				msg="<ul>";
			}
			msg = msg  + "<li>" + "<b>Home page</b> is required" + "</li>";
        }
		else
		{
			if (filterHomepage.test(homepage) ==false) {
				document.getElementById("id_homepage").className="errlabel";
				if (msg == "") {
					document.mainForm.homepage.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Homepage</b>: only lowcase letters, numbers and dashes in the middle" + "</li>";
			}
        }
        //-------------------check the country----------------------------------
        if ((country == "") || (country == "undefined")) {
			document.getElementById("id_country").className="errlabel";
			if (msg == "") {
				document.mainForm.country.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Country</b> is required" + "</li>";
        }

        //-------------------check the town ----------------------------------
        if ((town == "") || (town == "undefined")) {
        }
		else
		{
			if (filterTown.test(country) ==false) {
				document.getElementById("id_town").className="errlabel";
				if (msg == "") {
					document.mainForm.town.focus();
					msg="<ul>";
				}
				msg = msg  + "<li>" + "<b>Town/Location</b>: some characters are not allowed" + "</li>";
			}
        }
        //-------------------check the email ----------------------------------
		// the email is required..... 
        if ((email == "") || (email == "undefined")) {
			document.getElementById("id_email").className="errlabel";
			if (msg == "") {
				document.mainForm.email.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Email</b> is required" + "</li>";
		}else{	
			if (filterEmail.test(email)){
				// if true do nothing...
			}else{
				if (msg == "") {
					document.mainForm.email.focus();
					msg="<ul>"; //begin the Unordered List
				}
				document.getElementById("id_email").className="errlabel";
				msg = msg  + "<li>" + "<b>Email</b>: wrong format" + "</li>";
			}
        }

		//--FINAL CHECK ------------------------------------------------------------
		if (msg == "") {
			//no errors, send data...
			//document.mainForm.action = "01-insartist-do.php";
			if ((page == "") || (page == "undefined")) {
				page = 	"01-insartist-do.php";
			}
			document.mainForm.action = page;
			document.mainForm.submit();
			}
        else { 
			// errors, back to the login page...
			submsg = "Please, check the hilighted fields:" + msg + "</ul>";
			cella2.innerHTML = submsg;
			tabdiag.className="errtable";
			cella1.className="errlogo";
			cella2.className="errmsg";
			return false; 
        }
  } // end function validate_InsArtist()

//========================================================================0
//#08-                function Validate_UpdArtist()           xxxxxxxxxxxx0
//========================================================================0
// #08-
  function Validate_UpdArtist() {
	  
     // variables definition
	var description = document.mainForm.description.value;
	var homepage = document.mainForm.homepage.value;
	var channel_1 = document.mainForm.channel_1.value;
	var email = document.mainForm.email.value;
	var country = document.mainForm.country.value;

	//
	var tabdiag = document.getElementById("id_tabdiag");
	var cella1 = document.getElementById("id_cella1");
	var cella2 = document.getElementById("id_cella2");
	var msg = "";
	var submsg = "";
	//var filter="/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i";
	var filter = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var filterEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	var filterCountry = /^[a-zA-Z]+([^0-9]+)$/; //start with lowercase, then everything except numbers
	//var filterHomepage = /^([a-zA-Z0-9]{1})+([a-zA-Z0-9\-])+([a-zA-Z0-9]{1})+$/; //lowercases and uppercases, numbers and dashes in the middle
	var filterHomepage = /^([a-z0-9]{1})+([a-z0-9\-])+([a-z0-9]{1})+$/; //lowercases, numbers and dashes in the middle
//-------------------check the description----------------------------------
        if ((description == "") || (description == "undefined")) {
			document.getElementById("id_description").className="errlabel";
			if (msg == "") {
				document.mainForm.description.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>About the artist</b> is required" + "</li>";
        }
        //-------------------check the music channel----------------------------------
        if ((channel_1 == "") || (channel_1 == "undefined") || (channel_1 == "XX")) {
			//document.login.password.style.backgroundColor="#f7d05b";
			//document.mainForm.channel.className="errborder";
			document.getElementById("id_channel").className="errlabel";
			if (msg == "") {
				document.mainForm.channel_1.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Main Music Channel</b> is required" + "</li>";
        }
        //-------------------check the home page----------------------------------
		//homepage = homepage.replace(/\s/g, ""); //strip blanks
        if ((homepage == "") || (homepage == "undefined")) {
			document.getElementById("id_homepage").className="errlabel";
			if (msg == "") {
				document.mainForm.homepage.focus();
				msg="<ul>";
			}
			msg = msg  + "<li>" + "<b>Home page</b> is required" + "</li>";
        }
		else
		{
			if (filterHomepage.test(homepage) ==false) {
				document.getElementById("id_homepage").className="errlabel";
				if (msg == "") {
					document.mainForm.homepage.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Homepage</b>: only lowcase letters, numbers and dashes in the middle" + "</li>";
			}
        }
        //-------------------check the country ----------------------------------
        if ((country == "") || (country == "undefined")) {
			document.getElementById("id_country").className="errlabel";
			if (msg == "") {
				document.mainForm.country.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Country</b> is required" + "</li>";
        }
		else
		{
			//sono accettati solo caratteri alfanumerici: si usa il filter2
			if (filterCountry.test(country) ==false) {
				document.getElementById("id_country").className="errlabel";
				if (msg == "") {
					document.mainForm.country.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Country</b>: some characters are not allowed" + "</li>";
			}
        }


        //-------------------check the email ----------------------------------
		// the email is required..... 
        if ((email == "") || (email == "undefined")) {
			document.getElementById("id_email").className="errlabel";
			if (msg == "") {
				document.mainForm.email.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Email</b> is required" + "</li>";
		}else{	
			if (filterEmail.test(email)){
				// if true do nothing...
			}else{
				if (msg == "") {
					document.mainForm.email.focus();
					msg="<ul>"; //begin the Unordered List
				}
				document.getElementById("id_email").className="errlabel";
				msg = msg  + "<li>" + "<b>Email</b>: wrong format" + "</li>";
			}
        }

		//--FINAL CHECK ------------------------------------------------------------
		if (msg == "") {
			//no errors, send data...
			document.mainForm.action = "0a-updartist-do.php";
			document.mainForm.submit();
			}
        else { 
			// errors, back to the login page...
			submsg = "Please, check the hilighted fields:" + msg + "</ul>";
			cella2.innerHTML = submsg;
			tabdiag.className="errtable";
			cella1.className="errlogo";
			cella2.className="errmsg";
			return false; 
        }
  } // end function Validate_UpdArtist()


//========================================================================0
//#09-                function Validate_UpdProfile($page)     xxxxxxxxxxxx0
//========================================================================0
// #09-
  function Validate_UpdProfile($page) {
	  
     // variables definition
	var firstname = document.mainForm.firstname.value;
	var lastname = document.mainForm.lastname.value;
	var address = document.mainForm.address.value;
	var city = document.mainForm.city.value;
	var country = document.mainForm.COUNTRY.value;
	var zipcode = document.mainForm.zipcode.value;
	var gender = document.mainForm.gender.value;

	firstname=trim(firstname);
	lastname=trim(lastname);
	address=trim(address);
	city=trim(city);
	zipcode=trim(zipcode);

	var myDayStr = document.mainForm.birth_day.value;
	var myMonthStr = document.mainForm.birth_month.value - 1; //setFullYear uses months = 0-11
	var myYearStr = document.mainForm.birth_year.value;
	var myMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 
	var myDateStr = "";

	//
	var tabdiag = document.getElementById("id_tabdiag");
	var cella1 = document.getElementById("id_cella1");
	var cella2 = document.getElementById("id_cella2");
	var msg = "";
	var submsg = "";
	var filter = /^[a-zA-Z\s\-\é\è\ò\à\ù\xa0]+$/; //letters, blanks, dashes

        //-------------------check the firstname----------------------------------
        if ((firstname == "") || (firstname == "undefined")) {
			document.getElementById("id_firstname").className="errlabel";
			if (msg == "") {
				document.mainForm.firstname.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Name</b> is required" + "</li>";
        }
		else
		{
			if (filter.test(firstname) ==false) {
				document.getElementById("id_firstname").className="errlabel";
				if (msg == "") {
					document.mainForm.firstname.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "il <b>Name</b>: some characters are not allowed" + "</li>";
			}
        }
		
		
        //-------------------check the lastname----------------------------------
        if ((lastname == "") || (lastname == "undefined")) {
			document.getElementById("id_lastname").className="errlabel";
			if (msg == "") {
				document.mainForm.lastname.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Surname</b> is required" + "</li>";
        }
		else
		{
			if (filter.test(lastname) ==false) {
				document.getElementById("id_lastname").className="errlabel";
				if (msg == "") {
					document.mainForm.lastname.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "il <b>Surname</b>: some characters are not allowed" + "</li>";
			}
        }
		
        //-------------------check the address----------------------------------
		/*
        if ((address == "") || (address == "undefined")) {
			document.getElementById("id_address").className="errlabel";
			if (msg == "") {
				document.mainForm.address.focus();
				msg="<ul>";
			}
			msg = msg  + "<li>" + "<b>Address</b> is required" + "</li>";
        }
		*/
        //-------------------check the city only if present  -------------------
		if ((city != "") && (city != "undefined")) {
			//only alphabetical
			if (filter.test(city) ==false) {
				document.getElementById("id_city").className="errlabel";
				if (msg == "") {
					document.mainForm.city.focus();
					msg="<ul>";
				}
				msg = msg  + "<li>" + "il <b>Town/Location</b>: some characters are not allowed" + "</li>";
			}
        }
		
        //-------------------check the country----------------------------------
        if ((country == "") || (country == "undefined")) {
			document.getElementById("id_country").className="errlabel";
			if (msg == "") {
				document.mainForm.COUNTRY.focus();
				msg="<ul>";
			}
			msg = msg  + "<li>" + "<b>Country</b> is required" + "</li>";
        }

        //-------------------check the zipcode----------------------------------
		/*
        if ((zipcode == "") || (zipcode == "undefined")) {
			document.getElementById("id_zipcode").className="errlabel";
			if (msg == "") {
				document.mainForm.zipcode.focus();
				msg="<ul>";
			}
			msg = msg  + "<li>" + "<b>Zip code</b> is required" + "</li>";
        }
		*/
        //-------------------check the gender----------------------------------
		/*
        if ((gender == "") || (gender == "undefined")) {
			document.getElementById("id_gender").className="errlabel";
			if (msg == "") {
				document.mainForm.gender.focus();
				msg="<ul>";
			}
			msg = msg  + "<li>" + "<b>Gender</b> is required" + "</li>";
        }
		*/
        //-------------------check the date----------------------------------
		if ( myDayStr == "" || (myMonthStr +1) == "" || myYearStr == "" ) {
			document.getElementById("id_birthdate").className="errlabel";
			if (msg == "") {
				document.mainForm.birth_day.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Date of birth</b>: wrong format" + "</li>";
		}
		
		if ( myDayStr != "" && myMonthStr != "" && myYearStr != "" )
  		{ //doing the test if only mm,dd,yyyy are all defined
		/* Using form values, create a new date object
		using the setFullYear function */
		var myDate = new Date();
		myDate.setFullYear( myYearStr, myMonthStr, myDayStr );
			if ( myDate.getMonth() != myMonthStr ) {
			  //alert( 'I\'m sorry, but "' + myDateStr + '" is NOT a valid date.' );
				document.getElementById("id_birthdate").className="errlabel";
				if (msg == "") {
					document.mainForm.birth_day.focus();
					msg="<ul>"; //begin the Unordered List
				}
				myDateStr = myDayStr + ' ' + myMonth[myMonthStr] + ' ' + myYearStr;
				msg = msg  + "<li>" + myDateStr + ":&nbsp;wrong date" + "</li>";
			} 
		}
		
		//--ONLY FOR THE REGISTRATION PROCESS---------------------------------------
		if ( $page == "0a-personalinfocheck.php") {
				if ( document.mainForm.agree.checked == false ) {
					//document.getElementById("id_agree").className="errlabel";
					if (msg == "") {
						document.mainForm.agree.focus();
						msg="<ul>"; //begin the Unordered List
					}
					msg = msg  + "<li>" + "Approval of <b>General conditions</b> is required" + "</li>";
				}
		}
		


		//--FINAL CHECK ------------------------------------------------------------
		if (msg == "") {
			//no errors, send data...
			document.mainForm.action = $page;
			//document.mainForm.action = "0a-profileupdate.php";
			document.mainForm.submit();
			}
        else { 
			// errors, back to the calling page...
			submsg = "Please, check the hilighted fields:" + msg + "</ul>";
			cella2.innerHTML = submsg;
			tabdiag.className="errtable";
			cella1.className="errlogo";
			cella2.className="errmsg";
			return false; 
        }
  } // end function Validate_UpdProfile($page)




//========================================================================0
//#10-                function contatore(val)         xxxxxxxxxxxxxxxxxxxx0
//========================================================================0
// #10- 
function contatore(val)
{
  var max = 10000;
  if (val.description.value.length > max) {
    val.description.value = val.description.value.substring(0,max)
    rest = 0
  } 
  else
  {
    rest = max - val.description.value.length
  }
  val.num.value = rest
}

//========================================================================0
//#11-                function Validate_Register()           xxxxxxxxxxxx0
//========================================================================0
// #11-
  function Validate_Register(next_page) {
	  
     // variables definition
	var username = document.mainForm.username.value;
	var email = document.mainForm.email.value;
	var password = document.mainForm.password.value;
	var password_conf = document.mainForm.password_conf.value;

	//
	var tabdiag = document.getElementById("id_tabdiag");
	var cella1 = document.getElementById("id_cella1");
	var cella2 = document.getElementById("id_cella2");
	var msg = "";
	var submsg = "";
	//var filter="/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i";
	var filterEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	var filterLogin = /^[a-zA-Z0-9]+$/; //only letters and numbers
	var filterLogin2 = /^[a-zA-Z0-9]+([a-zA-Z0-9\_\-]+)$/; //start with one or more letters, then alphanum., dash, undersc.

		//-------------------check the username----------------------------------
        if ((username == "") || (username == "undefined")) {
			document.getElementById("id_username").className="errlabel";
			if (msg == "") {
				document.mainForm.username.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Username</b> is required" + "</li>";
        }
		else
		{
			//
			if (filterLogin2.test(username) ==false) {
				document.getElementById("id_username").className="errlabel";
				if (msg == "") {
					document.mainForm.username.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Username</b>: wrong format" + "</li>";
			}
        }
		//check on username length
        if (username.length > 0)  {
			if (username.length < 3 || username.length > 15)  {
					document.getElementById("id_username").className="errlabel";
					if (msg == "") {
						document.mainForm.username.focus();
						msg="<ul>"; //begin the Unordered List
					}
					msg = msg  + "<li>" + "<b>Username</b>: between 3 and 15 characters long" + "</li>";
			}
        }
        //-------------------check the email ----------------------------------
		// the email is required..... 
        if ((email == "") || (email == "undefined")) {
			document.getElementById("id_email").className="errlabel";
			if (msg == "") {
				document.mainForm.email.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Email</b> is required" + "</li>";
		}
		else
		{	
			if (filterEmail.test(email))
				{
				// if true do nothing...
				}
				else
				{
				if (msg == "") {
					document.mainForm.email.focus();
					msg="<ul>"; //begin the Unordered List
					}
				document.getElementById("id_email").className="errlabel";
				msg = msg  + "<li>" + "<b>Email</b>: wrong format" + "</li>";
				}
        }


		//-------------------------------------------------------------------------
        //check the password
		if ((password == "") || (password == "undefined")) {
			document.getElementById("id_password").className="errlabel";
			if (msg == "") {
				document.mainForm.password.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Password</b> is required" + "</li>";
        }
		else
		{
			if (filterLogin.test(password) ==false) {
				document.getElementById("id_password").className="errlabel";
				if (msg == "") {
					document.mainForm.password.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Password</b>: wrong format" + "</li>";
			}
        }
		//check on password length
        if (password.length > 0)  {
			if (password.length < 6 || password.length > 20)  {
					document.getElementById("id_password").className="errlabel";
					if (msg == "") {
						document.mainForm.password.focus();
						msg="<ul>"; //begin the Unordered List
					}
					msg = msg  + "<li>" + "<b>Password</b>: between 6 and 20 characters long" + "</li>";
			}
        }
        //-------------------check the password_conf----------------------------------
        if ((password_conf == "") || (password == "password_conf")) {
			document.getElementById("id_password_conf").className="errlabel";
			if (msg == "") {
				document.mainForm.password_conf.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Confirm Password</b> is required" + "</li>";
        }

        //-------------------check the password = password_conf --------------------
        if (  (password !== "") && (password !== "undefined") &&
			(password_conf !== "") && (password_conf !== "undefined")  ) {
			if (password !== password_conf) {
				document.getElementById("id_password_conf").className="errlabel";
				if (msg == "") {
					document.mainForm.password_conf.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Confirm Password</b> must be the same of <b>Password</b>" + "</li>";
			}
        }
		
		//--FINAL CHECK ------------------------------------------------------------
		if (msg == "") {
			//no errors, send data...
			document.mainForm.action = next_page;
			document.mainForm.submit();
			}
        else { 
			// errors, back to the login page...
			submsg = "Please, check the hilighted fields:" + msg + "</ul>";
			cella2.innerHTML = submsg;
			tabdiag.className="errtable";
			cella1.className="errlogo";
			cella2.className="errmsg";
			return false; 
        }
  } // end function Validate_Register()
//========================================================================0
//#12-                function Validate_Sendpa()           xxxxxxxxxxxx0
//========================================================================0
// #12-
  function Validate_Sendpa() {
	  
     // variables definition
	var email = document.mainForm.email.value;

	//
	var tabdiag = document.getElementById("id_tabdiag");
	var cella1 = document.getElementById("id_cella1");
	var cella2 = document.getElementById("id_cella2");
	var msg = "";
	var submsg = "";
	var filterEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
        //-------------------check the email ----------------------------------
		// the email is required..... 
        if ((email == "") || (email == "undefined")) {
			document.getElementById("id_email").className="errlabel";
			if (msg == "") {
				document.mainForm.email.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Email</b> is required" + "</li>";
		}
		else
		{	
			if (filterEmail.test(email))
				{
				// if true do nothing...
				}
				else
				{
				if (msg == "") {
					document.mainForm.email.focus();
					msg="<ul>"; //begin the Unordered List
					}
				document.getElementById("id_email").className="errlabel";
				msg = msg  + "<li>" + "<b>Email</b>: wrong format" + "</li>";
				}
        }

		//--FINAL CHECK ------------------------------------------------------------
		if (msg == "") {
			//no errors, send data...
			document.mainForm.action = "01-sendpa_do.php";
			document.mainForm.submit();
			}
        else { 
			// errors, back to the login page...
			submsg = "Please, check the hilighted fields:" + msg + "</ul>";
			cella2.innerHTML = submsg;
			tabdiag.className="errtable";
			cella1.className="errlogo";
			cella2.className="errmsg";
			return false; 
        }
  } // end function Validate_Register()
//========================================================================0
//#14-                function Validate_NewPassword()           xxxxxxxxxxxx0
//========================================================================0
// #14- 
  function Validate_NewPassword() {
	  
     // variables definition
	var old_password = document.mainForm.old_password.value;
	var password = document.mainForm.password.value;
	var password_conf = document.mainForm.password_conf.value;

	//
	var tabdiag = document.getElementById("id_tabdiag");
	var cella1 = document.getElementById("id_cella1");
	var cella2 = document.getElementById("id_cella2");
	var msg = "";
	var submsg = "";
	

		//-------------------------------------------------------------------------
        //check the old password
		if ((old_password == "") || (old_password == "undefined")) {
			document.getElementById("id_old_password").className="errlabel";
			if (msg == "") {
				document.mainForm.old_password.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Current Password</b> is required" + "</li>";
        }
		//-------------------------------------------------------------------------
        //check the new password
		if ((password == "") || (password == "undefined")) {
			document.getElementById("id_password").className="errlabel";
			if (msg == "") {
				document.mainForm.password.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>New Password</b> is required" + "</li>";
        }
		//check on password length
        if (password.length > 0)  {
			if (password.length < 6 || password.length > 20)  {
					document.getElementById("id_password").className="errlabel";
					if (msg == "") {
						document.mainForm.password.focus();
						msg="<ul>"; //begin the Unordered List
					}
					msg = msg  + "<li>" + "<b>New Password</b>: between 6 and 20 characters long" + "</li>";
			}
        }
        //-------------------check the password_conf----------------------------------
        if ((password_conf == "") || (password == "password_conf")) {
			document.getElementById("id_password_conf").className="errlabel";
			if (msg == "") {
				document.mainForm.password_conf.focus();
				msg="<ul>"; //begin the Unordered List
			}
			msg = msg  + "<li>" + "<b>Confirm New Password</b> is required" + "</li>";
        }

        //-------------------check the password = password_conf --------------------
        if (  (password !== "") && (password !== "undefined") &&
			(password_conf !== "") && (password_conf !== "undefined")  ) {
			if (password !== password_conf) {
				document.getElementById("id_password_conf").className="errlabel";
				if (msg == "") {
					document.mainForm.password_conf.focus();
					msg="<ul>"; //begin the Unordered List
				}
				msg = msg  + "<li>" + "<b>Confirm New Password</b> must be the same of <b>Password</b>" + "</li>";
			}
        }
		
		//--FINAL CHECK ------------------------------------------------------------
		if (msg == "") {
			//no errors, send data...
			document.mainForm.action = "01-gespa_do.php";
			document.mainForm.submit();
			}
        else { 
			// errors, back to the login page...
			submsg = "Please, check the hilighted fields:" + msg + "</ul>";
			cella2.innerHTML = submsg;
			tabdiag.className="errtable";
			cella1.className="errlogo";
			cella2.className="errmsg";
			return false; 
        }
  } // end function Validate_Register()
  
//========================================================================0
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0
//========================================================================0



