window.onload = function () {
                var src = document.getElementById("arrow").src,
                    angle = 0;
                document.getElementById("holder").innerHTML = "";
                var R = Raphael("holder", 215, 215);
                R.circle(107.5, 107.5, 107.5).attr({stroke: "none"});
                var img = R.image(src, 0, 0, 215, 215);
				
				var australia = document.getElementById("australia");
				var europa = document.getElementById("europa"); 
				var olanda = document.getElementById("olanda");
				var italia_monza = document.getElementById("italia-monza");
				var usa = document.getElementById("usa");
				var sanmarino = document.getElementById("sanmarino");
				var spagna = document.getElementById("spagna");
				var repceca = document.getElementById("repceca");
				var uk = document.getElementById("uk");
				var germania = document.getElementById("germania");
				var italia_imola = document.getElementById("italia-imola");				
				var francia = document.getElementById("francia");
				var portogallo = document.getElementById("portogallo");
				
								
				id1 = -31;
				id2 = -16;
				id3 = 0;
				id4 = 16;
				id5 = 32;
				id6 = 47;
				id7 = 63;
				id8 = 79;
				id9 = 95;
				id10 = 111;
				id11 = 127;
				id12 = 142;
				id13 = 158;
				
				anno = "2011";
				
				/* determina posizione iniziale */
								
				
				$.post( "showDets.php", function(initQ){											  
											
						current_angle = window["id"+initQ];	
						
						img.animate({rotation: current_angle}, 500, "<>");
							$.post( "showDets.php?id="+initQ+"&anno="+anno, function(theResponse){
								$("#display").html(theResponse);
							});	
				});	
				
				
				
				/* Aggiungere tempi diversi di rotazione a seconda della distanza fra le gare */
				
				
				
				australia.onclick = function () {
    				angle = id1;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=1&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
						
					});	
				};
				
				europa.onclick = function () {
    				angle = id2;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=2&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				olanda.onclick = function () {
    				angle = id3;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=3&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				italia_monza.onclick = function () {
    				angle = id4;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=4&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				usa.onclick = function () {
    				angle = id5;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=5&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				sanmarino.onclick = function () {
    				angle = id6;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=6&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				spagna.onclick = function () {
    				angle = id7;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=7&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				repceca.onclick = function () {
    				angle = id8;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=8&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				uk.onclick = function () {
    				angle = id9;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=9&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				germania.onclick = function () {
    				angle = id10;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=10&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				italia_imola.onclick = function () {
    				angle = id11;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=11&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				francia.onclick = function () {
    				angle = id12;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=12&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
				portogallo.onclick = function () {
    				angle = id13;
                    img.animate({rotation: angle}, 500, "<>");
					$.post( "showDets.php?id=13&anno="+anno, function(theResponse){
						$("#display").html(theResponse);
					});	
				};
				
                setTimeout(function () {R.safari();});
            };
