var returnVal = true;
var DEBUG = 0;

//=========================================


//================================================
// Purpose: check if field is blank or NULL
// Params:
//	field (IN)
//	errorMsg (IN - MODIFIED)
//	fieldTitle (IN)
// Returns:
//	errorMsg - error message
// Globals:
//	sets global variable (returnVal) to FALSE if field is blank or NULL
//=============================================
function ValidateAllFields(obj)
{
   returnVal = true;
   errorMsg = "The required field(s):\n\n";
// document.print();
	// return;
//------------------

   if (isSomeFieldsEmpty(obj) == true) {
// if (true== true) {
     // DISPLAY ERROR MSG
     displayErrorMsg();
     returnVal = false;
   }

   if (returnVal == true)
     document.forms[0].submit();
}

//================================================
function displayErrorMsg()
{
   errorMsg += "\nhas not been completed.";
   alert(errorMsg);
}

//================================================


//================================================
function isSomeFieldsEmpty(obj)
{
   var returnVal3 = false;
   var stateIndex = obj.state.selectedIndex;

   var countryIndex = obj.country.selectedIndex;

   if (obj.name.value == "" || obj.name.value == null) {
     errorMsg += " " + "Name" + "\n";
     returnVal3 = true;
   }

   if (obj.company.value == "" || obj.company.value == null) {
     errorMsg += " " + "Company" + "\n";
     returnVal3 = true;
   }

   if (obj.address.value == "" || obj.address.value == null) {
     errorMsg += " " + "Street Address" + "\n";
     returnVal3 = true;
   }

   if (obj.city.value == "" || obj.city.value == null) {
     errorMsg += " " + "City" + "\n";
     returnVal3 = true;
   }

   if (stateIndex == 0) {
     errorMsg += " " + "State/Province" + "\n";
     returnVal3 = true;
   } else if (stateIndex == 1) {
     if (obj.otherState.value == "" || obj.otherState.value == null) {
       errorMsg += " " + "Other State/Province" + "\n";
       returnVal3 = true;
     }
   }

   if (obj.zip.value == "" || obj.zip.value == null) {
     errorMsg += " " + "Zip/Postal Code" + "\n";
     returnVal3 = true;
   }

   if (countryIndex == 0) {
     errorMsg += " " + "Country" + "\n";
     returnVal3 = true;
   }
//	 else if (countryIndex == 1) {
//     if (obj.otherCountry.value == "" || obj.otherCountry.value == null) {
//       errorMsg += " " + "Other Country" + "\n";
//       returnVal3 = true;
//     }
//   }

   if (obj.phone.value == "" || obj.phone.value == null) {
     errorMsg += " " + "Phone Number" + "\n";
     returnVal3 = true;
   }

   if (obj.email.value == "" || obj.email.value == null) {
     errorMsg += " " + "E-mail Address" + "\n";
     returnVal3 = true;
   }

   return (returnVal3);
}

function checkMem(obj)
{
//	if (obj.MemType.Professional.checked)
//	if (obj.Professional.checked)
	if (obj.MemType.value == "Professional")
	if (obj.MemType[1].checked)
	{
		alert("Professional selected");
	}
}

//=========================================

function setFocus(f, n)
{
	if (DEBUG) alert ("f[0].name: " + f[n].name);
	f[n].focus();
}

//=========================================

function showStuff(obj)
{
var s="";
	 s = "i in obj\n";		for (i in obj) s+=i+": "+i+"\n"; alert(s);
	// s = "i in this\n"; 		for (i in this) s+=i+": "+i+"\n"; alert(s);
	for (i =0, s="obj.names\n", n=""; i < obj.length-1; i++)
	{
		n = obj[i].name;
		s += n + ", ";
	}
 	alert (s);
	// s=""; 	for (i in document) s+=i+": "+i+"\n"; alert(s);
	 setFocus(obj, 2);
}

//===============================================


