/***PAGE INIT**/
$(function() {
    Popup.initCommentPopups();
});

var Popup = {
	box:null,
	lastTarget: null,
    initCommentPopups: function() {
        $(".commentLink").click(function(e) {
			if(Popup.box != undefined) Popup.box.hide();
			
			var x = $(this).offset().left + $(this).width();
            var y = $(this).offset().top + $(this).height() / 2 - 74;
					
			var target = "/blog/?comments_popup=" + $(this).attr("target");
		   
		    if(Popup.lastTarget != target){
				var content = $("<div class='comment-content'/>")
						  .append($("<iframe frameborder='0' id='commentIframe' name='commentIframe' />")
								   .attr("src", target));
								  
				Popup.box = new Boxy(content, {draggable: false, center: false, unloadOnHide: true, fixed:false});
				Popup.box.resize(500,400);
				Popup.box.moveTo(x,y);
				Popup.lastTarget = target;
			} else {
				Popup.lastTarget = null;
			}
            return false;
        });
    },
    currentArticle: undefined,
    openAddComment: function() {
        Popup.box.tween(850, 400);
    }
};

var User = {
	initShare: function() {
		$('.fb_share_size_Small').click(function(){
			alert("Ha!");
			FB.Connect.streamPublish(
			  "test", // user_message
			  { 
				name: "Hier komt denaam",
				href: window.location.href,
				caption: 'A post on the blog ' + FBConnect.blog_name,
				description: "Description"
			  }, // attachment
			  null, // action links
			  null, // target_id
			  'My Comment', // prompt
			  function() {
				
			  }
			);
			return false;
		});
	}
};