$(document).ready(function() {

    var mouseX = 0;
    var mouseY = 0;
    $().mousemove(function(e){
        mouseX = e.pageX; mouseY = e.pageY; /* cache mouse x and y in globals */
    });

    $.fn.setXY = function(x, y) {
        $(this).css('top', y).css('left', x);
    }
    $.fn.slideTo = function(x, y, time) {
        $(this).animate({ top: x, left: y }, time);
    }

    $whee = $('.wheel div');

    $whee.hide();

    var raylength = 300;
    var arclength = Math.PI / (1.9);  // 2.0 fails with IE 6 ... WHY??
    var raystep = arclength / $whee.length;
    var rayangle = $whee.length * raystep;
    var offset = $('h1').offset();
    var fn = function() {
        $whee.fadeIn(300);
        $whee.each(function() {
            var $this = $(this);
            var x = Math.cos(rayangle) * raylength;
            var y = Math.sin(rayangle) * raylength;
            $this.css('position', 'relative').setXY(offset.left, offset.top);
            // ie 6 just can't handle opacity...
            //$this.animate({opacity:1, top: x+75, left: y}, 350);
            //$this.slideTo(x + 50, y, 250);
            $this.animate({top:x, left: y}, 250);
            rayangle -= raystep;
        });
    };
    setTimeout(fn, 250);

});

