var status = null;
var hornet = null;
var motionMillisPause = 20;
var animMillisPause = 80;
var radianStep = .02;
var count_y = 0;

var up = true;
var count_frame = 0;

function loadHornet() {

	hornet = document.getElementById("hornet");
    hornet.style.display = "block";
	hornet.style.position = "absolute";

    animate();
	move();

}

function animate() {
    if ( up )
        count_frame++;
    else
        count_frame--;
        
    if (count_frame == 6) 
        up = false; // count down next time
        
    if (count_frame == 0) 
        up = true; // count up next time
        
    switch( count_frame ) {
        case 0:
            var pos = "0 0px";
            break;
        case 1:
            var pos = "-64 0px";
            break;
        case 2:
            var pos = "-128 0px";
            break;
        case 3:
            var pos = "-192 0px";
            break;
        case 4:
            var pos = "-256 0px";
            break;
        case 5:
            var pos = "-320 0px";
            break;
        case 6:
            var pos = "0 -64px";
            break;
        case 7:
            var pos = "-64 -128px";
            break;

        default: 
            alert( "not 0-7" );
            break;
            
            
    }
    hornet.style.backgroundPosition = pos;
    setTimeout( animate, animMillisPause );
}

function move() { 
	count_y = count_y + radianStep;
	count_y = count_y > 6.28 ? 0 : count_y;

	// circle
	//var x = smiley.style.left = 200 + 50* Math.cos(count) + "px";
	
	// up and down with "dampening"
    // If you specify an X value, then you need to change the position
    // value to relative, in order to prevent the hornet from moving around
    // based on browser window size - however this creates a big 64px space
    // in your page.
	//var x = hornet.style.left = 200 + "px";


	var y = hornet.style.top = 330 + 50 * Math.sin(count_y) + "px";
	
	setTimeout(move, motionMillisPause);

}


