window.lightbox = window.lightbox || {};
lightbox = {

    /**
     * close lightbox
     */
    close : function()
    {
        if(jQuery.browser.msie) {
        // this.style.removeAttribute('filter');
            $("#overlay").hide();
            $("#container").hide();
            $(".lightbox").hide();
        } else {
            $("#overlay").fadeOut(300);
            $("#container").fadeOut(300);
            $(".lightbox").fadeOut(300);
        }
    },

    open : function()
    {   
        if(jQuery.browser.msie) {
        // this.style.removeAttribute('filter');
            $("#overlay").show();
            $("#container").show();
            $(".lightbox").show();
        } else {
            $("#overlay").fadeIn(350);
            $("#container").fadeIn(350);
            $(".lightbox").fadeIn(350);
        }
    },

    scroll : function()
    {
        var scrollTop = $(window).scrollTop();
        var scrollLeft = $(window).scrollLeft();
        this.moveToPosition(scrollTop, scrollLeft);
    },

    moveToPosition : function(top, left, duration)
    {
        $(".lightbox").animate( { top: top-156, left: left-256 }, { queue:false, duration:300 } );
    }
}

$(document).keyup(function(event){
    if (event.keyCode == 27 && $('.lightbox').is(':visible')) {
        lightbox.close();
        return false;
    }
});
    
if (jQuery.browser.msie && jQuery.browser.version == 6) {
    var width = $(window).width();
    var height = $(window).height();
    var pageHeight = document.body.clientHeight;
    if (pageHeight > height) {
        height = pageHeight;
    }
    $("#overlay").css({width: width, height: height});
} 
    
$("#overlay").click(function() {
    lightbox.close();
    return false;
});

$(window).scroll(function() {
    lightbox.scroll();
});
