String.prototype.trim = function() { return this.replace(/^\s*|\s*$/g, ""); };

function trim(s) {
  return s.replace(/^\s*|\s*$/g, "");
}

function isEmpty(s) {
  if (s==null) return true;
  return (s.trim().length == 0);
}

function isFCKEmpty(objname) {
  var oEditor = FCKeditorAPI.GetInstance(objname) ;
  var oDOM = oEditor.EditorDocument ;
  var iLength ;
  if (document.all) {
    iLength = oDOM.body.innerText.length ;
  } else {
    var r = oDOM.createRange() ;
    r.selectNodeContents( oDOM.body ) ;
    iLength = r.toString().length ;
  }
  return (iLength <= 0);
}

function isValidEmail(sEmail){
   var emailRE = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/);
  return emailRE.test(sEmail);

	/*
  return ((sEmail.indexOf("@") > 0) && 
      (sEmail.indexOf(".") > 0) && 
      (sEmail.lastIndexOf("@") < sEmail.length - 1) && 
      (sEmail.lastIndexOf(".") < sEmail.length - 1) &&
      !isMoreThanOnce(sEmail,"@")) ;
  */
}

function isMoreThanOnce(s, c) {
  return (s.indexOf(c) != s.lastIndexOf(c));	
}

function isIntegerChar(s){
  for(var i=0; i<s.length; i++) {
    var c = s.charAt(i);
    if (!isDigit(c)) return false ; 
  }
  return true;  
}

function isDigit (c){   
  return ((c >= "0") && (c <= "9")) ;
}

function isRadioChecked(formObj) {
  if (!isNaN(formObj.length)) {
    for (var j=0; j<formObj.length; j++) {
      if (formObj[j].checked) return true;
    }
    return false;    
  } else {
    return formObj.checked; 
  }
}

function isOptionSelected(formObj) {
  return (formObj.options[formObj.selectedIndex].value!="- Select -" && formObj.options[formObj.selectedIndex].value != "" && formObj.options[formObj.selectedIndex].value != "0");
}

function isDate(yyyy, mm, dd) {
  if (!isIntegerChar(yyyy) || !isIntegerChar(mm) || !isIntegerChar(dd)) {
    return false;
  } else {
    return (((mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10 || mm == 12) && (dd >=1 && dd <=31)) || 
    ((mm == 4 || mm == 6 || mm == 10 || mm == 12) && (dd>=1 && dd <=30)) || 
    ((mm==2) && ((yyyy%4 == 0 && (dd>=1 && dd<=29)) || (yyyy%4 > 0 && (dd>=1 && dd<=28)))));
  }
}

function isValidLogin(s) {
  return (s.length>=5 && (s.match(/[~!@#$%^&*()+`=:;"'<>?,\/ ]/g)==null));
}

function isValidFilename(s) {
  return (s.length<=255 && !(s.match(/[\\\/?\*:<>\|'\"]/g)));
}


function isValidData(s) {
	var matches = s.match(/[a-zA-Z0-9._\-]/gi);
	if(matches!=null){
	 	return (s.length>=6 && s.length<=16 && matches.length==s.length);
	}else{
		return false;	
	}
}

function isValidLength(s,num){
	return (s.length<=num);	
}

function isValidSpace(s){
		
	
}
