function esegui_submit ( ) { 
  // INIT
  var us   = $('#dbuser').val();
  var pw   = $('#dbpwd').val();
  var er   = $('#errind').val();
  var form = $('#form_login');
  var url  = "";
  var dom_host = window.location.hostname;
  var toploc = window.top.location;
  //var errind = "&noauth=1";
  /*if (window.top.location.match("noauth=1")) { 
	errind = "";
  } else {
	errind = "&noauth=1";
  }*/
  //toploc.= errind;
  //alert (toploc);

  //alert (dom_host);
  //alert (toploc);
  // VALUTAZIONE CREDENZIALI NON VUOTE
  if ( us == "" || pw == "" ) { return false; }
  
  // VALUTAZIONE ED IMPOSTAZIONE TARGET FORM
  $.ajax({
    url: "http://"+dom_host+"/servizi/valutazione_tipo_utente.php",
    dataType: 'json',
    async: false,
    data: { user: us, pass: pw },
    success: function ( tipo ) { 
      // alert ( tipo );
      switch ( tipo ) {
        case "CLIENT" : url = "http://www.masteritalia.it/clienti/"; break;
        case "SOTCLI" : url = "http://www.atlantis-caps.com/magazzino/magazzino_new/"; break;
        default       : url = toploc+er;
						form.attr ( 'target', '_self' )				
						break;
      }
    }
  });

  // alert ( "url"+url );
  // VALUTA URL
  if ( url == "" ) { window.location.search = "noauth=1"; return false; }
        
  // ASSEGNA TARGET
  form.attr ( 'action', url ); 
  return true;
  
};

