function createPreloader(photo) {
    $("#ram").after('<div id="preloader"><img src="/design/preloader.gif" /></div>');
    center($("#preloader"));
}

function createPopup(photo) {
    createPreloader();
    $("#ram").after('<img id="popup" />');
    $("#popup").attr("src", photo).load(function() {
        $("#preloader").fadeOut();
        center($(this));
        $(this).fadeIn(300);
    }).click(function() {
        $(this).fadeOut(300);
    });
}

function center(obj) {  
    //var windowWidth = document.documentElement.clientWidth;  
    //var windowHeight = document.documentElement.clientHeight;
    var windowWidth = $(window).width();  
    var windowHeight = $(window).height();
    var scroll = $(document).scrollTop();
    obj.css({
        "left": windowWidth/2 - obj.width()/2 - 25,
        "top": windowHeight/2 - obj.height()/2 + scroll - 5
    });
}  

$(document).ready(function() {
    $(".popup").click(function() {
        createPopup($(this).attr("href"));
        return false;
    });

    $("#actualButton").click(function() {
        $("#actualBox").show();
        $("#actualButton").hide();
        return false;
    });
});


