// <![CDATA[ 
$(document).ready(function(){
	
	//submit new blurb
	$('#blurbForm').ajaxForm({
		beforeSubmit: function(a,f,o) {
			o.dataType = 'html'; 
			$('#inputBlurb').hide();
			$('#blurbFormResultShow').show();
			$('#blurbFormMsgShow').show().html('Sending...'); 
		},
		success: function(data) { 
			$('#blurbFormMsgShow').show().html("<a href='javascript:void(0);' id='closebutton'><font color='333333'>Blurb added. Got it, thanks!</font></a>"); 
			$('#blurbFormResultShow').show(); 			
			$('#mainContent').html(data);
			
			
		},
		error: function(msg){
			var id = $(this).attr('rel');
			$('#blurbFormMsgShow').show().html("<a href='javascript:void(0);' id='closebutton'><font color='333333'>Whoops! Problem sending this blurb.</font></a>");
			$('#blurbFormResultShow').show();
			}
		}); 
	
	//close button
	$('#closebutton').live('click', function(){
		$('#inputBlurb').show();
		$('#blurb').show().val('');
		$('#blurbFormMsgShow').hide().html(''); 
		$('#blurbFormResultShow').hide(); 			  
	}); 
	
	
	//remove blurb button 
	$('.deleteBlurbNew').live('click', function(){
												
		 var blurb_id = $(this).attr('rel');
		 var dataString = $('#deleteBlurb_' + blurb_id).serialize();
		 $('#ajax_result_deleteBlurb_' + blurb_id).html('');	
		 
						 
		$.ajax({
			type: "POST",
			url: "homeAjax.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#ajax_result_deleteBlurb_' + blurb_id).html(html);
			},
			error: function(msg){

				$('#ajax_result_deleteBlurb_' + blurb_id).html('Error');

			}
		});
		return false;
	});		
	
	
	//more blurb button 	
	$('.more').live('click', function(){
												
		 var latest_blurb_date = $(this).attr('id');
		 $('#more' + latest_blurb_date).html('<ul class="comment"><li class="blurbMore">Loading more ...</li></ul>');
						 
		$.ajax({
			type: "GET",
			url: "moreHomeAjax.php?morebefore=" + latest_blurb_date,
			cache: false,
			success: function(html){				
				$('#more' + latest_blurb_date).html(html);
			},
			error: function(msg){

				$('#more' + latest_blurb_date).html('Error');

			}
		});
		return false;
	});		
	
			
	//addCookieForm 
	$('.addCookieForm').live('click', function(){
												
		 var blurb_id = $(this).attr('rel');
		 var dataString = $('#addCookieForm_' + blurb_id).serialize();
		 $('#ajax_result_' + blurb_id).html('');	
		 
						 
		$.ajax({
			type: "POST",
			url: "homeAjax.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#ajax_result_' + blurb_id).html(html);
			},
			error: function(msg){

				$('#ajax_result_' + blurb_id).html('Error');

			}
		});
		return false;
	});		

	
	//addEGOForm
	$('.addEGOForm').live('click', function(){
												
		 var blurb_id = $(this).attr('rel');
		 var dataString = $('#addEGOForm_' + blurb_id).serialize();
		 $('#ajax_result_' + blurb_id).html('');	
		 
						 
		$.ajax({
			type: "POST",
			url: "homeAjax.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#ajax_result_' + blurb_id).html(html);
			},
			error: function(msg){

				$('#ajax_result_' + blurb_id).html('Error');

			}
		});
		return false;
	});	
	
	
	//deleteReblurb
	$('.deleteReblurb').live('click', function(){
												
		 var blurb_id = $(this).attr('rel');
		 var dataString = $('#deleteReblurb_' + blurb_id).serialize();
		 $('#ajax_result_deleteReblurb_' + blurb_id).html('');	
		 
						 
		$.ajax({
			type: "POST",
			url: "homeAjax.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#ajax_result_deleteReblurb_' + blurb_id).html(html);
			},
			error: function(msg){

				$('#ajax_result_deleteReblurb_' + blurb_id).html('Error');

			}
		});
		return false;
	});	
	
	
	
	//addCookieForm_Reblurb 
	$('.addCookieForm_Reblurb').live('click', function(){
												
		 var blurb_id = $(this).attr('rel');
		 var dataString = $('#addCookieForm_Reblurb_' + blurb_id).serialize();
		 $('#ajax_result_' + blurb_id).html('');	
		 
						 
		$.ajax({
			type: "POST",
			url: "homeAjax.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#ajax_result_reblurb_' + blurb_id).html(html);
			},
			error: function(msg){

				$('#ajax_result_reblurb_' + blurb_id).html('Error');

			}
		});
		return false;
	});		


	//addEGOForm_Reblurb
	$('.addEGOForm_Reblurb').live('click', function(){
												
		 var blurb_id = $(this).attr('rel');
		 var dataString = $('#addEGOForm_Reblurb_' + blurb_id).serialize();
		 $('#ajax_result_' + blurb_id).html('');
		 
						 
		$.ajax({
			type: "POST",
			url: "homeAjax.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#ajax_result_reblurb_' + blurb_id).html(html);
			},
			error: function(msg){

				$('#ajax_result_reblurb_' + blurb_id).html('Error');

			}
		});
		return false;
	});	
	


});
// ]]>






$(document).ready(function(){
			
			
	//Comment Button
	$(".comment_button").live('click', function(){
	
		var element = $(this);
		var I = element.attr("id");
	
		$("#slidepanel"+I).slideToggle(300);
		$(this).toggleClass("active"); 
	
		return false;
	
	});
	
	//Comment Expand Button
	$(".comments_expand").live('click', function(){
		
		var msgID = $(this).attr('rel');
		
		$(this).hide(); $('#replyComments_' + msgID).show(); 
				
		var element = $('#' + msgID);
		
		var I = element.attr("id");
		
		$("#slidepanel"+I).slideToggle(300);
		
		$(this).toggleClass("active"); 
		
		return false;
										 
	});
	
	
	$(".comment_submit").live('click', function(){
		
		
		var element = $(this);
		var Id = element.attr("id");
		
		var test = $("#textboxcontent"+Id).val();
		var testuserid = $("#user_id"+Id).val();
		var testuname = $("#username"+Id).val();
		var testblurbid = $("#blurb_id"+Id).val();
		var testuublurbid = $("#uublurb_id"+Id).val();
		var testplaceid = $("#place_id"+Id).val();
		var dataString = 'textcontent='+ encodeURIComponent(test) + '&com_msgid=' + Id + '&textuserid='+ testuserid + '&com_msgid=' + Id + '&textuname='+ testuname + '&com_msgid=' + Id + '&textblurbid='+ testblurbid + '&com_msgid=' + Id + '&textuublurbid='+ testuublurbid + '&com_msgid=' + Id + '&textplaceid='+ testplaceid + '&com_msgid=' + Id;
		
			if(test==''){}
			else{
				$("#flash"+Id).show();
				$("#flash"+Id).fadeIn(400).html('loading...');
				
						
						$.ajax({
						type: "POST",
						url: "/insertajax.php",
						data: dataString,
						cache: false,
						success: function(html){
							$("#flash"+Id).hide();
									$("#loadplace"+Id).append(html);
									var error = $('#comment_post_error').val();		
									if(error){
										$("#error_"+Id).html(error);
									}else{								
										$("#textboxcontent"+Id).val('');
										$("#error_"+Id).html('');
									}
									$('#comment_post_error').remove();
					
							}
						});
			
			}
		return false;
	});
	
	
});