var logopened=false;
$(document).ready(function(){
    $('#login,#logclose').click(function(){
        if(logopened)
        {
            $('#logform').fadeOut('fast');
            $('#login').removeClass('active');
        }    
        else
        {
            $('#logform').fadeIn('fast');
            $('#login').addClass('active');
        }
        logopened=!logopened;
        return false;
    });
}).click(function(e){
    if(!logopened)
        return;
    e=e||window.event;
    var target=e.target||e.srcElement;
    while(target)
    {
        if(target==$('#logform').get(0))
            return;
        target=target.parentNode;
    }
    $('#logform').fadeOut('fast');
    $('#login').removeClass('active');
    logopened=false;    
})
