//
$(document).ready(function(){
var t=false; //定时器
var time=4000; //切换间隔
var speed=500; //滚动时间
var fot=300; //淡出时间
var fin=300; //淡入时间
var i=0; //起始序列						   
var len=$("#list li").length; //滚动内容个数
var wh=200; //每个滚动内容的宽度
$("#info").css({"width": wh*len + "px"});
//标记当前					   
function cur(ele,currentClass){
	ele= $(ele)? $(ele):ele;
	ele.addClass(currentClass).siblings().removeClass(currentClass);
	}
	$("#prev").click(function(){			
		roll(-1);		
		})
	$("#next").click(function(){			
		roll(1);		
		})	
	$("#list li").mouseover(function(){
		checkfade();
		i=$("#list li").index($(this)[0]);	
		if(!$(this).hasClass("cur")){
			fade(i);
			}		
		cur(this,"cur");		
		})
	function roll(j){
        checkroll();
        if (!$("#info").is(":animated")) {
            i+=j;
			if(i!=-1 && i!=len){						
				$("#info").animate({"left" : -(wh*i)+"px"},speed);
				}else if(i==-1){
					i=len-1;
					$("#info").css({"left" : -(wh*(i-1))+"px"});
					$("#info").animate({"left" : -(wh*i)+"px"},speed);
					}else if(i==len){								
						i=0;
						$("#info").css({"left" : -wh+"px"});
						$("#info").animate({"left" : 0+"px"},speed);						
						}	
			cur($("#list li").eq(i) , "cur");			
			 
            }			
		}
    function checkroll(){        
        if($("#info").find(".hide").html()){
            //alert("执行了 checkroll 函数"+index);
            $("#info").find("div").removeClass("hide").show();
            $("#info").css({"left" : -(wh*i)+"px"});
            }
        }
	function fade(k){
		checkfade();
		$("#info").find("div:visible").fadeOut(fot,function(){
			$("#info").find("div").eq(k).fadeIn(fin)
			})
		}

	function checkfade(){
		if(!$("#info").find(".hide").html()){
			$("#info").find("div").not($("#info").find("div").eq(i)).addClass("hide");
			$("#info").css({"left" : 0+"px"});
			}
		}
	function setInt(){
		t=setInterval(function(){roll(1)},time);
		}
	function clearInt(){
		if(t) clearInterval(t);
		}
		
	$("#area").hover(
		function(){ clearInt() },
		function(){ setInt() }
		)	
	$(document).keydown(function(event){ 
		event = event || window.event;
		if(event.keyCode==38 || event.keyCode==37){	
			clearInt();
			roll(-1);
			setInt();
			};
		if(event.keyCode==40 || event.keyCode==39){			
			clearInt();
			roll(1);
			setInt();
			};	
		})
	setInt();	
	})//焦点图
function AutoScroll(obj){
$(obj).find("ul:first").animate({
marginTop:"-50px"
},500,function(){
$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
});
}
$(document).ready(function(){
setInterval('AutoScroll("#scrollDiv")',2000)
});//竖向滚动文字
(function () {
    $.fn.jingcai = function () {
        function repeat(str, n) {
            return new Array( n + 1 ).join(str);
        }
        
        return this.each(function () {
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
                $slider = $wrapper.find('> ul').width(9999),
                $items = $slider.find('> li'),
                $single = $items.filter(':first')
                
                singleWidth = $single.outerWidth(),
                visible = Math.ceil($wrapper.innerWidth() / singleWidth),
                currentPage = 1,
                pages = Math.ceil($items.length / visible);
            if ($items.length % visible != 0) {
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }
            $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li');
            $wrapper.scrollLeft(singleWidth * visible);
            function gotoPage(page) {
                var dir = page < currentPage ? -1 : 1,
                    n = Math.abs(currentPage - page),
                    left = singleWidth * dir * visible * n;
                
                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        page = 1;
                    } else if (page == 0) {
                        page = pages;
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                    }
                    
                    currentPage = page;
                });
            }
            $wrapper.after('<a href="#" class="arrow back">&lt;</a><a href="#" class="arrow forward">&gt;</a>');
            $('a.back', this).click(function () {
                gotoPage(currentPage - 1);
                return false;
            });
            
            $('a.forward', this).click(function () {
                gotoPage(currentPage + 1);
                return false;
            });
            
            $(this).bind('goto', function (event, page) {
                gotoPage(page);
            });
            $(this).bind('next', function () {
                gotoPage(currentPage + 1);
            });
        });
    };
})(jQuery);
 
$(document).ready(function () {
    var autoscrolling = true;
    
    $('.jingcai').jingcai().mouseover(function () {
        autoscrolling = false;
    }).mouseout(function () {
        autoscrolling = true;
    });
    
    setInterval(function () {
        if (autoscrolling) {
            $('.jingcai').trigger('next');
        }
    }, 2000);
});//横向滚动图片

$(function(){
	var span = '<span></span>';
	$('.tab li a').wrapInner(span);
	$('.tab_content ul:gt(0),.tab_content1 ul:gt(0),.tab_content2 ul:gt(0)').hide();
	var menu_li = $('.tab li');
	$('.tab li').mouseover(function(){
		$(this).addClass('selected')
			   .siblings().removeClass('selected');
		var index = menu_li.index(this);
		$('.tab_content ul,.tab_content1 ul,.tab_content2 ul').eq(index).show()
							 .siblings().hide();
		return false;
	});
});//tab变换

