document.observe("dom:loaded", function() {
					 
	document.voting = Array;
	
  $$('.voting').each(function(oVote)
							  {	
							  
							  	if(!oVote.id || oVote.id == "undefined")
								{
									alert('Debug: Voting hat keine Id...');	
								}
							  
							  	document.voting[oVote.id] = $(oVote).getElementsByClassName('innerVoting')[0].style.width;
								
								$(oVote).observe('mouseout', function(elem)								   
								 {
									this.getElementsByClassName('innerVoting')[0].style.width = document.voting[this.id]; 
								 });
								 
								 $(oVote).observe('mousemove', function(elem)								   
								 {
							 
									x =  $(elem).pointerX() - Position.positionedOffset(this)[0];
									p = x * 2; // prozent

									/* Steps ... */
									if(p < 100)
									{
										
										b = false;
										
										if(x < 4)
											b = 0;
										
										if(x < 10 && !b)
											b = 10;
										
										if(x < 20 && !b)
											b = 20;
											
										if(x < 30 && !b)
											b = 30;
											
										if(x < 40 && !b)
											b = 40;
											
										if(x < 50 && !b)
											b = 50;
										
										if(b)
											x = b;
											
										this.getElementsByClassName('innerVoting')[0].style.width = x+"px";
									}
	 
								  }
								  );
								 
								 $(oVote).observe('click', function(elem)								   
								 {
									document.voting[oVote.id] = this.getElementsByClassName('innerVoting')[0].style.width;
									
									id = this.id;
									vote = (this.getElementsByClassName('innerVoting')[0].style.width).substr(0,1);
									
									new Ajax.Request('/Tools/Vote.ashx?id='+id+'&vote='+vote, {
									  onSuccess: function(transport) {
										  alert('Erfolgreich bewertet');
									  }
									});

									
								  }
								  );
							   }
				);
  
  
});
