/**
 * handles the ajax call to remove the post in question.
 */
function dmgDelCoExhibitor ($postID, $parentID, $userID, $redirect) {
	jQuery.ajax({
		url: "http://www.globalpetroleumshow.com/?cf_action=del_co_exhibitor",
		type: "POST",
		dataType: "json",
		data: {'post_id':$postID, 'parent_id':$parentID, 'user_id':$userID},
		complete: function() {
	    	//called when complete
		},
		success: function(r) {
			alert(r.message);
			if ($redirect) {
				location.href = r.redirect;
			};
			jQuery("#dmg-del-"+$postID).parent().remove();
		},
		error: function(a,b,c) {
	    	//called when there is an error
			alert('An error('+b+') prevented this user being deleted');
			if(c){
				alert(c);
			};
		}
	});
	return false;
};

jQuery(function($) {
	$("#dmg-keyword-redirect").change(function(s) {
		location.href = $("#dmg-keyword-redirect").attr("value");
		return false;
	});
	$(".dmg-del-co-exhibitor").click(function(){
		var answer = confirm('Are you sure you want to delete this Exhibitor?');
		if (answer) {
			dmgDelCoExhibitor($(this).attr("dmg_exhibitor"), $(this).attr("dmg_parent"), $(this).attr("dmg_user"), $(this).attr("dmg_redirect"));
		};
		return false;
	});
});
