
diffComments = 0;
oneCommentHeight = 61;


//$('.pojPhoto').ready(function(){wyrownaj(mainArticles)});

function ajaxComment()
{
	trescK = $('#trescK')[0].value;
	if ($('#pseudoK').length>0)
		pseudoK = $('#pseudoK')[0].value;
	else
		pseudoK = '';
	blog_rel = $('#blog_rel_value').text();
	$('#commentForm').html('<b>Trwa wysyłanie komentarza</b>');
	$.ajax({
		type: "GET",
		url: "ajax-comment.html",
		data: "bXml=1&trescK="+trescK+"&pseudoK="+pseudoK+"&blog_rel="+blog_rel,
		dataType: "xml",
		success: function(oXml){
			iStatus = $(oXml).find('status').text();
			sComment = $(oXml).find('comment').text();
			sDane = $(oXml).find('dane').text();
			if (iStatus==1)
			{
				if (sDane!='')
					$('#commentForm').html('<b>'+sDane+'</b>');
				else
					$('#commentForm').html('<b>Dodano komentarz</b>');
				if ($('#bComments > .bTextInside > .bOneComment').length>0)
				{
					if ($('#bComments > .bTextInside > .bOneComment').length==5)
					{
						$('#bComments > .bTextInside > .bOneComment').eq($('#bComments > .bTextInside > .bOneComment').length-1).remove();
					}	

					$('#bComments > .bTextInside').prepend(sComment);
					$('#bComments > .bTextInside > .bOneComment > .bCommentText').eq($('#bComments > .bTextInside > .bOneComment').length-1).removeClass('bOneCommentBorder');
					//$('#bComments > .bTextInside > .bOneComment > .bCommentText').eq(0).addClass('bOneCommentBorder');
					
				}
				else
				{
					$('#bComments > .bTextInside').html(sComment);
				}
				countComments = parseInt($('#countComments').html());
				$('#countComments').html(countComments+1);
				$('.bCommentsWidth').show();
				
			}
			else
			{
				if (sDane!='')
					$('#commentForm').html('<b>'+sDane+'</b>');
				else
					$('#commentForm').html('<b>Błąd podczas wysyłania komentarza</b>');
			}
		}
	});
}


function ajaxRank(iId, iRank)
{
	$('a.gwiazdki').hide();
	$.ajax({
		type: "POST",
		url: "ajax-rank.html",
		data: "bXml=1&sType=blog&iId="+iId+"&iRank="+iRank,
		dataType: "xml",
		success: function(oXml){
			iStatus = $(oXml).find('status').text();
			iRank = $(oXml).find('rank').text();
			if (iStatus==1)
			{
				$('a.b5Star').after('<span class="gwiazdkiNoMove bHidden">&nbsp;</span>');
				$('.gwiazdkiNoMove').css('width', parseInt(iRank*20)+'%');
				$('.gwiazdkiNoMove').show();
			}
			else
			{
				//alert('ssd');
				$('a.gwiazdki').show();
			}
		}
	});
}

function getComments()
{
	$('#bAllComments').remove();
	if ($('.bOneComment').not('#bAllComments').length<5)
		return true;

	if ((arguments.length==0)||((arguments[0] == true) && (diffComments>=oneCommentHeight)))
	{
		sEnd = 0;
		if ((arguments.length>0)&&(arguments[0]==true))
		{
			sEnd = $('.bOneComment').not('#bAllComments').length + Math.ceil(diffComments/oneCommentHeight);
		}
		$.ajax({
			type: "POST",
			url: "ajax-getcomments.html",
			data: "bXml=1&sType=blog&sStart="+$('.bOneComment').not('#bAllComments').length+"&sEnd="+sEnd+'&blog_rel='+$('#article_rel_value').text(),
			dataType: "xml",
			success: function(oXml){
				iStatus = $(oXml).find('status').text();
				bAll = $(oXml).find('all').text();
				sComments = $(oXml).find('comments').text();
				if (iStatus==1)
				{
					sAllText = $(oXml).find('allText').text();
					//$('.bCommentText').addClass('bOneCommentBorder');
					$('#bComments > .bTextInside').append(sComments);
					$('#bAllComments').remove();
					$('#bComments > .bTextInside').append(sAllText);
				}
				else
				{

				}
			}
		});
	}
}


$(document).ready(function(){
		$('#bArticleOne .bTextInside .bListStyle a').not('.pojPhotoCopy a').not('.pojPhotoNo a').unbind('click').click(function(){window.open(this.href,'_blank');return false;});
});

