// controlli locali 
//
var NN4=(document.layers);
var IE4=(document.all);
function nameOf()
   {
    alert("controlli locali");
    }
//...................... 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 verifMail(s)
{
  if(isblank(s)) return true;
  var mail  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (mail.test(s.value)) 
     return true;
  return false;
}
//...................... 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 < 48)||(c > 57)) return true;
	}
    return false;
}

function show_error(allErr)
 {
   alert(allErr); 
   }

//controllo data a partire dai numeri di anno,mese,giorno
function check_data(anno,mese,giorno) {

  var ritorno;

  anno = parseInt(anno);
  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;
}
/*** controllo su keypress **/
function numericPositive(e) { return  validateKeyPress(e, '0123456789');}
function validateKeyPress(e, validSet) 
{ 
    var key; 
    var keychar; 
    if(window.event || !e.which) // IE 
        key = e.keyCode; // IE 
    else if(e)  
        key = e.which;   // Netscape 
    else 
        return true;     // no validation 
    keychar = String.fromCharCode(key); 
    validSet += String.fromCharCode(8); 
    if (validSet.indexOf(keychar) < 0) 
      return false; 
    return true;  
} 
/** azione illumina campo **/
function azioneBlur(aField) {aField.className ="edit_nosel"; }
function azioneFocus(aField){aField.className ="edit_sel";aField.select();}

