$(document).ready(function(){ 
    $(".link-popup a").click(function(){
        $(this).next("div").stop(true, true).animate({opacity: "show"}, "fast"); 
	//CenterPopup($(this).next("div"));

$(this).next("div").center();

        $(this).next("div").click(function(){
            $(this).animate({opacity: "hide"}, "fast");
        });
    }, function() {
        $(this).next("div").animate({opacity: "hide"}, "fast");
        
    }); 
  $(".sf_postListing").find("p.sf_postTags").each(function (i) {
        $("<div class='clear'></div>").insertAfter($(this));
    });
});

function CenterPopup(element)
{
 	var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $(element).height();
        var popupWidth = $(element).width();
        $(element).css({
            "position": "absolute",
            "top": windowHeight / 2 - popupHeight / 2,
            "left": windowWidth / 2 - popupWidth / 2
        });
}

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

function scrollToTop()
{
    scrollTo(0, 0);
}


function itemOpening(sender, args){  
	 
   var element = args.get_item().get_element();
}

function DialogPopup(id)
{
  $("#" + id).dialog();
}
