var iw = 5;

function myt(){
    tstmp = new Date();    
    return tstmp.getTime();
} 

function PrintPhoto(i, des){	
	document.getElementById('bigimgsrc').innerHTML = '<img src="' + i + '" style="padding: 5px;" alt="" />';
	document.getElementById('bigimgdesc').innerHTML = des;
}

function PrintGallery(n){
	var num = imgsrc.length;
	if(num >= 2){
		var pp = "<div>";
		if(n < 0) n = 0;
		max = Math.ceil(num/iw);
		if(n==0) start = 0;
		else start = n*iw;		
		if(n == 0) prev = '<img src="/img/gbackt_2.gif" alt="" />';		
		else prev = '<img onClick="PrintGallery(' + (n-1) + ')" class="pr" src="/img/gback_1.gif" alt="" />';	
		
		if((n+1) == max) next = '<img src="/img/gnext_2.gif" alt="" />';	
		else next = '<img onClick="PrintGallery(' + (n+1) + ')" class="pr" src="/img/gnext_1.gif" alt="" />';
		
		pp += '<div style="float: left; width: 14px; height: 105px; margin-left: 5px; margin-right: 5px;">' + prev + '</div>'
		+'<div style="float: left; width: ' + gaw + 'px; margin: 0px 5px 0px 5px">';
		
		for (var i=start; i<(start+iw); i++){	
			if(i < num){
				pp += '<div style="float: left; text-align: center; margin: 3px">'
				+'<img src="' + imgsrc[i]  + '" alt="" style="border: 1px solid #990000; padding: 3px" onclick="PrintPhoto(\'' + imgsrcb[i]  + '\', \'' + imgsrco[i]  + '\')" class"pr" />'
				+'</div> ';
			}
		}
		pp += '</div>'	
		+'<div style="float: left; width: 14px; height: 105px; margin-right: 5px">' + next + '</div>'
		+'<div style="overflow:hidden; height: 0px; width: 1%; clear:both;"></div>';
		
		document.getElementById('imgsrc').innerHTML = pp;
	}
}
	
function GetImg(fdesc, fname){
	
	document.getElementById('foto_desc').innerHTML = fdesc;
	
	eval("document.getElementById('bimg').src = '/img/gallery/" + fname + ".jpg';");

}

function PollResults(p){
	$("#pollmess").html("<div class=\"pollmess\">Proszę czekać ...</div>"); 
	$.ajax({type: "POST", url: "/js/poll.php", data:{ nocache: myt(), p: p }, dataType:"html", success:function(data){ $("#poll").html(data); }, error:function(xhr,err,e){  } });
}
		
function PollVote(p, s){	
	var o = 0;
	if (s){
		for(var i = 0; i < s.length; i++){
			if(document.getElementById('poll' + s[i]).checked == true) o = s[i];
		}
	}	
	if(o == 0) $("#pollmess").html("<div class=\"pollmess\">Proszę zaznaczyć 1 z opcji</div>"); 
	else{
		$("#pollmess").html("<div class=\"pollmess\">Proszę czekać ...</div>"); 
		$.ajax({type: "POST", url: "/js/poll.php", data:{ nocache: myt(), p: p, o: o}, dataType:"html", success:function(data){ $("#poll").html(data); }, error:function(xhr,err,e){  } });
	}
}
