var _c = _h = 0;
var _q=-1;
$(function(){
    $("#pic img").each(function(i){
        $("#play").append('<a href="javascript:void(0);" alt="'+(i+1)+'">'+(i+1)+'</a>');
		_q++;
    });
    
    //$("#tips").html($("#pic img:first").attr("data"));
    
    $('#play>a').click(function(){
        var i = $(this).attr('alt') - 1;
        clearInterval(_h);
        _c = i;
        play();
        change(i);
    })
    $("#pic img").hover(function(){clearInterval(_h)}, function(){play()});
    play();
})
function play()
{
    _h = setInterval("auto()", 5000);
}
function change(i)
{
    $('#play > a').css('background-color','#002C9C').eq(i).css('background-color','#00A69E').blur();
    $("#pic img").hide('fast',function(){$("#pic img").eq(i).css({left: -$(this).width()/2, top: -$(this).height()/2}).width(''+$(this).width()*2).height(''+$(this).height()*2);} ).eq(i).animate({left:'0px', top: '0px', width: '377px', height:'320px', opacity:'show'}, 900);
   
	//$("#tips").html($("#pic img").eq(i).attr("data"));
}
function auto()
{    
    _c = _c >= _q ? 0 : _c + 1;
    change(_c);
}



