function onl() {
	var el=document.getElementById('focusonload');
	if (el)  el.focus();
}
function _tc(xml,tag) {
	return xml.getElementsByTagName(tag)[0].childNodes[0].nodeValue;
}
function rimg(img,pview) {
	if (img.width>500 || img.name=='big') {
		img.style.width = '500px';
		img.style.border = '1px dashed';
		img.onclick = function() {
			var pop = window.open(this.src, 'fullscale');
			pop.focus();
		}
		img.style.cursor = 'pointer';
		img.title = 'Kliknij tutaj aby powiększyć obrazek';
		if (img.parentNode.nodeName == 'A') img.parentNode.onclick = function() { return false; }

		if (pview && img.name!='big') alert('Uwaga! Twój post zawiera obrazek o szerekości większej niż 500 pixeli.\n\n'
+'Wysłanie go w obecnej postaci zaburzy estetyczne ładowanie się tematu.\n'
+'By tego uniknąć do tak szerokich obrazków nie używaj [img] lecz [imgb].\n\n'
+'W tym przypadku powinieneś zmienić na:\n[imgb]'+img.src+'[/imgb]\n\n'
+'Inaczej mówiąc: dopisz w dwóch miejscach literkę "b" i będzie git.');
	}
}
function setlogo(id)
{
	try { xmlHttp=new XMLHttpRequest(); }
	catch (e) {
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("AJAX error!"); return null; }
		}
	}
	xmlHttp.open("GET","aj.php?s="+sid+"&x=log&i="+id,true);
	xmlHttp.send(null);
	document.getElementById('thelogo').src = id!=6 ? "pics/logo"+id+".jpg" : "http://img6.imageshack.us/img6/60/banerruchomydj7.gif";
}
function gaj() {
	try { xmlHttp=new XMLHttpRequest(); }
	catch (e) {
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) { alert("AJAX error!"); return null; }
		}
	}
	return xmlHttp;
}
function wag(tid,sel,id,u)
{
	var xmlHttp = gaj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('st'+id).innerHTML = '<i style="color:blue">Nowa waga zapisana</i>';
			document.getElementById('ocena').innerHTML = xmlHttp.responseText;
		}
	}
	document.getElementById('st'+id).innerHTML = '<i style="color:red">Zapisywanie nowej wagi...</i>';
	xmlHttp.open("GET","aj.php?s="+sid+"&x=wag&t="+tid+"&w="+sel.selectedIndex+"&u="+u,true);
	xmlHttp.send(null);
}
function sco(tid,sel)
{
	xmlHttp = gaj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('ocena1').innerHTML = xmlHttp.responseText;
			document.getElementById('votd'+sel).bgColor = "#7083F7";
			document.getElementById('vott'+sel).bgColor = "#F7D0F7";
		}
	}
	xmlHttp.open("GET","aj.php?s="+sid+"&x=oce&t="+tid+"&o="+sel,true);
	xmlHttp.send(null);
	for(i=0; i<=5; i++) {
	    if (document.getElementById('votd'+i) == null)  continue;
		document.getElementById('votd'+i).bgColor = document.getElementById('vott'+i).bgColor = "white";
	}
	document.getElementById('ocena1').innerHTML = "<i>zapisywanie<br>głosu...</i>";
}
function pod(cnt)
{
  el = document.getElementById('sim0');
  tmp = el.style.display;
  el.style.display = 'none';
  for(i=4; i<=cnt; i++) {
    el = document.getElementById('sim'+i);
    if(el==null) return;
    el.style.display = tmp;
  }
}
function sh() {
  document.getElementById('kli').style.display = 'none';
  document.getElementById('simform').style.display = 'block';
}
function simxx(url,tid)
{
 xmlHttp = gaj();
 xmlHttp.onreadystatechange=function() {
  if(xmlHttp.readyState==4) {
   document.getElementById('simform').innerHTML = xmlHttp.responseText;
  }
 }
 xmlHttp.open("GET","aj.php?x=sim&t="+tid+"&u="+url,true);
 xmlHttp.send(null);
 document.getElementById('simform').innerHTML = "<i>zapisywanie...</i>";
}
function v2t(v) {
	if (v==0)  return '<b style="color:red">NIE</b>';
	else  if (v==1)  return '<b style="color:green">TAK</b>';
	else  if (v==2)  return '<b style="color:gray">Nie wiem</b>';
	else return "<i>brak</i>"
}
function glo(val,sid,id) {
	a = document.getElementById('oce');
	xmlHttp = gaj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			a.innerHTML = v2t(_tc(xmlHttp.responseXML,'V'));
			if (admin)  getvoters(id);
		}
	}
	xmlHttp.open("GET","aj.php?s="+sid+"&x=pod&i="+id+"&w="+val,true);
	xmlHttp.send(null);
	a.innerHTML = '<i style="color:blue">Zapisywanie...</i>';
}
function usearch(str)
{
	if (str.length==0) {
		document.getElementById("livesearch").innerHTML="";
		document.getElementById("livesearch").style.border="0px";
		return;
	}
	xmlhttp=gaj();
	if (xmlhttp==null) {
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
			document.getElementById("livesearch").style.border="1px solid #A5ACB2";
		}
	};
	xmlhttp.open("GET","aj.php?x=use&q="+str+"&s="+sid,true);
	xmlhttp.send(null);
}
