function verifyLogin() {
    if(document.getElementById('username').value.length < 5) {
        $('#error-box').html('<p><strong>Something went wrong!</strong> Username must be at least 5 characters long.');
        return false    ;
    }
    if(document.getElementById('password').value.length < 5) {
        $('#error-box').html('<p><strong>Something went wrong!</strong> Password must be at least 5 characters long.');
        return false    ;
    }

    $.post('/ajax/check_login.php?rnd=' + Math.random(), $('#login-form').serialize(), function(data) {
        if(data == 'OK') {
            self.setTimeout("self.location = '/dashboard/index.php'", 1000);

	}
        else {
            $('#error-box').html('<p><strong>' + data + '</strong>').height(30);
	}
    });
    return false;
}

function registerSave() {
    code = document.getElementById('registration-code').value;
    msg = '';

    if(code.match(/^S*$/))
        msg = "<strong>Something went wrong!</strong> You have not entered any code! Please try again.";
    else if(code.length < 8)
        msg = "<strong>Something went wrong!</strong> The code must have 8 letters or digits! Please try again.";
    if(msg != '') {
        $("#register-error-p").html(msg);
        $("#register-error-box").css("display", "block");
        $.fn.colorbox.resize(); 
        return;
    }
    $.post('/ajax/check_pal.php', $('#register-code-form').serialize(), function(data) {
        if(data == 'OK') {
            self.location = "/Register/index.php";
            return;
	}
        $("#register-error-p").html("<strong>Something went wrong!</strong> " + data + " Please try again.");
        $("#register-error-box").css("display", "block");
        $.fn.colorbox.resize(); 
        return;
    });
}

function registerForFree() {
    self.location = '/Register/index.php?code=free';
    return false;
}

$('#problem').live('click', function(e) {
    e.preventDefault();
    $('#modal, .modal').hide();
    $('#nocode').show();
});
/*
$('#for_free').live('click', function(e) {
    e.preventDefault();
    $('#modal, .modal').hide();
    $('#for_free_div').show();
});
*/
$('.back').live('click', function(e) {
    e.preventDefault();
    $('#nocode').hide();
    $('#modal, .modal').show();
});



