
function SetTimeZone()
{
	var today = new Date();
	var GMTOffset = - Math.round(today.getTimezoneOffset() / 30) / 2;
	var expires = new Date();
	expires.setTime(expires.getTime() + 3E11);
	document.cookie = "GMTOffset=" + escape(GMTOffset) + "; expires=" + expires.toGMTString();
}

function StripOutSpaces(strValue)
{
	var oRE = /\s/g;
	return strValue.replace(oRE, "");
}

function ValidEmailAddress(strEmail)
{
	 // Simple client-side email address validation.  It saves round trips.
	 strEmail = StripOutSpaces(strEmail);
	 return /^[^@]+@[^@]+\.[^@]{2,}$/i.test(strEmail);
}

function ValidNumber(strNumber) 
{
	// Check if the value parsed any contains numbers and/or a full stop
	if (strNumber.length == 0) return false;

	// Check for 0 - 9 and decimal place (period)
	for (i = 0; i < strNumber.length; i++) 
	{
		if ((strNumber.charAt(i) > "9") || (strNumber.charAt(i) < "0") && (strNumber.charAt(i) != '.'))
		return false;
	}

	return true;
}

// check and ensure a whole non-decimal number is returned /Tobi 21 April 2009
function ValidInteger(strNumber) {
    if (!ValidNumber(strNumber))
        return false;
    else
        return (strNumber.indexOf(".") == -1);
}
  

function PhoneNumberChars(strValue) 
{
	var strReturnValue = '';

    // Take out any spaces in the specified string
    for (i = 0; i < strValue.length; i++) 
    {
       if ((strValue.charAt(i) >= "0") && (strValue.charAt(i) <= "9"))
			 strReturnValue += strValue.charAt(i)
    }
  
    return strReturnValue;
  }

  function ValidNumberWithSpaces(strNumber) 
  {
    // Check if the value parsed only contains numbers or spaces

    if (strNumber.length == 0) return false;

    // if (strNumber == '') return false;

    // Check for 0 - 9 and decimal place (period)
    for (i = 0; i < strNumber.length; i++) 
    {
      if ((strNumber.charAt(i) > "9") || (strNumber.charAt(i) < "0") && (strNumber.charAt(i) != ' '))
         return false;
    }

    return true;
  }

  function StripOutSpaces(strValue) 
  {
    var strReturnValue = '';

    // Take out any spaces in the specified string
    for (i = 0; i < strValue.length; i++) 
    {
       if (strValue.charAt(i) != ' ')
	  strReturnValue = strReturnValue + strValue.charAt(i)
    }
  
    return strReturnValue;
  }

function SpacesPresent(text) 
{
	for (var iLoop = 0; iLoop < text.length; iLoop++) 
	{
		if (text.charAt(iLoop) == " ") return true;
	}
	return false;
}
  
function CountWords(text)
{
	var count = 1;

	for (var iLoop = 1; iLoop < text.length; iLoop++)
	{
		if (text.charAt(iLoop) == " " && text.charAt(iLoop-1) != " ") count++;
	}

	return count;
}