var site = {
    home: './',
    is_logged_in: false
}

function site_init(home)
{
    site.home = home;

    // doubleclick protector
    $('a,button').click(function (e) {
        if (site.is_clicking) {
            log('STOPPED');
            e.preventDefault();
            e.stopPropagation();
            e.stopImmediatePropagation();
        } else {
            site.is_clicking = true;
            setTimeout(function () {
                site.is_clicking = false;
            }, 700);
            // continue event
        }
    });

    window.log = function (s)
    {
        if (window.console) {
            if (window.console.log) {
                console.log(s);
            }
        }
    };


    // focusing handler for the inputs

    $(':input').focus(function () {
        //$(this).select().addClass('focused');
        $(this).addClass('focused');
    }).blur(function () {
        $(this).removeClass('focused');
    });

    $('#fake-password').focus(function() {
        $('#fake-password').hide();
        $('#real-password').show().focus();
    });

    $('#real-password').blur(function() {
        if ( ! $(this).val()) {
            $('#real-password').hide();
            $('#fake-password').show();
        }
    });


    // focus the input
    if ($('.focus').length) {
        $('.focus:visible:enabled:first').focus();
    } else {
        $(':input:visible:enabled:not(button):not(.radio):not(.skip-autofocus):first').focus();
    }

    // behaviour for inputs with the default descriptive text

    $('input.with-default').focus(function () {
        var t = $(this).removeClass('inactive');
        if (t.val() == t.attr('title')) {
            t.val('');
        }
    }).blur(function () {
        $t = $(this);
        if (!$t.val() || $t.val() == $t.attr('title')) {
            $t.val($t.attr('title')).addClass('inactive');
        }
    }).blur();

}

