var next=0;
var timeid;
//½¹µãÍ¼ÇÐ»»
$(document).ready(function(){
	    $(".show_img").click(function(){
	        var cur = $(this);
	        next = $("#m_scroll_bar div").index(cur.parent()[0]);
	        var id = cur.attr("relation");
	        $(".box").children().animate({"bottom":"-45px"},"slow");
	        $(".box").fadeOut("slow");
	        $("#"+id).fadeIn("slow");
	        $("#"+id).children().animate({"bottom":"0px"},"fast");
	        clearInterval(timeid);
	        timeid = setInterval("flash()",5000);
	    });
		$("#m_scroll_left_bar").click(function(){
			var left = parseInt($("#m_scroll").attr("scrollLeft"));
			if(left>=300)
			{
				$("#m_scroll").animate({"scrollLeft":left-300},"slow");
				clearInterval(timeid);
	            next=0;
	            $(".show_img").eq(0).click();
			}
		});
		$("#m_scroll_right_bar").click(function(){
			var left = parseInt($("#m_scroll").attr("scrollLeft"));
			if(left<300)
			{
				$("#m_scroll").animate({"scrollLeft":left+300},"slow");
	            clearInterval(timeid);
	            next=4;
	            $(".show_img").eq(4).click();
			}
		});
		$(".leftbutton").click(function(){
		    var left = parseInt($(this).next().attr("scrollLeft"));
		    if(left>=212)
			{
				$(this).next().animate({"scrollLeft":left-212},"slow");
			}
		});
		$(".rightbutton").click(function(){
		    var left = parseInt($(this).prev().attr("scrollLeft"));
		    if(left<212)
			{
				$(this).prev().animate({"scrollLeft":left+212},"slow");
			}
			
		});
	    setTimeout("flash()",5000);
	});

	
	function flash()
    {
	    if(next==7)
	    {
		    next=0;
		    var slash1=parseInt($("#m_scroll").attr("scrollLeft"));
		     $("#m_scroll").animate({scrollLeft:slash1-300},"slow");
	    }
	    else
	    {
		    next++;
		    if(next==4){
		     var slash2=parseInt($("#m_scroll").attr("scrollLeft"));
		     $("#m_scroll").animate({scrollLeft:slash2+300},"6000");
		    }
	    }
    	
	    $(".show_img").eq(next).click();
    	
    } 



