$(document).ready(function() {

    //Load menu
    $('#menu').load("shared/menu.html");
    //load top
    $('#top').load("shared/top.html");
    

    // Theme switcher		   
    if ($.cookie("nonodarlingTheme") != null) {
        $('#theme').attr('href', $.cookie("nonodarlingTheme"));
    }
    else {
        $('#theme').attr('href', 'css/theme1.css');
    }

    $("#themeChange li a").live("click",function() {

        $("#theme").attr("href", $(this).attr('rel'));
        $.cookie("nonodarlingTheme", $(this).attr('rel'), { expires: 14 });
        return false;
    });

    // menu
    $('#menu').hover(function() {
        $(this).stop().animate({ 'bottom': 0 }, 300);
        $('#menu h3').hide();
    }, function() {
        $(this).stop().animate({ 'bottom': -150 }, 300);
        $('#menu h3').show();
    });

    //Modal Login
    var targetWindow = $('#dialog1');

    var screenHeight = $(document).height();
    var screenWidth = $(document).width();
    $('#mask').css({ 'width': screenWidth, 'height': 4000 });
    $('#mask').fadeTo('slow', 0.6);

    var winHeight = $(window).height();
    var winWidth = $(window).width();

    $(targetWindow).css('top', winHeight / 2 - $(targetWindow).height() / 2);
    $(targetWindow).css('left', winWidth / 2 - $(targetWindow).width() / 2);

    $(targetWindow).fadeIn(2000);


    $('#submitButton').click(function(e) {
        e.preventDefault();
        var userName = $('#un').val().toLowerCase();
        var password = $('#pw').val().toLowerCase();
        if (userName == "askayang" && password == "aska0404") {

            $('#mask, .window').fadeOut(2000);
            $("#jquery_jplayer").jPlayer("play");
        }
        else {
            $('#errorMsg').css('display', 'block');
        }
    });
  
});

