var hot_ball_bounce =
{
/*120 x 1906*/
	init: function()
	{
		//gif is positioned at top left of image at 0,0, positive position down
		hot_ball_bounce.div = document.getElementById("hot_ball");
		hot_ball_bounce.frameHeight = 100; //distance to move to next image position
		hot_ball_bounce.windowheight = 500; //defined in main css definition
		hot_ball_bounce.bounceheight = hot_ball_bounce.windowheight- hot_ball_bounce.frameHeight; //initial height = frame then reduces using a function
		hot_ball_bounce.deltaT = 20.0; //ms iteration period
		hot_ball_bounce.droptime = 1.5; //seconds to drop over full distance
		hot_ball_bounce.rate = (2.0*Math.PI/hot_ball_bounce.droptime);
		hot_ball_bounce.time = 0.0; //cumulative time
		hot_ball_bounce.frames = 2; //number of repeated cycles of bounce
		hot_ball_bounce.originx = parseInt(Core.getComputedStyle(hot_ball_bounce.div, "left"), 10);
		hot_ball_bounce.originy = 0;
		hot_ball_bounce.offsetY = parseInt(Core.getComputedStyle(hot_ball_bounce.div, "top"), 10); //holds the offset releative to o,o positive down
		hot_ball_bounce.bounceheightdecay=0;
		/* Include this code to run animation on opening the page */
		hot_ball_bounce.animate();
	},

	animate: function()
	{
		hot_ball_bounce.time+=(hot_ball_bounce.deltaT)/1000; //cmulative time, convert deltaT to seconds
		//simple harmonic motion
		hot_ball_bounce.originy = hot_ball_bounce.offsetY+0.5*((hot_ball_bounce.bounceheight)+hot_ball_bounce.bounceheight*(Math.cos(hot_ball_bounce.rate*hot_ball_bounce.time+Math.PI)));//simple harmonic motion
		//modify frame position
		hot_ball_bounce.div.style.left = Math.round(hot_ball_bounce.originx) + "px";
		hot_ball_bounce.div.style.top = Math.round(hot_ball_bounce.originy) + "px";

		hot_ball_bounce.timer = setTimeout(hot_ball_bounce.animate, hot_ball_bounce.deltaT);
	
		/* Use this code to play the animation once then stop */
		if(hot_ball_bounce.time >= hot_ball_bounce.droptime*hot_ball_bounce.frames)
		{
			//hot_ball_bounce.div.style.backgroundPosition = "0 " + hot_ball_bounce.offsetY + "px";

			/* Stop the animation */
			clearTimeout(hot_ball_bounce.timer);
			hot_ball_bounce.div.style.background = "url(images/socket.jpg) no-repeat -8px -8px";
		}
	}}

/* Ensure the javascript only runs on completion of page load */
Core.start(hot_ball_bounce);
