$(document).ready(function(){
    // Background for old browsers

    if (!Modernizr.backgroundsize) {
        $('body').append('<img src="/images/bg.jpg" class="bg">');
    }

    // Login tail

    $(window).resize(function() {
    	if ($(document).width() > 1600) {
    		$('#login-tail').addClass('detached');
    		//$('#login').animate({
    		//	right: '',
    		//});
    	} else if ($('#login-tail').hasClass('detached')) {
    		$('#login-tail').removeClass('detached');
    		//$('#login').animate({
    		//	right: 0,
    		//});
    	}
    });
    
    // Used to detect initial (useless) popstate.
    // If history.state exists, assume browser isn't going to fire initial popstate.
    var popped = ('state' in window.history), initialURL = location.href


    // popstate handler takes care of the back and forward buttons
    $(window).bind('popstate', function(event){
        // Ignore inital popstate that some browsers fire on page load
        var initialPop = !popped && location.href == initialURL
        popped = true
        if ( initialPop ) return
        
	    window.location = location.href
    });
});
