function Trim(str)
{
  if (str.length = 0) 
    return "";

  var whitespace = new String(" \t\n\r");
  var s = new String(str);
  if (whitespace.indexOf(s.charAt(0)) != -1) {
  // We have a string with leading blank(s)...
  var j=0, i = s.length;
  // Iterate from the far left of string until we
  // don't have any more whitespace...
  while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;
    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...
    var j = s.length - 1;       // Get length of string
    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (j >= 0 && whitespace.indexOf(s.charAt(j)) != -1)
      j--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, j+1);
  }
  return s;
}
// To check if whitespace(s) exist in a string
function CheckSpace( str ) {
   var re = /[\s]+/;        
                            
   if( str.match( re ) ) {  
      return false;          
   }                        
   else {                   
      return true;         
   }                        
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function isInteger (s)
{   
    var i;
       if (s.length == 0) return  false;
    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    // All characters are numbers.
    return true;
}

function isDigit (c){   
	return ((c >= "0") && (c <= "9") && (c="."))
}
