// JavaScript Document


$(function() {
	
	$(".comment_button").click(function() {
		
		var element = $(this);
				
		var dataString = 'comment='+$("#comment").val()+'&name='+$("#name").val()+"&page="+$("#page").val();
		
		if($("#comment").val()==''){
			alert("Please Enter Some Text");
		
		}else{
			$("#flash").show();
			$("#flash").fadeIn(400).html('<img src="/images/ajax.gif" align="absmiddle">&nbsp;<span class="loading">Loading Update...</span>');
			$.ajax({
				type: "POST",
				url: "/foodie/_ajaxUpdate.php",
				data: dataString,
				cache: false,
				success: function(html){
					
					$("ol#update").prepend(html);
					$("ol#update li:first").slideDown("slow");
					
					document.getElementById('comment').value='';
					$('#comment').value='';
					$('#comment').focus();
					$("#flash").hide();
				
				}
			});
		}
		return false;
	});
	
	
	// delete undate
	
	$('.delete_update').live("click",function(){
		var ID = $(this).attr("id");
		
		if(confirm("Sure you want to delete this update? There is NO undo!")){
			
			$.ajax({
				type: "POST",
				url: "/foodie/_ajaxUpdate.php",
				data: "del="+ID,
				cache: false,
				success: function(what){
					//alert("hey #"+what);
					$("#"+what).slideUp();
				
				}
			});	
			
		}
	});
	
	//comment slide
	$('.comment').live("click",function(){
		
		var ID = $(this).attr("id");
		$(".fullbox"+ID).show();
		$("#c"+ID).slideToggle(300);
	
	
	});
	
	
	
});

function tweet(what){
	
	if(what == "foodie"){
		earl = "http://bit.ly/9X29OJ #foodie";
		add = "The @metmarket Foodie Finder van found me!";
	}else{
		earl = "http://bit.ly/d09wFP #mmkirkland";
		add = "I'm excited about the @metmarket opening in kirkland!";
	}
	if($("#comment").val() == ""){
		status = add+" "+earl;
	}else{
		status = $("#comment").val()+" "+earl;
	}
	statusE = escape(status);
	window.open("http://twitter.com/home?status="+statusE, "Twitter");
	
}
