function gotoComments(){
	location.href = "#k";
}
function showComments(page,advice_id,go){
	var t = Math.random()*10000;
	var url = '/komentarze.html?t='+t+'&s='+page+'&advice_id='+advice_id;
	if(go)
		new Ajax.Updater('commentsDiv', url, {method:'get', onComplete: gotoComments });
	else
		new Ajax.Updater('commentsDiv', url, {method:'get'});
}


var activeCommentDiv = new Array();

var starImg = new Image();
starImg.src = 'images/star_icons27.gif';
var starImgBW = new Image();
starImgBW.src = 'images/star_icons27bw.gif';


function addComment(divTarget){
	if(!$(divTarget)) return;
	
	if(activeCommentDiv[divTarget]!=1){
		$(divTarget).innerHTML = "<center><img src='images/loading.gif' /></center>";
		new Ajax.Updater(divTarget, 'dodaj_komentarz.html');
		activeCommentDiv[divTarget] = 1;
	}
}

var user_rate_value = 0;

function rateMouseOver(r){
	for(a=1; a<=r; a++){
		var o = $('rate'+a);
		o.src = starImg.src;
	}
	if(r<5){
		for(a=r+1; a<=5; a++){
			var o = $('rate'+a);
			o.src = starImgBW.src;
		}
	}
}

function rateMouseOut(r){
	for(a=1; a<=r; a++){
		var o = $('rate'+a);
		o.src = starImgBW.src;
	}
	
	if(user_rate_value>0) rateMouseOver(user_rate_value);
}

function doRate(val){
	if(val>0){
		$('starsy').hide();
		$('starsy_thx').show();
		var url = 'ocena-porady.html?v='+val;
		new Ajax.Request(url);
		user_rate_value = val;
		setTimeout(function(){ $('starsy_thx').hide(); $('starsy').show(); rateMouseOver(user_rate_value);},3000);
	}
}// doRate


var nop = 0;
var nopTO;
var progress = 0;
var picture_id = 0;
function viewPicture(nazwa,_picture_id){
	/*
	try{
		picture_id = _picture_id;
		$('stepImageWait'+picture_id).show();
	}
	catch(e){}
	*/
	obrazek = new Image();
	obrazek.src = nazwa;
	progress = 0;

	fnop(obrazek);

} // function viewPicture(nazwa){

function fnop(o){
	progress++;
	if(progress>50) progress = 1;
	var obrazek = o;
	
	var str = '';
	for(var a=0; a<progress; a++) str+='.';
	//document.title = "?adowanie obrazka: "+str;
	
	if(obrazek.width==0){
		nopTO=setTimeout("fnop(obrazek);",100);
	}
	else{
		okno = window.open(obrazek.src,"obrazek","directories=no, location=no, menubar=no, toolbar=no, status=no, resizable=yes, width="+(obrazek.width+20)+", height="+(obrazek.height+20));
		clearTimeout(nopTO);
		//document.title="exor.idealan.pl";
		//$('stepImageWait'+picture_id).hide();
	}

}// function fnop(o){


function newPictureForm(){
	//$('newPictureFormDivID').BlindDown();
	new Effect.BlindDown('newPictureFormDivID',{duration:0.5});
}

function newPictureFormClose(){
	new Effect.BlindUp('newPictureFormDivID',{duration:0.5});
}



function updateStepPictures(){
	var url = '/step-pictures.html';
	new Ajax.Updater('stepPictures', url);
}// updateStepPictures


function delPicture(fn){
	if(confirm('Na pewno usunąć ten obrazek?')){
		var url = '/step-pictures.html?fn2del='+fn;
		new Ajax.Updater('stepPictures', url);
	}
}