(function ($) { //makes jQuery play nice
	
	$(document).ready(function() {
	
		$("body").append("<div id='dialog'></div>");
		
		$('a.wishlistaddlink').click(function(){
			
			$.post($(this).attr('href'),function(data){
				var d = $("#dialog"); 
				
				d.html(data);
				
				d.dialog({
					title:'Wishlist',
					bgiframe: true,
					modal: true,
					resizable:false,
					buttons: {
						Ok: function() {
							$(this).dialog('close');
						},
						"View Wishlist": function(){
							window.location = "member/wishlist";
						}
					}
				});
				$("#dialog").dialog('open');
				
			});

			return false;
			
		});
		
		//TODO: customise to send the same url every time
		//TODO: add google analytics event recording
				
		$('a.sharelink').mouseover(function(){
			return addthis_open(this, '', '[URL]', '[TITLE]');
		}).mouseout(function(){
			addthis_close();
		}).click(function(){
			return addthis_sendto();
		});

	});
	
})(jQuery);