var delayTime = 5000;
var isPlay=true;

jQuery(document).ready(function(){
    $('#prev').click(function(){
        $('#homeNews li:visible').fadeOut('fast', function(){
            if ($(this).prev().is('li')) {
                $(this).prev().fadeIn('fast');
            }
            else {
                $("#homeNews li:last").fadeIn('fast');
            }
        });
    });
    $('#next').click(function(){
        $('#homeNews li:visible').fadeOut('fast', function(){
            if ($(this).next().is('li')) {
                $(this).next().fadeIn('fast');
            }
            else {
                $('#homeNews li:first').fadeIn('fast');
            }
        });
    });
    var b, a = function(){
        $('#next').trigger('click');
        b = setTimeout(a, delayTime);
    };
    commOver('#homeNews');
    commOver('#prev');
	commOver('#stop');
    commOver('#next');
    b = setTimeout(a, delayTime);
	
    //设置感应的时候清除时间
    function commOver(obj){
        $(obj).hover(function(){
            clearTimeout(b);
        }, function(){
			if(isPlay){
            	b = setTimeout(a, delayTime);
			}
        });
    }
	
	$('#stop').click(function(){
		
		if(isPlay){
			isPlay=false;
			clearTimeout(b);
			//$('#stop').css("background-position","-93px 0");
			$('#stop').hide();
			$('#stop2').show();
		}else{
			isPlay=true;
			//$('#stop').css("background-position","-14px 0px");
			$('#stop').show();
			$('#stop2').hide();
		}
	});
	
	$('#stop2').click(function(){
		
		if(isPlay){
			isPlay=false;
			clearTimeout(b);
			//$('#stop').css("background-position","-93px 0");
			$('#stop').hide();
			$('#stop2').show();
		}else{
			isPlay=true;
			//$('#stop').css("background-position","-14px 0px");
			$('#stop').show();
			$('#stop2').hide();
		}
	});
    
});

