// JavaScript Document
/*
 ______________________________________________________
/ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\
|          Another JavaScript from Uncle Jim           |
|                                                      |
|   Feel free to copy, use and change this script as   |
|        long as this part remains unchanged.          |
|                                                      |
|      Visit my website at http://www.jdstiles.com     |
|           for more scripts like this one             |
|                                                      |
|                     Created: 1996                    |
|              Last Updated: December, 2005            |
\______________________________________________________/
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/
// Revised 2007-2008 by David J. Kind
// Validates the form. If a field fails the validation, The form is not submitted.
function validateForm(myForm)
{
// Validates the sender's name.
    if (myForm.name.value==myForm.name.defaultValue ||
        myForm.name.value.indexOf(' ',0)==0)
    {
		document.location.href="#top";
        alert('\nNo name entered.');
        myForm.name.select();
        myForm.name.focus();
        return false;
    }
	// next feature added by Ray Woods
    if (countInstances(myForm.name.value,' ')<1)
    {
		document.location.href="#top";
        alert("Please enter both your first and your last name.");
        myForm.name.select();
        myForm.name.focus();
        return (false);
    }
// which facility does the sender work for?
// both conditions added by Ray Woods
    if (myForm.hospital.value==myForm.hospital.defaultValue)
    {
		document.location.href="#top";
        alert("Please enter a value for the \"HOSPITAL\" field.");
        myForm.hospital.select();
        myForm.hospital.focus();
        return (false);
    }
    if (myForm.hospital.value.length < 5)
    {
		document.location.href="#top";
        alert("Please enter at least 5 characters in the \"HOSPITAL\" field.");
        myForm.hospital.select();
        myForm.hospital.focus();
        return (false);
    }
// Validates the sender's street address.
    if (myForm.address.value==myForm.address.defaultValue)
    {
		document.location.href="#top";
        alert('\nPlease enter a street address, too.');
        myForm.address.select();
        myForm.address.focus();
        return false;
    }
	// feature added by Ray Woods
    if (countInstances(myForm.address.value,' ') < 2)
    {
		document.location.href="#top";
        alert('Address is incomplete or invalid.\nPlease try again.');
        myForm.address.select();
        myForm.address.focus();
        return (false);
    }
// Validates city of sender's address.
    if (myForm.city.value==myForm.city.defaultValue)
    {
		document.location.href="#top";
        alert('\nPlease include city or town in address.');
        myForm.city.select();
        myForm.city.focus();
        return false;
    }
	// feature added by Ray Woods
    if (myForm.city.value.length < 3)
    {
		document.location.href="#top";
        alert("Please enter at least 3 characters in the \"CITY\" field.");
        myForm.city.select();
        myForm.city.focus();
        return (false);
    }
    if (myForm.state.value==myForm.state.defaultValue)
    {
		document.location.href="#top";
        alert("\nPlease enter either the state or province of destination.");
        myForm.state.select();
        myForm.state.focus();
        return false;
    }
    if (myForm.state.value.length < 2)
    {
		document.location.href="#top";
        alert("\nYour provincial or state code must have at least 2 letters.");
        myForm.state.select();
        myForm.state.focus();
        return false;
    }
    if (myForm.country.value==myForm.country.defaultValue)
    {
		document.location.href="#top";
        alert("\nWhich country are you from?");
        myForm.country.select();
        myForm.country.focus();
        return false;
    }
    if (myForm.zip.value==myForm.zip.defaultValue)
    {
		document.location.href="#top";
        alert("\nDon't forget to include a zip or postal code with your address.");
        myForm.zip.select();
        myForm.zip.focus();
        return false;
    }
    if (myForm.zip.value.length < 5)
    {
		document.location.href="#top";
        alert("\nPlease remember to make your zip or postal code the right length.");
        myForm.zip.select();
        myForm.zip.focus();
        return false;
    }
// Validates the sender's phone number.
    if (myForm.phone.value==myForm.phone.defaultValue)
    {
		document.location.href="#top";
        alert('\nPlease provide your phone number.');
        myForm.phone.select();
        myForm.phone.focus();
        return false;
    }
	// verify that the phone number fits the right format
    if (VerifyPhone(myForm.phone.value)==false)
    {
		document.location.href="#top";
		alert('\nThis phone number is invalid.\nTry again.');
        myForm.phone.select();
        myForm.phone.focus();
        return false;
    }
// Validates the email address provided by sender.
    if (myForm.email.value==myForm.email.defaultValue)
    {
		document.location.href="#top";
        alert('\nNo email address entered.');
        myForm.email.select();
        myForm.email.focus();
        return false;
    }
    var goodEmail = myForm.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
    if (!goodEmail)
    {
		document.location.href="#top";
        alert('\nInvalid email address.');
        myForm.email.select();
        myForm.email.focus();
        return false;
    }

// Validates selection.
    var product_list = new Array();
	product_list[0] = 'iodine';
	product_list[1] = 'palladium';
	product_list[2] = 'iridium';
	product_list[3] = 'cesium';
	product_list[4] = 'implant';
	product_list[5] = 'hdr';
	product_list[6] = 'steppers';
	product_list[7] = 'exam';
	product_list[8] = 'gold';
	product_list[9] = 'nuclear';/*
	product_list[10] = 'medphys';
	product_list[11] = 'mosfet';
	product_list[12] = 'position';
	product_list[13] = 'betacath';
	product_list[14] = 'catmail'; // include requests for catalog as selections
	product_list[15] = 'catlink';*/
	var total = 0;
    for (counter=0; counter < product_list.length; counter++)
	{ if (eval("document.order_form."+product_list[counter]+".checked")==true)
	     { total+= 1; // check to see how many products have been selected
		 } 
	}
	if (myForm.other.value!=myForm.other.defaultValue)
	{ total += 1; } // if information is entered in the "Other" field, that counts as a selection too
    if (total < 1) // do not submit if no selection has been made
    {
        document.location.href="#products";
        alert('\nYou must select a product to submit this form.');
        return false;
    }
	
// Prompts user for confirmation
    else
    {
        if(confirm('\nClick OK button to submit this form.'))
        {   		    
            return true;
        } else {
            return false;
        }
    }
}

// Validates the form. If a field fails the validation, The form is not submitted.
function validate2(myForm)
{
// Validates the sender's name.
    if (myForm.name.value==myForm.name.defaultValue ||
        myForm.name.value.indexOf(' ',0)==0)
    {
		document.location.href="#top";
        alert('\nNo name entered.');
        myForm.name.select();
        myForm.name.focus();
        return false;
    }
	// next feature added by Ray Woods
    if (myForm.name.value.length < 5)
    {
		document.location.href="#top";
        alert("Please enter at least 5 characters in the \"NAME\" field.");
        myForm.name.select();
        myForm.name.focus();
        return (false);
    }
// which hospital does the sender work for?
// both conditions added by Ray Woods
    if (myForm.hospital.value==myForm.hospital.defaultValue)
    {
		document.location.href="#top";
        alert("Please enter a value for the \"HOSPITAL\" field.");
        myForm.hospital.select();
        myForm.hospital.focus();
        return (false);
    }
    if (myForm.hospital.value.length < 5)
    {
		document.location.href="#top";
        alert("Please enter at least 5 characters in the \"HOSPITAL\" field.");
        myForm.hospital.select();
        myForm.hospital.focus();
        return (false);
    }
// which department?
    if (myForm.dept.value==myForm.dept.defaultValue)
    {
		document.location.href="#top";
        alert("Please enter a value for the \"DEPARTMENT\" field.");
        myForm.dept.select();
        myForm.dept.focus();
        return (false);
    }
// Validates the sender's street address.
    if (myForm.address.value==myForm.address.defaultValue)
    {
		document.location.href="#top";
        alert('\nPlease enter a street address, too.');
        myForm.address.select();
        myForm.address.focus();
        return false;
    }
	// feature added by Ray Woods
    if (myForm.address.value.length < 5)
    {
		document.location.href="#top";
        alert("Please enter at least 5 characters in the \"ADDRESS\" field.");
        myForm.address.select();
        myForm.address.focus();
        return (false);
    }
// Validates the email address provided by sender.
    if (myForm.email.value==myForm.email.defaultValue)
    {
		document.location.href="#top";
        alert('\nNo email address entered.');
        myForm.email.select();
        myForm.email.focus();
        return false;
    }
    var goodEmail = myForm.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
    if (!goodEmail)
    {
		document.location.href="#top";
        alert('\nInvalid email address.');
        myForm.email.select();
        myForm.email.focus();
        return false;
    }
// Validates the sender's phone number.
    if (myForm.phone.value==myForm.phone.defaultValue)
    {
		document.location.href="#top";
        alert('\nPlease provide your phone number.');
        myForm.phone.select();
        myForm.phone.focus();
        return false;
    }
	// next feature added by Ray Woods
    if (myForm.phone.value.length < 10)
    {
		document.location.href="#top";
        alert("Please enter at least 10 digits in the \"PHONE\" field.");
        myForm.phone.select();
        myForm.phone.focus();
        return false;
    }
// Validates the sender's fax number.
    if (myForm.fax.value==myForm.fax.defaultValue)
    {
		document.location.href="#top";
        alert('\nPlease provide your fax number, too.');
        myForm.fax.select();
        myForm.fax.focus();
        return false;
    }
	// next feature added by Ray Woods
    if (myForm.fax.value.length < 7)
    {
		document.location.href="#top";
        alert("Please enter at least 7 digits in the \"FAX\" field.");
        myForm.fax.select();
        myForm.fax.focus();
        return false;
    }

// Validates selection.
    var dates = new Array();
	dates[0] = 'monday';
	dates[1] = 'tuesday';
	var total = 0;
    for (counter=0; counter < dates.length; counter++)
	{ if (eval("document.invitation."+dates[counter]+".checked")==true)
	     { total+= 1; // check to see how many products have been selected
		 } 
	}
    if (total < 1) // do not submit if no selection has been made
    {
        document.location.href="#dates";
        alert('\nYou must select at least one date of attendance to submit this form.');
        return false;
    }
	
// Prompts user for confirmation
    else
    {
        if(confirm('\nClick OK button to submit this form.'))
        {   		    
            return true;
        } else {
            return false;
        }
    }
}


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Philip Peterson (IronMagma@hotmail.com) -->
<!-- Web Site:  http://www.ironmagma.tk -->

function countInstances(element,word) {
montage=element.split(word).length-1;
return montage;
}


/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: David Leppek :: https://www.azcode.com/Mod10*/

function VerifyPhone(phone_num) {  // v2.0
var valid = "0123456789 "  // valid digits in a phone number
var len = phone_num.length;  // The length of the submitted phone number
var sPN = phone_num.toString();  // string of phone number
sPN = sPN.replace (/^\s+|\s+$/g,'');  // strip spaces

// Determine if the phone number is, in fact, all numbers, with the exception of spaces
for (var j=0; j<len; j++) {
  temp = "" + sPN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1") { return false; }
}
// Determine if it is the proper length 
if (len < 7) { return false; }
return true; // return true if it is
}
// -->
