
	var iedom=document.all||document.getElementById;

	function checkMail( str )
	{
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		
		str = str.toLowerCase();
		
		if (!filter.test(str)) 
			return false;
		else
			return true;
	} // function checkMail( str )

	function checkInputMail( obj )
	{
		var str = document.getElementById( obj.id ).value;
		str = str.toLowerCase();
		if ( checkMail( str ) === true )
		{
			document.getElementById( obj.id ).value = str;
			goodInput( obj );
		} else {
			alert("L'indirizzo e-mail inserito non e' corretto.");
			badInput( obj );
			objID = obj.id;
			document.getElementById( objID ).value='';
		}
	} // function checkInputMail( obj )
	
	function checkPassword( obj )
	{
		if ( ( typeof obj ) == "object" )
		{
			var str = document.getElementById( obj.id ).value;
			if ( checkPassword( str ) == true )
			{
				goodInput( obj );
			} else {
				alert("la password inserita non e' valida");
				badInput( obj );
			}
		} else {
			if ( obj.length < 6 )
			{
				return false;
			} else {
				return true;
			}
		}
	} // function checkPassword( str )

	function serializeData( obj )
	{
		var data = document.getElementById( obj.id  ).value;
		var A = data.split("/");
		A[1]--;
		var c = new Date( A[2], A[1], A[0] );
		d = c.getDate(); 		if ( d < 10 ) d = '0' + d;
		m = c.getMonth(); m++;	if ( m < 10 ) m = '0' + m;
		Y = c.getFullYear();
		document.getElementById( obj.id  ).value = d +'/'+ ( m ) +'/'+ Y;
	}

	function checkDate( obj )
	{
		var ok = false;

		var data = document.getElementById( obj.id ).value;
		
		// se la lunghezza della data è compresa tra 6 e i 10 caratteri
		if ( 6 <= data.length <= 10 && data.indexOf("/") )
		{
			
			var A = data.split( "/" );

			if ( A.length == 3 )
			{
				
				d = parseInt( A[0], 10 ); 
				m = parseInt( A[1], 10 );
				Y = parseInt( A[2], 10 );
				
				if (
						(
							m == 1	// gennaio
							||
							m == 3	// marzo
							||
							m == 5	// maggio
							||
							m == 7	// luglio
							||
							m == 8	// agosto
							||
							m == 10	// ottobre
							||
							m == 12	// dicembre
						)
						&&
						d <= 31		// i giorni sono meno di 31
					) 
				{
					ok = true;
				}
				
				if ( 
						(
							m == 11	// novembre
							||
							m == 4	// aprile
							||
							m == 6	// giugno
							||
							m == 9	// settembre
						)
						&& 
						d <= 30 	// i giorni sono meno di 30
					)
				{
					ok = true;
				}
				
				if (
					m == 2		// febbraio
					&&
					(
						d <= 28	// i giorni sono meno di 28
						&&
						( 
							parseInt( Y / 4, 10 ) != ( Y / 4 ) ) // anno non bisestile
						) || (
						d <= 29	// i giorni sono meno di 29
						&&
						( 
							parseInt( Y / 4, 10 ) == ( Y / 4 ) ) // anno bisestile
						)
					)
				{
					ok = true;
				}
			
			} // ( A.length == 3 )
			
		} // ( 6 <= data.length <= 10 && data.indexOf("/") )
		
		if ( ok == true )
		{
			serializeData( obj );
			goodInput( obj );
		} else {
			alert( "La data inserita non e' corretta! ");
			badInput( obj );
			document.getElementById( obj.id ).focus();
		}
	}

	function badInput( obj )
	{
		document.getElementById( obj.id ).style.borderWidth="3px";
		document.getElementById( obj.id ).style.borderStyle="dashed";
		document.getElementById( obj.id ).style.borderColor="#C00";
		document.getElementById( obj.id ).style.backgroundColor="#FFF";
		document.getElementById( obj.id ).value = '';
	}

	function goodInput( obj )
	{
		document.getElementById( obj.id ).style.borderWidth="1px";
		document.getElementById( obj.id ).style.borderStyle="solid";
		document.getElementById( obj.id ).style.borderColor="#0C0";
		document.getElementById( obj.id ).style.backgroundColor="transparent";
	}

