var placemark_id_for_vote = -1; 
var user_id_for_vote =-1;
var req;
function $(o) { return((typeof(o)=='object'?o:document).getElementById(o)); } 
function $S(o) { return($(o).style); } 
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); } 
function abPos(o) { var o=(typeof(o)=='object'?o:$(o)), z={X:0,Y:0}; 
while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; 
return(z); }  
function XYrate(e,v) { var o=agent('msie')?{'X':event.clientX+document.body.scrollLeft+ document.documentElement.scrollLeft ,'Y':event.clientY+document.body.scrollTop+ document.documentElement.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); } 

var star=
{ /* Mouse Events */ 
	'cur':function(e,o) { 
		if(star.stop) 
		{ 
			star.stop=0; 
			document.onmousemove=function(e) { 
				var n=star.num; 
				var p=abPos($('star'+n)), x=XYrate(e), oX=x.X-p.X, oY=x.Y-p.Y; 
				star.num=o.id.substr(4); 
				if(oX<1 || oX>84 || oY<0 || oY>19) 
				{ 
					star.stop=1; star.revert(); 
				} 
				else 
				{ 
					$S('starCur'+n).width=oX+'px'; 
					$S('starUser'+n).color='#111'; 
					$('starUser'+n).innerHTML=Math.round(oX/84*100)+'%';
				} 
			}; 
		} 
	}, 
	'update':function(e,o) { 
		var n=star.num, v=parseInt($('starUser'+n).innerHTML); 
		n=o.id.substr(4); 
		$('starCur'+n).title=v; 
		req=new XMLHttpRequest(); 
		req.onreadystatechange=stateChanged ;
		req.open('GET','vote.php?t=placemark&user_id=' + user_id_for_vote + '&id=' + placemark_id_for_vote + '&vote=' +(v/100),true); 
		req.send(null); 
	}, 
	'revert':function() { 
		var n=star.num, v= $('starCur'+n).title ; 
		if(!isNaN(v)) $S('starCur'+n).width=Math.round(v*84/100)+'px'; 
		$('starUser'+n).innerHTML=(!isNaN(v)&&v>0?'Your rate: '+Math.round(v)+'%':v); 
		$('starUser'+n).style.color='#888'; 
		document.onmousemove=''; 
	}, /* Data */ 
	'stop':1, 
	'num':0 
};


var starW=
{ /* Mouse Events */ 
	'cur':function(e,o) { 
		if(star.stop) 
		{ 
			star.stop=0; 
			document.onmousemove=function(e) { 
				var n=star.num; 
				var p=abPos($('star'+n)), x=XYrate(e), oX=x.X-p.X, oY=x.Y-p.Y; 
				star.num=o.id.substr(4); 
				if(oX<1 || oX>84 || oY<0 || oY>19) 
				{ 
					star.stop=1; star.revert(); 
				} 
				else 
				{ 
					$S('starCur'+n).width=oX+'px'; 
					$S('starUser'+n).color='#111'; 
					$('starUser'+n).innerHTML=Math.round(oX/84*100)+'%';
				} 
			}; 
		} 
	}, 
	'update':function(e,o) { 
		var n=star.num, v=parseInt($('starUser'+n).innerHTML); 
		n=o.id.substr(4); 
		$('starCur'+n).title=v; 
		req=new XMLHttpRequest(); 
		req.onreadystatechange=stateChanged ;
		req.open('GET','vote.php?t=wikipoi&user_id=' + user_id_for_vote + '&id=' + wikipoi_id_for_vote + '&vote=' +(v/100),true); 
		req.send(null); 
	}, 
	'revert':function() { 
		var n=star.num, v= $('starCur'+n).title ; 
		if(!isNaN(v)) $S('starCur'+n).width=Math.round(v*84/100)+'px'; 
		$('starUser'+n).innerHTML=(!isNaN(v)&&v>0?'Your rate: '+Math.round(v)+'%':v); 
		$('starUser'+n).style.color='#888'; 
		document.onmousemove=''; 
	}, /* Data */ 
	'stop':1, 
	'num':0 
};

var starTrip=
{ /* Mouse Events */ 
	'cur':function(e,o) { 
		if(star.stop) 
		{ 
			star.stop=0; 
			document.onmousemove=function(e) { 
				var n=star.num; 
				var p=abPos($('star'+n)), x=XYrate(e), oX=x.X-p.X, oY=x.Y-p.Y; 
				star.num=o.id.substr(4); 
				if(oX<1 || oX>84 || oY<0 || oY>19) 
				{ 
					star.stop=1; star.revert(); 
				} 
				else 
				{ 
					$S('starCur'+n).width=oX+'px'; 
					$S('starUser'+n).color='#111'; 
					$('starUser'+n).innerHTML=Math.round(oX/84*100)+'%';
				} 
			}; 
		} 
	}, 
	'update':function(e,o) { 
		var n=star.num, v=parseInt($('starUser'+n).innerHTML); 
		n=o.id.substr(4); 
		$('starCur'+n).title=v; 
		req=new XMLHttpRequest(); 
		req.onreadystatechange=stateChanged ;
		req.open('GET','vote.php?t=trip&user_id=' + user_id_for_vote + '&id=' + trip_id_for_vote + '&vote=' +(v/100),true); 
		req.send(null); 
	}, 
	'revert':function() { 
		var n=star.num, v= $('starCur'+n).title ; 
		if(!isNaN(v)) $S('starCur'+n).width=Math.round(v*84/100)+'px'; 
		$('starUser'+n).innerHTML=(!isNaN(v)&&v>0?'Your rate: '+Math.round(v)+'%':v); 
		$('starUser'+n).style.color='#888'; 
		document.onmousemove=''; 
	}, /* Data */ 
	'stop':1, 
	'num':0 
};


function stateChanged() 
{ 
	if (req.readyState==4 || req.readyState=="complete")
 	{  
		document.getElementById("starTotal").innerHTML=req.responseText ;
 	} 
}
function placemarkStateChanged() 
{ 
	if (req.readyState==4 || req.readyState=="complete")
 	{  
		document.getElementById("placemarkList").innerHTML = req.responseText ;
 	} 
}