/* Author: 

*/

$(document).ready(function() {
    var end_date = new Date("Feb 2 2011");
    var current_date = new Date();
    
    var days_remaining = Math.floor((end_date - current_date)/(86400000));
    
    if(days_remaining > 0) {
        var img = new Image();
        img.src = "images/countdown/hello_and_days.gif";

        img.onload = function() {
            var $overlay = $('#overlay');
            var $new_store = $('#new-store');
            
            $overlay.css({'width':'100%', 'height':$(document).height(), 'opacity':0.8});
            $new_store.css({'top': -39, 'left':(($(document).width() / 2) - 954 / 2) });

            $new_store.find('.container').prepend(img);
            $new_store.find('#days-remaining').html(days_remaining);

            $overlay.show();
            $new_store.fadeIn();
            
            $('#new-store p a').click(function() {
                window.open($(this).attr('href'));
                return false;
            });
            
            $('#close-button').click(function(e) {
                $('#new-store').fadeOut(200, function(e) {
                    $overlay.fadeOut(200, function(e) {
                        $(this).remove();
                    });
                    
                    $(this).remove()
                });
                $new_store.hide();
                
                return false;
            });
            
            $overlay.css({'height':$(document).height()});
        }        
    }

})


