﻿function menuFix() {
    var sfEls = document.getElementById("MainNav").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
        this.className+=(this.className.length>0? " ": "") + "sfhover";
        }
        sfEls[i].onMouseDown=function() {
        this.className+=(this.className.length>0? " ": "") + "sfhover";
        }
        sfEls[i].onMouseUp=function() {
        this.className+=(this.className.length>0? " ": "") + "sfhover";
        }
        sfEls[i].onmouseout=function() {
        this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),
"");
        }
    }
}



/*Tab切换
-id：节点唯一标识
-index：初始索引（从0开始）
-eventType：事件类型（0-鼠标滑动，1-鼠标点击）
-showDelay：渐显时间
-isAuto：是否自动切换
-autoDelay：自动切换时间间隔）*/
function PZ_Tab(id, index, eventType, showDelay, isAuto, autoDelay)
{
	if($("#"+ id + " .tMenu .t").size() == $("#"+ id + " .tBox").size())
	{
		var j;function slide(j){$("#"+ id + " .tMenu .t").removeClass("current");$("#"+ id + " .tMenu .t").eq(j).addClass("current");$("#"+ id + " .tBox").hide();$("#"+ id + " .tBox").eq(j).fadeIn(showDelay);}
		if(index < 0 || index > $("#"+ id + " .tMenu .t").size() - 1){index = 0;}
		$("#"+ id + " .tBox:not(:eq(" + index + "))").hide();
		$("#"+ id + " .tMenu .t:eq(" + index + ")").addClass("current");
		$("#"+ id + " .tMenu .t").each(function(i)
			{if(eventType == 0){$(this).mouseover(function(){slide(i);});}else{$(this).click(function(){slide(i);});}}
		);
		if(isAuto)
		{
			j = index-1; var timer = null;
			function autoPlay(){n = $("#"+ id + " .tMenu .t").size()-1; j++;if(j > n){j = 0;}slide(j);timer = window.setTimeout(autoPlay, autoDelay);}
			function hookThumb()
			{$("#"+ id + " .tMenu .t").hover(function(){if (timer){clearTimeout(timer);j = $(this).prevAll().filter(".t").length;}},function (){timer = window.setTimeout(autoPlay, autoDelay);this.blur();return false;});$("#"+ id + " .tBox").hover(function(){if (timer){clearTimeout(timer);j = $(this).prevAll().filter(".tBox").length;}},function (){timer = window.setTimeout(autoPlay, autoDelay);this.blur();return false;});}autoPlay();hookThumb();
		}
	}
	else
	{
		alert("ID为[ " + id + " ]的tab个数有误！请检查");
	}
}


/*自动播放
-id：节点唯一标识
-showDelay：渐显时间
-autoDelay：自动切换时间间隔）*/
function HZ_AutoPlay(id, showDelay, autoDelay)
{
	$("#"+ id + " .tBox:not(:first)").hide();
	var j = -1;var timer = null;
	function autoPlay(){n = $("#"+ id + " .tBox").size()-1; j++;if(j > n){j = 0;}slide(j);timer = window.setTimeout(autoPlay, autoDelay);}
	function slide(j){$("#"+ id + " .tBox").hide();$("#"+ id + " .tBox").eq(j).fadeIn(showDelay);}
	function hookThumb()
	{$("#"+ id + " .tBox").hover(function(){if (timer){clearTimeout(timer);j = $(this).prevAll().filter(".tBox").length;}},	function (){timer = window.setTimeout(autoPlay, autoDelay);this.blur();return false;});}autoPlay();hookThumb();
}

function PZ_ChangeMovie(o, boxID)
{
	var movie = o.href;
	var html = '<object id="NSPlay"classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"  width="355" height="283">'
					   +' <param name="movie" value="Flvplayer.swf" />'
					   +' <param name="quality" value="high" />'
					   +'<param name="IsAutoPlay" value=1>'
						+'<param name="wmode" value="Opaque">'                               
					   +'<param name="allowFullScreen" value="true" />'
						+'<param name="FlashVars" value="vcastr_file='+movie+'&IsAutoPlay=1&BufferTime=3" />'
						+'<embed src="Flvplayer.swf" allowfullscreen="true" flashvars="vcastr_file='+movie+'&IsAutoPlay=1&BufferTime=3" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="355" height="283"></embed></object>';
	document.getElementById(boxID).innerHTML = html;
}
		
function PZ_PicShow(id)
{
	var speed=10;
	var tab=document.getElementById(id);
	var tab1=document.getElementById(id + "1");
	var tab2=document.getElementById(id + "2");
	tab2.innerHTML=tab1.innerHTML;
	function H_PicMarquee(){
	if(tab2.offsetWidth-tab.scrollLeft<=0)
	tab.scrollLeft-=tab1.offsetWidth
	else{
	tab.scrollLeft++;

	}
	}
	var MyMar=setInterval(H_PicMarquee,speed);
	tab.onmouseover=function() {clearInterval(MyMar)};
	tab.onmouseout=function() {MyMar=setInterval(H_PicMarquee,speed)};
}


//获取随机数
function F_GetRandom(len) {
    var myN = "";
    for (var i = 0; i < len; i++) {
        myN += Math.floor(Math.random() * 10) + ""
    }
    return myN;
}











function M_ShowAd(height, stopTime)
{
    var time = 500;
    var h = 0;
    function addCount()
    {
        if(time>0)
        {
            time--;
            h = h+5;
        }
        else
        {
            return;
        }
        if(h>height)  //高度
        {
            return;
        }
        document.getElementById("ads").style.display = "";
        document.getElementById("ads").style.height = h+"px";
        setTimeout("addCount()",30); 
    }
    
    window.onload = function showAds()
    {
        addCount();
        setTimeout("noneAds()",stopTime); //停留时间自己适当调整
    }
    var T = 100;
    var N = 100; //高度
    function noneAds()
    {
        if(T>0)
        {
            T--;
            N = N-5;
        }
        else
        {
            return;
        }
        if(N<0)
        {
            document.getElementById("ads").style.display = "none";
            return;
        }
        
        document.getElementById("ads").style.height = N+"px";
        setTimeout("noneAds()",30); 
    }
}










    /*------------------------------------弹出高亮窗口S------------------------------------*/
    var isIe = (document.all) ? true : false;
    var Sb_bgLayer;
    var Sb_boxLayer;

    //弹出高亮窗口
    function SB_ShowBox(title, w, h, src, msg) {
        var documentHtml = document.documentElement;

        //createBgLayer
        Sb_bgLayer = document.createElement("div");
        with (Sb_bgLayer) {
            className = "Sb_bgLayer";
            style.width = documentHtml.clientWidth + "px";

            var h0;
            var h1 = documentHtml.scrollHeight;
            var h2 = documentHtml.clientHeight;
            h0 = h1 > h2 ? h1 : h2;
            //alert(h1 + "-" + h2 + "-" + h0);

            style.height = (isIe) ? h0 + "px" : documentHtml.scrollHeight + "px";
            style.display = "none";
            if (!isIe) {
                style.cssText += "opacity:0;";
            }
        }
        document.body.insertBefore(Sb_bgLayer, document.body.firstChild);

        //背景透明度渐变
        SB_SetAlpha(Sb_bgLayer, 70);

        //createBox
        Sb_boxLayer = document.createElement("div");
        with (Sb_boxLayer) {
            className = "Sb_boxLayer";
            style.width = w + "px";
            style.height = h + "px";
            style.display = "none";
        };
        document.body.insertBefore(Sb_boxLayer, document.body.firstChild);

        var showBody = msg;
        if (msg == "") {
            showBody = "<iframe name='SB_Frame' id='SB_Frame' src='" + src + "' scrolling-x='no' frameborder=0 marginwidth=0 marginheight=0 style='height:" + (h - 32) + "px;width:100%;'></iframe>";
        }
        if (w == "") {
            w = 600;
        }
        if (h == "") {
            400;
        }
        Sb_boxLayer.innerHTML = "<div class='Sb_Title'><span>" + title + "</span><a href='javascript:void(0)' onfocus='this.blur()' onclick='SB_HideBox()' title='关闭'>关闭</a></div>" + "<div class='Sb_Body'>" + showBody + "</div>";
        Sb_bgLayer.style.display = "block";
        Sb_boxLayer.style.display = "block";
        Sb_boxLayer.style.left = documentHtml.offsetWidth / 2 - Sb_boxLayer.offsetWidth / 2 + "px";
        Sb_boxLayer.style.top = (document.documentElement.clientHeight + document.documentElement.scrollTop * 2) / 2 - h / 2 + "px";
    }

    //关闭高亮窗口
    function SB_HideBox() {
        try {
            Sb_bgLayer.style.display = "none";
            Sb_boxLayer.style.display = "none";
        }
        catch (err) {
            window.parent.SB_HideBox();
        }
    }

    //高亮窗口关闭并刷新窗口（父或本身）
    function SB_Refresh() {
        try {
            window.parent.location.reload() 
        }
        catch (e) {
            window.self.location.reload();
        }
        finally {
            SB_HideBox();
        }
    }
	
	//检测是否是合法弹出
	function SB_Check()
	{
		if(typeof(window.parent.Sb_boxLayer) == "undefined")
		{
			document.write("<div style='padding:30px; margin:100px auto; width:100%; text-align:center; border:#2fab0b solid 2px; color:#FF0000;'>非法操作，5秒后自动转入首页</div>");
			setTimeout(this.location.href = "/",5000);
		}
	}


    //让背景渐渐变暗
    function SB_SetAlpha(obj, endInt) {
        if (isIe) {
            try {
                obj.filters.alpha.opacity += 5;
                if (obj.filters.alpha.opacity < endInt) {
                    setTimeout(function() { SB_SetAlpha(obj, endInt) }, 1);
                }
            }
            catch (err) {
                obj.style.filter = "alpha(opacity=70)";
            }
        }
        else {
            var al = parseFloat(obj.style.opacity);
            al += 0.03;
            obj.style.opacity = al;
            if (al < (endInt / 100)) {
                setTimeout(function() { SB_SetAlpha(obj, endInt) }, 1);
            }
        }
    }
    /*------------------------------------弹出高亮窗口N------------------------------------*/
