// JavaScript Document
/************************
	获取页面对象
************************/
//根据id获取页面对象
function $(objID)
{
	return document.getElementById(objID);
}
//根据name获取页面对象数组
function $Name(objsName)
{
	return document.getElementsByName(objsName);
}
//根据tagname获取页面对象数组
function $TagName(objsTagName)
{
	return document.getElementsByTagName(objsTagName);
}

//获取下拉控件select的当前选定项的值
function $dropGet(obj)
{
	return obj.options[obj.selectedIndex].value;
}
//按值设置下拉控件select的当前选定项
function $dropSetByValue(dropobj,value)
{
	var list = dropobj.options;
	for(var i=0;i<list.length;i++)
	{
		dropobj[i].selected = (dropobj[i].value.toLowerCase() == value.toLowerCase()) ? true : false;
	}
}
//按文本设置下拉控件select的当前选定项
function $dropSetByText(dropObj,text)
{
	var list = dropObj.options;
	for(var i=0;i<list.length;i++)
	{
		dropObj[i].selected = (dropObj[i].text.toLowerCase() == text.toLowerCase()) ? true : false;
	}
}

/************************************************************
	设为主页和添加收藏
************************************************************/
//加入浏览器收藏
function bookmarkit()
{
   var url="http://"+window.location.host;
   var title=document.title;
   if (document.all)
   {
	  window.external.addFavorite(url,title);
   }
   else if (window.sidebar)
   {
	  window.sidebar.addPanel(title,url,  "");
   }
}
//设为主页
function SetHomePage()
{
   var url="http://"+window.location.host;
	if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(url);
    }
	else if(window.sidebar)
	{
		if(window.netscape)
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
			}   
			catch (e)
			{
				alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值改为true" );
			}
		} 
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
		prefs.setCharPref('browser.startup.homepage',url); 
	}
}
//复制信息到剪贴板
function CopyToClipboard(str)
{
	//var str = "我在" + sitename + "网站上看到的这个" + proname+"，蛮好的，你也看看吧，地址是：" + url;
	if(window.clipboardData)
	{
		 window.clipboardData.clearData();
		 window.clipboardData.setData("Text",str);
		 alert("本页信息复制成功，您可以粘贴到QQ、MSN或邮箱中，发送给您的好友。");
     }
     else if (window.netscape)
     {
          try
          {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          }catch(e)
          {
			alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
          }    
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var len = new Object();
          var str2 = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = str;
          str2.data = copytext;
          trans.setTransferData("text/unicode",str2,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
          alert("本页信息复制成功，您可以粘贴到QQ、MSN或邮箱中，发送给您的好友。");
     }
}

/*****************************************
	去除头尾空格
*****************************************/
String.prototype.Trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
	return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
	return this.replace(/(\s*$)/g, ""); 
} 
/*******************************
   限制键盘输入
*******************************/
//限制不允许输入除0～9之外的所有字符
function KeyPress(objTR)
{	
	var txtval=objTR.value;		
	
	var key = event.keyCode;

	if((key < 48||key > 57)&&key != 46)
	{		
		event.keyCode = 0;
	}
	else
	{
		if(key == 46)
		{
			event.keyCode = 0;
		}
	}
}
//限制只允许输入0~9及小数点
function KeyPressPoint(objTR)
{	
	var txtval=objTR.value;		
	
	var key = event.keyCode;

	if((key < 48||key > 57)&&key != 46)
	{		
		event.keyCode = 0;
	}
	else
	{
		if(key == 46)
		{
			if((objTR.value.length == 0) || (objTR.value.indexOf('.') >= 1))
			{
				event.keyCode = 0;
			}
		}
	}
}
//限制只能输入数字和横线(-)
function KeyPressLine(objTR)
{	
	var txtval=objTR.value;
	
	var key = event.keyCode;

	if((key < 48||key > 57)&&(key != 45))
	{		
		event.keyCode = 0;
	}
}

//限制不允许输入'和"
function KeyPressYin(objTR)
{
	var key = event.keyCode;
	
	if(key == 34||key == 39)
	{		
		event.keyCode = 0;
	}
}
//限制不允许输入任何英文符号
function KeyPressNonSymbol(obj)
{
	var key = event.keyCode;
	if((key>=33&&key<=47)||(key>=58&&key<=64)||(key>=91&&key<=96)||(key>=123&&key<=126))
	{
		event.keyCode = 0;
	}
}

/**********************************************
	页面跳转
**********************************************/

//跳到本页并且去除url参数
function RefreshMe()
{
//	alert(location.pathname);
	location.href(location.pathname);
}
//跳转到本页，不去除参数
function LocationToMe()
{
	location.href=location.href;
}
//跳转到本页，并删除指定的参数
//参数：param:应为匹配指定参数的js正则表达式字符串
function RefreshMeDelParam(param)
{
	var url = location.href;
	var reg = new RegExp(param,"ig");
	var x = url.replace(reg,"");
	LocationTo(x);
}
//跳到指定页
function LocationTo(url)
{
	location.replace ( url);
}
//顶部窗口跳转
function TopLocationTo(url)
{
	top.location.href(url);
}
//跳转到本页，并添加参数
function LocationToMeParam(param)
{
	location.href(SetUrlAddParam(location.href,param));
}
//提交本页
function SubmitToMeParam(url)
{
	document.forms[0].action = url;
	document.forms[0].submit();
}

//打开窗口的js类，默认打开空页面
function NewWindow()
{
	this.Url = "about:blank";
	this.Name = "_blank";
	this.Height = Math.round(window.screen.height / 2);
	this.Width = Math.round(window.screen.width / 2);
	this.ToolBar = "yes";
	this.MenuBar = "yes";
	this.ScrollBars = "yes";
	this.Location = "yes";
	this.Status = "yes";
	this.Resizable = "yes";
	this.Left = Math.round(((window.screen.availWidth-this.Width)/2)/2);
	this.Top = Math.round(((window.screen.availHeight-this.Height)/2)/2);
}
NewWindow.prototype.Open = function()
{
	window.open(this.Url,this.Name,'height='+this.Height+',width='+this.Width+',toolbar=' + this.ToolBar + ',menubar=' + this.MenuBar + ',scrollbars=' + this.ScrollBars + ',resizable=' + this.Resizable + ',location=' + this.Location + ',status=' + this.Status + ',left='+ this.Left +',top='+ this.Top +'');
}
//打开一个没有任何限制的窗口
function OpenUrl(url)
{
	var win = new NewWindow();
	win.Url = url;
	win.Open();
}
//打开一个所有操作工具条都没有的窗口
function OpenUrlNonAll(url,width,height)
{
	if(url == null || url == "")
		url = "/";
	if(width == null || width == 0)
		width = Math.round(window.screen.width / 2);
	if(height == null || height == 0)
		height = Math.round(window.screen.height / 2);
		
	var win = new NewWindow();
	win.Url = url;
	win.Height=height;
	win.Width = width;
	win.ToolBar="no";
	win.MenuBar = "no";
	win.ScrollBars = "auto";
	win.Location = "no";
	win.Status = "no";
	win.Resizable = "yes";
	win.Left = Math.round((window.screen.availWidth-win.Width)/2);
	win.Top = Math.round((window.screen.availHeight-win.Height)/2);
	win.Open();
}

/***********************************************
	搜索动作
***********************************************/
//设置文本框点击隐藏文字
var CONST_SEARCH_TEXT = "Enter keywords";
function SetTextBoxTextHidden(obj)
{
	if(obj.value.Trim() == CONST_SEARCH_TEXT)
	{
		obj.value = "";
	}
	
	obj.onfocus = function()
	{
		if(this.value.Trim() == CONST_SEARCH_TEXT)
		{
			this.value = "";
		}
	};
	obj.onblur = function()
	{
		if(this.value.Trim() == "")
		{
			this.value = CONST_SEARCH_TEXT;
		}
	};
}
//热门搜索动作
function HotKeyClick(keyword,key)
{
	$("txtSearchKeywords").value = keyword;
	//$("txtsearch_cid").value = key;
	CheckSearchBarInput('search');
	$("txtSearchKeywords").form.submit();
}
//搜索表单验证
function CheckSearchBarInput(formid)
{
	if(($(formid).txtSearchKeywords.value.Trim() == "") || ($(formid).txtSearchKeywords.value.Trim() == CONST_SEARCH_TEXT))
	{
		alert("Please enter your search keywords");
		return false;
	}
//	key_cid=$(formid).txtsearch_cid.value.Trim();
//	if(key_cid == "" )
//	{
//		alert("请选择搜索类别");
//		return false;
//	}
	$(formid).action="Products.php";
	return true;
}
/******************************************
	AXJX
******************************************/
var cncity_xmlHttp,ChangeCity;
function cncity_createXMLHttp(){
    if(window.ActiveXObject){
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest){
        return new XMLHttpRequest();
    }
}
function go_xmlhttp(url,evcity){
	cncity_xmlHttp=cncity_createXMLHttp();
	cncity_xmlHttp.onreadystatechange = evcity;
	cncity_xmlHttp.open("get",url,true);
	cncity_xmlHttp.send(null);
}
/******************************************
	注册
******************************************/
function checkUsername(str){
	var username=str.value;
	var ptn=/[0-9,a-z,A-Z,_]{3,16}/;
	if(username==""){
		$g("spUsernameMsg","× Username is empty!");
		return false;
	}
	if(username.match(ptn)==null){
		$g("spUsernameMsg","× Username is Mistake!");
		$("txtUsername").focus();
		return false;
	}
	url="check.php?type=checkusername&username=" + escape(username) + "&x=" + Math.random();
	if(go_xmlhttp(url,goUsername) == "error")
	{
		alert("网络出现故障，请稍候重试。");
	}
	return true;
}
function goUsername(){
	if(cncity_xmlHttp.readyState == 4)
	{
		var root = cncity_xmlHttp.responseText;
		if(root == null)
		{
			alert("网络出现故障，请稍候重试，");
		}
		else
		{
			if(root=="1"){
				$g("spUsernameMsg","√");
				return true;
			}else
			if(root=="0"){
				$g("spUsernameMsg","× <span>"+$("txtUsername").value+"</span> already exists!");
				return false;
			}else{
				$g("spUsernameMsg","× 未知错误!");
				return false;
			}
			return false;
		}
	}
	return false;
}
function checkEmail(str){
	var Email=str.value;
	var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if(Email==""){
		$g("spEmailMsg","× Email is empty!");
		return false;
	}
	if(Email.match(reg)==null){
		$g("spEmailMsg","× Email is Mistake!");
		$("txtEmail").focus();
		return false;
	}
	url="check.php?type=checkemail&email=" + escape(Email) + "&x=" + Math.random();
	if(go_xmlhttp(url,goEmail) == "error")
	{
		alert("网络出现故障，请稍候重试。");
	}
	return true;
}
function goEmail(){
	if(cncity_xmlHttp.readyState == 4)
	{
		var root = cncity_xmlHttp.responseText;
		if(root == null)
		{
			alert("网络出现故障，请稍候重试，");
		}
		else
		{
			if(root=="1"){
				$g("spEmailMsg","√");
				return true;
			}else
			if(root=="0"){
				$g("spEmailMsg","× "+$("txtEmail").value+" already exists!");
				return false;
			}else{
				$g("spEmailMsg","× 未知错误!");
				return false;
			}
			return false;
		}
	}
	return false;
}
function checkCode(str){
	var Code=str.value;
	if(Code==""){
		$g("msgCode","× <span>Code is empty!</span>");
		return false;
	}
	url="check.php?type=checkcode&code=" + escape(Code) + "&x=" + Math.random();
	if(go_xmlhttp(url,goCode) == "error")
	{
		alert("网络出现故障，请稍候重试。");
	}
	return true;
}
function goCode(){
	if(cncity_xmlHttp.readyState == 4)
	{
		var root = cncity_xmlHttp.responseText;
		if(root == null)
		{
			alert("网络出现故障，请稍候重试，");
		}
		else
		{
			if(root=="1"){
				$g("msgCode","√");
				return true;
			}else
			if(root=="0"){
				$g("msgCode","×");
				return false;
			}else{
				$g("msgCode","× 未知错误!");
				return false;
			}
			return false;
		}
	}
	return false;
}
function checkPin(str){
	var Pin=str.value;
	var reg=/^[a-z,A-Z,0-9]{6,16}/;
	if(Pin==""){
		$g("msgPin","× password is empty!");
		return false;
	}
	if(Pin.match(reg)==null){
		$g("msgPin","× password is Mistake!");
		$("txtPin").focus();
		return false;
	}else{
		$g("msgPin","√");
	}
	return true;
}
function checkConfirmPin(str){
	var Pin=str.value
	var reg=/^[a-z,A-Z,0-9]{6,16}/;
	if($("txtPin").value!=Pin)
	{
		$g("msgConfirmPin","× Enter the password twice inconsistent!");
		return false;
	}else
	if($("txtPin").value!=""){
		$g("msgConfirmPin","√");
	}
	return true;
}
function ddlSecQus_Changed(str){
	if(str.value==""){
		$("txtSecQus").style.display="";
	}else{
		$("txtSecQus").style.display="none";
		$("txtSecQus").value=str.value;
	}
	return true;
}
function checkD(src){
    var val=src.value;
    var ptn=/^\d*$/;
    if(val.length>0&&!ptn.test(val)){
		$g("msgAge","× Malformed");
		return false;
	}else if(val.length>0){
		$g("msgAge","√");
	}
		return true;
}
function donly(e){
	var key = window.event ? event.keyCode : e.which;
	if(key<27 || key >128)
	    return true;
	else if(key >= 48 && key <= 57)
	    return true;
	else 
		return false;
}
function $g(str,html){
	$(str).style.display="";
	$(str).innerHTML=html;
}
function signUp(str){
    var b1=checkUsername($("txtUsername"));
    var b2=checkEmail($("txtEmail"));
    var b3=checkPin($("txtPin"));
    var b4=checkConfirmPin($("txtConfirmPin"));
    var b5=checkD($("txtAge"),'msgAge');
    var b6=checkCode($("txtCode"));
    if(b1&&b2&&b3&&b4&&b5&&b6){
		$("register").action="?action=register";
		return true;
	}else{
		return false;
	}
}
/******************************************
	验证和提交评论
******************************************/
function SubmitProductComment()
{
	if($("txttitle").value.Trim() == "")
	{
		alert("Please enter title。");
		return false;
	}
	if($("txtContent").value.Trim() == "")
	{
		alert("Please enter content。");
		return false;
	}
	else
	{
		$("CommentForm").submit();
	}
}
/********************************************
	头部广告语
********************************************/
function correctPNG() 
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
//window.attachEvent("onload", correctPNG);
/************************************************************
	首页滚动的图片
************************************************************/
function MarqueeControl(ContainID,Directions,LeftBtn,RightBtn)
{
	var marquee1 = new Marquee(ContainID)
	marquee1.Direction = Directions;
	marquee1.Step = 1;
	marquee1.Width = 159;
	marquee1.Height = 250;
	marquee1.Timer = 30;
	marquee1.DelayTime = 0;
	marquee1.WaitTime = 0;
	marquee1.ScrollStep = 1;
//	$(LeftBtn).onclick = function(){marquee1.Direction=2;};
//	$(RightBtn).onclick = function(){marquee1.Direction=3;};
	marquee1.Start();
}
/************************************************************
	在线客服
************************************************************/
function getPosition() {
    var top    = document.documentElement.scrollTop;
    var left   = document.documentElement.scrollLeft;
    var height = document.documentElement.clientHeight;
    var width  = document.documentElement.clientWidth;
    
    return {top:top,left:left,height:height,width:width};
}
function QuickPostion(objID)
{
    var obj = document.getElementById(objID);
	
    window.onscroll = function (){
        var Position   = getPosition();
            obj.style.top  = (Position.top) + 140  +"px";
            obj.style.right = "6px";
    };
}
function QuickPostions(objID,adid)
{
    var obj = document.getElementById(objID);
    var ad = document.getElementById(adid);
	
    window.onscroll = function (){
        var Position   = getPosition();
            obj.style.top  = (Position.top) + 140  +"px";
            obj.style.right = "6px";
            ad.style.top  = (Position.top) + 140  +"px";
            ad.style.left = "6px";
    };
}


// *** Cookies ***

function setCookie(name,value)
{
    var Days = 1;
    var exp  = new Date();    //new Date("December 31, 9998");
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString() + "; path=/"; 
}
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}
function delCookie(name)
{
    var exp = new Date();
        exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
        if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}



// *** 地址重组 ***
function GetThisAllRequest()
{
	var url =window.location.search; //获取url中"?"符后的字串
	var thisquest="";
	if(url.indexOf("?") != -1)
	{ 
	    thisquest=url.slice(1);
	}
	return thisquest;
}


function GetUserID()
{
	var url =window.location.search; //获取url中"?"符后的字串
	var thisquest="";
	if(url.indexOf("/?") && url.indexOf("=") == -1)
	{ 
	    thisquest=url.slice(1);
	}
	return thisquest;
}


function GetThisRequest(rename)
{
	var url =window.location.search; //获取url中"?"符后的字串
	var thisquest="";
	if(url.indexOf("?") != -1)
	{ 
	  var str = url.slice(1);
	  strs = str.split("&");
	  for(var i = 0; i < strs.length; i ++){
			if (rename==strs[i].split("=")[0]){
			    thisquest=unescape(strs[i].split("=")[1]);
			}
	  }
	}
	return thisquest;
}



//document.write(GetUserID());

Promotion()

function Promotion()
{
    var SiteUrl=window.location.hostname;
    
    if(GetUserID().length>0){
        var UserID=GetUserID();
    }else{
        var UserID=GetThisRequest('UserID');
    }
    

    var PID=GetThisRequest('id');
    var UID=GetThisRequest('UserID');
    
    if( PID && UID ){
        var testme=getCookie('Promotion_PID');
        if(testme!==null){
           if(testme.indexOf(","+PID+",")==-1){
                setCookie('Promotion_PID',testme+PID+"," );
           }
        }else{
             setCookie('Promotion_PID',","+PID+",");
        }
    }

//    if(PID){
//        setCookie('Promotion_PID',PID);
//    }
    
    if(UserID){
        setCookie('Promotion_UserID',UserID);
    }else{
        setCookie('Promotion_UserID',"");
    }
    
    if(SiteUrl){
        setCookie('Promotion_SiteUrl',SiteUrl);
    }else{
        setCookie('Promotion_SiteUrl',"");
    }
}
function setCopy(_sTxt){try{clipboardData.setData('Text',_sTxt)}catch(e){}}
/************************************************************
	疑问提交与验证
************************************************************/
function checkquestion(phone,email){
	var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if(phone=="" || email==""){
		$("question").innerHTML="× <span>Phone or E-mail is empty!</span>";
		return false;
	}
	if(email.match(reg)==null){
		$("question").innerHTML="× <span>E-mail is Mistake!</span>";
		return false;
	}
	newid=$("txtid").value;
	url="check.php?type=checkquestion&phone=" + escape(phone) + "&email=" + escape(email) + "&newid=" + escape(newid) + "&x=" + Math.random();
	if(go_xmlhttp(url,goto_question) == "error")
	{
		alert("网络出现故障，请稍候重试。");
	}
	return true;
}
function goto_question(){
	if(cncity_xmlHttp.readyState == 4)
	{
		var root = cncity_xmlHttp.responseText;
		if(root == null)
		{
			alert("网络出现故障，请稍候重试，");
		}
		else
		{
			if(root=="0"){
				$g("question","×");
				return true;
			}else if(root=="1"){
				$g("question","√ Our professor explain to you by short message or E-mail as soon as posible!");
				return true;
			}else if(root=="2"){
				$g("question","× <span>E-mail is Mistake!</span>");
				return false;
			}else if(root=="3"){
				$g("question","× <span>Mobil Phone is Mistake!</span>");
				return false;
			}else{
				$g("question","× 未知错误!");
				return false;
			}
			return false;
		}
	}
	return false;
}
/************************************************************
	疑问提交与验证
************************************************************/
function checkcontent(){
	var txtname=$("txtname").value;
	var txttel=$("txttel").value;
	var txtemail=$("txtemail").value;
	var txtmsn=$("txtmsn").value;
	var txtbody=$("txtbody").value;
	url="check.php?type=checkcontent&value[name]="+ escape(txtname) +"&value[tel]="+ escape(txttel) +"&value[mail]="+ escape(txtemail) +"&value[msn]="+ escape(txtmsn) +"&value[body]="+ escape(txtbody) +"&x=" + Math.random();
	if(go_xmlhttp(url,goto_content) == "error")
	{
		alert("网络出现故障，请稍候重试。");
	}
	return true;
}
function goto_content(){
	if(cncity_xmlHttp.readyState == 4)
	{
		var root = cncity_xmlHttp.responseText;
		if(root == null)
		{
			alert("网络出现故障，请稍候重试，");
		}
		else
		{
		//	alert(root);
			if(root=="1"){
				alert("Success");
				LocationToMe();
				return true;
			}else if(root=="2"){
				alert("Name is empty");
				return false;
			}else if(root=="3"){
				alert("Tel is empty");
				return false;
			}else if(root=="4"){
				alert("E-Mail is empty");
				return false;
			}else if(root=="41"){
				alert("E-Mail is Mistake");
				return false;
			}else if(root=="5"){
				alert("Msn is empty");
				return false;
			}else if(root=="51"){
				alert("Msn is Mistake");
				return false;
			}else if(root=="6"){
				alert("Content is empty");
				return false;
			}else{
				alert("Mistake");
				return false;
			}
			return false;
		}
	}
	return false;
}
/************************************************************
	加入收藏夹
************************************************************/
function checkcollect(id){
	url="check.php?type=checkcollect&id="+ escape(id) +"&x=" + Math.random();
	if(go_xmlhttp(url,goto_collect) == "error")
	{
		alert("网络出现故障，请稍候重试。");
	}
	return true;
}
function goto_collect(){
	if(cncity_xmlHttp.readyState == 4)
	{
		var root = cncity_xmlHttp.responseText;
		if(root == null)
		{
			alert("网络出现故障，请稍候重试，");
		}
		else
		{
			if(root=="2"){
				alert("Mistake");
				return true;
			}else if(root=="3"){
				alert("No Login");
				return false;
			}
			alert(root);
			if(root=="1"){
				alert("Success");
				return true;
			}else if(root=="0"){
				alert("Name is empty");
				return false;
			}
			return false;
		}
	}
	return false;
}