function Cookie()
{
    this._Cookie=[];
    
    this.Load=function(){
        if(document.cookie.indexOf(";")!=-1){
            var _sp,_name,_tp,_tars,_tarslength;
            var _item=document.cookie.split("; ");
            var _itemlength=_item.length;
            while(_itemlength>0){
                _sp=_item[--_itemlength].split("=");
                _name=_sp[0];
				if (_sp.length <2 )
				{
					continue;
				}
                _tp=_sp[1].split(",");
                _tars=_tp.slice(1,_tp.length);
                this._Cookie[_name]=[];
                this._Cookie[_name]=_tars;
                this._Cookie[_name]["timeout"]=_tp[0];
                }
            return true;
            }
        return false;
        }
        
    this.Save=function(){
        var _str,_ars,_mars,_marslength,timeout,i,key;
        for(key in this._Cookie){
            if(!this._Cookie[key])return;
            _str=[];
            _mars=this._Cookie[key];
            _marslength=_mars.length;
            for(i=0;i<_marslength;i++)_str[_str.length]=escape(_mars[i]);
            document.cookie=key+"="+_mars["timeout"]+(_str.length>0?",":"")+_str+(_mars["timeout"]==0?"":";expires="+new Date(parseInt(_mars["timeout"])).toGMTString());
            }        
        }
        
    this.Create=function(name,days){
        days=days?days:0;
        if(!this._Cookie[name])this._Cookie[name]=[];
        this._Cookie[name]["timeout"]=days!=0?new Date().getTime()+parseInt(days)*86400000:0;
        }    
        
    this.Modify=function(name,days){
        this.Create(name,days);
        }
        
    this.Delete=function(name){
        this.Create(name,0);
        }     
        
    this.AddItem=function(name,value){
        this._Cookie[name][this._Cookie[name].length]=value;
        }
        
    this.DelItem=function(name,index){
        var _ttime=this._Cookie[name]["timeout"];
        this._Cookie[name]=this._Cookie[name].slice(0,index).concat(this._Cookie[name].slice(parseInt(index)+1,this._Cookie[name].length));
        this._Cookie[name]["timeout"]=_ttime;
        }

    this.GetItem=function(name,index){
        return this._Cookie[name][index];
        }

    this.GetTime=function(name){
        return new Date(parseInt(this._Cookie[name]["timeout"]));
        }

    this.GetCount=function(name){
        return this._Cookie[name].length;
        }

    this.GetCookieCount=function(){
        var _length=0,key;
        for(key in this._Cookie)_length++;
        return _length;
        }
        
	this.SetCookie=function(name,value){
		var today = new Date()
		var expires = new Date()
		expires.setTime(today.getTime() + 1000*60*60*24*365)
		document.cookie = name + "=" + escape(value)	+ "; expires=" + expires.toGMTString()
	}
	
	this.GetCookie=function(Name){
		var search = Name + "="
		if(document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			if(offset != -1) {
				offset += search.length
				end = document.cookie.indexOf(";", offset)
				if(end == -1) end = document.cookie.length
				return unescape(document.cookie.substring(offset, end))
			}	
		}
		return ""
	}
}	


//Cookie
function setCookie(name, value, path, domain) {
  var curCookie = name + "=" + escape(value) +
      "; expires=Thu, 6 Jan 2033 08:05:36 UTC" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function isEmpty(string)
{
	if(string=="")
	{
		return true;
	}
	else
	{return false;}
}

function isGBChar(string)
{
	valid="0123456789abcdefghijklmnqporstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+";
	for(var i=0;i<string.length;i++)
	{
		if(valid.indexOf(string.charAt(i))!=-1)
		{return false;}
	}
	return true;
}

function passformat(string)
{   
	valid="0123456789abcdefghijklmnqporstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
	for(var i=0;i<string.length;i++)
	{
		if(valid.indexOf(string.charAt(i))==-1)
		{return false;}
	}
	return true;
}

function isNumber(string)
{   
	if(string==""){return false}
	valid="0123456789.,";
	for(var i=0;i<string.length;i++)
	{
		if(valid.indexOf(string.charAt(i))==-1)
		{return false;}
	}
	return true;
}

function isPhone(string)
{
	if(string==""){return false}
	valid="0123456789——-()（）转";
	for(var i=0;i<string.length;i++)
	{
		if(valid.indexOf(string.charAt(i))==-1)
		{return false;}
	}
	return true;
}

function isemail(str){
if(str==""){testresults=false}
var filter=/^.+@.+\..{2,3}$/
if (filter.test(str))
testresults=true
else{
testresults=false
}
return (testresults)
}

function checktalkform(){
			var i=0
				if(document.getElementById("title").value==""){
						document.getElementById("talkformtitle").innerHTML="<br><font color=red>您需要输入留言标题！</font>";
						i=i+1;
				}
				if(document.getElementById("content").value==""){
						document.getElementById("talkformcontent").innerHTML="<br><font color=red>您需要填写留言内容！</font>";
						i=i+1;
				}
				if(document.getElementById("linkman").value==""){
						document.getElementById("talkformlinkman").innerHTML="<br><font color=red>您需要填写您的姓名！</font>";
						i=i+1;
				}
				if(isNumber(document.getElementById("checknumbercode").value)==false){
						document.getElementById("talkformchecknumbercode").innerHTML="<br><font color=red>请填写正确的数字验证码！</font>";
						i=i+1;
				}
				if(document.getElementById("tel").value==""){
						document.getElementById("talkformtel").innerHTML="<br><font color=red>您的电话填写错误，请按如下格式：0737-2697098！</font>";
						i=i+1;
				}
				if(isNumber(document.getElementById("qq").value)==false && isemail(document.getElementById("email").value)==false){
						document.getElementById("talkformqq").innerHTML="<br><font color=red>Email或QQ号必填一个，Email格式：webmaster@cnzy.net ,QQ号必须是数字!</font>";
						i=i+1;
				}


				if(i!=0){
					document.getElementById("errorinfo").innerHTML="<img src='/systempic/error_16x16.gif'><font color=red>您的操作有"+i+"处错误，请补充后再保存！</font>";
					return false;
					}else{
						return true;
						}
	
}

function Newshow(obj,N){
//obj是对象名称
//N是显示方式,1表示显示出来，0表示不显示出来
var Nobj=document.getElementById(obj);
	if(N==1){
		Nobj.style.display = "";   
	}else{
		Nobj.style.display = "none";   
	}
}

function getshow(obj){   
var Nobj=document.getElementById(obj);
if (Nobj.style.display == "none") {     
		Nobj.style.display = "";   
	}else{     
		Nobj.style.display = "none";     
	}     
}

function checkselected(obj){
	//检查对明选择的内容是否为大分类	
	if(document.getElementById(obj).value==""){
		//alert("您不能选择大分类，请选择前面带“--”字符的子分类!"+document.getElementById(obj).value);
		document.getElementById(obj+"info").innerHTML="<span style='color:red'><img src='/systempic/error_16x16.gif' align='absmiddle'>您不能选择大分类，请选择前面带“--”字符的子分类!</span>";
		return false;
		}else{
			//alert("您不能选择大分类，请选择前面带“--”字符的子分类!"+document.getElementById(obj).value);
		document.getElementById(obj+"info").innerHTML="";
		return true;
		
		}
}

function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
