function validateEmail( strValue) {
	var objRegExp  = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[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 objRegExp.test(strValue);
}

function validateCF(cfins)	{
  var cf = cfins.toUpperCase();
  var cfReg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
  if (!cfReg.test(cf))
    return false;
  var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
  var s = 0;
  for( i = 1; i <= 13; i += 2 )
    s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
  for( i = 0; i <= 14; i += 2 )
    s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
  if ( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
    return false;
  return true;
}


function validatePIVA(sz_Codice)	{
  var n_Val,n_Som1=0,n_Som2=0,lcv;
  if (sz_Codice.length!=11 || isNaN(parseFloat(sz_Codice)) || parseFloat(sz_Codice)<parseFloat(0))
    return false;
  /*
  for (lcv=0;lcv<9;lcv+=2)
  {
    n_Val=parseInt(sz_Codice.charAt(lcv));
    n_Som1+=n_Val;
    n_Val=parseInt(sz_Codice.charAt(lcv+1));
    n_Som1+=Math.floor(n_Val/5) + (n_Val<<1) % 10;
  }
  n_Som2 = 10 - (n_Som1 % 10);
  n_Val=parseInt(sz_Codice.charAt(10));
  if (n_Som2==n_Val)
    return true;
  return false;
  */
  return true;
}

function validateUrl(sUrl) {
	var re = /^http:\/\/./;
	return re.test(sUrl)
}


// Compare two options within a list by VALUES
function compareOptionValues(a, b) {
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.value, 36 );
  var sB = parseInt( b.value, 36 );
  return sA - sB;
}

// Compare two options within a list by TEXT
function compareOptionText(a, b) {
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.text, 36 );
  var sB = parseInt( b.text, 36 );
  return sA - sB;
}

// Dual list move function
function moveDualList( srcList, destList, moveAll ) {
  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )	{
    return;
  }
  newDestList = new Array( destList.options.length );
  var len = 0;
  for( len = 0; len < destList.options.length; len++ ) {
    if ( destList.options[ len ] != null ) {
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
    }
  }
  for( var i = 0; i < srcList.options.length; i++ ) { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
       // Statements to perform if option is selected
       // Incorporate into new list
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       len++;
    }
  }

  //Sort out the new destination list
  //newDestList.sort( compareOptionValues );   // BY VALUES
  //newDestList.sort( compareOptionText );   // BY TEXT

  // Populate the destination with the items from the new array
  for ( var j = 0; j < newDestList.length; j++ ) {
    if (newDestList[ j ] != null ) {
      destList.options[ j ] = newDestList[ j ];
    }
  }
  // Erase source list selected elements
  for( var i = srcList.options.length - 1; i >= 0; i-- ) { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
       // Erase Source
       //srcList.options[i].value = "";
       //srcList.options[i].text  = "";
       srcList.options[i] = null;
    }
  }
} // End of moveDualList()


function MM_verifyDate(str) {
	//var str = data;
	var format=0;
	var month=0;
	var day=0;
	var year=0;
	var err=false;
	if(str.length!=10)
		err=true;

	if(str.length==10)
		{
		// dd/mm/yyyy format
		if(str.charAt(2) == "/" && str.charAt(5) == "/" && str.length == 10)
				{
				format=1;
				// Check that day is a number.
				for (var i = 0; i < 2; i++) 
					{ var ch = str.substring(i, i + 1); if(ch < "0" || "9" < ch) err=true; }
				// Check that month is a number.
				for (var i = 3; i < 5; i++) 
					{ var ch = str.substring(i, i + 1); if(ch < "0" || "9" < ch) err=true; }
				// Check that year is a number.
				for (var i = 6; i < 10; i++) 
					{ var ch = str.substring(i, i + 1); if(ch < "0" || "9" < ch) err=true; }
				// Set variables
				if(err==
						false){day=eval(str.substring(0,2));month=eval(str.substring(3,5));  year=eval(str.substring(6,str.length)); }
				}


		// Incorrect format.
		if(format !=1)
				var err=true;
		}

		// Check that month is between 1 &12.
		if(month<=0 || month>=13)
		  err=true;

		// Check that day is right depending on month.
		if( month==2 && ((year/4)==parseInt(year/4)) )
		  { if(day<=0 || day>29) err=true; }
		if( month==2 && ((year/4)!=parseInt(year/4)) )
		  { if(day<=0 || day>28) err=true; }
		if( month==4 || month==6 || month==9 || month==11 )
		  { if(day<=0 || day>30) err=true; }
		if( month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12 )
		  { if(day<=0 || day>31) err=true; }


		// If anything appears incorrect, display error message.
		if(err==true)
		  {
		//  alert("Inserire la data nel formato gg/mm/aaaa");
			
		  return false;
		  }

		// If all is OK, return true.
		return true;

	}			
