function imgvote_setstar(id, glos) {
	for (i=1; i<=5; i++) {
	  document.getElementById("imgvote"+id+"_"+i).src = "gfx/star"+(i<=glos?1:0)+".png";
	}
}

function glosuj(id, ocena) {
  document.getElementById("glos"+id).innerHTML = "Łączenie...";
	  //alert(document.cookie);
	var nc="";
  c=document.cookie;
  i=c.indexOf("kxpd_vote=");
  if (i>=0) {
    c=c.substr(i);
  	j=c.indexOf(";");
  	if (j<0) j=c.length;
  	c=c.substr(0, j);
  	d=c.substr(10);
  	d="%2C"+d.replace(",", "%2C")+"%2C";
  	if (d.indexOf("%2C"+id+"%2C")>=0) {
  	  document.getElementById("glos"+id).innerHTML = "Głosowałeś już na ten dodatek!";
  	  return;
  	}
  	nc=c.replace("kxpd_vote=", "kxpd_vote="+id+"%2C");
  } else {
    var date = new Date();
    date.setTime(date.getTime()+(60*24*60*60*1000));
    nc = "kxpd_vote="+id+"; expires="+date.toGMTString();
  }
  advAJAX.get({
  retry: 5,
  retryDelay: 5000,
  url : "glos.php?id="+id+"&ocena="+ocena,
  timeout : 30000,
  onSuccess : function(obj) {
    x=obj.responseText;
    if (x.length>0) {
      if (x.indexOf("OK")>=0) {
				document.getElementById("glos"+id).innerHTML = "Głos zapisany!";
				if (nc!="") document.cookie = nc;
			} else {
	      document.getElementById("glos"+id).innerHTML = "Spróbuj ponownie później!";
			}
		} else {
      document.getElementById("glos"+id).innerHTML = "Błąd!";
    }
	}
  });
}

function spr_zoom(i, og) {
	myimg=new Image();
	myimg.src=i.src;
	if (myimg.width>og) {
		i.style.cursor='pointer';
		i.alt='Kliknij, aby powiększyć...';
	}
}

function spr_zoom2(i, og) {
	myimg=new Image();
	myimg.src=i.src;
	if (myimg.width>og) {
		i.parentNode.style.border='1px solid #F5F5F5';
	}
}

function zoom(s, og, naz) {
	myimg=new Image();
	myimg.src=s.src;
	if (myimg.width>og) {
		n=window.open('', '', 'resizable=yes,left=50,top=50,width='+(myimg.width+4)+',height='+(myimg.height+4));
		n.document.open();
		n.document.writeln("<html>\n<head>\n<title>"+naz+"</title>\n</head>");
		n.document.writeln("<body leftmargin=0 topmargin=0>");
		n.document.writeln("<img src='"+s.src+"' alt='' style='cursor: pointer;' onclick='window.close();'>");
		n.document.writeln("</body>\n</html>");
	}
}
