$(document).ready(function(){

	$("a#do-gory").click(function(){
		if(navigator.userAgent.indexOf("Opera")>-1) return true;
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});


});

function loadNewsComsForm()
{
	$.get("/news-coms-form.html?news_id="+news_id, function(data) {
		document.getElementById('comments_form').innerHTML = data;
		$('textarea#comment').autoResize({
			// On resize:
			/*
			onResize : function() {
				$(this).css({opacity:0.8});
			},
			// After resize:
			animateCallback : function() {
				$(this).css({opacity:1});
			},*/
			// Quite slow animation:
			animateDuration : 300,
			// More extra space:
			extraSpace : 16
		});
	});
}
var news_com_count = 1;
function addNewsCom()
{
	var msg = '';
	if(document.add_com_form.content.value=="") msg += "- Podaj treść komentarza\n";
	if(document.add_com_form.nick.value=="") msg += "- Podaj swój nick\n";

	if(msg)
	{
		alert("Błędne dane:\n"+msg);
		return false;
	}

	$.post("/news-coms-form.html",
		{
			news_id: news_id,
			nick: document.add_com_form.nick.value,
			user_id: document.add_com_form.user_id.value,
			content: document.add_com_form.content.value
		}, function(data) {

		coms_count++;
		document.getElementById('div_coms_count').innerHTML = coms_count;

		document.getElementById('news_com'+news_com_count).style.display = 'none';
		document.getElementById('news_com'+news_com_count).innerHTML = data;
		$('#news_com'+news_com_count).slideDown('slow',function(){});

		document.getElementById('news_com_msg').innerHTML = 'Dodano!';

		news_com_count++;
		if(document.add_com_form.user_id.value==0) document.add_com_form.nick.value = '';
		document.add_com_form.content.value = '';
	});

	return false;
}
