szavaz_id=false;
szavaz_w=0;
szavaz_txt=false;
szavaz_o=0;
szavaz_k=0;
szavaz_maxp=0;
sz_out=[];
szavaz_out_ev=false;
function szavaz_on(i, e, k, w, h, maxp, atip) {
	if (szavaz_id===false) {
		if (sz_out[i]) {
			window.clearTimeout(sz_out[i]);
			sz_out[i]=false;
		}
		if (szavaz_txt===false && document.getElementById('szavaz_txt')) {
			szavaz_txt=document.getElementById('szavaz_txt').value.split('|');
		}
		szavaz_p=0;
		document.getElementById('e1_'+i).style.backgroundPosition='0 '+h+'px';
		document.getElementById('e2_'+i).style.backgroundPosition='0 '+h+'px';
		szavaz_o=document.getElementById('e2_'+i).style.width;
		szavaz_id=i;
		szavaz_w=w;
		szavaz_k=k;
		szavaz_maxp=maxp;
		e.onmousemove=szavaz;
		szavaz_tip=atip;
		e.onclick=szavaz_click;
	}
}
function szavaz_on2(i) {
	if (szavaz_id==i) {
		if (sz_out[i]) {
			window.clearTimeout(sz_out[i]);
			sz_out[i]=false;
		}
	}
}
function szavaz_out() {
	if (szavaz_id!==false) {
		if (sz_out[szavaz_id]) {
			window.clearTimeout(sz_out[szavaz_id]);
		}
		sz_out[szavaz_id]=window.setTimeout("szavaz_out2("+szavaz_id+")", 200);
	}
}
function szavaz_out2(i) {
	var v;
	if (szavaz_out_ev===false) {
		szavaz_out_ev=document.getElementById('e1_'+i).onmouseover;
		document.getElementById('e1_'+i).onmouseover=null;
		v=true;
	} else {
		v=false;
	}

	document.getElementById('e1_'+i).onmousemove=null;
	document.getElementById('e1_'+i).onclick=null;
	document.getElementById('e1_'+i).style.backgroundPosition='0 0';
	document.getElementById('e2_'+i).style.backgroundPosition='0 0';
	document.getElementById('e3_'+i).style.display='none';
	document.getElementById('e2_'+i).style.width=szavaz_o;

	if (v) {
		window.setTimeout("document.getElementById('e1_"+i+"').onmouseover=szavaz_out_ev;szavaz_out_ev=false;", 100);
	}

	sz_out[i]=false;
	if (szavaz_id==i)
		szavaz_id=false;
}
function szavaz(event) {
	if (szavaz_id!==false) {
		if (!event)
			event = window.event;
		var x = event ? event.offsetX?event.offsetX:(event.layerX?event.layerX:0) : 0;
		var p = Math.ceil(x/szavaz_w*szavaz_maxp);
		document.getElementById('e2_'+szavaz_id).style.width=Math.round(p*szavaz_w/szavaz_maxp)+'px';
		if (szavaz_p!=p) {
			szavaz_p=p;
			var v=(szavaz_txt[szavaz_p-1]!=undefined);
			if (v!=(document.getElementById('e3_'+szavaz_id).style.display=='block')) document.getElementById('e3_'+szavaz_id).style.display=v ? 'block' : 'none';
			document.getElementById('e3_'+szavaz_id).innerHTML=szavaz_txt[szavaz_p-1];
			document.getElementById('e3_'+szavaz_id).style.left=Math.round((szavaz_p-1)*szavaz_w/szavaz_maxp /*- document.getElementById('e3_'+szavaz_id).clientWidth */+ szavaz_w/szavaz_maxp/2-1)+'px';
		}
	}
}
function szavaz_click() {
	if (szavaz_id!==false) {
		var xmlHttpReq = false;
		if (window.XMLHttpRequest)
			xmlHttpReq = new XMLHttpRequest();
		// IE
		else if (window.ActiveXObject)
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttpReq.open("POST", "ertekeles_ajax.php", true);
		xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttpReq.onreadystatechange = function() {
			if (xmlHttpReq.readyState == 4) {
				if (xmlHttpReq.status == 200) {
					var a=xmlHttpReq.responseText.split('|');
					if (a.length==7) {
						var tags=document.getElementsByTagName("div");
						var x, w, ww, p;
						for(var i=0; i<tags.length; i++) {
							if ((' '+tags[i].className+' ').indexOf(' sz_'+a[5]+'_'+a[1])!=-1) {
								x=tags[i].id.substr(3);
								w=parseInt(document.getElementById('e1_'+x).style.width);
								ww=(a[2]!=0&&a[4]!=0 ? Math.round(a[3]/a[2]/a[4]*w) : 0)+'px';
								document.getElementById('e2_'+x).style.width=ww;
								document.getElementById('e4_'+x).innerHTML=(a[2]!=0 ? Math.round(a[3]/a[2]*10)/10 : 0)+' ('+a[2]+')';
								if (szavaz_id==x) {
									szavaz_o=ww;
									szavaz_out2(szavaz_id);
								}
							}
						}
					}
				}
        		}
		}
		xmlHttpReq.send('kod='+szavaz_k+'&pont='+szavaz_p+'&tip='+szavaz_tip);
	}
}
