//Admin jquery
$(document).ready(function() {
	
	$('.delMessage').click(function(){

		if (location.href.search('home.php') >  -1 ||
			location.href.search('php') 	 == -1   )
			var currMsg = $(this).parent().parent().parent().parent().parent().parent()
			
		else if (location.href.search('studioHome.php') > -1 ||
				 location.href.search('carchat.php')    > -1   )
			var currMsg = $(this).parent().parent().parent()
			
		else //for all other pages
			var currMsg = $(this).parent().parent()
				
		var msgID = $(this).attr('id');
		if (confirm("Delete this message? \n\n"+$('.'+msgID+'.messageText').html().replace(/(<([^>]+)>)/ig,""))) {
		
			$.post("/web_ajax/delMessageAjax.php", { messageID: $(this).attr('id') },
				function(data){
					if (data.success)
						currMsg.slideUp();
					else 
						alert(data.msg);
						
				}, "json"
			);

		}
		return(false);

	});

});