function ChkFCContact() {
		if(document.FCForm.FCName.value == ""){
			alert("Please enter a value for Name.");
			document.FCForm.FCName.focus();
			return false;
		}

		if(document.FCForm.FCPhone.value == ""){
			alert("Please specify a phone number.");
			document.FCForm.FCPhone.focus();
			return false;
		}
		if(document.FCForm.FCEmail.value == ""){
			alert("Please specify an email address.");
			document.FCForm.FCEmail.focus();
			return false;
		}
		if(!isEmailAddr(document.FCForm.FCEmail.value)){
			alert("Please enter a valid email address.");
			document.FCForm.FCEmail.focus();
			return false;
		}
		if(document.FCForm.FCComment.value == ""){
			alert("Please enter a comment or question.");
			document.FCForm.FCComment.focus();
			return false;
		}
		
		
		var radio_choice = false;
		
		// Loop from zero to the one minus the number of radio button selections
		for (counter = 0; counter < document.FCForm.rep.length; counter++)
		{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.FCForm.rep[counter].checked)
		radio_choice = true; 
		}
		
		if (!radio_choice)
		{
			alert("Please select a Forms Committee representative to contact.")
			return false;
		}
		
		
		return true;
}

function ChkContact(){
		
		if(document.mainform.paymentMethod){
			if(document.mainform.paymentMethod[0].checked == true)
			{
				if(document.mainform.Account_Number.value == "")
				{
					alert("Please enter a value for Account Number.")
					document.mainform.Account_Number.focus();
					return false;
				}
			}
		}
		

		if(document.mainform.Firm_Name)
		{
			if(document.mainform.Firm_Name.value == ""){
				alert("Please enter a value for Firm Name.");
				document.mainform.Firm_Name.focus();
				return false;
			}
		}
		if(document.mainform.Ordered_By.value == ""){
			alert("Please specify who is placing this order.");
			document.mainform.Ordered_By.focus();
			return false;
		}
		if(document.mainform.Ship_To.value == ""){
			alert("Please specify where this order is to be shipped.");
			document.mainform.Ship_To.focus();
			return false;
		}
		if(document.mainform.Phone.value == ""){
			alert("Please specify a phone number for this order.");
			document.mainform.Phone.focus();
			return false;
		}
		if(document.mainform.City.value == ""){
			alert("Please specify a city.");
			document.mainform.City.focus();
			return false;
		}
		if(document.mainform.State.value == ""){
			alert("Please specify a state.");
			document.mainform.State.focus();
			return false;
		}
		if(document.mainform.Zip.value == ""){
			alert("Please specify a zip code.");
			document.mainform.Zip.focus();
			return false;
		}
		return true;
	}

		
function validNum(formField,fieldLabel,required)
{
	var formFieldValue = formField.value
	var result = true;//eval(formField + ".value");
	if(required == "1") {
		if(formFieldValue == "")
		{
			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	}

	var regex = /[a-zA-Z]+/g
	if(regex.test(formFieldValue))
	{
		alert('Please enter a number for the "' + fieldLabel +'" field.');
		formField.focus();		
		result = false;
	}
	
	
	return result;
}



function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}


function ChkSignup(){

		var myOption = -1;
			 
		var r = document.getElementsByName("classes");
		
		for(var i=0;i<r.length;i++){ 
			if (r[i].checked) {
				myOption = i;
			}
		}
		
		if (myOption == -1) {
			alert("Please select a class.");
			return false;
		}

		if(document.RForm.first_name.value == ""){
			alert("Please enter a value for First Name.");
			document.RForm.first_name.focus();
			return false;
		}
		if(document.RForm.last_name.value == ""){
			alert("Please enter a value for Last Name.");
			document.RForm.last_name.focus();
			return false;
		}
		if(document.RForm.office_name.value == ""){
			alert("Please enter a value for Office Name.");
			document.RForm.office_name.focus();
			return false;
		}
		
		if(document.RForm.night_phone_a.value == ""){
			alert("Please specify a phone number.");
			document.RForm.night_phone_a.focus();
			return false;
		}
		if(document.RForm.email.value == ""){
			alert("Please specify an email address.");
			document.RForm.email.focus();
			return false;
		}
		if(!isEmailAddr(document.RForm.email.value)){
			alert("Please enter a valid email address.");
			document.RForm.email.focus();
			return false;
		}
		
		if(document.RForm.address1.value == ""){
			alert("Please specify an address.");
			document.RForm.address1.focus();
			return false;
		}
		
		if(document.RForm.city.value == ""){
			alert("Please specify a city.");
			document.RForm.city.focus();
			return false;
		}
		if(document.RForm.state.value == ""){
			alert("Please specify a state.");
			document.RForm.state.focus();
			return false;
		}
		if(document.RForm.zip.value == ""){
			alert("Please specify a zip code.");
			document.RForm.zip.focus();
			return false;
		}
		var regex = /[a-zA-Z]+/g
		if(regex.test(document.RForm.zip.value))
		{
			alert('Please enter a number for the zip code.');
			document.RForm.zip.focus();		
			return false;
		}
		
		//process registration then submit to paypal
	    var mytime= "&ms="+new Date().getTime();
	    var PostStr = $("#RForm").serialize();
         var err = false
            $.ajax({
		    type:"POST",
		    url: "system/ws_classsignup.asp",
		    dataType: "application/x-www-form-urlencoded",
		    data: PostStr + "&x=" +mytime,
		    async: false,
		    error: function(msg){alert (msg); return false;},
		    success: function(msg){ 
		        document.RForm.item_number.value = msg;
		        document.RForm.action = document.RForm.PPAction.value;
		        return true;}
    		
	    })
	    
	   
	}
	
	function ChkInstanet(){

		var myOption = -1;
			 
		
		if(document.RForm.first_name.value == ""){
			alert("Please enter a value for First Name.");
			document.RForm.first_name.focus();
			return false;
		}
		if(document.RForm.last_name.value == ""){
			alert("Please enter a value for Last Name.");
			document.RForm.last_name.focus();
			return false;
		}
		if(document.RForm.office_name.value == ""){
			alert("Please enter a value for Office Name.");
			document.RForm.office_name.focus();
			return false;
		}
		
		if(document.RForm.night_phone_a.value == ""){
			alert("Please specify a phone number.");
			document.RForm.night_phone_a.focus();
			return false;
		}
		if(document.RForm.email.value == ""){
			alert("Please specify an email address.");
			document.RForm.email.focus();
			return false;
		}
		if(!isEmailAddr(document.RForm.email.value)){
			alert("Please enter a valid email address.");
			document.RForm.email.focus();
			return false;
		}
		
		if(document.RForm.address1.value == ""){
			alert("Please specify an address.");
			document.RForm.address1.focus();
			return false;
		}
		
		if(document.RForm.city.value == ""){
			alert("Please specify a city.");
			document.RForm.city.focus();
			return false;
		}
		if(document.RForm.state.value == ""){
			alert("Please specify a state.");
			document.RForm.state.focus();
			return false;
		}
		if(document.RForm.zip.value == ""){
			alert("Please specify a zip code.");
			document.RForm.zip.focus();
			return false;
		}
		var regex = /[a-zA-Z]+/g
		if(regex.test(document.RForm.zip.value))
		{
			alert('Please enter a number for the zip code.');
			document.RForm.zip.focus();		
			return false;
		}
		if(document.RForm.account_status.options[document.RForm.account_status.selectedIndex].value == "")
		{
		   alert('Please indicate whether this is a new account or a renewal.');
			document.RForm.account_status.focus();		
			return false; 
		}
		
	    //set the item number for paypal to be the first and last name that was entered
	    document.RForm.item_number.value = document.RForm.first_name.value + ' ' + document.RForm.last_name.value;
	    
	    //append the account status (new or renewal) to the item name
	    document.RForm.item_name.value += ' - ' + document.RForm.account_status.options[document.RForm.account_status.selectedIndex].value;
	    var oRet= SendStaffEmail();
	    if (!oRet)
	    {
	        alert("There was a problem submitting your sign-up. Please contact OREF to sign-up.");
	    }
        return oRet;
	}
	

function ChkRMLS(){

		var myOption = -1;
			 
		
		if(document.RForm.RMLSID.value == ""){
			alert("Please enter your RMLSweb Public ID. This is the same userid that you use to login to RMLSweb.");
			document.RForm.RMLSID.focus();
			return false;
		}
		
         // Check for white space
        if (document.RForm.RMLSID.value.indexOf(" ") > -1) {
          alert("Your RMLSweb Public ID should not include any spaces. Please re-enter your Public ID");
          document.RForm.RMLSID.focus();
          return false;
        }
		
	    //set the item number for paypal to be the first and last name that was entered
	    document.RForm.item_number.value = document.RForm.RMLSID.value
	  
	}
	
function SendStaffEmail()
{
     var PostStr = $("#RForm").serialize();
     var err = false
        $.ajax({
		type:"POST",
		url: "system/ws_sendemail.asp",
		dataType: "application/x-www-form-urlencoded",
		data: PostStr + "&Sub=New+Instanet+Subscription",
		async: false,
		error: function(msg){err = msg;}
		
	})
	
	   if (!err)
	   {
	    return true;
	   }
	   else { return false;}
	
}

