jQuery(document).ready(function($){
	$(".networkpublisherremove").bind("click", function(e) {
		$("#networkpub_remove").html('<div class="updated fade" style="padding:5px;text-align:center">'+$("#networkpub_text_removing").val()+'.</div>')
		var key = $(this).attr("id");
		$(this).parent().parent().css('opacity','.30');
		if(key) {
			var blog_url = $("#networkpub_plugin_url").val();
			$.post(blog_url+"networkpub_ajax.php", {action:"networkpub_remove", networkpub_key:key}, function(data) {
				if(data != key) {
					$("#networkpub_remove").html('<div class="updated fade" style="padding:5px;text-align:center">'+$("#networkpub_text_an_error_occured").val()+': <a href="http://www.linksalpha.com/publisher/pubs">'+$("#networkpub_text_linksalpha_publisher").val()+'</a></div>');
				} else {
					var dr = data.split("_");
					$("#r_key_"+dr[1]).remove();
					$("#networkpub_remove").html('<div class="updated fade" style="padding:5px;text-align:center">'+$("#networkpub_text_publication_has_been_removed").val()+'</div>')
				}
		    });
		} 
		return false;
	});
	$.receiveMessage(
		function(e){
			$("#networkpub_postbox").height(e.data.split("=")[1]+'px');
		},
		'http://www.linksalpha.com'
	);
	$("#site_links").live("change", function(event) {
		$.postMessage(
			$(this).val(),
			'http://www.linksalpha.com/post',
			parent
		);
	});
});