var phone_field_length=0;
function recoverpass(rPID,script) {
	var evar = document.getElementById('wf_email');
	if(evar.value != evar.title) {
		if(checkEmail(evar))
			document.location.href = script + "?PID=" + rPID + "&email=" + evar.value;
	}
	else {
		alert("Please type your E-mail and then click on Forgot Password again")	
		evar.focus();
	}
}

//Auto-Tabs to next inputbox
function TabNext(obj,devent,len,next_field) {
	if (devent == "down") {
		phone_field_length=obj.value.length;
		}
	else if (devent == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
			}
		}
	}
}

function setfocus(thisbox) {
	thisbox.focus();
}

//Validates Email
function checkEmail(entered) {
	with (entered) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
			entered.select();
			alert("Invalid Email. Please try again.");
			entered.focus();
			return false; 
		}
		else {
			return true;
		}
	}
}


function submitForm(fm) {
	if(fm.name_first.value == "First Name"){
		alert("Please Input a Valid First Name");
		return false;
	}
	else if(fm.name_last.value == "Last Name"){
		alert("Please Input a Valid Last Name");
		return false;
	}
	else if(fm.wf_email.value == "your@email.com"){
		alert("Please Input a Valid email");
		return false;
	}
	else
		return true;
}


//validation for the firstname and lastname fields (mainly for on submit use)
function checkName(objName) {
    var namefield = objName;
    if (chkname(objName) == false) {
        namefield.select();
        objName.focus();
        return false;
    }
    else {
        return true;
    }
}

//helper function for checkName()
function chkname(objName){
	thisName = objName.value;
	if(thisName == "First Name") {
		return false;
	}
	else if(thisName == "Last Name") {
		return false;
	}
	else {
		return true;	
	}
}

//validation for the email field (mainly for on submit use)
function checkEmailD(objName) {
    var emailfield = objName;
    if (chkEmailD(objName) == false) {
        emailfield.select();
        objName.focus();
        return false;
    }
    else {
        return true;
    }
}

//helper function for checkEmail()
function chkEmailD(objName){
	thisEmail = objName.value;
	if(thisEmail == "your@email.com") {
		return false;
	}
	else {
		return true;
	}
}

////validation for any field that does not contain a default input (ex. askQuestion textbox)
function checkNull(objName) {
    var nullfield = objName;
    if (chkNull(objName) == false) {
        nullfield.select();
        objName.focus();
        return false;
    }
    else {
        return true;
    }
}

//helper function for checkNull()
function chkNull(objName){
	thisNull = objName.value;
	if(thisNull == "") {
		return false;
	}
	else {
		return true;
	}
}

//validation for the phone fields
function checkPhone(objName) {
    var phonefield = objName;
    if (chkphone(objName) == false) {
		phonefield.select();
        alert("The phone number is invalid. Please input a valid number");
        objName.focus();
        return false;
    }
	else {
		return true;	
	}
}

//helper function for checkPhone()
function chkphone(objName){
	thisPhone = objName.value;
	if(thisPhone == "xxx") {
		return true;
	}
	else if(thisPhone == "xxxx") {
		return true;
	}
	else {
		if (thisPhone.length < 3) {
		   return false;
		}
		if(isNaN(thisPhone))
		return false;
	}
}

//validation for the zip field
function checkZip(objName) {
    var zipfield = objName;
    if (chkZip(objName) == false) {
        zipfield.select();
        alert("The zip code is invalid. Please input a valid zip code");
        objName.focus();
        return false;
    }
    else {
        return true;
    }
}

//helper function for checkZip
function chkZip(objName){
	thisZip = objName.value;
	if(thisZip == "Zip") {
		return true;
	}
	else {
		if (thisZip.length < 5) {
		   return false;
		}
		if(isNaN(thisZip)) return false;
	}
}

//RETURNS INPUT INDEX
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
	return index;
}

//LOOPS THROUGH ARRAYS CHECKING FOR THE STRING
function inArray(thisString,thisArray) {
    var len=thisArray.length;
    for(var i=0;i<len;i++){
        if(thisArray[i]==thisString)
            return i;
    }
    return -1;
}

//CHECKS IF CLASS ALREADY EXISTS
function isClassPresent(thisDoc,thisClass){
    var rgClasses=thisDoc.className.split(" ");
    return inArray(thisClass,rgClasses)>=0;
}

//CREATES CLASSES FOR EACH 'document.'
function addClass(Pq){
    var classes=Pq.className.split(" ");
    var len=arguments.length;
    for(var i=1;i<len;i++){
        var op=arguments[i].slice(0,1);
        var cls=arguments[i].slice(1);
        var idx=inArray(cls,classes);
        if(op=="-") {
            if(idx!=-1)
                classes.splice(idx,1);
        }
        else {
            if(idx==-1)
                classes.push(cls);
        }
    }
    var newClass=classes.join(" ");
    if(Pq.className!=newClass)
        Pq.className=newClass;
}

//KEEPS WHAT'S INSIDE INPUTBOXES
function keepInputText(pEvent,pDocument) {
    var bIsClean=isClassPresent(pDocument,"clean");
    if(bIsClean&&(pEvent.type=="focus"||pEvent.type=="drop")) {
        pDocument.value="";
        addClass(pDocument,"-clean");
    }
    else {
        if(pDocument.value.length==0&&pEvent.type=="blur") {
            pDocument.value=pDocument.getAttribute("title");
            addClass(pDocument,"+clean");
        }
    }
}


function validate(minimum_size) { 
	thisform = document.forms.regfrm;
	apos=thisform.wf_email.value.indexOf("@");
	dotpos=thisform.wf_email.value.lastIndexOf(".");
	lastpos=thisform.wf_email.value.length-1;
	
	if(thisform.wf_email.title == thisform.wf_email.value) {
		alert("Email is required. Please type your email.");
		thisform.wf_email.focus();
		return false;
	}
	else if(apos < 1 || dotpos - apos < 2 || lastpos - dotpos > 3 || lastpos - dotpos < 2) {
		thisform.wf_email.select();
		alert("Invalid Email. Please try again.");
		thisform.wf_email.focus();
		return false; 
	}	
	else if(thisform.wf_confirmemail.title == thisform.wf_confirmemail.value) {
		alert("Confirm Email is required. Please re-type your email.");
		thisform.wf_confirmemail.focus();
		return false;
	}
	else if(thisform.wf_email.value != thisform.wf_confirmemail.value) {
		alert("Your emails do not match. Please type the same email.");
		thisform.wf_confirmemail.focus();
		return false;
	}
	else if(thisform.wf_password.value == "" || thisform.wf_confirmpassword.value =="") {
		alert("Please type both passwords");
		thisform.wf_password.focus();
		return false;
	}
	else if(thisform.wf_password.value.length <= 3) {
		alert("Please use a password at least 4 digits long");
		thisform.wf_password.focus();
		return false;
	}
	else if(thisform.wf_password.value != thisform.wf_confirmpassword.value) {
		alert("Your passwords do not match. Please type the same password.");
		thisform.wf_confirmpassword.focus();
		return false;
	}
	else if(!thisform.sec_question.selectedIndex){
		alert("Please choose a Secret question.");
		thisform.sec_question.focus();
		return false;
	}
	else if(thisform.sec_answer.title == thisform.sec_answer.value) {
		alert("Answer to the Secret question is required.");
		thisform.sec_answer.focus();
		return false;
	}
	
	else if(thisform.name_first.title == thisform.name_first.value) {
		alert("Please type your First Name.");
		thisform.name_first.focus();
		return false;
	}
	else if(thisform.name_last.title == thisform.name_last.value) {
		alert("Please type your Last Name.");
		thisform.name_last.focus();
		return false;
	}
	else if(thisform.address1.title == thisform.address1.value) {
		alert("Please type your address.");
		thisform.address1.focus();
		return false;
	}
	else if(thisform.city.title == thisform.city.value) {
		alert("Please type your city.");
		thisform.city.focus();
		return false;
	}	
	
	else if(thisform.state[thisform.state.selectedIndex].value == ""){
		alert("Please select a state");
		thisform.state.focus();
		return false;
	}
	else if(thisform.zip.title == thisform.zip.value) {
		alert("Please type your zipcode");
		thisform.zip.focus();
		return false;
	}
	else if((thisform.hparea.title == thisform.hparea.value || thisform.hpfirst.title == thisform.hpfirst.value || thisform.hpfinal.title == thisform.hpfinal.value) && (thisform.cparea.title == thisform.cparea.value || thisform.cpfirst.title == thisform.cpfirst.value || thisform.cpfinal.title == thisform.cpfinal.value)) {
		alert("Please enter one of the contact phones");
		thisform.hparea.focus();
		return false;
	}
	else if(thisform.hparea.title == thisform.hparea.value && thisform.hpfirst.title == thisform.hpfirst.value && thisform.hpfinal.title == thisform.hpfinal.value) {
		thisform.hparea.value = '';
		thisform.hpfirst.value = '';
		thisform.hpfinal.value = '';
	}
	else if(thisform.cparea.title == thisform.cparea.value && thisform.cpfirst.title == thisform.cpfirst.value && thisform.cpfinal.title == thisform.cpfinal.value) {
		thisform.cparea.value = '';
		thisform.cpfirst.value = '';
		thisform.cpfinal.value = '';
	}
	if(thisform.address2.title == thisform.address2.value) {
		thisform.address2.value = '';
	}
	if(thisform.name_middle.title == thisform.name_middle.value || thisform.name_middle.value == 'M.I.') {
		thisform.name_middle.value = '';
	}

	if(thisform.reg_type.value == "group") {
		
		if(thisform.group_name.title == thisform.group_name.value) {
			alert("Please your Group Name.");
			thisform.group_name.focus();
			return false;
		}
		else if(thisform.group_size.title == thisform.group_size.value) {
			alert("Please type the Group Size.");
			thisform.group_size.focus();
			return false;
		}
		else if(isNaN(thisform.group_size.value)) {
			alert("The Size of group must be a number");
			thisform.group_size.focus();
			return false;
	    } 
		else if(thisform.group_size.value.length > 10) {
			alert("Please type your group size less than 10 digits");
			thisform.group_size.focus();
			return false;
		}
		else if(thisform.group_size.value < minimum_size) {
			alert("The Size of your group must be at least: " + minimum_size);
			thisform.group_size.focus();
			return false;
		}
		else if(thisform.g_address1.title == thisform.g_address1.value) {
			alert("Please type your group address.");
			thisform.g_address1.focus();
			return false;
		}
		else if(thisform.g_city.title == thisform.g_city.value) {
			alert("Please type your group city.");
			thisform.g_city.focus();
			return false;
		}	
		else if(!thisform.g_state.selectedIndex){
			alert("Please select your group state");
			thisform.g_state.focus();
			return false;
		}
		else if(thisform.g_zip.title == thisform.g_zip.value) {
			alert("Please type your group zipcode");
			thisform.g_zip.focus();
			return false;
		}
		if(thisform.address2.title == thisform.g_address2.value) {
			thisform.address2.value = '';
		}

	}
}

function validate_upd_address(form_name) { 
	thisform = document.forms.eval(form_name);
	if(thisform.address1.value == "") {
		alert("Please type your address.");
		thisform.address1.focus();
		return false;
	}
	else if(thisform.city.value == "") {
		alert("Please type your city.");
		thisform.city.focus();
		return false;
	}	
	else if(thisform.state[thisform.state.selectedIndex].value == ""){
		alert("Please select a state");
		thisform.state.focus();
		return false;
	}
	else if(thisform.zip.value == "") {
		alert("Please type your zipcode");
		thisform.zip.focus();
		return false;
	}
	else if(thisform.phone_home == "" && thisform.phone_home == "") {
		alert("Please enter one of the contact phones");
		thisform.home_phone.focus();
		return false;
	}
	if(thisform.address2.value == "") {
		thisform.address2.value = '';
	}
}

function validate_billing(form_name) { 
	thisform = document.forms.eval(form_name);
	if(thisform.address.value == "") {
		alert("Please type your address.");
		thisform.address.focus();
		return false;
	}
	else if(thisform.city.value == "") {
		alert("Please type your city.");
		thisform.city.focus();
		return false;
	}	
	else if(thisform.state[thisform.state.selectedIndex].value == ""){
		alert("Please select a state");
		thisform.state.focus();
		return false;
	}
	else if(thisform.zip.value == "") {
		alert("Please type your zipcode");
		thisform.zip.focus();
		return false;
	}
	if(thisform.address2.value == "") {
		thisform.address2.value = '';
	}
}

function validate_type() {
	if(document.getElementById('group').checked == true || document.getElementById('single').checked == true )
		return true;
	else {
		alert("You must select either Group or Individual registration type.");
		return false;
	}
}

function validatelogin() { 
	thisform = document.forms.login;
	apos=thisform.wf_email.value.indexOf("@");
	dotpos=thisform.wf_email.value.lastIndexOf(".");
	lastpos=thisform.wf_email.value.length-1;

	if(thisform.wf_email.title == thisform.wf_email.value) {
		alert("Please type your email.");
		thisform.wf_email.focus();
		return false;
	}
	else if(apos < 1 || dotpos - apos < 2 || lastpos - dotpos > 3 || lastpos - dotpos < 2) {
		thisform.wf_email.select();
		alert("Invalid Email. Please try again.");
		thisform.wf_email.focus();
		return false; 
	}	
	else if(thisform.wf_password.title == thisform.wf_password.value) {
		alert("Please type your password.");
		thisform.wf_password.focus();
		return false;
	}
}
function validate_step1() {
	if(document.getElementById('agree').checked == false) {
		alert("You must read and agree with the Refund Policy.")
		document.getElementById('agree').focus();
		return false;
	}
	else if(isNaN(document.group_step1.group_size.value) || (document.group_step1.group_size.value <= 3)) {
		alert("Please enter the number in the group.")
		document.forms.group_step1.group_size.focus();
		return false;
	}

}


<!-- Begin DATE CHECKING!!!
function checkdate(objName) {
    var datefield = objName;
    if (chkdate(objName) == false) {
        datefield.select();
        alert("That date is invalid.  Please try again.");
        datefield.focus();
        return false;
    }
    else {
        return true;
    }
}


function chkdate(objName) {
    var strDatestyle = "US";
    var strDate;
    var strDateArray;
    var strDay;
    var strMonth;
    var strYear;
    var intday;
    var intMonth;
    var intYear;
    var booFound = false;
    var datefield = objName;
    var strSeparatorArray = new Array("-"," ","/",".");
    var intElementNr;
    var err = 0;
    strDate = datefield.value;

    if (strDate.length == 0) {
        return true;
    }
    else if (strDate.length < 6) {
        return false;
    }
	



    //LOOPS THROUGH POSSIBLE SEPARATORS AND SPLITS DATE
    for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
        if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
            strDateArray = strDate.split(strSeparatorArray[intElementNr]);
            if (strDateArray.length != 3) {
                err = 1;
                return false;
            }
            else {
                strDay = strDateArray[0];
                strMonth = strDateArray[1];
                strYear = strDateArray[2];
            }
            booFound = true;
       }
    }
    //NO SEPARATOR
    if (booFound == false) {
        if (strDate.length>5) {
            strDay = strDate.substr(0, 2);
            strMonth = strDate.substr(2, 2);
            strYear = strDate.substr(4);
        }
    }
    if (strYear.length == 2) {
        if(strYear > 10)
            strYear = '19' + strYear;
        else
            strYear = '20' + strYear;
    }

    if (strDatestyle == "US") {
        strTemp = strDay;
        strDay = strMonth;
        strMonth = strTemp;
    }
    intday = parseInt(strDay, 10);
    if (isNaN(intday)) {
        err = 2;
        return false;
    }

    intMonth = parseInt(strMonth, 10);
    if (isNaN(intMonth)) {
        err = 3;
        return false;
    }
    intYear = parseInt(strYear, 10);
    if (isNaN(intYear)) {
        err = 4;
        return false;
    }
    if (intMonth>12 || intMonth<1) {
        err = 5;
        return false;
    }
    if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
        err = 6;
        return false;
    }
    if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
        err = 7;
        return false;
    }
    if (intMonth == 2) {
        if (intday < 1) {
            err = 8;
            return false;
        }
        if (LeapYear(intYear) == true) {
            if (intday > 29) {
                err = 9;
                return false;
            }
        }
        else {
            if (intday > 28) {
                err = 10;
                return false;
            }
        }
    }
    if (strDatestyle == "US") {
        datefield.value = intMonth + "-" + intday+"-" + strYear;
    }
    return true;
}
function LeapYear(intYear) {
    if (intYear % 100 == 0) {
        if (intYear % 400 == 0) { return true; }
    }
    else {
        if ((intYear % 4) == 0) { return true; }
    }
    return false;
}

var total=0;

function checkNum(count) {
	var tester = false;
	for(i=0;i<count;i++) { if(document.getElementById(i).value > 0) tester = true; }
	
	if(tester == false) {
		alert('Please choose at least one event and type the number of tickets you would like for it.'); 
		return false;	
	}
		
	if(document.getElementById('quantity_SKATE').value < 0 || document.getElementById('quantity_SKATE').value > document.getElementById(0).value) {
		alert("Invalid number or number of Late Skate Tickets exceeds All Events Tickets.");
		return false;
	}
	
	return true;
}

function updMaxNum() {
	if(document.getElementById('0')) {
		if(document.getElementById('0').value > 0) {
			for(var i=0; i<document.tickets.radio.length;i++ ) {
				document.tickets.radio[i].disabled = false;
			}
		}
		else {
			for(var i=0; i<document.tickets.radio.length;i++ ) {
				document.tickets.radio[i].disabled = true;
			}
			document.tickets.radio[0].checked = true;
		
		}
	}
	if(document.getElementById('MP4') && document.getElementById(0)) 
		document.getElementById('MP4').firstChild.nodeValue = document.getElementById(0).value;
	if(document.getElementById('MP6') && document.getElementById(0)) 
		document.getElementById('MP6').firstChild.nodeValue = document.getElementById(0).value;

}

function validateNum(p) {
	if(isNaN(p.value)) {
		alert('Please type a valid number for the amount of tickets');
		p.value=0;
		p.focus();
	}
	else {
		document.getElementById('MP4').firstChild.nodeValue = document.getElementById(0).value;
		document.getElementById('MP6').firstChild.nodeValue = document.getElementById(0).value;
	}
	if(document.getElementById(0).value > 0) {
		for(var i=0; i<document.tickets.radio.length;i++ ) {
			document.tickets.radio[i].disabled = false;
		}
	}
	else {
		for(var i=0; i<document.tickets.radio.length;i++ ) {
			document.tickets.radio[i].disabled = true;
		}
		document.tickets.radio[0].checked = true;
	
	}
				
}

function changebtn() {
	if(!document.forms.confirmfrm.Confirm.disabled) document.forms.confirmfrm.Confirm.disabled = true
	else document.forms.confirmfrm.Confirm.disabled=false
}
function checkGender() {
	if(document.addtormlistfrm.gender.value == '') {
		alert('Please select Room Type');
		document.addtormlistfrm.gender.focus();
		return false;
	}
	else
		return true;
}
//  End  CHECK DATE -->

//-->