
	function ConfirmDelete()
	{
		if (confirm('Are you sure you wish to delete this record?\nThis action cannot be undone.'))
			return true;
		else
			return false;
	}

	// Returns true if character c is a letter
	function IsLetter(c)
	{
		return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")));
	}

	// Returns true if character c is a digit 
	function IsDigit(c)
	{
		return ((c >= "0") && (c <= "9"));
	}

	// Returns true if all characters in string are letters
	function IsAlpha(string)
	{
		for (i = 0; i < string.length; i++)
			if (!IsLetter(string.charAt(i)))
				return false;
		return true;
	}

	// Returns true if all characters in string are digits
	function IsInteger(string)
	{
		string = string + '';
		for (i = 0; i < string.length; i++)
			if (!IsDigit(string.charAt(i)))
				return false;
		return true;
	}

	// Returns true if all characters in string are digits
	function IsNumeric(string)
	{
		string = Trim(string);
		for (i = 0; i < string.length; i++)
			if (!IsDigit(string.charAt(i)) && string.charAt(i) != ".")
				return false;
		return true;
	}

	// Returns true if string is valid Canadian postal code 
	// (6 characters of X9X9X9 - i.e. letter-number-letter-number-letter-number)
	// strips all spaces from the string before validating
	function IsPostal(string)
	{
		string = StripSpaces(string);
		if (string.length == 6)
			if (IsAlpha(string.charAt(0) + string.charAt(2) + string.charAt(4))
			 && IsNumeric(string.charAt(1) + string.charAt(3) + string.charAt(5)))
				return true;
			else
				return false;
		else
			return false;
	}

	// Strips leading spaces from string
	function LTrim(string)
	{
		while (string.charAt(0) == " ")
			string = string.substring(1, string.length);
		return string;
	}

	// Strips trailing spaces from string
	function RTrim(string)
	{
		while (string.charAt(string.length - 1) == " ")
			string = string.substring(0, string.length - 1);
		return string;
	}

	// Strips leading & trailing spaces from string
	function Trim(string)
	{
		return RTrim(LTrim(string));
	}

	// Strips all spaces from string
	function StripSpaces(string) 
	{
		var temp = "";
		string = '' + string;
		splitstring = string.split(" ");
		for (i = 0; i < splitstring.length; i++)
			temp += splitstring[i];
		return temp;
	}

	// Returns true if the string contains a valid 
	// email address (in form a@b.c).  There must
	// be one and only one @ and . characters. 
	function IsEmail(string)
	{
		string = string + '';

		// minimum is a@b.xx - 6 characters
		if (string.length < 6)
			return false;

		// only one '@' with characters before & after
		splitstring = string.split("@");
		if (splitstring.length != 2)
			return false;

		// get the part after the @ and check
		// at least one '.' with characters before & after
		temp = splitstring[1];
		splitstring = temp.split(".");
		if (splitstring.length < 2)
			return false;

		// get the part after the . and check
		// at least 2 characters after the . and
		// no more than 5 characters
		temp = splitstring[splitstring.length - 1];
		if ((temp.length < 2) || (temp.length > 5))
			return false;

		return true;
	}
	
	<!--- SIN --->
	function IsSIN(string)
	{		
	  	// f as frmMain.SINO not frmMain.SINO.value !Change to frmMain.SINO.value
	  	var f = string;
	      for (var j = 0; j < 9; j++)
	      {                               
	              //separate digits
	              var num1 = f.value.charAt(0);
	              var num2 = f.value.charAt(1);
	              var num3 = f.value.charAt(2);
	              var num4 = f.value.charAt(3);
	              var num5 = f.value.charAt(4);
	              var num6 = f.value.charAt(5);
	              var num7 = f.value.charAt(6);
	              var num8 = f.value.charAt(7);
	              var num9 = f.value.charAt(8);                           
	      }
	
	      //validate
	      var step1 = 2 * (num2 + num4 + num6 + num8);
	      var step2 = 0;
	      var tempNum = Math.floor(step1 / 10000);
	      step2 += tempNum;                       
	      step1 -= (tempNum * 10000);
	      tempNum = Math.floor(step1 / 1000);
	      step2 += tempNum;                       
	      step1 -= (tempNum * 1000);
	      tempNum = Math.floor(step1 / 100);
	      step2 += tempNum;                       
	      step1 -= (tempNum * 100);                       
	      tempNum = Math.floor(step1 / 10);
	      step2 += tempNum;                       
	      step1 -= (tempNum * 10);
	      tempNum = Math.floor(step1 / 1)
	      step2 += tempNum;
	                      
	      var step3 = num1 + num3 + num5 + num7;                          
	      tempNum = Math.floor(step3 / 1000);
	      step2 += tempNum;
	      step3 -= (tempNum * 1000);                      
	      tempNum = Math.floor(step3 / 100);
	      step2 += tempNum;                                       
	      step3 -= (tempNum * 100);                       
	      tempNum = Math.floor(step3 / 10);
	      step2 += tempNum;                                               
	      step3 -= (tempNum * 10);
	      tempNum = Math.floor(step3 / 1)
	      step2 += tempNum;
	                              
	      tempNum = Math.floor(step2 / 10);
	      valid = 10 - (step2 - (tempNum * 10));          
	      var msg = "The Social Insurance Number " + num1 + num2 + num3 +
	              " " + num4 + num5 + num6 + " " + num7 + num8 + num9 + " is ";
	      
	      if (valid == 10)
	            valid -= 10;
	            //alert (valid);                
	      if (valid == num9)
	            return (true);
	      else
		  		//alert("SIN must be a valid 9 digit number");
	      		return (false);
     }

	function GetCCType(string)
	{
		var f = string;

		// if we don't have at least 4 characters we're not even going to try
		if (f.length < 4)
			return 'INVALID';

		if (f.charAt(0) == '3')
		{
			// 300-305, 36, and 38 are Diners Club / Carte Blanche
			// 34, and 37 are American Express
			if ((f.charAt(1) == '0' && f.charAt(2) == '0') ||
				(f.charAt(1) == '0' && f.charAt(2) == '1') ||
				(f.charAt(1) == '0' && f.charAt(2) == '2') ||
				(f.charAt(1) == '0' && f.charAt(2) == '3') ||
				(f.charAt(1) == '0' && f.charAt(2) == '4') ||
				(f.charAt(1) == '0' && f.charAt(2) == '5') ||
				(f.charAt(1) == '6') ||
				(f.charAt(1) == '8'))
				return 'DINERS';
			else if (f.charAt(1) == '4' || f.charAt(1) == '7')
				return 'AMEX';
		}
		else if (f.charAt(0) == '4')
		{
			// starts with 4 is Visa
			return 'VISA';
		}
		else if ((f.charAt(0) == '5' && f.charAt(1) == '1') ||
				 (f.charAt(0) == '5' && f.charAt(1) == '2') ||
				 (f.charAt(0) == '5' && f.charAt(1) == '3') ||
				 (f.charAt(0) == '5' && f.charAt(1) == '4') ||
				 (f.charAt(0) == '5' && f.charAt(1) == '5'))
		{
			// starts with 51 through 55 is MasterCard
			return 'MC';
		}
		else if (f.charAt(0) == '6' && f.charAt(1) == '0' && f.charAt(2) == '1' && f.charAt(3) == '1')
		{
			// starts with 6011 is Discover
			return 'DISCOVER';
		}

		// didn't recognized it
		return 'UNRECOGNIZED';

	}

	function IsValidCCCheckDigit(string)
	{
		var f = string;

		var i, n, c, t;

		// First, reverse the string
		var r = '';
		for (i = 0; i < f.length; i++)
			r = f.charAt(i) + r;

		// Now run through each single digit to create a new string. Even digits
		// are multiplied by two, odd digits are left alone.
		t = '';
		for (i = 0; i < r.length; i++) 
		{
			c = r.charAt(i);
			if (i % 2 != 0)
				c *= 2;
			t = t + c;
		}

		// Finally, add up all the single digits in this string.
		n = 0;
		for (i = 0; i < t.length; i++) 
		{
			c = parseInt(t.charAt(i), 10);
			n = n + c;
		}

		// If the resulting sum is an even multiple of ten (but not zero), the
		// card number is good.
		if (n != 0 && n % 10 == 0)
			return true;
		else
			return false;
	}

	function IsValidVisa(string)
	{
		var f = string;

		// Visa numbers can be 13 or 16 digits
		if (f.length != 13 && f.length != 16)
			return false;

		if (!IsNumeric(f))
			return false;

		if (!IsValidCCCheckDigit(f))
			return false;

		return true;
	}

	// Visa numbers can be 13 or 16 digits
	// others can be MC-16, AMEX-15, DISCOVER-16, DINERS-14
	function IsCreditCard(string)
	{
		var f = string;

		var CCType = GetCCType(f);

		// CHECKING VISA ADD OTHERS LATER
		if (CCType == 'VISA')
			return IsValidVisa(f);
		else
			return false;
	}
	

	// Returns true if year is a leap year
	// A year is a leap year if it is evenly divisible by 4,
	// but not by 100, unless it is evenly divisible by 400
	function IsLeapYear(yr)
	{
		return ((yr % 400 == 0) || ((yr % 4 == 0) && (yr % 100 != 0)));
	}

	// Returns true if string is a valid date in form
	// YYYY-MM-DD, YY-MM-DD, YYYY/MM/DD, or YY/MM/DD
	function IsDate(string)
	{
		var Year, Mon, Day;

		string = string + '';

		// minimum is xx-xx-xx maximum is xxxx-xx-xx
		if ((string.length != 8) && (string.length != 10))
			return false;

		// make sure we don't have both - and /
		if ((string.indexOf("-") > 0)
		 && (string.indexOf("/") > 0))
			return false;

		// look for separator - or / and break date apart
		if (string.indexOf("-") > 0)
			temp = string.split("-");
		else if (string.indexOf("/") > 0)
			temp = string.split("/");
		else
			return false;

		// we need EXACTLY 3 date parts
		if (temp.length != 3)
			return false;

		// format is y/m/d
		Year = parseInt(temp[0]);
		Mon  = parseInt(temp[1]);
		Day  = parseInt(temp[2]);

		// convert 2 digit years to 4 digits
		if (Year < 50)
			Year += 2000;
		if (Year < 100)
			Year += 1900;

		// make sure month is valid
		if (Mon < 0 || Mon > 12)
			return false;

		// make sure day is valid
		if (Mon == 1
		 || Mon == 3 
		 || Mon == 5 
		 || Mon == 7 
		 || Mon == 8 
		 || Mon == 10 
		 || Mon == 12)
			MaxDays = 31;
		else if (Mon != 2)
			MaxDays = 30;
		else
			if (IsLeapYear(Year))
				MaxDays = 29;
			else
				MaxDays = 28;
		if (Day < 0 || Day > MaxDays)
			return false;

		return true;
	}

	function CheckRequired(string)
	{
		if (Trim(string) == '')
		{
			alert('Please enter a value');
			return false;
		}
		else
			return true;
	}

	function CheckEmail(string, required)
	{
		string = Trim(string);
		if (required && (string == ''))
		{
			alert('Please enter a value');
			return false;
		}
		if (!IsEmail(string))
		{
			alert('Invalid email address');
			return false;
		}
		else
			return true;
	}

