$( document ).ready ( function ()
{
$( ".slides li:first" ).addClass ( "active" );

var imageWidth = $( ".screen" ).width ();
var imageCount = $( ".images img" ).size ();
var sliderWidth = imageWidth * imageCount;

$( ".images" ).css (
{
"width" : sliderWidth
});

$( ".shine" ).attr ( "href", $( ".images li:eq(0) a" ).attr ( "href" ) );

rotate = function ()
{
var index = $( ".slides li" ).index ( $active );
var position = index * imageWidth;

$( ".shine" ).attr ( "href", $( ".images li:eq(" + index + ") a" ).attr ( "href" ) );

$( ".slides li" ).removeClass ( "active" );
$active.addClass ( "active" );

$( ".images" ).animate (
{ 
left: -position
}, 750 );
}; 

rotateSwitch = function()
{
play = setInterval ( function ()
{
$active = $( ".slides li.active" ).next ();

if ( $active.length === 0 )
{
$active = $( ".slides li:first" );
}
rotate ();
}, 4000 );
};

rotateSwitch ();

$( ".shine" ).hover ( function ()
{
clearInterval ( play );
}, function ()
{
rotateSwitch ();
});

$( ".slides li a" ).click ( function ()
{
$active = $( this ).parent ();

clearInterval ( play );
rotate ();
rotateSwitch ();

return false;
});
});
