/*****************************************************************
  Returns true if string only contains whitespace
                               11/07/01 22:52
*****************************************************************/
function isBlank(string)
{
  for(var i=0; i<string.length; i++) {
    var c = string.charAt(i);
    if((c!=' ') && (c!='\n') && (c!='\t'))
      return false;
  }
  return true;
}  // isBlank

/*****************************************************************
  Returns true if form element is blank
                               11/07/01 22:49
*****************************************************************/
function isFieldEmpty( field_name )
{
 if(field_name.value == null || field_name.value == "" || isBlank(field_name.value))
    return true;
 else
    return false;
}  // isFieldEmpty

function getWordCount ( sInputString )
{

	var theSplit = new Array()
	theSplit = sInputString.split(" ");
	return theSplit.length;

}

/*****************************************************************
  For use when Viewing/Hiding information when the user selects
  something.  Do not forget to include the :
  OnLoad="xsetup();" in your body tag or this script
  will not work.
                                24/08/01 13:00
*****************************************************************/
  
  var preloadFlag = false;
  function xsetup() {
  }
  function toggleHidden(b,c)
  {
  	if (b.style.display =='')
  	{
  		b.style.display = 'none';
  		c.src='../images/removeitem.gif'	
  	}
  	else
  	{
  		b.style.display='';
  		c.src='../images/showitem.gif'
  	}
  }
  
  function toggle (b){

			var myElement = document.getElementById("line" + b);
			var myImage = document.getElementById("image" + b);
		
			if (myElement.style.display=="none")
			{
				myElement.style.display = "";
				myImage.src='../images/removeitem.gif'
			}
			else
			{
				myElement.style.display = "none";
				myImage.src='../images/showitem.gif'	
			}
		}
		
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function isPhoneNumber(strPhone) 
{
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}