	function getStrLength(str) { 
		var i = 0; 
		var j=0; 
		for (i = 0; i< str.length; i++) {     
			if (str.charCodeAt(i) > 127 || str.charCodeAt(i) == 94) { 
				j=j+2;   
			} 
			else { 
				j=j+1 
			}    
		} 
		return j;
	}
	function isEmail (email) {
		var rStr = new RegExp("[^a-z,0-9,_,--,@,\.]", "ig");
		if((!email.match(rStr))&&email.length>5&&email.indexOf('@')>0&&email.indexOf('.')>0)
		return true;
		else
		return false;	
	}
	function checkEmail(){
		if(isEmail($('email').value)){
			$('emailTd').className='yesRegFont';
		}else{
			$('emailTd').className='errRegFont';
		}
	}
	function preEmail(){
		$('emailTd').className='regFont';
	}
	function preRegPwd(){
		$('regpwdTd').className='regFont';
	}
	function preConPwd(){
		$('conpwdTd').className='regFont';
	}
	function checkRegPwd(){
		if(getStrLength($('regpwd').value)<6 || getStrLength($('regpwd').value)>20){
			$('regpwdTd').className='errRegFont';
		}else{
			$('regpwdTd').className='yesRegFont';
		}
	}
	function checkConPwd(){
		if(getStrLength($('conpwd').value)<6 || getStrLength($('conpwd').value)>20 || $('conpwd').value!=$('regpwd').value){
			$('conpwdTd').className='errRegFont';
		}else{
			$('conpwdTd').className='yesRegFont';
		}
	}
	function checkForm(){
		if(!isEmail($('email').value)){
			$('emailTd').className='errRegFont';
			return false;
		}
		if(getStrLength($('regpwd').value)<6 || getStrLength($('regpwd').value)>20){
			$('regpwdTd').className='errRegFont';
			return false;
		}
		if(getStrLength($('conpwd').value)<6 || getStrLength($('conpwd').value)>20 || $('conpwd').value!=$('regpwd').value){
			$('conpwdTd').className='errRegFont';
			return false;
		}
		
		return true;
	}
	
	function controlForm(){
		if($('infoDisplay').checked==true){
			$('contactInfo').style.display='';
		}else{
			$('contactInfo').style.display='none';
		}
	}
	
	function checkLoginPwd(){
		if(getStrLength($('loginpwd').value)<6 || getStrLength($('loginpwd').value)>20){
			$('loginPwdTd').className='errRegFont';
		}else{
			$('loginPwdTd').className='yesRegFont';
		}
	}
	function preLoginPwd(){
		$('loginPwdTd').className='regFont';
	}
	function checkLoginForm(){
		if(!isEmail($('email').value)){
			$('emailTd').className='errRegFont';
			return false;
		}
		if(getStrLength($('loginpwd').value)<6 || getStrLength($('loginpwd').value)>20){
			$('loginPwdTd').className='errRegFont';
			return false;
		}
		return true;
	}
	function   check(str)   
	{   
		  if(!str   ||   isNaN(str))   return   0;   
		  str   =   (str   *   1).toString();   
		  if(str.indexOf(".")   ==   -1)   return   1;   
		  return   2;   
	}
	function pCount(itemObj,qobj,displayObj){
		quantity=$(qobj).value;
		if(quantity!=''&&check(quantity)!=1){
			alert('Please input a Integer!');
			$(qobj).value='';
			return;
		}
		itemprice = $(itemObj).value;
		if(quantity==0)
		$(displayObj).innerHTML='';
		else
		$(displayObj).innerHTML='* $'+itemprice+'=$'+(quantity*(itemprice*1000)/1000);
	}
	function checkBuyForm(){
		var have = 0;
		if($('firstnum')!=null&&$('firstnum').value!=''&& $('firstnum').value!=0){
			have='1';
		}
		if($('secondnum')!=null&&$('secondnum').value!=''&& $('secondnum').value!=0){
			have='1';
		}
		if($('thirdnum')!=null&&$('thirdnum').value!=''&& $('thirdnum').value!=0){
			have='1';
		}
		if(have==0){
			alert('Please input the quantity!');
			return false;
		}
		return true;
	}
	function checkYEmail(){
		if(isEmail($('yemail').value)){
			$('yEmailSpan').innerHTML='<b class="greenFont">*</b>';
			return true;
		}else{
			$('yEmailSpan').innerHTML='<font color="#FF0000">Please input your email</font>';
			return false;
		}
	}
	function preYEmail(){
		$('yEmailSpan').innerHTML='<b class="redFont">*</b>';
	}
	function checkSubject(){
		if($('subject').value==''){
			$('subjectSpan').innerHTML='<font color="#FF0000">Please input the email subject</font>';
			return false;
		}else{
			$('subjectSpan').innerHTML='<b class="greenFont">*</b>';
			return true;
		}
	}
	function preSubject(){
		$('subjectSpan').innerHTML='<b class="redFont">*</b>';
	}
	function checkContent(){
		if($('content').value==''){
			$('contentSpan').innerHTML='<font color="#FF0000">Please input the email content</font>';
			return false;
		}else{
			$('contentSpan').innerHTML='<b class="greenFont">*</b>';
			return true;
		}
	}
	function preContent(){
		$('contentSpan').innerHTML='<b class="redFont">*</b>';
	}
	function checkEmailForm(){
		if(checkYEmail()&&checkSubject()&&checkContent()){
			return true;
		}else{
			return false;
		}
	}
	function checkOrderNo(){
		if($('orderno').value==''){
			$('orderNoSpan').innerHTML='<font color="#FF0000">Please input the Order NO</font>';
			return false;
		}else{
			$('orderNoSpan').innerHTML='<b class="greenFont">*</b>';
			return true;
		}
	}
	function preOrderNo(){
		$('orderNoSpan').innerHTML='<b class="redFont">*</b>';
	}
	function checkStatusForm(){
		if(checkYEmail()&&checkOrderNo()){
			return true;
		}else{
			return false;
		}
	}
	
	function checkYAmount(){		
		if(isFloat(Trim($('Amount').value))){
			$('AmountSpan').innerHTML='<b class="greenFont">*</b>';
			return true;
		}else{
			$('AmountSpan').innerHTML='<font color="#FF0000">Please input correct mount</font>';
			return false;
		}
	}
	function preYAmount(){
		$('AmountSpan').innerHTML='<b class="redFont">*</b>';
	}
	
	function isFloat(s){
	var patrn=/^\d+(\.\d+)?$/; 
	if (!patrn.exec(s)){
		return false;
	}
	
	return true;
}
//去掉左面空格
function lTrim(str){
  return str.replace(/^\s*/,"");
}

//去掉右面空格
function rTrim(str){
  return str.replace(/\s*$/,"");
}

function Trim(str){
  return rTrim(lTrim(str));
}
