var onSite = false;

function _selectCanada()
{
//	northAmericanPhones();
}

function _selectUSA()
{
//	northAmericanPhones();
}

function _selectOther()
{
//	internationalPhones();
}

function northAmericanPhones()
{
	northAmericanPhone('contact_phone');
}

function internationalPhones()
{
	internationalPhone('contact_phone');
}

function splitPhones()
{
	splitPhone('contact_phone');
}

function unsplitPhones()
{
	if (getFormElement('country').selectedIndex == 2)
		return;
	unsplitPhone('contact_phone');
}

function validInput()
{
	if (showLogin)
		if (!validLogin())
			return false;
	if (warnIfBlank('first_name', "Account Holder's First Name"))
		return false;
	if (warnIfBlank('last_name', "Account Holder's Last Name"))
		return false;
	if (!onSite)
	{
		if (warnIfBlank('contact_phone', "Account Holder's Phone Number"))
			return false;
	}
	if (showLogin)
	{
		if (warnIfBlank('contact_email', "Account Holder's Email address"))
			return false;
		if (warnIfInvalidEmail("contact_email"))
			return false;
		var em = getFormElement('contact_email');
		var em2 = getFormElement('contact_email2');
		if (em2 != null && em2.value != em.value)
		{
			if (em2.value.length < 1)
				em2.value = ' ';
			em2.select();
			em2.focus();
			alert('Re-entered email does not match');
			return false;
		}
	}
	field = getFormElement('type');
	if (field.value == '-1')
	{
		alert('You must select a Registration type for the Account Holder');
		field.focus();
		return false;
	}
	if (!validAddress(onSite))
		return false;
	term = (getFormElement('country').value == 'USA') ? "Zip" : "Postal";
//	if (warnIfBlank('postal_code', term+" Code"))
//		return false;
	return true;
}

function fixupInput()
{
	trim('name');
	fixupLogin();
	fixupAddress();
	trim('first_name');
	trim('last_name');
	trim('contact_email');
	trim('contact_email2');
	fixupPhones();
}

function fixupPhones()
{
	fixupPhone('contact_phone');
}

function validPhones()
{
	// phone number is now a single field
	return validInternationalPhone('contact_phone');
}

var showLogin = true;

function toggleLogin()
{
	if (showLogin)
		noLogin();
	else
		needLogin();
}

function needLogin()
{
	showLogin = true;
	getFormElement('toggle').value = 'No ID';
	msg = document.getElementById('idmsg');
	msg.innerHTML = 'Note: A default Login ID and password will be automatically inserted<br>after you finish typing in the Last Name.';
	show('idlogin');
	show('idpw');
	generateIdAndPassword();
	if (!onSite)
	{
		document.getElementById('email_label').innerHTML = "<span class='required'>*</span>Email";
		document.getElementById('email_label2').innerHTML = "<span class='required'>*</span>Re-enter Email to verify";
	}
}

function noLogin()
{
	showLogin = false;
	getFormElement('toggle').value = 'Need ID';
	msg = document.getElementById('idmsg');
	msg.innerHTML = 'Click the Need ID button only if the registration form has an email address.';
	hide('idlogin');
	hide('idpw');
	clearIdAndPassword();
	document.getElementById('email_label').innerHTML = "Email";
	document.getElementById('email_label2').innerHTML = "Re-enter Email to verify";
}

function typeSelected()
{
}
