$(function(){
$('.badlogin').hide();
$('#login').blur(function(){
$('.badlogin').fadeOut();
var login = $('#login').val();
 $.post("inc/ajax.php",{
				loginsp: login
                }, function (data){
				if (data.error){
                    alert("Twój komentarz nie moze być dodany");
                } else{		
				if(data != '0'){	
				$('#login').val('');	
					$('.badlogin').fadeIn();
                }else{

				}}
                });
});
});
$(function(){
$('#addComment').hide();
$('#infokoment').hide();
$('.showcomment .odd').click(function(){
	$('#addComment').slideToggle(200);
	$('.errortext').hide();
	$('#submitcomment').click(function(){
	$('#infokoment').hide();
		var idnews = $('#idnews').val();
		var login = $('#login').val();
		var comment = $('#comment').val();
		var ip = $('#ip').val();
	
	if(login != ''){
	if(comment != ''){
		$('.errortext').hide();
		//$('.kom').slideUp('slow');
		 $.post("inc/ajax.php",{
                page_id: idnews,
                comment: comment,
				user: login,
				ip: ip
                }, function (data){
				if (data.error){
                    alert("Twój komentarz nie może być dodany");
                } else{
				$('#kom').html(' ');
				$('#kom').append(data);
				$('.kom').slideDown('slow');
				$('#infokoment').show();
                }			
                });

				$('#comment').val('');
				$('#addComment').slideToggle();
				


		}else{
		$('.errortext').show();
		}
}		
});	
});
});
