// JavaScript Document

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

star={};
star.mouse=function(e,o) { if(star.stop || isNaN(star.stop)) { star.stop=0;    document.onmousemove=function(e) { var n=star.num;            var p=abPos(j('star'+n)), x=XY(e), oX=x.X-p.X, oY=x.Y-p.Y; star.num=o.id.substr(4);      
if(oX<1 || oX>240 || oY<0 || oY>25) { star.stop=1; star.revert(); }               
else {  

if((oX > 0 )&& (oX <=24))
{
   val=24;	 
   jS('starCur'+n).width='24px';  
}
else if((oX > 24 )&& (oX <= 48))
  {
  val=48;	 	  
  jS('starCur'+n).width='48px';  
  }
else if((oX > 48 )&& (oX <= 72))
{
  val=72;
  jS('starCur'+n).width='72px';  
}
  
else if((oX > 72 )&& (oX <= 96))
{
  val=96;
  jS('starCur'+n).width='96px';  
}
  
else if((oX > 96 )&& (oX <=120))
{
  val=120;
  jS('starCur'+n).width='120px';  
}
  
else if((oX > 120 )&& (oX <=144))
{
  val=144;
  jS('starCur'+n).width='144px';  
}
  
else if((oX > 144 )&& (oX <=168))
{
  val=168;
  jS('starCur'+n).width='168px'; 
}
  
else if((oX > 168 )&& (oX <=192))
{
  val=192;
  jS('starCur'+n).width='192px';  
}
  
else if((oX > 192 )&& (oX <=216))
{
  val=216;
  jS('starCur'+n).width='216px'; 
}
else
{
  val=240;
 jS('starCur'+n).width='240px';   
}
 
//jS('starUser'+n).color='#111';    
j('starUser'+n).value=val;
//j('starUser'+n).value=Math.round(oX/240*100)+'';      

}    };} };


star.update=function(e,o,id,type) { 
var n=star.num,v=parseInt(j('starUser'+n).value);  
n=o.id.substr(4); j('starCur'+n).title=v;   
document.getElementById("vote_cast#"+id).innerHTML='<img src="images/loading.gif" /> <br /> Please wait...';
 // document.body.style.cursor='wait';
//req=new AjaxObjectCreateGeneral(); 

   try
	{
	// Firefox, Opera 8.0+, Safari
	req=new XMLHttpRequest();

	}
      catch (e)
	{
	// Internet Explorer
	try
	  {
	  req=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	catch (e)
	  {
	  req=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}

req.onreadystatechange=function()
            {
            
			   if (req.readyState==4)
                { 
                   var res=req.responseText;
				 
				   document.getElementById("vote_cast#"+id).innerHTML=res;
					// document.body.style.cursor='auto';
				}
			}


url='cast-member-vote.php?vote='+v+'&id='+id+'&type='+type;
req.open('GET',url,true);
req.send(null);   
};
star.revert=function() { 
var n=star.num,
v=parseInt(j('starCur'+n).title);   
//jS('starCur'+n).width=Math.round(v*240/100)+'px';  
jS('starCur'+n).width=v+'px'; 

j('starUser'+n).value=(v>0?Math.round(v)+'':''); 
 /*j('starUser'+n).innerHTML=(v>0?Math.round(v)+'%':'');   
  j('starUser'+n).style.color='#888';      */ 
   document.onmousemove='';};star.num=0;

