
var isIE = false;
var isOther = false;
var isNS4 = false;
var isNS6 = false;
if(document.getElementById)
{
	if(!document.all)
	{
		isNS6=true;
	}
	if(document.all)
	{
		isIE=true;
	}
}
else
{
	if(document.layers)
	{
		isNS4=true;
	}
	else
	{
		isOther=true;
	}
}

// Builds Registration Form Sets based on Registrant Count

function genRegForm(frmElement, conf){
	location.search = "conference" + "=" + conf + "&registrants" + "=" + frmElement.value;
}

function addSessions(regCount, conf, frmElement, session1, session2, session3, session4){
	frmElement.checked = true;
	location.search = "conference" + "=" + conf + "&registrants" + "=" + regCount + "&session1" + "=" + session1 + "&session2" + "=" + session2 + "&session3" + "=" + session3 + "&session4" + "=" + session4;
}
// Disables Registrant Address Fields if the Primary Address is the only Address needed

function toggleAddress(ID){
	if (isIE || isNS6){
		/*document.write(currentElement); */
		document.ConferenceRegistration.StateReg2.disabled=!document.ConferenceRegistration.StateReg2.disabled;
	}
}

// Masking Functions that set specific fields to exceptable formats | Courtesy of younpup.net
function phoneFieldBlurHandler() {
	var temp = this.value.replace(/\D/g, "")

	if (temp.length > 9 && temp.length < 26)
		if (temp.length == 10) {
			this.value = "(" + temp.substring(0,3) + ") " 
			this.value += temp.substring(3,6) + "-" + temp.substring(6,10)
		}
	}
	
// Sets Billing Address to be the same as the Primary Registrant Address if they are the same
function setBillingAddress(addressElementToChange) {
	var addressSource = "Reg1"
	
	if(document.ConferenceRegistration[addressElementToChange + "AddressSame"].checked)
	{
		if(addressElementToChange != "Billing")
		{
			document.ConferenceRegistration[addressElementToChange + "Organization"].value = document.ConferenceRegistration[addressSource + "Organization"].value;
		}
		document.ConferenceRegistration[addressElementToChange + "Address"].value = document.ConferenceRegistration[addressSource + "Address"].value;
		document.ConferenceRegistration[addressElementToChange + "City"].value = document.ConferenceRegistration[addressSource + "City"].value;
		var reg1State = document.ConferenceRegistration[addressSource + "State"].selectedIndex;
		document.ConferenceRegistration[addressElementToChange + "State"].selectedIndex = reg1State;
		var reg1Country = document.ConferenceRegistration[addressSource + "Country"].selectedIndex;
		document.ConferenceRegistration[addressElementToChange + "Country"].selectedIndex = reg1Country;
		document.ConferenceRegistration[addressElementToChange + "Zip"].value = document.ConferenceRegistration[addressSource + "Zip"].value;
		document.ConferenceRegistration[addressElementToChange + "Phone"].value = document.ConferenceRegistration[addressSource + "Phone"].value;
		document.ConferenceRegistration[addressElementToChange + "Fax"].value = document.ConferenceRegistration[addressSource + "Fax"].value;
		// document.ConferenceRegistration[addressElementToChange + "Email"].value = document.ConferenceRegistration[addressSource + "Email"].value;
	}
	else {
		if(addressElementToChange != "Billing")
		{
			document.ConferenceRegistration[addressElementToChange + "Organization"].value = "";
		}
		document.ConferenceRegistration[addressElementToChange + "Address"].value = "";
		document.ConferenceRegistration[addressElementToChange + "City"].value = "";
		document.ConferenceRegistration[addressElementToChange + "State"].selectedIndex = 0;
		document.ConferenceRegistration[addressElementToChange + "Zip"].value = "";
		document.ConferenceRegistration[addressElementToChange + "Country"].selectedIndex = 2;
		document.ConferenceRegistration[addressElementToChange + "Phone"].value = "";
		document.ConferenceRegistration[addressElementToChange + "Fax"].value = "";
		// document.ConferenceRegistration[addressElementToChange + "Email"].value = "";
	}
}

function regWarning(){
	alert("Processing your registration may take several minutes, so please only press the Register button once. Pressing Register more than once can result in multiple registrations for you and your team.\n\n" +
		  "Thank you for your patience.");
}

function checkOutWarning(){
	alert("Processing your purchase may take several minutes, so please only press the Purchase button once. Pressing Purchase more than once can result in multiple purchases and charges.\n\n" +
		  "Thank you for your patience.");
}


