$(document).ready(function(){

 
   $(".error").hide();
      var options = {
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        url:       "php/engine.php",// override for form's 'action' attribute
        type:      'post'        // 'get' or 'post', override for form's 'method' attribute
    }
    // bind form using 'ajaxForm'
    $('#loginGenerale').ajaxForm(options);
// pre-submit callback
function showRequest(formData, jqForm, options) {
 var form = jqForm[0];
    if($("#edit-name").val()==""){
      $("#edit-name").val("OBBLIGATORIO");
      $("#edit-name").focus();
      return false;
    }
    if($("#edit-pass").val()==""){
      $('#edit-pass').get(0).type='text';
      $("#edit-pass").val("OBBLIGATORIO");
      $("#edit-pass").focus();
      return false;
    }
    
    return true;
}
// post-submit callback
function showResponse(responseText, statusText)  {
    if(responseText==0){
     jAlert("Credenziali di accesso non valide , i dati inseriti in questo form per motivi di sicurezza saranno registrati nel nostro database e saranno trattati in base alla normativa sulla privacy 196/2003", "Maia cms confirmation");
    }else if(responseText==1){
     document.location.href="http://www.emycosmetic.com/azienda-Area_Clienti-2-35";
    }
}


var options2 = {
        beforeSubmit:  showRequest2,  // pre-submit callback
        success:       showResponse2,  // post-submit callback
        url:       "php/engine.php",// override for form's 'action' attribute
        type:      'post'        // 'get' or 'post', override for form's 'method' attribute
    }
    $('#reg_form').ajaxForm(options2);
function showRequest2(formData, jqForm, options) {
 var form = jqForm[0];
    if($("#edit-name2").val()==""){
      $("#edit-name2").val("OBBLIGATORIO");
      $("#edit-name2").focus();
      return false;
    }
    if($("#edit-name3").val()==""){
      $("#edit-name3").val("OBBLIGATORIO");
      $("#edit-name3").focus();
      return false;
    }
    if($("#edit-pass2").val()==""){
      $("#edit-pass2").val("OBBLIGATORIO");
      $("#edit-pass2").focus();
      return false;
    }

    return true;
}
// post-submit callback
function showResponse2(responseText, statusText)  {
    if(responseText==0){
     jAlert("Ops ! Qualcosa è andato male contatta l'amministratore del sistema per avere maggiori informazioni ", "Maia cms confirmation");
    }else{
     jAlert(responseText, "Maia cms confirmation");
    }
}

    });
