$(document).ready(function() {

    /*
    if ($.browser.msie && $.browser.version == '6.0') {
        $(document.body).css('background-color', '#fff').find('#doc2').hide('fast');
    }
    */

    var $head = $('#head');
    var $topper = $head.find('.topper');

    $topper.find('.login').click(function() {
        var $hide_panel = $head.find('.hide-panel');
        if ($hide_panel.css('display') == 'none') {
            $hide_panel.show('');
        } else {
            $hide_panel.hide('');
        }
    });

    $('#coda-slider-1').codaSlider({
        autoHeight:false,
        autoSlide: true,
        dynamicArrows: false,
        dynamicTabs: false
    });

    $('span.snapshots a').fancybox({
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'titlePosition'     : 'over',
        'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length
                + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });

    $('#prevBtn, #nextBtn').click(function() {
        return false;
    });

    $('.fi-tabs li').click(function() {
        $('.fi-tabs li').removeClass('selected');
        $('.coda-slider-wrapper, .video').hide();
        var currentScreen = $(this).find('a').attr('rel');
        $(this).addClass('selected');
        $('.'+currentScreen).show();
        return false;
    });

    $('.fi-tabs li').click(function() {
        $('.fi-tabs li').removeClass('selected');
        $('.coda-slider-wrapper, .video').hide();
        var currentScreen = $(this).find('a').attr('rel');
        $(this).addClass('selected');
        $('.'+currentScreen).show();
        return false;
    });
    
    //$('.slider li').animate({marginLeft:0}, 500, 'easeInOutExpo');
    
    // flash video
    swfobject.embedSWF('images/swf/heisoo.swf', 'myFlashContent', '620', '300', '9.0.0');

    // change css by hour
    var currentDate = new Date();
    var currentHour = currentDate.getHours();
    var $original_head = $('head');

    if ( style = $.url.param('style') ) {

        $original_head.append('<link rel="stylesheet" type="text/css" href="css/' + style + '.css"/>');

    } else {

        if (currentHour <= 10) {
            $original_head.append('<link rel="stylesheet" type="text/css" href="css/morning.css"/>');
        } else if (currentHour <= 18 ) {
            $original_head.append('<link rel="stylesheet" type="text/css" href="css/day.css"/>');
        } else {
            $original_head.append('<link rel="stylesheet" type="text/css" href="css/night.css"/>');
        }

    }

});

