// JavaScript Document
var bSaving = false;
var submitcount=0;
function validate(register) {
	      if (bSaving) {
		    myPreference = -1;
            bSaving = false; // reset
			goemail = true;
            var msg = '';
			if (document.contact.First_Name.value == '') {
                msg += 'First Name is missing.\n';
            }
			if (document.contact.State.selectedIndex == 0) {
                msg += 'State is missing.\n';
            }
			if (document.contact.Zip_Code.value == '') {
                msg += 'Zip Code is missing.\n';
            }
			if (document.contact.Country.selectedIndex == 0) {
                msg += 'Country is missing.\n';
            }
			if (document.contact.Country.selectedIndex == 1) {
                if(document.contact.Zip_Code.value.length !=5){
				msg += 'Please type your 5 digit Zip Code.\n';
				}
            }
			if (document.contact.Area_Code.value == '') {
                msg += 'Area Code is missing.\n';
            }
			if (document.contact.Phone_Prefix.value == '') {
                msg += 'Phone Prefix is missing.\n';
            }
			if (document.contact.Phone_Suffix.value == '') {
                msg += 'Phone Suffix is missing.\n';
            }
			
			
			if(document.contact.Email_Address.value==''){
			msg += 'Email is missing.\n';
			goemail = false
            }
			str = document.contact.Email_Address.value
			  checkdot = str.indexOf(".")
			  checkarb = str.indexOf("@")
			  if(goemail){
                 if((checkdot<=-1) || (checkarb<=-1)){
			        msg += 'Please use a valid Email Address.\n';
			     }
			  }
			   if (document.contact.Birth_Month.selectedIndex == 0) {
                msg += 'Birth Month is missing.\n';
            }
			if (document.contact.Birth_Day.selectedIndex == 0) {
                msg += 'Birth Day is missing.\n';
            }
			if (document.contact.Birth_Year.selectedIndex == 0) {
                msg += 'Birth Year is missing.\n';
            }
			if(document.contact.Email_Check.value != document.contact.Email_Address.value){
			    msg += 'The Email Addresses don\'t match.\n';
			}
			
            if (msg != '') {
                msg = 'The following errors were found:\n\n' + msg;
                alert(msg);
                return false;
            } else {
                return true;
            }
        } else {
            return true;
        }
		}
