jQuery.fn.switchTab = function(settings) {
    settings = jQuery.extend({
        defaultIndex: 0,
        titOnClassName: "on",
        titCell: "dt span",
        mainCell: "dd",
        delayTime: 250,
        interTime: 0,
        trigger: "click",
        effect: "",
        omitLinks: false,
        debug: ""
    },
    settings,
    {
        version: 120
    });
    this.each(function() {
        var st;
        var curTagIndex = -1;
        var obj = jQuery(this);
        if(settings.omitLinks && settings.titCell.substr(settings.titCell.length-1, 1)=="a"){
            settings.titCell = settings.titCell + "[href^='#']";
        }
        var oTit = obj.find(settings.titCell);
        var oMain = obj.find(settings.mainCell);
        var cellCount = oTit.length;
        var ShowSTCon = function (oi){
            if(oi != curTagIndex){
                if(curTagIndex<0)obj.find(settings.titCell+"."+settings.titOnClassName).removeClass(settings.titOnClassName);
                else oTit.eq(curTagIndex).removeClass(settings.titOnClassName);
                oMain.hide();
                obj.find(settings.titCell + ":eq(" + oi + ")").addClass(settings.titOnClassName);
                if(settings.delayTime <250 && settings.effect != "")settings.effect = "";
                if(settings.effect == "fade"){
                    obj.find(settings.mainCell + ":eq(" + oi + ")").fadeIn({queue: false, duration: 250});
                }else if(settings.effect == "slide"){
                    obj.find(settings.mainCell + ":eq(" + oi + ")").slideDown({queue: false, duration: 250});
                }else{
                    obj.find(settings.mainCell + ":eq(" + oi + ")").show();
                }
                curTagIndex = oi;
            }
        };
        var ShowNext = function (){
            oTit.eq(curTagIndex).removeClass(settings.titOnClassName);
            oMain.hide();
            if(++curTagIndex >= cellCount)curTagIndex = 0;
            oTit.eq(curTagIndex).addClass(settings.titOnClassName);
            oMain.eq(curTagIndex).show();
        };
        ShowSTCon(settings.defaultIndex);
        if(settings.interTime > 0){
            var sInterval = setInterval(function(){
                ShowNext();
            }, settings.interTime);
        }
        oTit.each(function(i, ele){
            if(settings.trigger=="click"){
                jQuery(ele).click(function(){
                    ShowSTCon(i);
                    return false;
                });
            }else if(settings.delayTime > 0){
                jQuery(ele).hover(function(){
                    st = setTimeout(function(){
                        ShowSTCon(i);
                        st = null;
                    }, settings.delayTime);
                },function(){
                    if(st!=null)clearTimeout(st);
                });
            }else{
                jQuery(ele).mouseover(function(){
                    ShowSTCon(i);
                });
            }
        });
    });
    if(settings.debug!="")alert(settings[settings.debug]);
    return this;
};
jQuery.fn.scrollUp = function(settings) {
    settings = jQuery.extend({
        delayTime: 4000,
        sItem: 'li'
    }, settings);
    var obj = jQuery(this);
    this.each(function() {
        var stepScroll = function(){
            var curItem = obj.find(settings.sItem + ":first");
            curItem.animate({
                marginTop: "-" + curItem.height()
            },
            300,
            "",
            function(){
                curItem.appendTo(obj);
                curItem.css("margin-top", "0px");
            });
        };
        setInterval(stepScroll, settings.delayTime);
    });
    return this;
};
function Marquee(marqueeBox, delaytime, direction, itemCell){
    if(delaytime == undefined)delaytime = 50;
    if(direction == undefined)direction = "up";
    if(itemCell == undefined)itemCell = "ul";
    var oMarquee = jQuery(marqueeBox);
    var oMarqueeCon = oMarquee.find(itemCell);
    var oMarqueeCopy = oMarqueeCon.clone(true).insertAfter(oMarqueeCon);
    var ScrollUp = function(){
        if(oMarqueeCopy[0].offsetHeight-oMarquee[0].scrollTop<=0){
            oMarquee[0].scrollTop = 0;
        }else{
            oMarquee[0].scrollTop++;
        }
    }
    var ScrollLeft = function(){
        if(oMarqueeCopy[0].offsetWidth-oMarquee[0].scrollLeft<=0){
            oMarquee[0].scrollLeft = 0;
        }else{
            oMarquee[0].scrollLeft++;
        }
    }
    switch(direction){
        case "left":
            var oScroll=setInterval(ScrollLeft, delaytime);
            oMarquee.hover(function(){
                clearInterval(oScroll);
            }, function(){
                oScroll=setInterval(ScrollLeft, delaytime);
            });
            break;
        case "up":
        default:
            var oScroll = setInterval(ScrollUp, delaytime);
            oMarquee.hover(function(){
                clearInterval(oScroll);
            }, function(){
                oScroll=setInterval(ScrollUp, delaytime);
            });
    }
}
function HeightFix(column, column2, offset){
    var oCol = jQuery(column);
    var oCol2 = jQuery(column2);
    if(offset == undefined)offset = 0;
    if(oCol.height() > oCol2.height()){
        oCol2.height(oCol.height() - offset);
    }else{
        oCol.height(oCol2.height() - offset);
    }
}
function RunGLNL(obj){
    var today = new Date();
    var d = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
    var DDDD = (today.getFullYear()<100 ? today.getFullYear()+1900:today.getFullYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日";
    DDDD = DDDD + " " + d[today.getDay()];
    jQuery(obj).text(DDDD);
}
function hover(obj, className){
    jQuery(obj).hover(function(){
        jQuery(this).addClass(className);
    },function(){
        jQuery(this).removeClass(className);
    });
}