
function fValidate(varProcess) {
	
	document.forms["frm1"].Process.value = varProcess;

	if (document.forms["frm1"].BusinessType.value == "")
	{
	    alert('Business Type required');
	    document.forms["frm1"].BusinessType.focus();
	    fRequiredField();
		return false;
	}			
	else if (document.forms["frm1"].CompanyName.value == "")
	{
	    alert('Company Name required');
	    document.forms["frm1"].CompanyName.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].MrMs.value == "")
	{
	    alert('Mr./Ms. required');
	    document.forms["frm1"].MrMs.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].FullName.value == "")
	{
	    alert('Full Name required');
	    document.forms["frm1"].FullName.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].Title.value == "")
	{
	    alert('Job Title required');
	    document.forms["frm1"].Title.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].Address.value == "")
	{
	    alert('Address required');
	    document.forms["frm1"].Address.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].CityTown.value == "")
	{
	    alert('City/Town required');
	    document.forms["frm1"].CityTown.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].StateProvince.value == "")
	{
	    alert('State/Province required');
	    document.forms["frm1"].StateProvince.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].ZipPostalCode.value == "")
	{
	    alert('Zip/Postal Code required');
	    document.forms["frm1"].ZipPostalCode.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].Country.value == "")
	{
	    alert('Country required');
	    document.forms["frm1"].Country.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].TelephoneCountryCode.value == "")
	{
	    alert('Telephone Country Code required');
	    document.forms["frm1"].TelephoneCountryCode.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].TelephoneAreaCode.value == "")
	{
	    alert('Telephone Area Code required');
	    document.forms["frm1"].TelephoneAreaCode.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].TelephoneNumber.value == "")
	{
	    alert('Telephone Number required');
	    document.forms["frm1"].TelephoneNumber.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].Email.value == "")
	{
	    alert('E-mail address required');
	    document.forms["frm1"].Email.focus();
	    fRequiredField();
		return false;
	}
	else if ( !(checkEmailAddress(document.forms["frm1"].Email.value.toLowerCase()) ) )
	{
	  alert('Invalid E-mail address');		  
	  document.forms["frm1"].Email.focus();
	  fRequiredField();
	  return false;
	}
	else if (document.forms["frm1"].PartNumber.value == "")
	{
	    alert('Sponge Ball Part Number or Size Required');
	    document.forms["frm1"].PartNumber.focus();
	    fRequiredField();
		return false;
	}
	else if (document.forms["frm1"].Usage.value == "")
	{
	    alert('Please explain usage');
	    document.forms["frm1"].Usage.focus();
	    fRequiredField();
		return false;
	}
	else {
		document.body.style.cursor = 'wait';
		document.forms["frm1"].submit1.disabled = true;
		document.forms["frm1"].reset1.disabled = true;
		return true;
	}
		
}

function fRequiredField(){
	document.forms["frm1"].BusinessType.style.backgroundColor='#fff8dc';
	document.forms["frm1"].CompanyName.style.backgroundColor='#fff8dc';
	document.forms["frm1"].MrMs.style.backgroundColor='#fff8dc';
	document.forms["frm1"].FullName.style.backgroundColor='#fff8dc';
	document.forms["frm1"].Title.style.backgroundColor='#fff8dc';
	document.forms["frm1"].Address.style.backgroundColor='#fff8dc';
	document.forms["frm1"].CityTown.style.backgroundColor='#fff8dc';
	document.forms["frm1"].StateProvince.style.backgroundColor='#fff8dc';
	document.forms["frm1"].ZipPostalCode.style.backgroundColor='#fff8dc';
	document.forms["frm1"].Country.style.backgroundColor='#fff8dc';
	document.forms["frm1"].TelephoneCountryCode.style.backgroundColor='#fff8dc';
	document.forms["frm1"].TelephoneAreaCode.style.backgroundColor='#fff8dc';
	document.forms["frm1"].TelephoneNumber.style.backgroundColor='#fff8dc';
	document.forms["frm1"].Email.style.backgroundColor='#fff8dc';
	document.forms["frm1"].PartNumber.style.backgroundColor='#fff8dc';
	document.forms["frm1"].Usage.style.backgroundColor='#fff8dc';
}

function fResetContact(){
	if (confirm('Reset form fields?')==true){
		document.forms["frm1"].BusinessType.value='';
		document.forms["frm1"].CompanyName.value='';
		document.forms["frm1"].MrMs.value='';
		document.forms["frm1"].FullName.value='';
		document.forms["frm1"].Title.value='';
		document.forms["frm1"].Department.value='';
		document.forms["frm1"].Address.value='';
		document.forms["frm1"].CityTown.value='';
		document.forms["frm1"].StateProvince.value='';
		document.forms["frm1"].ZipPostalCode.value='';
		document.forms["frm1"].Country.value='';
		document.forms["frm1"].TelephoneCountryCode.value='';
		document.forms["frm1"].TelephoneAreaCode.value='';
		document.forms["frm1"].TelephoneNumber.value='';
		document.forms["frm1"].FaxCountryCode.value='';
		document.forms["frm1"].FaxAreaCode.value='';
		document.forms["frm1"].FaxNumber.value='';
		document.forms["frm1"].Email.value='';
		document.forms["frm1"].CompanyUrl.value='http://';
		document.forms["frm1"].CurrentMfg.value='';
		document.forms["frm1"].PartNumber.value='';
		document.forms["frm1"].Usage.value='';
		document.forms["frm1"].PlannedPurchaseQuantities.value='';
		document.forms["frm1"].Comments.value='';
		document.forms["frm1"].NotifyFlag.checked=true;
	}
	return false;
}


function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
}
				
function isNumeric(val){
	return(parseFloat(val,10)==(val*1));
}


function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}


function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
	// only allow 0-9 be entered, plus any values passed
	// (can be in any order, and don't have to be comma, period, or hyphen)
	// if all numbers allow commas, periods, hyphens or whatever,
	// just hard code it here and take out the passed parameters
	var checkOK = " .0123456789" + comma + period + hyphen;
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";

	for (i = 0;  i < checkStr.value.length;  i++)
	{
	ch = checkStr.value.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
	allValid = false;
	break;
	}
	if (ch != ",")
	allNum += ch;
	}
	if (!allValid)
	{	
	alertsay = "Please enter only these values \""
	alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
	alertsay = "Invalid Number"
	alert(alertsay);
	return (false);
	}

	// set the minimum and maximum
	var chkVal = allNum;
	var prsVal = parseInt(allNum);
	if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
	{
	alertsay = "Please enter a value greater than or "
	alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
	alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
	alertsay = "Invalid Number"
	alert(alertsay);
	return (false);
	}
}


function Trim(str)
    {
       return RTrim(LTrim(str));
    }


function LTrim(str) {
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            s = s.substring(j, i);
        }
        return s;
    }
    
    
function RTrim(str) {            
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            var i = s.length - 1;
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            s = s.substring(0, i+1);
        }
        return s;
    }


function ValidateInteger(TheValue,Min,Max,AllowBlank) {
	if (!TestInteger(TheValue) > 0){
		return false;
	}
	if (!TestInteger(parseInt(TheValue)) > 0){
		return false;
	}
	if (TheValue < Min || TheValue > Max){
		return false;
	}	
	return true
}


function TestInteger(x) 
{
	if ((x % 1) == 0)
		return true;		
	return false;
}


function checkEmailAddress(emailStr)
{
  /* Verify that address ends in two-letter country or well-known
  TLD.  1 means check, 0 means don't. */

  var checkTLD=1;

  /* List of known TLDs that e-mail address must end with. */

  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

  /* Pattern is used to check if the e-mail address
  fits the user@domain format.  Also used to separate the username
  from the domain. */

  var emailPat=/^(.+)@(.+)$/;

  /* String represents the pattern for matching all special
  characters.  We don't want to allow special characters in the address. 
  These characters include ( ) < > @ , ; : \ " . [ ] */

  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

  /* String represents the range of characters allowed in a 
  username or domainname.  It really states which chars aren't allowed.*/

  var validChars="\[^\\s" + specialChars + "\]";


  /* Pattern applies if "user" is a quoted string in
  which case, there are no rules about which characters are allowed
  and which aren't E.g. "jiminy cricket"@disney.com
  is a legal e-mail address. */

  var quotedUser="(\"[^\"]*\")";

  /* Pattern for domains that are IP addresses,
  rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
  e-mail address. NOTE: The square brackets are required. */

  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

  /* String represents an atom (basically a series of non-special characters.) */

  var atom=validChars + '+';

  /* String represents one word in typical username.
  For example, in john.doe@somewhere.com, john and doe are words.  */

  var word="(" + atom + "|" + quotedUser + ")";

  // Pattern describes the structure of the user

  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

  /* Pattern describes the structure of a normal symbolic
  domain, as opposed to ipDomainPat, shown above. */

  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

  /* Begin with the coarse pattern to simply break up user@domain into
  different pieces that are easy to analyze. */

  var matchArray=emailStr.match(emailPat);

  if (matchArray==null)
  {

    /* Too many/few @'s or something; basically, this address doesn't
    even fit the general mould of a valid e-mail address. */
    errorIndex = 0;
    // "Email address incorrect (check @ and .'s)"
    return false;
  }

  var user=matchArray[1];
  var domain=matchArray[2];

  // Start by checking that only basic ASCII characters are in the strings (0-127).

  for (i=0; i<user.length; i++)
  {
    if (user.charCodeAt(i)>127)
    {
      errorIndex = 1;
      // "Username contains invalid characters."
      return false;
    }

  }

  for (i=0; i<domain.length; i++)
  {
    if (domain.charCodeAt(i)>127)
    {
      errorIndex = 2;
      // "Domain name contains invalid characters."
      return false;
    }

  }

  // See if "user" is valid 

  if (user.match(userPat)==null)
  {

    // user is not valid
    errorIndex = 3;
    // "Username doesn't seem to be valid."
    return false;
  }

  /* if the e-mail address is at an IP address (as opposed to a symbolic
  host name) make sure the IP address is valid. */

  var IPArray=domain.match(ipDomainPat);
  if (IPArray!=null)
  {

    // this is an IP address

    for (var i=1;i<=4;i++)
    {
      if (IPArray[i]>255)
      {
        errorIndex = 4;
        // "IP address is invalid!"
        return false;
      }
    }
    return true;
  }

  // Domain is symbolic name.  Check if it's valid.
 
  var atomPat=new RegExp("^" + atom + "$");
  var domArr=domain.split(".");
  var len=domArr.length;
  for (i=0;i<len;i++)
  {
    if (domArr[i].search(atomPat)==-1)
    {
      errorIndex = 5;
      // "Domain name does not seem to be valid."
      return false;
    }
  }

  /* domain name seems valid, but make sure it ends in a
  known top-level domain (like com, edu, gov) or a two-letter word,
  representing country (uk, nl), and that there's a hostname preceding 
  the domain or country. */

  if (checkTLD && domArr[domArr.length-1].length!=2 && 
    domArr[domArr.length-1].search(knownDomsPat)==-1)
  {
    errorIndex = 6;
    // "Address must end in known domain or two letter country suffix"
    return false;
  }

  // Make sure there's a host name preceding the domain.

  if (len<2)
  {
    errorIndex = 7;
    // "This address is missing a hostname!"
    return false;
  }


  // Everything's valid!
  return true;
}





//MM_preloadImages('images/system/home2.jpg');
//MM_preloadImages('images/system/charity2.jpg');
//MM_preloadImages('images/system/links2.jpg');
//MM_preloadImages('images/system/news2.jpg');
//MM_preloadImages('images/system/search2.jpg');
//MM_preloadImages('images/system/contact2.jpg');

function MM_preloadImages() { //v1.2
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    var preloadArray = new Array();
    for (var i=0; i<imgFiles.length; i++) {
      preloadArray[i] = new Image;
      preloadArray[i].src = imgFiles[i];
    }
  }
}

function MM_swapImage() { //v1.2
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function MM_swapImgRestore() { //v1.2
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}