 // JScript source code
// Functions that will be used by suppliers




//-------------------------------------------
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"First and Last Names\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"First and Last Names\" field.");
    theForm.Name.focus();
    return (false);
  }

   if (theForm.LName.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.LName.focus();
    return (false);
  }

  if (theForm.LName.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Last Name\" field.");
    theForm.LName.focus();
    return (false);
  }
  
  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.Prov.selectedIndex == 0)
  {
    alert("The first \"State - Province\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Prov.focus();
    return (false);
  }
	
  if (theForm.Prov.value == "0")
  {
    alert("Your selection in the Prov./State is not valid. Please choose one of the other options");
    theForm.Prov.focus();
    return (false);
  }
	
  if (theForm.Country.selectedIndex < 0)
  {
    alert("Please select one of the \"Country\" options.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.Country.selectedIndex == 0)
  {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.Tel.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.Tel.focus();
    return (false);
  }

  if (theForm.Tel.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Phone\" field.");
    theForm.Tel.focus();
    return (false);
  }
  
  if (theForm.Areacode.value.length > 3)
  {
    alert("Please enter only a 3 digit area code in the \"Area Code\" field.");
    theForm.Areacode.focus();
    return (false);
  }
  
  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }
  
   if (theForm.Email.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }
  
     
 // if (!ctrlEmail)
//  {
//    alert("Invalid Email address - Please try once again");
//    theForm.Email.focus();
//    return (false);
//  }
  
     if(theForm.Email.value.indexOf("@")<0 || theForm.Email.value.indexOf(".")<0)
  {
	alert("Invalid email address - Please try again");
	theForm.Email.focus();
    return (false);
  }
  
  var chOK="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz???????????????????????????????????0123456789-_@.";
  var Email = theForm.Email.value;
  var ctrlEmail = true;
  var i=0;
  var ch;
  
  while(ctrlEmail==true && i<Email.length)
  {
	ch=Email.charAt(i);
	if(chOK.indexOf(ch)<0)
	{
		ctrlEmail=false;
	}
	i++;
  }
  
  if (!ctrlEmail)
  {
    alert("Invalid Email address - Please try again");
    theForm.Email.focus();
    return (false);
  }

//---	  if (theForm.Product1.selectedIndex < 0)
//---	  {
//---	    alert("Please select one of the \"Product1\" options.");
 //---   theForm.Product1.focus();
//---    return (false);
//---  }

//---  if (theForm.Program1.selectedIndex == 0)
//---  {
//---    alert("The first \"Program1\" option is not a valid selection.  Please choose one of the other options.");
//---    theForm.Program1.focus();
//---    return (false);
//---  }
	
//---  if(document.FrontPage_Form1.Product1.value=="0")
//---	{
//---		alert("Please select a product.");
//---		theForm.Product1.focus();
//---	return (false);
//---	}
	
	//**alan writes here 'location; test
	
//	var opt0=document.FrontPage_Form1.Location[0].checked;
 // var opt1=document.FrontPage_Form1.Location[1].checked;
//  var opt2=document.FrontPage_Form1.Location[2].checked;
//  var opt3=document.FrontPage_Form1.Location[3].checked;
	
//	if(opt0==false && opt1==false && opt2==false && opt3==false)
//	{
//		alert("Please select a study location.");
//		if(trvbc.style.display=='')
//		{
//			theForm.Location[0].focus();
//		}
//		else
//	{
//			if(trto.style.display=='')
//			{
//				theForm.Location[1].focus();
//			}
//			
//			else
		{
//			if(trpq.style.display=='')
//			{
//				theForm.Location[2].focus();
//			}
			
//			else
//		{
//				if(trdl.style.display=='')
//			{
//					theForm.Location[3].focus();
//				}
//			}
//		}	
//		}
//		return (false);
//	}	

	
	//**alan writes here 'location; test
	
		
//** '    if (theForm.StartDate.selectedIndex < 0)
//** '   {
//** '     alert("Please select one of the \"Start date\" options.");
//** '     theForm.StartDate.focus();
//** '     return (false);
//** '   }

//** '   if (theForm.StartDate.selectedIndex == 0)
//** '   {
//** '     alert("The first \"Start date\" option is not a valid selection.  Please choose one of the other options.");
//** '     theForm.StartDate.focus();
//** '     return (false);
//** '   }

//** '   if (theForm.StartYear.selectedIndex < 0)
//** '   {
//** '     alert("Please select one of the \"Start Year\" options.");
//** '     theForm.StartYear.focus();
//** '     return (false);
//** '   }

//** '   if (theForm.StartYear.selectedIndex == 0)
//** '   {
//** '     alert("The first \"Start Year\" option is not a valid selection.  Please choose one of the other options.");
//** '     theForm.StartYear.focus();
//** '     return (false);
//** '   }

   if (theForm.TimeToContact.selectedIndex < 0)
   {
    alert("Please select one of the \"Best time to contact you\" options.");
   theForm.TimeToContact.focus();
   return (false);
   }

  if (theForm.TimeToContact.selectedIndex == 0)
   {
    alert("The first \"Best time to contact you\" option is not a valid selection.  Please choose one of the other options.");
    theForm.TimeToContact.focus();
    return (false);
  }


//** '  var radioSelected = false;
//** '  for (i = 0;  i < theForm.Source.length;  i++)
//** '  {
//** '    if (theForm.Source[i].checked)
//** '        radioSelected = true;
//** '  }
 //** ' if (!radioSelected)
//** '  {
 //** '   alert("Please select one of the \"Where did you learn about ATC?\" options.");
//** '    return (false);
//** '  }
  
  //-------------------

    var iChars = "@#$%^&*()+=-[]\\\;/{}|\":<>\\'\\";
        for (var i = 0; i < theForm.comments.value.length; i++) {
                if (iChars.indexOf(theForm.comments.value.charAt(i)) != -1) {
                alert ("The box has special characters. \nThese are not allowed.\n");
				 theForm.comments.focus();
                return false;
        }
                }
  
  return (true);
}
}
//end FrontPage_Form1_Validator(theForm)




