var rotatingObject = function(obj)
 {   
	var x,y; 
	var eingrad = Math.PI/180;
	var pivotX,pivotY;
	var isclicked = false;
	var speed = 1;
	var radius;
	var url = obj.href;
	var width  =  obj.firstChild.width;
	var height =  obj.firstChild.height;
	
	
	obj.style.position = 'absolute';
	obj.onclick = function() { 
	
	if(isclicked || rotation)return false;
	this.blur(); this.parentNode.blur();
	resetall();
	isclicked = true;
	
	drehen();
	return false;
	 }  
	 
	this.reset = function(){obj.firstChild.style.width = width+'px';obj.firstChild.style.height = height+'px';} 
	this.setPivot = function(xx,yy) { pivotX = xx; pivotY = yy; }
	this.setPercent = function(p) {
	
	  p = p/100;
	  width = obj.firstChild.width * p;
	  height = obj.firstChild.height * p;
	  obj.firstChild.style.width = width + 'px';
	  obj.firstChild.style.height = height + 'px';
	}

	
this.allowRotation = function()
{
	isclicked = false;
}

this.denyRotation = function()
{
	isclicked = true;
}
	
this.setXY = function(xx,yy)
{
	x = xx;
	y = yy;
}

this.setRadiusGrad = function(r,g)
{

	radius = r;
	x = r * Math.cos(eingrad * g);
	y = r * Math.sin(eingrad * g); obj.style.left = pivotX + x + 'px'; obj.style.top = pivotY + y + 'px';
	
} 
	  
	  
this.setSpeed = function(value) { speed = value; }
	   
this.rotate = function() {  
	   
	   if(isclicked && (Math.floor(y + 0.1) == radius))
	   {
	    new Effect.Scale(obj, 50,{scaleFromCenter:false,duration:0});
	    new Effect.Scale(obj, 200,{scaleFromCenter:true,duration:0.5,afterFinishInternal:function(){location.href = url;}});
	   	new Effect.Scale(obj.firstChild, 200,{scaleFromCenter:true,duration:0.5,afterFinishInternal:function(){/*location.href = url;*/}});
	   	stop = true;
	   }
	   x1 = x * Math.cos(eingrad*speed) - y * Math.sin(eingrad*speed);
       y1 = x * Math.sin(eingrad*speed) + y * Math.cos(eingrad*speed);

       x = x1;
       y = y1;

       obj.style.left = pivotX + x + 'px';
	   obj.style.top = pivotY + y + 'px'; 
}  
	   
this.getX = function() { return x; }
this.getY = function() { return y; }
this.getURL = function() {  return url; }   }





	   var counter = 0;
	   var stop = false;
	   var buttons = new Array();
	   var rotation = false;
	   
	   var denyAction = function()
	   {
	   		 for(var i=0; i < buttons.length; i++)
			 {
		 	  buttons[i].denyRotation();
		 	 }
	   }
	   
	   var resetall = function()
	   {
	   		 for(var i=0; i < buttons.length; i++)
			 {
		 	  buttons[i].reset();
		 	 }
	   }
	   
	   var drehen = function() {
	   
	     rotation = true;
	     if(stop){
		 rotation = false;
		 stop=false;
		 for(var i=0; i < buttons.length; i++)
		 {
		 buttons[i].allowRotation();
		 }
		 
		 return false;
		 }
		 for(var i=0; i < buttons.length; i++) {
         buttons[i].rotate();
		 }

         setTimeout('drehen()',10);

       }


