﻿function activeToggleClass(cssClassName,arrNavi,arrContent,iSpeed,sContainerId){
 this.iSpeed=iSpeed;
 this.iNow=0;
 this.sContainer=document.getElementById(sContainerId);
 var thisObj=this;
 
 for (var i=0;i<arrNavi.length;i++){
 (function(j,k,iNow){
  document.getElementById(j).onmouseover=function(){openNavi(j);showContent(k);thisObj.iNow=iNow;}
 })(arrNavi[i],arrContent[i],i);
 }
 function openNavi(naviID){
 for (var i=0;i<arrNavi.length;i++){
  document.getElementById(arrNavi[i]).className="";
 }
 document.getElementById(naviID).className=cssClassName;
 }
 function showContent(contentID){
 for (var i=0;i<arrContent.length;i++){
  document.getElementById(arrContent[i]).style.display="none";
 }
 document.getElementById(contentID).style.display="block"; 
 } 
 this.activeNext=function(){
 if(++this.iNow>=arrNavi.length){this.iNow=0;}
 openNavi(arrNavi[this.iNow]);
 showContent(arrContent[this.iNow]);
 }
 thisObj.loopScroll=setInterval(function(){thisObj.activeNext()},thisObj.iSpeed);
 thisObj.sContainer.onmouseover=function() {window.clearInterval(thisObj.loopScroll)};
 thisObj.sContainer.onmouseout=function() {thisObj.loopScroll=setInterval(function(){thisObj.activeNext()},thisObj.iSpeed);};
}
function waitScrollObj(sContainerId,sElementId,iSpeed,iDirection,iWaitTime,iWaitLength){
 scrollLeft=function(){(this.sElement.offsetWidth-this.sContainer.scrollLeft<=0)?this.sContainer.scrollLeft-=(this.sElement.offsetWidth-1):this.sContainer.scrollLeft++;}
 scrollRight=function(){(this.sContainer.scrollLeft<=0)?this.sContainer.scrollLeft+=(this.sElement.offsetWidth-1):this.sContainer.scrollLeft--;}
 scrollUp=function(){(this.sElement.offsetHeight-this.sContainer.scrollTop<=0)?this.sContainer.scrollTop-=(this.sElement.offsetHeight-1):this.sContainer.scrollTop++;}
 scrollDown=function(){(this.sContainer.scrollTop<=0)?this.sContainer.scrollTop+=(this.sElement.offsetHeight-1):this.sContainer.scrollTop--;}
 this.wait=0;	
 this.waitOrRun=function(WT,WL){
 	this.wait++;
 	if (this.wait>(WT+WL)){this.wait=0;}
 	if (this.wait>WT){return true}
 	return false;
 	}
	
 this.sContainer=document.getElementById(sContainerId);
 this.sElement=document.getElementById(sElementId);
 this.iSpeed=iSpeed;
 this.sElement2=this.sElement.parentNode.appendChild(this.sElement.cloneNode(true));
 switch(iDirection){ 
 case "right":this.doScroll=scrollRight;break;
 case "up":this.doScroll=scrollUp;break;
 case "down":this.doScroll=scrollDown;break;
 default: this.doScroll=scrollLeft;
}
 var thisObj=this;
 thisObj.loopScroll=setInterval(function(){ if(thisObj.waitOrRun(iWaitTime,iWaitLength)){thisObj.doScroll()} },thisObj.iSpeed);
 thisObj.sContainer.onmouseover=function() {window.clearInterval(thisObj.loopScroll)};
 thisObj.sContainer.onmouseout=function() {thisObj.loopScroll=window.setInterval(function(){if(thisObj.waitOrRun(iWaitTime,iWaitLength)){thisObj.doScroll()}},thisObj.iSpeed)};
 }
function scrollObj(sContainerId,sElementId,iSpeed,iDirection){
 scrollLeft=function(){(this.sElement.offsetWidth-this.sContainer.scrollLeft<=0)?this.sContainer.scrollLeft-=(this.sElement.offsetWidth-1):this.sContainer.scrollLeft++;}
 scrollRight=function(){(this.sContainer.scrollLeft<=0)?this.sContainer.scrollLeft+=(this.sElement.offsetWidth-1):this.sContainer.scrollLeft--;}
 scrollUp=function(){(this.sElement.offsetHeight-this.sContainer.scrollTop<=0)?this.sContainer.scrollTop-=(this.sElement.offsetHeight-1):this.sContainer.scrollTop++;}
 scrollDown=function(){(this.sContainer.scrollTop<=0)?this.sContainer.scrollTop+=(this.sElement.offsetHeight-1):this.sContainer.scrollTop--;}
 this.sContainer=document.getElementById(sContainerId);
 this.sElement=document.getElementById(sElementId);
 this.iSpeed=iSpeed;
 this.sElement2=this.sElement.parentNode.appendChild(this.sElement.cloneNode(true));
 switch(iDirection){ 
 case "right":this.doScroll=scrollRight;break;
 case "up":this.doScroll=scrollUp;break;
 case "down":this.doScroll=scrollDown;break;
 default: this.doScroll=scrollLeft;
}
 var thisObj=this;
 thisObj.loopScroll=setInterval(function(){thisObj.doScroll()},thisObj.iSpeed);
 thisObj.sContainer.onmouseover=function() {window.clearInterval(thisObj.loopScroll)};
 thisObj.sContainer.onmouseout=function() {thisObj.loopScroll=window.setInterval(function(){thisObj.doScroll()},thisObj.iSpeed)};
 }
function toggleClass(cssClassName,arrNavi,arrContent){
 for (var i=0;i<arrNavi.length;i++){
 (function(j,k){
  document.getElementById(j).onmouseover=function(){openNavi(j);showContent(k);}
 })(arrNavi[i],arrContent[i]);
 }
 function openNavi(naviID){
 for (var i=0;i<arrNavi.length;i++){
  document.getElementById(arrNavi[i]).className="";
 }
 document.getElementById(naviID).className=cssClassName;
 }
 function showContent(contentID){
 for (var i=0;i<arrContent.length;i++){
  document.getElementById(arrContent[i]).style.display="none";
 }
 document.getElementById(contentID).style.display="block"; 
 }
}
function toggleClass2nd(cssClassName,arrNavi,arrContent,extContent){
 for (var i=0;i<arrNavi.length;i++){
 (function(j,k,l){
  document.getElementById(j).onmouseover=function(){openNavi(j);showContent(k);showExt(l);}
 })(arrNavi[i],arrContent[i],extContent[i]);
 }
 function openNavi(naviID){
 for (var i=0;i<arrNavi.length;i++){
  document.getElementById(arrNavi[i]).className="";
 }
 document.getElementById(naviID).className=cssClassName;
 }
 function showContent(contentID){
 for (var i=0;i<arrContent.length;i++){
  document.getElementById(arrContent[i]).style.display="none";
 }
 document.getElementById(contentID).style.display="block"; 
 }
 function showExt(contentID){
 for (var i=0;i<extContent.length;i++){
  document.getElementById(extContent[i]).style.display="none";
 }
 document.getElementById(contentID).style.display="block"; 
 }
}

function changeContentTimer(cContainer,cWaitTime){
	var cMain=document.getElementById(cContainer)
	var cLen=cMain.childNodes.length;
	var itemList=new Array();
	for (var c=0;c<cLen;c++){
		if (cMain.childNodes[c].nodeType==1){ itemList.push(cMain.childNodes[c]);}
	}
	var iLen=itemList.length
	this.iNow=0;
	var thisObj=this;
	function showContent(num){
		for(var i=0;i<iLen;i++){
			itemList[i].style.display='none';
			itemList[num].style.display='block';
		}
	}
	this.activeNext=function(){
		++thisObj.iNow>=iLen?thisObj.iNow=0:true;
		showContent(thisObj.iNow);
	}
	thisObj.loopAct=setInterval(function(){thisObj.activeNext()},cWaitTime);
	document.getElementById(cContainer).onmouseover=function(){window.clearInterval(thisObj.loopAct);}
	document.getElementById(cContainer).onmouseout=function(){ thisObj.loopAct=setInterval(function(){thisObj.activeNext()},cWaitTime); }
}



function AddFavorite(sURL, sTitle)
{
  try
  {
    window.external.addFavorite(sURL, sTitle);
  }
  catch (e)
  {
    try
    {
      window.sidebar.addPanel(sTitle, sURL, "");
    }
    catch (e)
    {
      alert("加入收藏失败，请使用Ctrl+D进行添加");
    }
  }
}
function SetHome(obj,vrl){
    try{
        obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
    }
    catch(e){
        if(window.netscape) {
            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',vrl);
         }
    }
}

function printDate(dateText){
/* printDate("2010/03/22") */
	var day="";
	var month="";
	var ampm="";
	var ampmhour="";
	var myweekday="";
	var year="";
	mydate=new Date(dateText);
	myweekday=mydate.getDay();
	mymonth=mydate.getMonth()+1;
	myday= mydate.getDate();
	myyear= mydate.getYear();
	year=(myyear > 200) ? myyear : 1900 + myyear;
	if(myweekday == 0)
	weekday=" 星期日 ";
	else if(myweekday == 1)
	weekday=" 星期一 ";
	else if(myweekday == 2)
	weekday=" 星期二 ";
	else if(myweekday == 3)
	weekday=" 星期三 ";
	else if(myweekday == 4)
	weekday=" 星期四 ";
	else if(myweekday == 5)
	weekday=" 星期五 ";
	else if(myweekday == 6)
	weekday=" 星期六 ";
	document.getElementById('dateArea').innerHTML=year+"年"+mymonth+"月"+myday+"日 "+weekday;
}
