		//limits the number of characters in a text area
		function limitText(limitField, limitCount, limitNum) {
		
			if (limitField.value.length > limitNum) {
		
				limitField.value = limitField.value.substring(0, limitNum);
		
			} else {
		
				limitCount.value = limitNum - limitField.value.length;
		
			}
		
		}
		
		//checks the validity of an email
		function echeck(str) {
		
				var at="@";
				var dot=".";
				var lat=str.indexOf(at);
				var lstr=str.length;
				var ldot=str.indexOf(dot);
				if (str.indexOf(at)==-1){
				   return false;
				}
		
				if (str.indexOf(at)===-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
				   return false;
				}
		
				if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
					return false;
				}
		
				 if (str.indexOf(at,(lat+1))!=-1){
					return false;
				 }
		
				 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
					return false;
				 }
		
				 if (str.indexOf(dot,(lat+2))==-1){
					return false;
				 }
				
				 if (str.indexOf(" ")!=-1){
					return false;
				 }
		
				 return true;					
		}
		

		//checks the validity of an email
		function isAnEmailAddress(aTextField) {
		// 1+@3+ [or x@x.x] is as close as we will test
		if (aTextField.length<5) {
			return false;
		}
		else if (aTextField.indexOf("@") < 1) {
			return false;
		}
		else if (aTextField.length - aTextField.indexOf("@") < 4) {
			return false;
		}
		else { return true; }
		}
		
		function isNumeric(sText) {
		
		if (sText=="") return false;
		var ValidChars = "0123456789.";
		var IsNumber=true;
		var Char;
		var dotCnt = 0;
		
		if(sText.length<10) {
			IsNumber = false;
		}
		
		for (i = 0; i < sText.length && IsNumber == true; i++)
		{
			Char = sText.charAt(i);
			if (Char==".") dotCnt = dotCnt +1;
			if (ValidChars.indexOf(Char) == -1 || dotCnt>1)
			{
				IsNumber = false;
			}
		}
		
		return IsNumber;
		
		}
		
		
		function providerChanged(carrier){
		
			if ((carrier==="Pick One") ||
		
					(carrier===null)) {
		
			return false;
		
			}
		
			else { return true; }
		
		}
		
		function usertypeChanged(usertype){
		
			if ((usertype==="Pick One") ||
		
					(usertype===null)) {
		
			return false;
		
			}
		
			else { return true; }
		
		}
		
		function isEmpty(aTextField) {	
			//alert(aTextField);
			if ((aTextField.value.length==0) ||
		 	(aTextField.value==null)) {	
				return true;
			}
				else { return false; }
		}
				
		function setFocus(aField) {
			//alert(aField);
			aField.focus();
		}
		
		function validate(form1) {
		
			var form1 = document.forms["form1"];
					
			// will return true or false
			// Step 1: check that required fields are
			// filled in, alert and exit without
			// submitting if not
			// check that the name field is valued
			if (isEmpty(form1.email)) {
				alert("Please fill in an email.");
				setFocus(form1.email);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form1.register_password)) {
				alert("Please fill in a password.");
				setFocus(form1.register_password);
				return false;
			}
			
			// check that the phone field is valued
			if (isEmpty(form1.phone)) {
				alert("Please fill in a phone number.");
				setFocus(form1.phone);
				return false;
			}
			
			//check that a provider is selected
			if (!providerChanged(form1.carrier.options[form1.carrier.selectedIndex].text)) {
				alert("Please select a provider.");
				setFocus(form1.carrier);
				return false;
			}
			
			//check that a member type is selected
			if (!usertypeChanged(form1.usertype.options[form1.usertype.selectedIndex].text)) {
				alert("Please select a Member Type.");
				setFocus(form1.usertype);
				return false;
			}
			
			// Step 2: check that the email address is
			// even close, alert and exit without
			// submitting if not
	
			//check that phone number has only digits
			if (!isNumeric(form1.phone.value)) {
				alert("Please fill in a valid phone number.");
				setFocus(forn1.phone);
				return false;
			}
			
			if (!echeck(form1.email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.email);
				return false;
			 }
			
			if (!isAnEmailAddress(form1.email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.email);
				return false;
			}
			
			if (form1.consent.checked == 0) {
				alert("Please accept the CampuSMS Terms of Use");
				return false;
			}
		
			// if we get this far everthing is ok, so	
			// let the form submit
			return true;
		}		
		
		
		//validation for the login form
		function validateLoginForm(form2) {
		
			var form2 = document.forms["form2"];
					
			// will return true or false
			// Step 1: check that required fields are
			// filled in, alert and exit without
			// submitting if not
			// check that the name field is valued
			if (isEmpty(form2.username)) {
				alert("Please fill in a login ID.");
				setFocus(form2.username);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form2.password)) {
				alert("Please fill in a password.");
				setFocus(form2.password);
				return false;
			}
						
			if (!echeck(form2.username.value)) {
				alert("The entered login ID is invalid.");
				setFocus(form2.username);
				return false;
			 }
			
			if (!isAnEmailAddress(form2.username.value)) {
				alert("The entered login ID is invalid.");
				setFocus(form2.username);
				return false;
			}
			
			// if we get this far everthing is ok, so	
			// let the form submit
			return true;
		}	
		
		function validateContactForm(form1) {
			var form1 = document.forms["form1"];
						
			// check that the password field is valued
			if (isEmpty(form1.name)) {
				alert("Please fill in your name.");
				setFocus(form1.name);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form1.email)) {
				alert("Please fill in your email.");
				setFocus(form1.email);
				return false;
			}
			
			// check that the phone field is valued
			if (isEmpty(form1.message)) {
				alert("Please fill in your request or inquiry.");
				setFocus(form1.message);
				return false;
			}
			
			// Step 2: check that the email address is
			// even close, alert and exit without
			// submitting if not
			
			if (!echeck(form1.email.value)) {
				alert("Your email address is invalid.");
				setFocus(form1.email);
				return false;
			 }
			
			
			if (!isAnEmailAddress(form1.email.value)) {
				alert("Your email address is invalid.");
				setFocus(form1.email);
				return false;
			}
			
			// if we get this far everthing is ok, so
			// let the form submit
			return true;
		}
		
		//function to make sure the user wants to unsubscribe
		function conf(obj){
			if(obj.checked)
			{
				//alert("Are you sure you want to UNSUBSCRIBE?")
				var cf = confirm("Are you sure you want to UNSUBSCRIBE?")
				if(cf)
				{
					obj.checked = true
				}
				else
				{
					obj.checked = false
				}
			}
			else
			{}	
		}
		
		function validateDashboardForm(form1) {
			var form1 = document.forms["form1"];
				
				// check that the phone field is valued
				if (isEmpty(form1.phone)) {
					alert("Please fill in a phone number.");
					setFocus(form1.phone);
					return false;
				}
				
				//check that phone number has only digits
				if (!isNumeric(form1.phone.value)) {
					alert("Please fill in a valid phone number.");
					setFocus(form1.phone);
					return false;
				}
				
				// if we get this far everthing is ok, so
				// let the form submit
				return true;	
		}

			function validateSendTextForm(form1) {
			var form1 = document.forms["form1"];
				
				// check that the phone field is valued
				if (isEmpty(form1.eventname)) {
					alert("Please fill in an Event Name.");
					setFocus(form1.eventname);
					return false;
				}
				
				// check that the phone field is valued
				if (isEmpty(form1.description)) {
					alert("Please fill in a message.");
					setFocus(form1.description);
					return false;
				}

				// if we get this far everthing is ok, so
				// let the form submit
				return true;	
		}


		function validateReferForm(form1) {
				var form1 = document.forms["form1"];
			
			// check that the password field is valued
			if (isEmpty(form1.sender_name)) {
				alert("Please fill in your name.");
				setFocus(form1.sender_name);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form1.sender_email)) {
				alert("Please fill in your email.");
				setFocus(form1.sender_email);
				return false;
			}
			
			// check that the phone field is valued
			if (isEmpty(form1.rec_name)) {
				alert("Please fill the receiver's name.");
				setFocus(form1.rec_name);
				return false;
			}
			
			// check that the receivers email field is valued
			if (isEmpty(form1.rec_email)) {
				alert("Please fill in the receiver's email.");
				setFocus(form1.rec_email);
				return false;
			}
			
			// Step 2: check that the email address is
			// even close, alert and exit without
			// submitting if not
			if (!echeck(form1.rec_email.value)) {
				alert("The receiver's email address is invalid.");
				setFocus(form1.rec_email);
				return false;
			 }
			
			
			if (!isAnEmailAddress(form1.rec_email.value)) {
				alert("The receiver's email address is invalid.");
				setFocus(form1.rec_email);
				return false;
			}
			
			if (!echeck(form1.sender_email.value)) {
				alert("Your email address is invalid.");
				setFocus(form1.sender_email);
				return false;
			 }
			
			
			if (!isAnEmailAddress(form1.sender_email.value)) {
				alert("Your email address is invalid.");
				setFocus(form1.sender_email);
				return false;
			}
			
			// if we get this far everthing is ok, so
			// let the form submit
			return true;
	
	}

		function validateNewBusiness(form1) {
			
				var form1 = document.forms["form1"];
			
			// check that the email field is valued
			if (isEmpty(form1.contact_email)) {
				alert("Please fill in a contact e-mail address.");
				setFocus(form1.contact_email);
				return false;
			}
			// check that the groupname field is valued
			if (isEmpty(form1.business_name)) {
				alert("Please fill in a group name.");
				setFocus(form1.business_name);
				return false;
			}
			
			// check that the contactname field is valued
			if (isEmpty(form1.contact_name)) {
				alert("Please fill in a contact name.");
				setFocus(form1.contact_name);
				return false;
			}
	
			if (!echeck(form1.contact_email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.contact_email);
				return false;
			 }
	
			if (!isAnEmailAddress(form1.contact_email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.contact_email);
				return false;
			}
		
			// if we get this far everthing is ok, so
			// let the form submit
			return true;
	
	}

	function validateNewGroup(form1) {
			
		var form1 = document.forms["form1"];
		
		// check that the email field is valued
		if (isEmpty(form1.contact_email)) {
			alert("Please fill in a contact e-mail address.");
			setFocus(form1.contact_email);
			return false;
		}
		// check that the groupname field is valued
		if (isEmpty(form1.group_name)) {
			alert("Please fill in a group name.");
			setFocus(form1.group_name);
			return false;
		}
		
		// check that the contactname field is valued
		if (isEmpty(form1.contact_name)) {
			alert("Please fill in a contact name.");
			setFocus(form1.contact_name);
			return false;
		}
		
		
		
		if (!echeck(form1.contact_email.value)) {
			alert("The entered email address is invalid.");
			setFocus(form1.contact_email);
			return false;
		 }
		
		// Step 2: check that the email address is
		// even close, alert and exit without
		// submitting if not
		
		
		if (!isAnEmailAddress(form1.contact_email.value)) {
			alert("The entered email address is invalid.");
			setFocus(form1.contact_email);
			return false;
		}
	
		// if we get this far everthing is ok, so
		// let the form submit
		return true;
	
	}

		function validateForgotPassword(form1) {
			
			var form1 = document.forms["form1"];
			
			// check that the email field is valued
			if (isEmpty(form1.email)) {
				alert("Please fill in an e-mail address.");
				setFocus(form1.email);
				return false;
			}
		
		
			if (!echeck(form1.email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.email);
				return false;
			 }
	
			if (!isAnEmailAddress(form1.email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.email);
				return false;
			}
			
		// if we get this far everthing is ok, so
		// let the form submit
			return true;
			
		}
		
	function validateChangePassword(form1) {
			
			var form1 = document.forms["form1"];
			
			// check that the email field is valued
			if (isEmpty(form1.email)) {
				alert("Please fill in an e-mail address.");
				setFocus(form1.email);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form1.password)) {
				alert("Please fill in password.");
				setFocus(form1.password);
				return false;
			}

			
			// check that the email field is valued
			if (isEmpty(form1.newpassword)) {
				alert("Please fill in a new password.");
				setFocus(form1.newpassword);
				return false;
			}

			// check that the email field is valued
			if (isEmpty(form1.confirmpassword)) {
				alert("Please confirm your new password.");
				setFocus(form1.confirmpassword);
				return false;
			}

			if (!echeck(form1.email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.email);
				return false;
			 }
	
			if (!isAnEmailAddress(form1.email.value)) {
				alert("The entered email address is invalid.");
				setFocus(form1.email);
				return false;
			}
			


			// if we get this far everthing is ok, so
			// let the form submit
			return true;
			
		}
		
		function validateChangeEmail(form1) {
			
			var form1 = document.forms["form1"];
			
			// check that the email field is valued
			if (isEmpty(form1.email_current)) {
				alert("Please fill in a valid current e-mail address.");
				setFocus(form1.email_current);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form1.email_new)) {
				alert("Please fill in a valid new e-mail address.");
				setFocus(form1.email_new);
				return false;
			}
			
						// check that the email field is valued
			if (isEmpty(form1.email_new_confirm)) {
				alert("Please fill in a valid new e-mail address.");
				setFocus(form1.email_new_confirm);
				return false;
			}
			
			// check that the email field is valued
			if (isEmpty(form1.password)) {
				alert("Please fill in password.");
				setFocus(form1.password);
				return false;
			}

			if (!echeck(form1.email_current.value)) {
				alert("The entered current email address is invalid.");
				setFocus(form1.email_current);
				return false;
			 }
	
			if (!isAnEmailAddress(form1.email_current.value)) {
				alert("The entered current email address is invalid.");
				setFocus(form1.email_current);
				return false;
			}
			
			if (!echeck(form1.email_new.value)) {
				alert("The entered newemail address is invalid.");
				setFocus(form1.email_new);
				return false;
			 }
	
			if (!isAnEmailAddress(form1.email_new.value)) {
				alert("The entered new email address is invalid.");
				setFocus(form1.email_new);
				return false;
			}
			
			if (!echeck(form1.email_new_confirm.value)) {
				alert("The entered newemail address is invalid.");
				setFocus(form1.email_new_confirm);
				return false;
			 }
	
			if (!isAnEmailAddress(form1.email_new_confirm.value)) {
				alert("The entered new email address is invalid.");
				setFocus(form1.email_new_confirm);
				return false;
			}

			// if we get this far everthing is ok, so
			// let the form submit
			return true;	
		}
		
		/* This script and many more are available free online at
		The JavaScript Source!! http://javascript.internet.com
		Created by: Steve | http://jsmadeeasy.com/ */
		//countdown of characters
		function textCounter(field,cntfield,maxlimit) {
		if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
		else
		cntfield.value = maxlimit - field.value.length;
		}

		