$(function(){
	
	
	$(".box").hoverIntent( function(){ 
							  $(this).find(".entrytop").slideDown();						  
							  }, function(){
								  
								  $(this).find(".entrytop").slideUp();	
								  } );

	
	$("a.navilink").hover(function(){
								   $(this).stop().animate({paddingRight: "0.15in"}, 150 );
								   
								   
								   },function(){
								   $(this).stop().animate({paddingRight: "0in"}, 150 );
								   })
	
	$("li.navilist").hover(function(){
						   $(this).find("ul").slideDown(500);
						   }, function(){
							  $(this).find("ul").slideUp(500); 
						   });
	
	$('textarea.quoteinput').focus(function() {
											$(this).html("");
								   $("#extendetform").slideDown(0);
								   }); 
	
	$('.fbloader').each(function(){
								 var id = $(this).attr("id").split("_");
									   $(this).html("<iframe src=\"http://www.facebook.com/plugins/like.php?href=neobash.de/!"+id[1]+"/&amp;send=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:100%; height:21px;\" allowTransparency=\"true\"></iframe>");
									   });
								
		   

		   
		   
		   
/*$("a.opencomments").click(function(){
								  the_id = $(this).attr('name');
								 status = $('.coq'+the_id).children(".commentbox").css('display');
								 if(status == 'none'){
								  $('.coq'+the_id).children(".commentbox").slideDown("slow");
								 } else {
									 $('.coq'+the_id).children(".commentbox").slideUp("slow"); 
								 }
								   });*/
	$("a.RateUp").click(function(){
	//get the id
	the_id = $(this).attr('id').split("_");
	the_id = the_id[1];
	
	//fadeout the vote-count 
	$("a#P_"+the_id).fadeOut("fast");
	$("a#C_"+the_id).fadeOut("fast");
	$("span#B"+the_id).html('<img src="images/spinner.gif" alt="loading"/>');
	//the main ajax request
		$.ajax({
			type: "POST",
			data: "mode=inc&id="+the_id,
			url: "/rate_quote.php",
			success: function(msg)
			{
				$("span#B"+the_id).html(msg);
				$("span#notice_"+the_id).html("Vielen dank f&uuml;r deine Bewertung!");
				
				/*//fadein the vote count
				$("span#votes_count"+the_id).fadeIn();
				//remove the spinner
				$("span#vote_buttons"+the_id).remove();*/
			}
		});
		
	});
	$("a.RateDown").click(function(){
	//get the id
	the_id = $(this).attr('id').split("_");
	the_id = the_id[1];
	
	//fadeout the vote-count 
	$("a#P_"+the_id).fadeOut("fast");
	$("a#C_"+the_id).fadeOut("fast");

	
	//fadeout the vote-count 
	$("a#P"+the_id).fadeOut("fast");
	$("a#C"+the_id).fadeOut("fast");
	$("span#B"+the_id).html('<img src="images/spinner.gif" alt="loading"/>');
	//the main ajax request
		$.ajax({
			type: "POST",
			data: "mode=dec&id="+the_id,
			url: "/rate_quote.php",
			success: function(msg)
			{
				$("span#B"+the_id).html(msg);
				//fadein the vote count
				//$("span#votes_count"+the_id).fadeIn();
				
			}
		});
	});
	$("a.submitcomment").live('click',submitcomment);
	$(".opencomments").click(function(){
									  var t = $(this);
									  id = $(this).attr("id").split("_");
									 
								$.ajax({
			type: "POST",
			data: "id="+id[1],
			url: "/loadcomments.php",
			success: function(msg)
			{
				t.parents(".box").find(".commentcontainer").html(msg);
				t.parents(".box").find(".commentcontainer").slideDown();
				
			}
		});	   
									   
									   
	 });
	function submitcomment(){
		var t = $(this);
	var comment = t.parent().find("textarea.comment").val();
	$.ajax({
			type: "POST",
			data: "id="+$(this).attr("name")+"&comment="+comment,
			url: "/submitcomment.php",
			success: function(msg)
			{
				t.parents(".box").find(".commentcontainer").html(msg);
				X
			}
		});	   
	
	}
	$("a.MarkSpam").click(function(){
	//get the id
	the_id = $(this).attr('name');

	
	//fadeout the vote-count 
	$("a#S"+the_id).fadeOut("fast");
	//the main ajax request
		$.ajax({
			type: "POST",
			data: "mode=spam&id="+$(this).attr("name"),
			url: "/rate_quote.php",
			success: function(msg)
			{
				alert("Das Zitat wird von der Moderation geprueft und dann eventuell geloescht.");
			}
		});
	});
	Fopen = false;
	$("a.Filter").click(function(){
								 if(!Fopen){
						 $('.filter_content').slideDown();
						 Fopen = true;
								 } else {
									  $('.filter_content').slideUp();
									  	 Fopen = false;
								 }
								 
						  });
	
	
	$("textarea.comment_small").click(function(){
											   $(this).html("");
											   $(".[class*='fastcomment_options']").slideUp(0);
											   $("textarea.comment_small").animate({height: "14px"}, 0 );
											   $(this).animate({height: "100px"}, 0 );
											   id = $(this).parent().attr("name");
											   $(".fastcomment_options_"+id).slideDown(0);
											   
											   });

$("textarea.comment").click(function(){
										   $(this).html("");
										   });

});
