		var numItems = 0;  // manual list counter
			
			function ValidateForm()
			{
				form = document.frmRegistration;
				if(form.name.value == "")
				{
					alert("Please Enter your Name.");
					form.name.focus();
					return false;
				}
				
				var emailID = form.email;
				
				if ((emailID.value==null)||(emailID.value==""))
				{
					alert("Please Enter your Email ID");
					emailID.focus();
					return false;
				}
				if (emailcheck(emailID.value)==false)
				{
					emailID.value="";
					emailID.focus();
					return false;
				}
				
				//VALIDATE PARTICIPANT TYPE
				var parttype = document.getElementById("ParticipantType");
				var value = parttype.options[parttype.selectedIndex].text;
				
				if(value == "Individual")
				{
					form.pnumber.value = "1";
				}
				else
				{
					if(form.pnumber.value == "")
					{
						alert("Please Enter the Number of Participants.")
						form.pnumber.focus();
						return false;
					}
					if(numItems > Number(form.pnumber.value))
					{
						form.pnumber.value = numItems;
					}
					if(numItems < Number(form.pnumber.value))
					{
						alert("Please Enter all the Participants information.")
						form.partname.focus();
						return false;
					}
				}
				SaveClass();
				SavePartList(value);
				return true;
			 }

			function ValidatePartEmail()
			{
				var partemailID = document.frmRegistration.partemail;
				if ((partemailID.value==null)||(partemailID.value=="")){
					alert("Please Enter your Email ID");
					partemailID.focus();
					return false;
				}
				if (emailcheck(partemailID.value)==false){
					partemailID.value="";
					partemailID.focus();
					return false;
				}
				return true;
			 }

				//Save the number of positions available and the class reference
			function SaveClass()
			{
				var list = document.getElementById("WeekendClassList");	
				var pos = list.options[list.selectedIndex].title;
				document.getElementById("ClassId").value = list.options[list.selectedIndex].id;
				document.getElementById("Class_pos").value = pos;		
			 	document.getElementById("quantity").value =  document.getElementById("pnumber").value;
			}
			
			function ActiveParticipants()
			{
				var parttype = document.getElementById("ParticipantType");
				var value = parttype.options[parttype.selectedIndex].text;
				if(document.getElementById("Class_pos").value == 0)
				{
					SaveClass();
				}
				if(value != "Individual")
				{
					document.getElementById("pnumber").disabled = false;
					document.getElementById("partList").disabled = false;
					document.getElementById("partEntryName").disabled = false;					
					document.getElementById("partEntryEmail").disabled = false;					
					document.getElementById("addpart").disabled = false;
					document.getElementById("clearpart").disabled = false;
					document.getElementById("deletepart").disabled = false;
				}else
				{
					//If there are items on the list
					if(numItems > 0)
					{
						alert("The participants list will be disactivated because you choose Individual, if you want to active the list again, please choose another type.");
					}
					document.getElementById("pnumber").disabled = true;
					document.getElementById("partList").disabled = true;
					document.getElementById("partEntryName").disabled = true;					
					document.getElementById("partEntryEmail").disabled = true;					
					document.getElementById("addpart").disabled = true;
					document.getElementById("clearpart").disabled = true;
					document.getElementById("deletepart").disabled = true;
				}
			}
			
			function SavePartList(strPartType)
			{
				var cont = 0;
				var list = document.frmRegistration.entryList;
				var numPart = list.length;
				var strPart = "";
				var custname = document.getElementById("name").value;
				var custemail = document.getElementById("email").value;
				var parttype = document.getElementById("ParticipantType");
				var parttypeid = parttype.options[parttype.selectedIndex].value;
				
				strPart = parttypeid + "," + numPart + "," + custname + "," + custemail;
				if(strPartType != "Individual")
				{
					// loop through all selected items and save them in the pay-pal variable
					while (cont < numPart) 
					{
						strPart = strPart + ",";
						strPart = strPart + list.options[cont].value;
						cont++;
					}
				}
				document.getElementById("custom").value = strPart;
			}

			function notEmpty(){
				var myTextField = document.getElementById('WeekendClassList');
				if(myTextField.value != "")
					alert("You entered: " + myTextField.value)
				else
					alert("Would you please enter some text?")		
			}
							
			function validatepos()
			{
				var pos = Number(document.getElementById("Class_pos").value);		
				var part = Number(document.getElementById("pnumber").value);
				if(part >= pos)
				{
					var message = "There is only " + pos + " positions available in this class. The participants number will be changed. If you need to include more participants, please select another class.";
					alert(message);
					document.getElementById("pnumber").value = pos;
				}		
				if(numItems > part)
				{
					alert("The participants number can not be less that the number of participants list bellow.");
					return false;
				}
				numPart = document.getElementById("pnumber").value;
			}
						
			function addItem() 
			{
				var txtname = document.frmRegistration.partname.value;
				var txtemail = document.frmRegistration.partemail.value;
				if(txtname=="")
				{
					alert("Please indicate the complete name of the participant.");
					document.frmRegistration.partname.focus();
					return false;
				}
				if(txtemail=="")
				{
					alert("Please indicate the email of the participant.");
					document.frmRegistration.partemail.focus();
					return false;
				}
				
				var val = ValidatePartEmail();
				if(val == false)
				{
					document.frmRegistration.partemail.focus();
					return false;
				}				
				var txt = txtname + "," + txtemail;
				addOption = new Option(txt,txt);
				document.frmRegistration.entryList.options[numItems++] = addOption;
				document.frmRegistration.partname.value = "";
				document.frmRegistration.partemail.value = "";				
				numPart = Number(document.getElementById("pnumber").value);
				numItems = Number(numItems);
				if(numItems == numPart)
				{
					document.getElementById("partEntryName").disabled = true;					
					document.getElementById("partEntryEmail").disabled = true;					
					document.getElementById("addpart").disabled = true;
				}
				return true;
       		} 
			
			function deleteItem() 
			{
			  var contSearch = 1;
			  var selIndex;
			  
			  // check to see if there is at least one item selected
			  if (document.frmRegistration.entryList.selectedIndex == -1) {
				   alert("No entries selected for deletion");
				   return true;
			  }
			  
			  // loop through all selected items and delete them
			 while (contSearch > 0) {
				  selIndex = document.frmRegistration.entryList.selectedIndex;
				if (selIndex >= 0) {    
					 document.frmRegistration.entryList.options[selIndex] = null;
					  --numItems;
			 	}
				else 
					 contSearch = 0;
			  	}
				document.getElementById("partEntryName").disabled = false;					
				document.getElementById("partEntryEmail").disabled = false;					
				document.getElementById("addpart").disabled = false;
			  return true;              
		 }
		 function clearList() {
			document.frmRegistration.entryList.length = 0;
			numItems = 0;
			document.frmRegistration.entryList.value = "";  
			document.getElementById("partEntryName").disabled = false;					
			document.getElementById("partEntryEmail").disabled = false;					
			document.getElementById("addpart").disabled = false;
			return true;
		 }
