
// Last updated:  10.27.09

self.focus();

function validateAll() {

	if(document.frmCPL['Contact0FirstName'].value=='') {
		alert('* Enter your First Name *');
		document.frmCPL['Contact0FirstName'].focus();
		return false;
	}
	if(document.frmCPL['Contact0LastName'].value=='') {
		alert('* Enter your Last Name *');
		document.frmCPL['Contact0LastName'].focus();
		return false;
	}
	
//	if(document.frmCPL['Contact0JobTitle'].value=='') {
//		alert('* Enter your Occupation *');
//		document.frmCPL['Contact0JobTitle'].focus();
//		return false;
//	}
	if(document.frmCPL['Contact0StreetAddress1'].value=='') {
		alert('* Enter your Address *');
		document.frmCPL['Contact0StreetAddress1'].focus();
		return false;
	}
	if(document.frmCPL['Contact0City'].value=='') {
		alert('* Enter your City *');
		document.frmCPL['Contact0City'].focus();
		return false;
	}
	if(document.frmCPL['Contact0State'].options[0].selected == true) {
		alert('* Select your State *');
		document.frmCPL['Contact0State'].focus();
		return false;
	}
	if(document.frmCPL['Contact0PostalCode'].value.length == 0) {
		alert('* Enter your Zip Code *');
		document.frmCPL['Contact0PostalCode'].focus();
		return false;
	}
	else {
		if(document.frmCPL['Contact0PostalCode'].value.length != 5) {
			alert('* Your Zip Code must have 5 digits *');
			document.frmCPL['Contact0PostalCode'].focus();
			return false;
		}
    	for (var i=0;i < document.frmCPL['Contact0PostalCode'].value.length;i++) {
        	if ((document.frmCPL['Contact0PostalCode'].value.substring(i,i+1) < '0') || (document.frmCPL['Contact0PostalCode'].value.substring(i,i+1) > '9')) {
				alert('* Your Zip Code must only be digits *');
				document.frmCPL['Contact0PostalCode'].focus();
				return false;
			}
		}
	}

	if(!(document.frmCPL['Contact0_TextMessageOptIn'][0].checked || document.frmCPL['Contact0_TextMessageOptIn'][1].checked)) {
		alert('* Select your Text Message Reminder preference *');
		document.frmCPL['Contact0_TextMessageOptIn'][0].focus();
		return false;
	}

	
	// Mobile Phone required for Text Message
	if(document.frmCPL['Contact0_TextMessageOptIn'][0].checked) {
		if(document.frmCPL['Contact0Phone2'].value=='') {
			alert('* Enter your Mobile Phone number *');
			document.frmCPL['Contact0Phone2'].focus();
			return false;
		}
	}
	
	
	if(document.frmCPL['Contact0Email'].value=='' || document.frmCPL['Email1'].value=='') {
		if(document.frmCPL['Contact0Email'].value=='' && document.frmCPL['Email1'].value=='') {
			alert('* Enter your Email Address *');
			document.frmCPL['Contact0Email'].focus();
			return false;
		}
		else {
			if(document.frmCPL['Contact0Email'].value=='') {
				alert('* Enter your Email into the 1st box *');
				document.frmCPL['Contact0Email'].focus();
				return false;
			}
			if(document.frmCPL['Email1'].value=='') {
				alert('* Enter your Email into the 2nd box *');
				document.frmCPL['Email1'].focus();
				return false;
			}			
		}

	}
	if((document.frmCPL['Email1'].value!='' && document.frmCPL['Contact0Email'].value!='') &&
	  (document.frmCPL['Email1'].value != document.frmCPL['Contact0Email'].value)) {
		alert('* Your Email entries do not match *\n* Please check both entries *');
		document.frmCPL['Email1'].focus();
		return false;
	}
	
	if(document.frmCPL["Contact0_Exposure1"].options[0].selected == true) {
		alert('* Please let us know how you heard about Investors United *');
		document.frmCPL['Contact0_Exposure1'].focus();
		return false;
	}
	
			if(document.frmCPL["Contact0_Exposure1"].value=='Other_Select' && document.frmCPL['Contact0_Exposure1Other'].value=='') {
				alert('* Please let us know the \"Other\" way that you heard about Investors United *');
				document.frmCPL['Contact0_Exposure1Other'].focus();
				return false;
			}
			if(document.frmCPL["Contact0_Exposure1"].value=='Referral_Select' && document.frmCPL['Contact0_ReferredBy'].value=='') {
				alert('* Please let us know \"Referred You\" to Investors United *');
				document.frmCPL['Contact0_ReferredBy'].focus();
				return false;
			}


	if(!( document.frmCPL['Contact0_LectureDateText'][0].checked || 
	      document.frmCPL['Contact0_LectureDateText'][1].checked ||
	      document.frmCPL['Contact0_LectureDateText'][2].checked ) ) {

		alert('* Select a Lecture Date *');
		document.frmCPL['Contact0_LectureDateText'][0].focus();
		return false;
		
	}
	
	return true;



}
