function hasSpecial(str) {
 return str.match(/[!,@,#,$,%,^,*,?,_,~,-]/g);
}

function countUpper(str) {
 return str.replace(/[^A-Z]/g, "").length;
}

function countLower(str) {
 return str.replace(/[^a-z]/g, "").length;
}

function hasNumber(t)
{
 return /\d/.test(t);
}


function toInt(s) {
	while ((s.length > 0) && (s[0] == '0')) {
		s = s.substr(1, s.length);
	}
	if ((!s) || (s == '')) { s = '0'; }
	return parseInt(s);
}


/*****************************************************************************************/
/* Lets start with leftTrim() function, which will trim all white spaces in front of a   */
/* string and will return the trimmed string. Please have a look at the leftTrim         */
/* JavaScript function below:                                                            */
/*****************************************************************************************/

function leftTrim(sString)
{
  while (sString.substring(0,1) == ' ')
  {
    sString = sString.substring(1, sString.length);
  }
  return sString;
}

/*****************************************************************************************/
/* The rightTrim() JavaScript function works in exactly the same way, except that it     */
/* trims the white spaces at the end of the string:                                      */
/*****************************************************************************************/

function rightTrim(sString)
{
  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}

/*****************************************************************************************/
/* The allTrim() JavaScript function combines both leftTrim() and rightTrim() functions: */
/*****************************************************************************************/

function trimAll(sString)
{
  while (sString.substring(0,1) == ' ')
  {
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}

function validatePostcode(sPostcode)
{
  var postcodeRegxp = /^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/;;
  if (postcodeRegxp.test(sPostcode) != true)
  {
    return false;
  }
  else
  {
    return true;
  }
}

function checkTelefoon(sTelefoon) {
  return ((/^\d{3}[-]?\d{7}$|^\d{4}[-]?\d{6}$/).test(sTelefoon));
}

