var sk0="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_";
var sk1="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_ ¡¡";

function CHKSystemKeyword(chkstr,keystr){
	for (var s=0;s<=chkstr.length-1;s++){
		if(keystr.indexOf(chkstr.charAt(s))==-1){
			if (!(chkstr.charCodeAt(s)<1||chkstr.charCodeAt(s)>128)){
				return false;
			}
		}
	}
  return true;
}

function CHKUserID(userid){
	var len_userid=0
	if (!CHKSystemKeyword(userid,sk0)) return false;
	for (var i=0;i<=userid.length-1;i++){
		if (userid.charCodeAt(i)<1||userid.charCodeAt(i)>128){
			len_userid+=2;
		}
		else len_userid+=1;
	}
	if (len_userid<3||len_userid>19) return false;	
	return true;
}
function CHKUserPwd(userpwd){
	if (!CHKSystemKeyword(userpwd,sk0)) return false;
	if (userpwd.length<6) return false;
	return true;
}

function CHKAnswer(answer){
	if (answer=="") return false;
	if (!CHKSystemKeyword(answer,sk1)) return false;
	return true;
}

function CHKTrueName(truename){
	for (var i=0;i<=truename.length-1;i++){
		if (truename.charCodeAt(i)>=1&&truename.charCodeAt(i)<=128&&truename.charAt(i)!=" "&&truename.charAt(i)!="¡¡") return false;
	}
	if (truename=="") return false;
  return true;
}

function CHKAreaNo(areano){
	if (areano.length<3||areano.length>5) return false;
	if (areano.substring(0,1)!="0"&&areano.substring(0,1)!="£°") return false;
	if (!CHKNumber("0123456789£°£±£²£³£´£µ£¶£·£¸£¹",areano)) return false;
	return true;
}

function CHKPhone(phone){
	if (phone.length<7) return false;
	//if (!CHKNumber("0123456789£°£±£²£³£´£µ£¶£·£¸£¹-/",phone)) return false;
	//if (!CHKNumber("0123456789£°£±£²£³£´£µ£¶£·£¸£¹",phone.substring(0,7))) return false;
	return true;
}

/*function CHKMobile(mobile){
	if (mobile=="") return true;
	if (mobile.length!=11) return false;
	if (mobile.substring(0,2)!="13") return false;
	if (!CHKNumber("0123456789",mobile)) return false;
	return true;
}*/

function CHKMobile(mobile){
	if (mobile.length<7) return false;
	//if (!CHKNumber("0123456789",mobile)) return false;
	return true;
}

function CHKEmail(email){
	var mailstr="abcdefghijklmnopqrstuvwxyz0123456789.@_-"
	if (email.indexOf(".")==-1||email.indexOf("@")==-1||email.indexOf(".@")!=-1||email.indexOf("@.")!=-1) return false;
	if (email.substring(0,1)=="."||email.substring(0,1)=="@"||email.charAt(email.length-1)=="."||email.charAt(email.length-1)=="@") return false;
	for (var i=0;i<=email.length-1;i++){
		if (mailstr.indexOf(email.charAt(i).toLowerCase())==-1){
			if (i==email.length-1){
				if (email.charAt(i)==" "){
					return true;
				}
				else {return false;}
			}
			else{
				return false;
				break
			}
		}
	}
	return true;
}

function CHKZipcode(zipcode){
	if (zipcode.length!=6) return false;
	if (!CHKNumber("0123456789£°£±£²£³£´£µ£¶£·£¸£¹",zipcode)) return false;
	return true;
}

function CHK_SubmitLinkURL(LinkURL){
	URL=LinkURL.toLowerCase();
	if (URL.indexOf("guestid")!=-1){
		return false;
	}
  return true;
}

function CHKNumber(StandardString,SubmitString){
	for (var i=0;i<=SubmitString.length-1;i++){
		if (StandardString.indexOf(SubmitString.charAt(i))==-1){
			return false;
		}
	}
	return true;
}

function goodssearch(search_string,sortid){
	for (var i=0;i<=document.FormSearch.sort.length-1;i++){
		if (document.FormSearch.sort.options[i].value==sortid){
			document.FormSearch.sort.options[i].selected=true;
		}
	}
	//var sid=document.FormSearch.sort.selectedIndex;
	document.FormSearch.keyword.value=search_string;
	document.FormSearch.target="_blank";
	document.FormSearch.submit();
	//document.FormSearch.sort.selectedIndex=sid;
	document.FormSearch.keyword.value="";
}

function openLink(link){
	if (link!=""){
		var url="http://publish.no5.com.cn/" + link + "?GuestID=www.no5.com.cn";
		var h=window.screen.availHeight;
		var openArticle=window.open (url,'','top=0,left=0,width=780,height=550,resizable=yes,scrollbars=yes');
		openArticle.focus();
	}
}

function ShowMyShoppingCar(action,goodsid,GuestID,VerifyCode){
	var w,h;
	if (VerifyCode==undefined){VerifyCode=0}
	if (window.screen.width==1024&&window.screen.height==768||window.screen.width==1280&&window.screen.height==1024){
		w=800;
		h=650;
	}
	else{
		w=window.screen.width-10;
		h=window.screen.height-35;
	}
	var LinkURL="/ShoppingCarList.asp?action=" + action + "&goodsid=" + goodsid + "&VerifyCode=" + VerifyCode + "&show=refresh"
	var OpenShoppingCar=window.open (LinkURL,"ShoppingCar","menubar=0,resizable=1,scrollbars=1,toolbar=0,status=0,location=0,width="+w+",height="+h+",top=5,left=5")
}

function ViewAppendGoods(ProductID,GuestID){
	var LinkURL="/ViewAppendGoods.asp?id="+ProductID+"&GuestID="+GuestID
	var OpenAppendGoods=window.open(LinkURL,"","top=10,left=10,width=500,height=400,scrollbars=1");
	OpenAppendGoods.focus();
}

function ViewFavorite(gid){
	alert("ÄúÉÐÎ´µÇÂ¼£¬²»ÄÜ²é¿´ÔÝ´æ¼Ü¡£");
	window.location.href="/user/myaccount.asp?action=myfavorite&GuestID=" + gid;
}
function OpenForChat(){
	var l=(window.screen.availWidth-550)/2;
	var t=(window.screen.availHeight-480)/2;
	var OpenWindow=window.open ("/OnlineService/default.asp","ofc","menubar=0,resizable=0,width=550,height=480,status=0,top=" + t + ",left=" + l);
	OpenWindow.focus();
}
function Feedback(action){
	var fd=window.open("/Feedback/Feedback.asp?action="+action,"feedback","menubar=0,resizable=1,scrollbars=1,width=450,height=500,top=100,left=100");
	fd.focus();
}
function OpenVote(){
	var h=(window.screen.availHeight-100);
	var OpenWindow=window.open ("/vote/vote.asp","vote","menubar=0,resizable=0,width=550,height=" + h + ",status=0,top=10,left=10,scrollbars=1");
	OpenWindow.focus();
}
function chksearch(){
	if (document.FormSearch.keyword.value.length==0){
		alert("ÇëÄúÊäÈëËÑË÷¹Ø¼ü×Ö¡£");
		document.FormSearch.keyword.focus();
		return false;
	}
  return true;
}