﻿function $(id){ return document.getElementById(id);}
if(document.all){}
var MyCookie = {
    set:function(name,value,day,hour,minute,path){
	    var expires=new Date();
	    if(typeof(day)=="number"){expires.setDate(expires.getDate()+day);}
	    if(typeof(hour)=="number"){expires.setHours(expires.getHours()+hour);}
	    if(typeof(minute)=="number"){expires.setMinutes(expires.getMinutes()+minute);}
	    document.cookie=name+"="+escape(value)+";"+(day||hour||minute? " expires="+expires.toGMTString():"") +((path==null) ? "" : "; path="+path);
    },
    get:function(name){
	    var arr=document.cookie.split("; ");
	    for(var i=0; i<arr.length; i++){var kv=arr[i].split("=");if(name==kv[0]){return unescape(kv[1]);}}
	    return null;
    },
    remove:function(name){
	    document.cookie=name+"=; expires=Fri, 31 Dec 1000 23:59:59 GMT;";
    }
};
var __ie8=(navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf('MSIE 8')!=-1);
var MyCursor={
    get:function(evt){
        evt = evt ? evt : (window.event ? window.event : null);
        var x=0,y=0,ml=0,mt=0;
        if (document.all){x= evt.x;y =evt.y;if(!__ie8){ml=document.documentElement.scrollLeft;mt=document.documentElement.scrollTop;}}else{x= evt.pageX;y = evt.pageY;ml=document.body.scrollLeft;mt=document.body.scrollTop;}
        return {x:x+ml,	y:y+mt};
    }
};
function jt_8bo_index(){
    var _currentfobx;
    var _day=10000;
	var _floater1=0,_floater2=0;
	var _goalint=0,_goal=null,_goaltxt=null,_goalbox=null,_goaliframe=null,_goalpos=0;
	var _dd=document.documentElement;
    function closecal(){try{if(calendar.isopen){calendar.hide();}; }catch(ex){} }
    function style(name){var css=$('cssstyle');if(!css){return;} css.href='css/'+name+'.css';MyCookie.set('cssstyle',name,_day);}
    function Floater(obj,y,bottomalign,objh){
		var d = document;
	    this.y = y;
		this.yy =0;
	    this.objElement=obj;
	    this.objElement.y = y;
	    this.h = obj.clientHeight||objh;
	    this.py = obj.offsetTop;
	    this.bottomalign=bottomalign;
		this.lt =-1;
	    if(d.layers){this.objElement.style=this.objElement;}
	    this.playie = function(index){
			bodytop = d.documentElement.scrollTop||d.body.scrollTop;
			bodyheight = d.documentElement.clientHeight;
			var top;
		    if(this.bottomalign){
				this.yy +=(bodytop - parseInt(this.y) + bodyheight  - this.yy)/2;
	            top=this.yy;
		    }else{
		         if(bodytop > this.py){
		            this.yy += (bodytop + this.y - this.yy)/2;
		            top=this.yy;
		         }else{
					top=this.py;
		         }
		    }
		    this.objElement.style.top=top+'px';
			if(this.lt==top){
				switch(index){
					 case 1:clearInterval(_floater1);break;
					 case 2:clearInterval(_floater2);break;
				}
			}else{this.lt=top;}
	    };
    }
    function analytxt(s){
        var uri,path;
        if(!s){s= ' ';}else{var i=s.indexOf(',');uri=s.substring(0,i);path=s.substr(i+1); s=null;}
        return {"uri":uri,"path":path,"txt":s};
    }
    function imgad(s,index){ 
        var at= new analytxt(s); 
        if(at.txt){s=at.txt;}else{
            if(at.path.substr(at.path.length-4).toLowerCase()=='.swf'){
                s='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"><param name="movie" value="'+ at.path +'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><embed src="'+ at.path +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent" ></embed></object>';
            }else{
                s='<a href="'+at.uri+'" target="_blank"><img src="'+ at.path +'"/></a>';
            }
        }
        s='<li'+ (index==0?' class="first"':'')+'>'+s+'</li>';
        s=s.replace('<li> </li>','').replace('<li> </li>','').replace('<li> </li>','').replace('<li> </li>','');
        return s;	
    }
    function txtad(s){ 
        var at= new analytxt(s); 
        if(at.txt){s=at.txt;}else{s='广告：<a href="'+at.uri+'" target="_blank">'+ at.path +'</a>';}
        return s;	
    }
    function bindtablead(name,ads){
        var arr=name.split(',');
	    var obj=$(arr[0]); 
	    var count=parseInt(arr[1])||ads.length;
        if(obj){
            obj.setAttribute('xname',name);
            var k=obj.rows.length;
            for(var j=0;j<k;j++){
                var tr=obj.rows[j];if(tr){if(tr.getAttribute('xt')=='AD'){obj.removeChild(tr);j++;}}
            }
            if(!ads){
                for(var j=0;j>-1;j++){
                    if(!obj.getAttribute('xads'+j)){break;}
                    obj.removeAttribute('xads'+j);
                }
                return;
            }
            if(!obj.getAttribute('xads0')){
                for(var i=0;i<ads.length;i++){obj.setAttribute('xads'+i,ads[i]);}
            }
            var skip=(parseInt(arr[5])||1)+1;
            var lastrow=parseInt(arr[6])||10;
            k=obj.rows.length;
            var i=0;
            var start=parseInt(arr[4])|0;
            for(var j= start;j<k;j+=skip)
            {
                if(txtad(ads[i])==" ")
                   continue;
                var newTR=obj.insertRow(j);
                var newTD=newTR.insertCell(0);
                newTD.colSpan=11;
                newTR.setAttribute('xt','AD');
                if(arr[3]=='txt'){
                    newTD.className='txtad';
                    newTD.innerHTML='<span class="close" onclick="_d.closetxtad(this);">x</span>'+txtad(ads[i]);
                }else{
                    //newTD.innerHTML=imgad(ads[i]); //暂时不用
                }
                i++;
                k++;
                if(i==count-1){
                    var n=j+lastrow-skip+1;
                    if(n>=k||n<j){ j=k-1;}else{ j=n;}
                }
                if(i>=count){break;}
            }
        }
    }
    function init(){
        var name='';
        //name=MyCookie.get('cssstyle');if(name){ style(name);}
    }
    init();
    this.addfavorite = function() {
        if(document.all) {
            window.external.addFavorite(location.href ,document.title);
        }else if(window.sidebar) {
            window.sidebar.addPanel(document.title,location.href ,  "" );
        }
    };
    this.sethome=function() {
         if(document.all) {
            document.body.style.behavior  =   ' url(#default#homepage) ' ;
            document.body.setHomePage(location.href);
        }else   if (window.sidebar) {
             if  (window.netscape) {try {netscape.security.PrivilegeManager.enablePrivilege( " UniversalXPConnect " );}catch (e) {return;}}
            var  prefs  =  Components.classes[ ' @mozilla.org/preferences-service;1 ' ].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref( ' browser.startup.homepage ' , location.href);
        }

    };
	this.unselect=function(){};
	this.selectall=function(){};
	this.schange=function(obj,url,count,dvalue){
		var v=obj.options[obj.selectedIndex].value;
		if(!v){return;}
		var arr=v.split(',');
		if(arr.length<count){
		    arr[arr.length]=dvalue;
		}
		
		for(var i=0;i<arr.length;i++){
		    url=url.replace('{'+i+'}',arr[i]);
		}
		window.open(url);
	};
    var _isloadfad=false;
    this.loadad=function(adname,adpath,type,isfloat,objh){
	    function appendad(name,ads){
	        var arr=name.split(',');
		    var obj=$(arr[0]); 
		    var count=parseInt(arr[1])||ads.length;
		    var type=arr[2];
		    var s='';
		    count=parseInt(count);
		    switch(type){
		        case 'txt':
		            for(var i=0;i<count;i++){
		                obj=$(arr[0]+i);if(obj){obj.innerHTML=txtad(ads[i]);}
		            }
		            break;
		        case 'table':
		            bindtablead(name,ads);
		            break;
		        default :
		            if(!obj){return;}
		            for(var i=0;i<count;i++){s+=imgad(ads[i],i);}
		            obj.innerHTML=s;
		    }
	    }
		var sh=$('shistory');if(sh){sh.style.visibility='visible';}
		var lstart=0;
		var lend=adname.length;
		if(type=='txt'){
			lstart=lend-1;
		}else{
			lend--;
		}
	    for(var i=lstart;i<lend;i++){appendad(adname[i],adpath[i]);}
	    objh=objh+60;
		if(!_isloadfad&&type=='img'){
			_isloadfad=true;
			var lrfad=$('lrfad');if(lrfad){floater1= new Floater(lrfad,5);_floater1=setInterval("floater1.playie(1);",20);}
			var floatlrad=$('floatlrad');if(floatlrad){floater2= new Floater(floatlrad,0,true,objh);_floater2=setInterval("floater2.playie(2);",20);}
			if(lrfad||floatlrad){
				/*window.onresize=function(){
					floatlrad.style.width=document.documentElement.clientWidth<920?'920px':'100%';
				};*/
				window.onscroll=function(){
					clearInterval(_floater1);clearInterval(_floater2);
					if(_floater1){_floater1=setInterval("floater1.playie(1);",20);}
					if(_floater2){_floater2=setInterval("floater2.playie(2);",20);}
					if(_goalint){in_goalscroll();}
				};
			}
		}

    };
    this.closefbox=function(obj){
        while(obj){
            if(obj.className.indexOf('fbox')!=-1){
                obj.style.display='none';
                break;
            }
            obj=obj.parentNode;
        }
        closecal();
    };
    this.bindtablead=function(obj){
        var tr;
        var tbody;
        var isclose=false;
        if(obj){
            if(obj.nodeName=='TD'){
                tr=obj.parentNode;
            }else{
                tr=obj.parentNode.parentNode;
                isclose=true;
            }
            tbody=tr.parentNode;
            tbody.removeChild(tr);
        }else{
            tbody=$('myd');
        }
        var name=tbody.getAttribute('xname');
        if(isclose){
            bindtablead(name,false);
            tbody.setAttribute('isclose','true')
            return;
        }
        if(tbody.getAttribute('isclose')=='true'){
            bindtablead(name)
            return;
        }
        var ads=new Array();
        for(var i=0;i>-1;i++){
            var s=tbody.getAttribute('xads'+i);
            if(!s){break;}
            ads[ads.length]=s;
        }
        bindtablead(name,ads);
    };
    this.openfbox=function(name,yadd,y){
        var obj=$(name);if(!obj){return;}
        if(_currentfobx&&obj!=_currentfobx){_currentfobx.style.display='none';} obj.style.display='block';_currentfobx=obj;
        if(y){obj.style.top= yadd+ (y + obj.clientHeight) + 'px';}
        closecal();
    };
    this.style=function(name){style(name);};
	this.closead=function(o){
		o.parentNode.style.display='none';
	};
	this.goalhide=function(){
		_goal.style.visibility='hidden';
		clearTimeout(_goalint);
	};
	function objposition(o){
		return {
			st:_dd.scrollTop||document.body.scrollTop,
			sw:_dd.clientWidth,
			sh:_dd.clientHeight,
			w:o.clientWidth,
			h:o.clientHeight
		};
	}
	function goalpos(){
		var g=objposition(_goal);
		var t=0,l=0;
		switch(_goalpos){
			case 0:t=g.st;l=(g.sw-g.w)/2;break; //正上方
			case 1:t=g.st+g.sh-g.h;l=(g.sw-g.w)/2;break;//正下方
			case 2:t=g.st+(g.sh-g.h)/2;l=0;break; //正左方
			case 3:t=g.st+(g.sh-g.h)/2;l=g.sw-g.w-3;break; //正右方
			case 4:t=g.st;l=0;break; //左上角
			case 5:t=g.st;l=g.sw-g.w-3;break; //右上角
			case 6:t=g.st+g.sh-g.h;l=0;break;  //左下角
			case 7:t=g.st+g.sh-g.h;l=g.sw-g.w-3;break; //右下角
		}
		return {top:t+'px',left:l+'px'};
	}
	this.goalshow=function(pos,txt){
		_goalpos=parseInt(pos);

		if(!_goal){_goal=$('goaltip');_goaltxt=$('goaltxt');_goalbox=$('goaltipbox');_goaliframe=$('goaliframe');}
		if(txt){_goaltxt.innerHTML=txt;}
		if(_goalint){clearTimeout(_goalint);}
		_goal.style.visibility='visible';
		_goal.style.height=_goaliframe.style.height=_goalbox.clientHeight+'px';
		var g=goalpos();
		_goal.style.top= g.top;
		_goal.style.left= g.left;
		_goalint=setTimeout('_ibo.goalhide();',30000);
	};
	function in_goalscroll(){
		_goal.style.top= goalpos().top;
	}
	if(!document.all){
		var css=document.createElement('style');
		css.type='text/css';
		document.getElementsByTagName('head')[0].appendChild(css);
		css.innerHTML='code{ font-size:11px;}';
	}
}
var _ibo=new jt_8bo_index();

function currentMenu(currentPage,menuName){
	if(!menuName)
		menuName='hMenuName';
	var objCurrentName=document.getElementById(menuName);
	if(objCurrentName){
		if(objCurrentName.value!=''){
			var obj=document.getElementById(objCurrentName.value);
			if(obj)
				obj.className='';
		}
		objCurrentName.value=currentPage;
	}
	if(currentPage=='')
		currentPage='menuHome';
	var obj=document.getElementById(currentPage);
	if(obj){
		obj.className='sel';
		obj.blur();
	}
}

function showMenu(id){
	var obj=document.getElementById(id);
	if(!obj)
		return;
	if(obj.style.display!='block')
		obj.style.display='block';
	else
		obj.style.display='none';
}
//
function qh_bf(bs)
{
	var obj=document.getElementById('z_js');
	if(bs==0)
	{
		document.getElementById('h_js').src='js/bf_all.js';
		obj.src='js/bf.js';
		document.getElementById('qh0').className='sel';
		document.getElementById('qh1').className='';
	}
	if(bs==1)
	{
		document.getElementById('h_js').src='js/bf_zd.js';
		obj.src='js/zdbf.js';
		document.getElementById('qh0').className='';
		document.getElementById('qh1').className='sel';
	}
}
window.onload=function(){currentMenu('menuLive');};

