function controllaData( _value ) {
  var g = "";
  var m = "";
  var a = "";

  var count = 0;
  var start = 0;
  var pos = _value.indexOf( "/", start );
  while ( pos > 0 ) {
    if ( count == 0 )
      g = _value.substring( start, pos );

    if ( count == 1 )
      m = _value.substring( start, pos );

    if ( count > 1 )
      return false;

    start = pos;
    start ++;
    count ++;
    pos = _value.indexOf( "/", start );
  }
  a = _value.substring( start, _value.length );
 
  if ( g.length > 2 )
    return false;
  else {
    if ( g.length == 1 )
      //g = "0" + g;
	  return false;
  }

  if ( m.length > 2 )
    return false;
  else {
    if ( m.length == 1 )
     // m = "0" + m;
	 return false;
  }
 
  if ( a.length > 4 || a.length < 2 || a.length == 3 )
    return false;
  else {
    if ( a.length == 2 ) {
		return false;
     /* if ( a > 50 )
        a = "19" + a;
      else
        a = "20" + a;*/
    }
  }

  bIsLeap = false;
  if ( a % 4 == 0 )
    bIsLeap = true;

  //Controllo il mese
  if ( m < 1 || m > 12 )
    return false;

  //Controllo il giorno
  if ( g < 1 || g > 31 )
    return false;

  switch ( m ) {
    case "04":
    case "06":
    case "09":
    case "11": {
      if ( g > 30 )
        return false;
      break;
    }
    case "02": {
      if ( bIsLeap == true ) {
       if ( g > 29 )
        return false;
      }
      else {
        if ( g > 28 )
          return false;
      }
      break;
    }
  }

  return true;
}

function isObbligatorio(campo){	
	for(x=0;x<campiobbl.length;x++){
		if(campiobbl[x]==campo){
			return true;
		}
	}
	return false;
}

function controllo(form){
	var elem=form.elements;
	for(i=0;i<elem.length;i++){
		if(isObbligatorio(elem[i].name) && (elem[i].value=="" || elem[i].value==" ")){
			alert("Inserisci il campo: "+elem[i].id);
			elem[i].focus();
			return false;
		}
	}
	return true;
}
function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Puoi inserire solo numeri!");
        return false;
    }
    return true;
}
function controlloEmail(emailAddress) { 
	if (emailAddress.indexOf ('@',0) == -1 || emailAddress.indexOf ('.',0) == -1) { 
		alert("\nL' E-mail deve contenere un indirizzo reale") 
		return false; 
	} 
	return true; 	 
} 
function apri(){
	window.open('montoroinvolo.htm','Evento','width=530, height=500 , location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
}
