/*******************************************************************************
 * usernamePasswordChecker
 *
 * @author Leo de Carvalho
 * @translation Facyla 2010 (1 string : "Checking...")
 ******************************************************************************/
function usernameChecker(verifyUserDisponibilityFile, messageExists, messageMinChar, messageAvailable) {
  //remove all the class add the messagebox classes and start fading
  $('input[name=username]').before('<span id="msgbox" style="display:none"></span>');
  $("#msgbox").removeClass().addClass('messagebox').text('Vérification...').fadeIn("slow");
  //check the username exists or not from ajax
  $.post(verifyUserDisponibilityFile,{ username:$('input[name=username]').val() } ,function(data) {
    //if username not available
    if(data=='no') {
      //start fading the messagebox
      $("#msgbox").fadeTo(200,0.1,function() {
        //add message and change the class of the box and start fading
        $(this).html(messageExists).addClass('messageboxerror').fadeTo(900,1);
      });
    } else if (data == 'error') {
      //start fading the messagebox
      $("#msgbox").fadeTo(200,0.1,function() {
        //add message and change the class of the box and start fading
        $(this).html(messageMinChar).addClass('messageboxerror').fadeTo(900,1);
      });
    } else {
      $("#msgbox").fadeTo(200,0.1,function() {
      //start fading the messagebox
        //add message and change the class of the box and start fading
        $(this).html(messageAvailable).addClass('messageboxok').fadeTo(900,1);
      });
    }
  });
}
