function createCookie(name,value,days){
     var argv=createCookie.arguments;
     var argc=createCookie.arguments.length;
     //var expires=(2<argc)?argv[2]:null;
     //var path=(3<argc)?argv[3]:null;
     //var domain=(4<argc)?argv[4]:null;
     //var secure=(5<argc)?argv[5]:false;
	if (days) { 
		var expires = new Date(); 
		expires.setTime(expires.getTime()+(days*24*60*60*1000)); 
		//var expires = date.toGMTString(); 
	}
	 var path = '/';
	 //var domain = '369.com';
	 var domain = null;
	 var secure = false;
     document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
function readCookie(Name) {
 var search = Name + "=";
 var returnvalue = "";
 if (document.cookie.length > 0) {
  offset = document.cookie.lastIndexOf(search);
  if (offset != -1) {
   offset += search.length;
   end = document.cookie.indexOf(";", offset);
   if (end == -1)
   end = document.cookie.length;
   returnvalue=unescape(document.cookie.substring(offset,end));
  }
 }
 return returnvalue;
}

document.getElementsByClassName = function(className,oBox) {
 this.d= oBox || document;
 var children = this.d.getElementsByTagName('*') || document.all;
 var elements = new Array();
 for (var i = 0; i < children.length; i++) {
 var child = children[i];
 var classNames = child.className.split(' ');
 for (var j = 0; j < classNames.length; j++) {
 if (classNames[j] == className) {
 elements.push(child);
 break;
 }
 }
 }
 return elements;
}

$Cls = function (s,o){return document.getElementsByClassName(s,o);};

function SavMyHit(o){//OK
 var MyHitStatus=readCookie("MyHitStatus");
 if (MyHitStatus=="close") return;
 if (o.href.substring(0, 7) != 'http://' || o.href.substring(0, 18) == 'http://C3C6.com' || o.href.substring(0, 14) == 'http://369.com') {return;}
 var sNewSite=o.innerHTML+"|"+o.href+";";
 var sOldSite=readCookie("My369Hits");
  sOldSite.length>2048?sOldSite=sOldSite.substring(0,2048):"";
 if (sOldSite.indexOf(sNewSite)!=-1) {
  sOldSite=sOldSite.replace(sNewSite,"");
 }
  sNewSite+=sOldSite;
  createCookie("My369Hits",sNewSite, 180);
}

function GetMyHit(n){//OK
 this.maxlength=n || 45;
 var sOldSite=readCookie("My369Hits");
 sOldSite=sOldSite.split(";");
 var nMaxNum=sOldSite.length>this.maxlength?this.maxlength+1:sOldSite.length;
 var sHtml="<ul class=\"mzA\">\n";
 //var sHtml="";
 for (i=0;i<nMaxNum-1;i++) {
  var sTempInfo=sOldSite[i].split("|");
  //sHtml+="<li><b>"+(i+1)+".</b><a href=\""+sTempInfo[1]+"\" >"+sTempInfo[0]+"</a></li>\n";
  sHtml+="<li><a href=\""+sTempInfo[1]+"\" >"+sTempInfo[0].substring(0,10)+"</a></li>\n";
 }
 if (nMaxNum<=1) {
   //sHtml="<ul class=\"Top listUrl\">\n";
   sHtml="<ul class=\"mzA\">\n";
   //sHtml="";
   sHtml+="<li>暂无浏览记录！</li>\n"
 }
 sHtml+="</ul>\n";
 //sHtml+="<div id=\"clearHits\"><a href=\"javascript:;\" title=\"点此可以清除您“最近浏览网站”的所有记录。\" onclick=\"clearMyHit();\">[清除记录]</a>&nbsp;";
 sHtml+="<div class=\"mz2\" style=\"text-align:right\"><a href=\"javascript:;\" target=\"_self\" title=\"点此可以清除您“最近浏览网站”的所有记录。\" onclick=\"clearMyHit();\">[清除记录]</a>&nbsp;";
  
  var MyHitStatus=readCookie("MyHitStatus");
  if (MyHitStatus=="open"||MyHitStatus=="")
    sHtml+="<a href=\"javascript:;\" target=\"_self\" title=\"点此停用“最近浏览网站”的功能，系统将不再记录您最近浏览过的网站。\" onclick=\"chgMyHit('close');\">[停用]</a>&nbsp;</div>";
  else
    sHtml+="<a href=\"javascript:;\" target=\"_self\" title=\"点此启用“最近浏览网站”的功能，系统将记录您最近浏览过的网站。\" onclick=\"chgMyHit('open');\">[启用]</a>&nbsp;</div>";
 document.getElementById("My369His").innerHTML=sHtml;
}

function clearMyHit(){//OK
  createCookie("My369Hits","", 180);
  createCookie("My369Hits","", 180);
  GetMyHit();
}

function set369Hit(allSiteBox){//OK
  var arrSites="";
  for(var i=0;i<allSiteBox.length;i++){
   arrSites=allSiteBox[i].getElementsByTagName("a");
   for(var j=0;j<arrSites.length;j++){
	arrSites[j].onclick=function(){
	 SavMyHit(this);
	}
   }
  }
}

function set369HomeHit(allSiteBox){//OK
  var arrSites="";
  for(var i=0;i<allSiteBox.length;i++){
   arrSites=allSiteBox[i].getElementsByTagName("a");
   for(var j=0;j<arrSites.length;j++){
	arrSites[j].onclick=function(){
	 SavMyHit(this);
	 GetMyHit();
	}
   }
  }
}

function chgMyHit(stat){//OK
  createCookie("MyHitStatus",stat, 180);
  GetMyHit();
}

//style
function setActiveStyleSheet(title) { 
  var i, a, main; 
	if (title != '') {
		document.getElementById('skintheme').href="style/style"+title+".css?090401";
	} else {
		document.getElementById('skintheme').href="style/style1.css?090401";
	}
	createCookie('skintheme', title, 30);
	var bodyBgImage = readCookie('bodyBgImage');
	if (!(bodyBgImage != '' && bodyBgImage != 'none')) {
		set_line_bg_color(true, 1);
	}
}

var cookie = readCookie("skintheme"); 
if (cookie && cookie != '1' && cookie != '6') {
	document.getElementById('skintheme').href = "style/style"+cookie+".css?090401";
}

//box
function changea4(srcObj,tid) {
var tabList = srcObj.parentNode.getElementsByTagName("li");
if(srcObj.className=='b')return;
for(var i=0;i<tabList.length;i++){
if(tabList[i].className=='b')tabList[i].className='a';
//document.getElementById("card"+(i+1)).style.display = 'none';
}
//document.getElementById("card"+tid).style.display ='';
srcObj.className ='b';//TAB切换
return false;
}
function changea2(srcObj,tid) {
var tabList = srcObj.parentNode.getElementsByTagName("li");
if(srcObj.className=='b1')return;
for(var i=0;i<tabList.length;i++){
if(tabList[i].className=='b1')tabList[i].className='a1';
document.getElementById("mz"+(i+1)).style.display = 'none';
}
document.getElementById("mz"+tid).style.display ='';
srcObj.className ='b1';//TAB切换
return false;
}