/**
 * Created by JetBrains PhpStorm.
 * User: thesouk
 * Date: 14/09/11
 * Time: 11:52
 * To change this template use File | Settings | File Templates.
 */
$(document).ready(function() {
    $('#main_nav').click(function() {
        var State = $(this).attr('State');
        if (State == 'Hidden') {
            $(this).animate({left:"0px"}, 1000);
            $(this).attr('State', 'Visible');
        }
        else {
            $(this).animate({left:"-190px"}, 1000);
            $(this).attr('State', 'Hidden');
        }
    });

    $('#closer a').click(function(e) {
        var url = $(this).attr('href');
        if(url == '')
            e.preventDefault();
        else
            window.location = url;
        $('.wrapper').remove();
        CoolClock.findAndCreateClocks();
    });

    $('#hitme').mouseover(function() {
        $('#loginImageday').css('backgroundPosition', '-0px 0px');
        $('#loginImagenight').css('backgroundPosition', '-178px -30px');
    });
    $('#hitme').mouseout(function() {
        $('#loginImageday').css('backgroundPosition', '-162px -33px');
        $('#loginImagenight').css('backgroundPosition', '0px 0px');
    });

    $('.hitpoint').mouseover(function() {
        $('#' + $(this).attr('rel')).toggle();
    });
    $('.hitpoint').mouseout(function() {
        $('#' + $(this).attr('rel')).toggle();
    });


      // create a dummy image
    var img = new Image();

      // give it a single load handler
    $(img).one('load',function() {
        setTimeout("swing()", 1900);
        setTimeout("lift()", 4);
    });
      // give it the src of your background image
    img.src = "images/day-bg.png";
      // make sure if fires in case it was cached
    if( img.complete )
        $(img).load();


});

function swing() {
    $('#swinging-man').animate({left:"+=15px"}, 1500).animate({left:"-=15px"}, 1500);
    setTimeout("swing()", 2450);
}

function lift() {
    $('#swinging-man').animate({top:"+=207px"}, 5000);
}


