$(function() {

   

    /*
        3.) Simply Centered Informational DIV Popup
    */

    /*
        The viewport object is mainly for the cross-browser mess
        that is unfortunately necessary to get a DIV to center.

        There is also an officially supported plugin called "Dimensions"
        that can manage some of this on your own projects. Check it out at:

        http://jquery.com/plugins/project/dimensions
    */

    var viewport = {
        o: function() {
            if (self.innerHeight) {
    			this.pageYOffset = self.pageYOffset;
    			this.pageXOffset = self.pageXOffset;
    			this.innerHeight = self.innerHeight;
    			this.innerWidth = self.innerWidth;
    		} else if (document.documentElement && document.documentElement.clientHeight) {
    			this.pageYOffset = document.documentElement.scrollTop;
    			this.pageXOffset = document.documentElement.scrollLeft;
    			this.innerHeight = document.documentElement.clientHeight;
    			this.innerWidth = document.documentElement.clientWidth;
    		} else if (document.body) {
    			this.pageYOffset = document.body.scrollTop;
    			this.pageXOffset = document.body.scrollLeft;
    			this.innerHeight = document.body.clientHeight;
    			this.innerWidth = document.body.clientWidth;
    		}
    		return this;
        },
        init: function(el) {
            $(el).css("left",Math.round(viewport.o().innerWidth/2) + viewport.o().pageXOffset - Math.round($(el).width()/2));
            $(el).css("top",Math.round(viewport.o().innerHeight/2) + viewport.o().pageYOffset - Math.round($(el).height()/2));
        }
    };
    $(".simple_popup_info").each(function(){
        $(this).css("display","none").siblings(".simple_popup").click(function(){
            $(".simple_popup_div").remove();
           // alert('ok');
            var strSimple = "<div class='simple_popup_div'><div class='simple_popup_inner'>";
            strSimple += "<p class='simple_close'><a href='#'>Sluiten</a></p>";
            strSimple += $(this).siblings(".simple_popup_info").html();
            strSimple += "</div></div>";
            
            $("body").append(strSimple).fadeIn('fast');
            
            $(this).siblings(".simple_popup_info")
            
            var width= $(this).siblings(".simple_popup_info").children("img.imgs").attr("width") + 50;
            var height= $(this).siblings(".simple_popup_info").children("img.imgs").attr("height")+ 40;
            
            $(".simple_popup_div").css("width", width);
            $(".simple_popup_div").css("height", height);
            viewport.init(".simple_popup_div");
            
            $(".simple_close").click(function(){
                $(".simple_popup_div").fadeOut('fast');
                return false;
            });
            return false;
        });
    });

   

});
