﻿function Show_Sub(id_num, num) { //舌签功能
    for (var i = 0; i <= 9; i++) {
        if ($("#S_Menu_" + id_num + i)) {$("#S_Menu_" + id_num + i).attr("class", ""); }
        if ($("#S_Cont_" + id_num + i)) { $("#S_Cont_" + id_num + i).hide(); }
		if ($("#S_More_" + id_num + i)) { $("#S_More_" + id_num + i).hide(); }
    }
    if ($("#S_Menu_" + id_num + num)) { $("#S_Menu_" + id_num + num).attr("class", "current"); }
    if ($("#S_Cont_" + id_num + num)) { $("#S_Cont_" + id_num + num).show(); }
	if ($("#S_More_" + id_num + num)) { $("#S_More_" + id_num + num).show(); }
}

//文字左右滚动
jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.03
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;		
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");					
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).width();
				});
				$strip.width(stripWidth);			
				var defTiming = stripWidth/settings.travelocity;
				var totalTravel = stripWidth+containerWidth;								
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};

//图片左右滚动
(function ($) {
    $.fn.extend({
        Scroll: function (opt, callback) {
            //参数初始化
            if (!opt) var opt = {};
            var _btnUp = $("#" + opt.up); //Shawphy:向上按钮
            var _btnDown = $("#" + opt.down); //Shawphy:向下按钮
            var timerID;
            var _this = this.eq(0).find("ul:first");
            var lineH = _this.find("li:first").width(), //获取行高
                        line = opt.line ? parseInt(opt.line, 10) : parseInt(this.height() / lineH, 10),
                        speed = opt.speed ? parseInt(opt.speed, 10) : 500; //卷动速度，数值越大，速度越慢（毫秒）
            timer = opt.timer //?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
            if (line == 0) line = 1;
            var upHeight = 0 - line * lineH;
            //滚动函数
            var scrollUp = function () {
                _btnUp.unbind("click", scrollUp); //Shawphy:取消向上按钮的函数绑定
                _this.animate({
                    marginLeft: upHeight
                }, speed, function () {
                    for (i = 1; i <= line; i++) {
                        _this.find("li:first").appendTo(_this);
                    }
                    _this.css({ marginLeft: 0 });
                    _btnUp.bind("click", scrollUp); //Shawphy:绑定向上按钮的点击事件
                });

            }
            //Shawphy:向下翻页函数
            var scrollDown = function () {
                _btnDown.unbind("click", scrollDown);
                for (i = 1; i <= line; i++) {
                    _this.find("li:last").show().prependTo(_this);
                }
                _this.css({ marginLeft: upHeight });
                _this.animate({
                    marginLeft: 0
                }, speed, function () {
                    _btnDown.bind("click", scrollDown);
                });
            }
            //Shawphy:自动播放
            var autoPlay = function () {
                if (timer) timerID = window.setInterval(scrollUp, timer);
            };
            var autoStop = function () {
                if (timer) window.clearInterval(timerID);
            };
            //鼠标事件绑定
            _this.hover(autoStop, autoPlay).mouseout();
            _btnUp.css("cursor", "pointer").click(scrollUp).hover(autoStop, autoPlay); //Shawphy:向上向下鼠标事件绑定
            _btnDown.css("cursor", "pointer").click(scrollDown).hover(autoStop, autoPlay);

        }
    })
})(jQuery);
/*
==轮播{对象|对象属性}==
对象属性{宽度|高度|文字大小|自动切换时间}
*/
function dk_slideplayer(object,config){
	this.obj = object;
	this.config = config ? config : { width: "300px", height: "200px", fontsize: "12px", right: "10px", bottom: "10px", time: "5000", istext: "1" };
	this.pause = false;
	var _this = this;
	if (!this.config.istext) {
	    this.config.istext = "1";
	}
	if(!this.config.right){
		this.config.right = "0px"
	}
	if(!this.config.bottom){
		this.config.bottom = "3px"
	}
	if(this.config.fontsize == "12px" || !this.config.fontsize){
		this.size = "12px";
		this.height = "21px";
		this.right = "6px";
		this.bottom = "10px";
	}else if(this.config.fontsize == "14px"){
		this.size = "14px";
		this.height = "23px";
		this.right = "6px";
		this.bottom = "15px";
	}
	this.count = jQuery(this.obj + " li").size();
	this.n =0;
	this.j =0;
	var t;
	this.factory = function () {
	    //alert(config.istext);
	    jQuery(this.obj).css({ position: "relative", zIndex: "0", margin: "0", padding: "0", width: this.config.width, height: this.config.height, overflow: "hidden" })
	    jQuery(this.obj).prepend("<div style='position:absolute;z-index:20;right:" + this.config.right + ";bottom:" + this.config.bottom + "'></div>");
	    jQuery(this.obj + " li").css({ width: "100%", height: "100%", overflow: "hidden" }).each(function (i) { if (config.istext == "1") { jQuery(_this.obj + " div").append("<a>" + (i + 1) + "</a>") } else { jQuery(_this.obj + " div").append("<a style='display:none'>" + (i + 1) + "</a>") } });

	    jQuery(this.obj + " img").css({ border: "none", width: "100%", height: "100%" })

	    if (config.istext == "1") {
	        this.resetclass(this.obj + " div a", 0);

	        jQuery(this.obj + " p").each(function (i) {
	            jQuery(this).parent().append(jQuery(this).clone(true));
	            jQuery(this).html("");
	            jQuery(this).css({ position: "absolute", margin: "0", padding: "0", zIndex: "1", bottom: "0", left: "0", height: _this.height, width: "100%", background: "#000", opacity: "0.4", overflow: "hidden" })
	            jQuery(this).next().css({ position: "absolute", margin: "0", padding: "0", zIndex: "2", bottom: "0", left: "0", height: _this.height, lineHeight: _this.height, textIndent: "5px", width: "100%", textDecoration: "none", fontSize: _this.size, color: "#FFFFFF", background: "none", zIndex: "1", opacity: "1", overflow: "hidden", "font-family": "宋体", cursor: "pointer" })
	            if (i != 0) { jQuery(this).hide().next().hide() }
	        });
	    }

	    this.slide();
	    this.addhover();
	    t = setInterval(this.autoplay, this.config.time);
	}

	this.slide = function () {
	    jQuery(this.obj + " div a").mouseover(function () {
	        _this.j = jQuery(this).text() - 1;
	        _this.n = _this.j;
	        if (_this.j >= _this.count) { return; }
	        jQuery(_this.obj + " li").hide();
	        jQuery(_this.obj + " p").hide();
	        if (config.istext != "1") {
	            jQuery(_this.obj + " div a").hide();
	        }
	        jQuery(_this.obj + " li").eq(_this.j).fadeIn("slow");
	        if (config.istext == "1") {
	            jQuery(_this.obj + " li").eq(_this.j).find("p").show();
	            _this.resetclass(_this.obj + " div a", _this.j);
	        }
	    });
	}

	this.addhover = function(){
		jQuery(this.obj).hover(function(){clearInterval(t);}, function(){t = setInterval(_this.autoplay,_this.config.time)});
	}
	
	this.autoplay = function(){
		_this.n = _this.n >= (_this.count - 1) ? 0 : ++_this.n;
		jQuery(_this.obj + " div a").eq(_this.n).triggerHandler('mouseover');
	}
	
	this.resetclass =function(obj,i){
		jQuery(obj).css({float:"left",marginRight:"3px",width:"15px",height:"14px",lineHeight:"15px",textAlign:"center",fontWeight:"800",fontSize:"12px",color:"#000",background:"#FFFFFF",cursor:"pointer"});
		jQuery(obj).eq(i).css({color:"#FFFFFF",background:"#FF7D01",textDecoration:"none"});
	}

	this.factory();
}
