function IsEmpty(str){
  var s;
  
  s = new String(str);
  s = s.replace(/ /g,"");
  if (s == "")
    return true;
  else
    return false; 
}

function check_email(s){
  if ((s.indexOf("@")==-1)||(s.indexOf(".")==-1)||((s.charAt(0)) == "@")||(s.indexOf(",")>1))
    return false;
  else
    return true;
}


function check_insert(str){
    for (i=0 ; i<str.length ; i++){
      if (!("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".indexOf(str.substr(i,1),0)>-1)){
        return false;
        break;
      }
    }
    return true;
}


function check_brand(str){
    for (i=0 ; i<str.length ; i++){
      if (!("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-".indexOf(str.substr(i,1),0)>-1)){
        return false;
        break;
      }
    }
    return true;
}

function check_AZ(str){
    for (i=0 ; i<str.length ; i++){
      if (!("ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(str.substr(i,1),0)>-1)){
        return false;
        break;
      }
    }
    return true;
}

function check_EmailUse(str){
    var i,j,NoUse;
    UnUseEmail = ["@yahoo.com.cn","@yahoo.com","@google.com","@126.com","@163.com","@163.net","@263.com","@sohu.com","@saku2.com","@gmail.cn","@mail.ru","@inbox.ru","@bk.ru","@list.ru","@pisem.net","@inbox.lv"];
    UseEmail = ["@yahoo.com.tw","@yahoo.com.hk","@yahoo.com.sg","@yahoo.com.ph","@yahoo.com.au"];
    for(i in UnUseEmail){
	if (str.toLowerCase().indexOf(UnUseEmail[i])>0){
	  NoUse=true;
	  for(j in UseEmail){
	    if (str.toLowerCase().indexOf(UseEmail[j])>0){
	    	NoUse=false;
	    }
	  }

	  if (NoUse) {
		return UnUseEmail[i];
		break;	
	  }else{
		return true;
	     	break;	
	  }	
	}	      
    }    
    return true;
}

function check_EmailAllow(str){
    var i,j,NoUse;
    BadEmail = ["@yaohoo.","@ayahoo.","@yhnoo.","@yahcoo.","@yanoo.","@yaho.","@ahoo.","@yhoo.","@yaoo.","@yahoocom","@yahoo.co.tw","@yahoo.cm.tw","@yaho.com","@yaohoo.cn","@yaho.cn","@hotmail.com.tw","@hotmail.net","@hotmail.mail","@homail.","@hatmail.","@hotmil.","@hotmai.","@hotmaile.","@hoymail.","@htomail.","@gmai.com","@gamil.com","@hient.","@hinet.com.tw","@.","@com","@com.tw","@.com","@123.com.tw","@sinamail.com.tw"];
    CheckEmail = ["@com"]
    for(i in BadEmail){
	if (str.toLowerCase().indexOf(BadEmail[i])>0){
	  NoUse=true;
	  for(j in CheckEmail){
	    if (str.toLowerCase().indexOf(CheckEmail[j])>0){
		  if ((str.toLowerCase().indexOf(CheckEmail[j])+CheckEmail[j].length) == str.length)
		  {
		  	NoUse=true;
		  }else{
			NoUse=false;	
		  }		
	    }
	  }
	
	  if (NoUse) {
		return BadEmail[i];
		break;	
	  }else{
		return true;
	     	break;	
	  }
	}	      
    }    
    return true;
}

function check_EmailEmpty(str){
    for (i=0 ; i<str.length ; i++){
      if (" ".indexOf(str.substr(i,1),0)>-1){
        return str;
        break;
      }
    }
    return true;
}
