﻿function qiehuan(num){
    for(var id = 0;id<=num;id++)
    {
	    if(id==num)
	    {
		    document.getElementById("st_con"+id).style.display="block";
		    document.getElementById("mynav"+id).className="nav-on";
	    }
	    else
	    {
		    document.getElementById("st_con"+id).style.display="none";
		    document.getElementById("mynav"+id).className="";
	    }
    }
}

//设为首页&加入收藏
var isIE=(document.all&&document.getElementById&&!window.opera)?true:false; 
var isMozilla=(!document.all&&document.getElementById&&!window.opera)?true:false; 
var isOpera=(window.opera)?true:false;
var seturl='url(#default#homepage)';
var weburl="http://www.duchawang.com";
var webname=document.title;

function myhomepage(obj)	{
    if(isMozilla){
	    try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");} 
	    catch (e){alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");}
	    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
	    prefs.setCharPref('browser.startup.homepage',weburl);
    }
    if(isIE){
	    obj.style.behavior = seturl; obj.sethomepage(weburl);

    }
}

function addfavorite()
{
    if(isMozilla){
	    if (document.all){ window.external.addFavorite(weburl,webname);}
	    else if (window.sidebar){ window.sidebar.addPanel(webname, weburl,"");}
    }
    if(isIE){window.external.AddFavorite(weburl, webname);}	
}

//菜单定位
function  setMenuHover(){
    var cata = ["/marketline","/market","/stcompany","/news","/video","/train","bbs.aspx"];
    var url = window.top.location.href.toLowerCase();
    var index = -1;

    for(var i=0;i<cata.length;i++){
        var l = url.indexOf(cata[i]);
        if(l>=0 &&((l+cata[i].length)==url.length || url.substr(l+cata[i].length,1)=="/")){index=i;break;}
    }
    
   if(index==-1 && url.indexOf('/stmarket')>0){index=1;}

   if(index == -1&& url.indexOf('/commpany')>0){index=1;}
    qiehuan(index+1);
}

(function($){
$.fn.extend({
    Scroll:function(opt,callback){
        //参数初始化
        if(!opt) var opt={};
        var _this=this.eq(0).find("ul:first");
        var lineH=_this.find("li:first").height(), //获取行高
            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;
        //滚动函数
        scrollUp=function(){
                _this.animate({
                        marginTop:upHeight
                },speed,function(){
                        for(i=1;i<=line;i++){
                                _this.find("li:first").appendTo(_this);
                        }
                        _this.css({marginTop:0});
                });
        }
        //鼠标事件绑定
        _this.hover(function(){
            clearInterval(timerID);
        },function(){
           timerID=setInterval("scrollUp()",timer);
        }).mouseout();
    }
})
})(jQuery);
