/***************************************************** filename: jquery.login.js description: contains needed functions to display login dialog and submit login form created by: kailer last modified by: kailer *****************************************************/ // login // login functions $(function(){ var usuario = $("#login_usuario"), clave = $("#login_clave"); function checkLength(o,n,min,max) { if ( o.val().length > max || o.val().length < min ) { $("#dialog4").dialog('open'); return false; } else { return true; } } $("#dialog_login_tb").click(function(){ $("#dialog3").dialog('open'); return false; }); $(".login_button").click(function(){ $("#dialog3").dialog('open'); return false; }); $("#dialog3").dialog({ bgiframe: true, autoOpen: false, open: function(){ $(".ui-widget-header").css("background","url(http://download01.regnumonlinegame.com/images/english/headers/login_header.png)"); $(this).css("visibility", "visible"); $('#login_usuario').focus() }, close: function(){ $(this).css("visibility", "hidden"); $("#loginForm").each(function(){this.reset();}); }, height: 195, width: 250, resizable: false, shadow: false, modal: true, buttons: { 'Login': function() { var bValid = true; bValid = bValid && checkLength(usuario,"username",2,20); bValid = bValid && checkLength(clave,"password",4,30); if (bValid) { $("#loginForm").submit(); $("#dialog3").html("

Logging in...
"); } }, 'Cancel': function() { $(this).dialog('close'); } } }); $("#dialog4").dialog({ bgiframe: true, autoOpen: false, open: function(){ $(this).css("visibility", "visible"); $('#login_usuario').focus() }, close: function() {$(this).css("visibility", "hidden")}, height: 195, width: 250, resizable: false, shadow: false, modal: false, buttons: { 'OK': function() { $(this).dialog('close'); $('#login_usuario').focus(); } } }); $("#login_error").dialog({ bgiframe: true, autoOpen: false, open: function(){ $(this).css("visibility", "visible") }, close: function() {$(this).css("visibility", "hidden")}, height: 195, width: 250, resizable: false, shadow: false, modal: true, buttons: { 'Go back': function() { $(this).dialog('close'); $("#dialog3").dialog('open'); }, 'Cancel': function() { $(this).dialog('close'); } } }); });