// JavaScript Document
/*
# ------------------------------
# Created by: Ramesh N Sharma.
# Created date: 2nd April 2007
# File description: validation file
# Special instructions-notes: none
# Tables used: none
# Stored procedures: none 
# Triggers used: none
# ------------------------------
*/
String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};
function IsNumeric(sText)
{
   var ValidChars = "0123456789-.";
   var IsNumber=true;
   var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}
function istelephoneno(fax)
{
	tel_arr=explodeArray(fax,"-")
	if (tel_arr[0].length!=3) return false;
	if (tel_arr[1].length!=3) return false;
	if (tel_arr[2].length!=4) return false;
	if (!IsNumeric(tel_arr[0])) return false;
	if (!IsNumeric(tel_arr[1])) return false;
	if (!IsNumeric(tel_arr[2])) return false;
	return true;
}
function explodeArray(item,delimiter) 
{
  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) 
  {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }
  tempArray[Count]=tempString;
  return tempArray;
}
function isCharsInBag (s, bag)
{  
  var i;
  for (i = 0; i < s.length; i++)
  {   
	  var c = s.charAt(i);
	  if (bag.indexOf(c) == -1) return false;
  }
  return true;
}
function isEmail(string)
{
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	return false;
}
