
function LikeIt(id)
{
  jQuery.ajax({
	 url: "/gallery/like_post_ajax.php?id="+id,
	 beforeSend:function(jqXHR, settings){
	 jQuery("#like_"+id).addClass('disable');
	 jQuery("#like_count_"+id).addClass('disable');
	 },
	 success: function(data, textStatus, jqXHR){
	 if(data == '1')
	 {
	 var old_count = parseInt(jQuery("#like_count_"+id).html());
	 old_count++;
	 jQuery("#like_count_"+id).html(old_count);
	 jQuery("#like_"+id).addClass('disable');
	 jQuery("#like_count_"+id).addClass('disable');
	 }
	 else alert(data);
  }
});
}

function CommentIt(id)
{

 jQuery("#add_comment_box_"+id).toggle();
}

function CommentSend(id)
{
   var comment = jQuery('#comment_text_'+id).val();

   jQuery.ajax({
        type: 'POST',
	converters:"text json",
	dataType: 'json',
        url: "/gallery/comment_post_ajax.php",
        data: { id: id, comment: comment },
	success: function(data, textStatus, jqXHR){
	 if(data.RES == '1')
	 {
	 clone_obj = jQuery('#comment_temp_'+id).clone();
	 clone_obj.find('.comment_username_temp_'+id).html(data.USER_NAME+': ');
	 clone_obj.find('.comment_text_temp_'+id).html(data.COMMENT);
	 clone_obj.prependTo('#comment_box_'+id).fadeIn();
	 jQuery("#add_comment_box_"+id).toggle();
	 }
	 }
      });
}

function ReviewSend(id)
{
   var comment = jQuery('#comment_text_'+id).val();

   jQuery.ajax({
        type: 'POST',
	converters:"text json",
	dataType: 'json',
        url: "/gallery/comment_ajax.php",
        data: { id: id, comment: comment },
	success: function(data, textStatus, jqXHR){
	 if(data.RES == '1')
	 {
	 clone_obj = jQuery('#comment_temp_'+id).clone();
	
	 clone_obj.find('.comment_username_temp_'+id).html(data.USER_NAME+': ');
	 clone_obj.find('.comment_text_temp_'+id).html(data.COMMENT);
	  
	 clone_obj.prependTo('#comment_box_'+id).fadeIn();
	 jQuery("#add_comment_box_"+id).toggle();
	 }
	 }
      });
}

function FavoriteIt(id)
{
  jQuery.ajax({
	 url: "/gallery/fav_post_ajax.php?id="+id,
	 beforeSend:function(jqXHR, settings){
	 jQuery("#fav_"+id).addClass('disable');
	 jQuery("#fav_count_"+id).addClass('disable');
	 },
	 success: function(data, textStatus, jqXHR){
	 if(data == '1')
	 {
	 var old_count = parseInt(jQuery("#fav_count_"+id).html());
	 old_count++;
	 jQuery("#fav_count_"+id).html(old_count);
	 jQuery("#fav_"+id).addClass('disable');
	 jQuery("#fav_count_"+id).addClass('disable');
	 alert("Post was added to Favorites");
	 }
	 else alert(data);
  }
});
}

