// controlli locali 
//
var NN4=(document.layers);
var IE4=(document.all);
//...................... controllo che il campo non sia vuoto
function isblank(s)
   {
    for(var i = 0; i < s.value.length; i++)
     {
        var c = s.value.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
     }
        return true;
    }
//...................... controllo che il campo contenga  '@'
function isNoMail(s)
   {
    for(var i = 0; i < s.value.length; i++)
     {
        var c = s.value.charAt(i);
        if (c == '@') return false;
     }
        return true;
    }
//...................... controllo che siano solo numeri
function isNotNumeric(s,flag_obblig)
{
   	var a;
   	do 	{
   		a = s.value.indexOf(" ",0);
   		if (a !=-1)
   			s.value = s.value.substring(0,a) + s.value.substring(a+1,s.value.length);
   	} while (a != -1);
   
   if (s.value.length == 0 && flag_obblig==true)
   		return true;
   	   
   for(var i = 0; i < s.value.length; i++)
	{
        var c = s.value.charCodeAt(i);
        var b = s.value.charAt(i);

        if (b == ' ')
         	return true
		 else
                if (c != 44) { 
        	if ((c < 48)||(c > 57)) return true;}
	}
    return false;
}

function show_error(allErr)
 {
   var msg =  "_____________________________________________________________\n\n";
   msg += "Il modulo non è stato accettato a causa di errori.\n";
   msg += "Si prega di correggere e rieseguire.\n";
   msg += "_____________________________________________________________\n\n";
 
   msg += "The form was not submitted because of the following error(s).\n";
   msg += "Please correct these error(s) and resubmit.\n";
   msg += "_____________________________________________________________\n\n";
   msg += allErr;
   alert(msg); 
   }


//controllo data a partire dai numeri di anno,mese,giorno
function check_data(anno,mese,giorno) {

  var ritorno;

  anno = parseInt(anno);
  //mese = parseInt(mese);
  giorno = giorno;

  if (giorno==0) return false;

  ritorno = true;



  switch (mese){
     case '00':
           ritorno=false;	
     case '01':
     case '03':
     case '05':
     case '07':
     case '08':
     case '10':
     case '12':
          if (giorno>31){
            ritorno = false;
          }
          break;
     case '04':
     case '06':
     case '09':
     case '11':
          if (giorno>30){
            ritorno = false;
          } 
          break;
     case '02':
        if ((anno/4) == Math.floor(anno/4)) {
          if (giorno>29){
            ritorno = false;
          }
        }
        else { 
          if (parseInt(giorno)>28){
            ritorno = false;
          }
        }
  }

  return ritorno;
}
// da data gg/mm/aaaa a data aaaammgg
function getDataAMG(aData)
 {  
   	var gg = aData.substring(0,2);
   	var mm = aData.substring(3,5);
   	var aa = aData.substring(6,10);
    return (aa *10000) + (mm *100) + (gg * 1);
 }


function azioneBlur(aField)
 {  
   	aField.className='edit_nosel';
 }

function azioneFocus(aField)
 {
	aField.className='edit_sel';
	aField.select();
}

