function dateChanged () {

	var daySelect = document.getElementById("DayComboBox");
	var monthSelect = document.getElementById("MonthComboBox");
	var yearSelect = document.getElementById("YearComboBox");
	
	if (daySelect != null)
	{
		document.getElementById("DateHidden").value = daySelect.options[daySelect.selectedIndex].text + "/" + 
												  monthSelect.options[monthSelect.selectedIndex].text + "/" +
												  yearSelect.options[yearSelect.selectedIndex].text;
	}
	
	daySelect = document.getElementById("ExistingDSUDayComboBox");
	monthSelect = document.getElementById("ExistingDSUMonthComboBox");
	yearSelect = document.getElementById("ExistingDSUYearComboBox");

	if (daySelect != null)
	{
		document.getElementById("ExistingDSUDateHidden").value = daySelect.options[daySelect.selectedIndex].text + "/" + 
												  monthSelect.options[monthSelect.selectedIndex].text + "/" +
												  yearSelect.options[yearSelect.selectedIndex].text;
	}
}

function selectDate () {

	var daySelect = document.getElementById("DayComboBox");
	var monthSelect = document.getElementById("MonthComboBox");
	var yearSelect = document.getElementById("YearComboBox");

	if (daySelect == null)
	{
		return;
	}
	
	if (document.getElementById("DateHidden") == null || document.getElementById("DateHidden").value == "") {
		return;
	}

	var date = document.getElementById("DateHidden").value.split("/");

	for (var i = 0; i < daySelect.length-1; i++) {
		if (daySelect.options[i].text == date[0]) {
			daySelect.selectedIndex = i;
		}
	}
	for (var i = 0; i < monthSelect.length-1; i++) {
		if (monthSelect.options[i].text == date[1]) {
			monthSelect.selectedIndex = i;
		}
	}
	for (var i = 0; i < yearSelect.length-1; i++) {
		if (yearSelect.options[i].text == date[2]) {
			yearSelect.selectedIndex = i;
		}
	}
}

function validateTextRequired(textBoxId, message)
{
	var textBox = document.getElementById( textBoxId );
	if ((textBox != null) && (textBox.value == ""))
	{
		alert( message );
		textBox.focus();
		return false;
	}
	
	return true;
}

function validateComboRequired(comboId, textBoxId, message)
{
	var combo = document.getElementById( comboId );
	if ((combo != null) && (combo.selectedIndex == (combo.options.length - 1)))
	{
		var textBox = document.getElementById( textBoxId );
		if ((textBox != null) && (textBox.value == ""))
		{
			alert( message );
			combo.focus();
			return false;
		}
	}
	
	return true;
}

function validate(requirePassword) {

	return true
		&& validateTextRequired( "FirstNameTextBox", dsuss_WebClient_Register.ValidateErrorFirstName )
		&& validateTextRequired( "LastNameTextBox", dsuss_WebClient_Register.ValidateErrorLastName )
		&& validateComboRequired( "CountryComboBox", "CountryTextBox", dsuss_WebClient_Register.ValidateErrorCountry )
		&& validateComboRequired( "CityComboBox", "CityTextBox", dsuss_WebClient_Register.ValidateErrorCity )
		&& validateComboRequired( "ZipComboBox", "ZipTextBox", dsuss_WebClient_Register.ValidateErrorZip )
		&& validateTextRequired( "Address1TextBox", dsuss_WebClient_Register.ValidateErrorAddress )
		&& validateTextRequired( "EmailTextBox", dsuss_WebClient_Register.ValidateErrorEmail )
		&& validateTextRequired( "RegisterUserNameTextBox", dsuss_WebClient_Register.ValidateErrorUserName )
		&& (!requirePassword ||
			(  validateTextRequired( "RegisterPasswordTextBox", dsuss_WebClient_Register.ValidateErrorPassword )
			&& validateTextRequired( "PasswordConfirmTextBox", dsuss_WebClient_Register.ValidateErrorConfirmPassword )
		))
}

function onBodyLoaded()
{
	document.title = dsuss_WebClient.GlobalTitle;
	if (document.getElementById( "RegisterDivActive" ))
	{
		switch (document.getElementById( "RegisterDivActive" ).value)
		{
			case "Register":
			switchDivs( true );
			break;
			
			case "Dsu":
			switchDivs( false );
			break;
			
			case "MemberChooser":
			break;
		}
		
	}
	
	document.getElementById("MainContainer").style.display="block";
}

function switchDivs (register)
{
	if (register == true) {
		if (document.getElementById("RegisterDiv")) document.getElementById("RegisterDiv").style.display="block";
		if (document.getElementById("ExistingDSUDiv")) document.getElementById("ExistingDSUDiv").style.display="none";
		if (document.getElementById("MemberTypeChooserDiv")) document.getElementById("MemberTypeChooserDiv").style.display="none";
	} else {
		if (document.getElementById("RegisterDiv")) document.getElementById("RegisterDiv").style.display="none";
		if (document.getElementById("ExistingDSUDiv")) document.getElementById("ExistingDSUDiv").style.display="block";
		if (document.getElementById("MemberTypeChooserDiv")) document.getElementById("MemberTypeChooserDiv").style.display="none";
	}
}

function dsuss_WebClient_Register_StringsLoaded()
{
	try
	{
		dateChanged();
	}
	catch (e)
	{
	}

	if (document.getElementById("LoginAsGuestLink") != null) {
		document.getElementById("LoginAsGuestLink").innerHTML = dsuss_WebClient_Register.LoginAsGuestLink;
	}
	if (document.getElementById("ForgotPasswordLink") != null) {
		document.getElementById("ForgotPasswordLink").innerHTML = dsuss_WebClient_Register.ForgotPasswordLink;
	}
	if (document.getElementById("ProfileLink") != null) {
		document.getElementById("ProfileLink").innerHTML = dsuss_WebClient_Register.ProfileLink;
	}
	if (document.getElementById("LogoutLink") != null) {
		document.getElementById("LogoutLink").innerHTML = dsuss_WebClient_Register.LogoutLink;
	}
	document.getElementById("BackLink").innerHTML = dsuss_WebClient_Register.BackLink;
	
	if (document.getElementById("UserNameLabel") != null)
	{
		document.getElementById("UserNameLabel").innerHTML = dsuss_WebClient_Register.UserNameLabel;
	}
	
	if (document.getElementById("ConfirmLabel") != null)
	{
		document.getElementById("PasswordLabel").innerHTML = dsuss_WebClient_Register.PasswordLabel;
		document.getElementById("ConfirmLabel").innerHTML = dsuss_WebClient_Register.ConfirmLabel;
		document.getElementById("FirstNameLabel").innerHTML = dsuss_WebClient_Register.FirstNameLabel;
		document.getElementById("MiddleNameLabel").innerHTML = dsuss_WebClient_Register.MiddleNameLabel;
		document.getElementById("LastNameLabel").innerHTML = dsuss_WebClient_Register.LastNameLabel;
		document.getElementById("BirthDateLabel").innerHTML = dsuss_WebClient_Register.BirthDateLabel;
		document.getElementById("CountryLabel").innerHTML = dsuss_WebClient_Register.CountryLabel;
		document.getElementById("CityLabel").innerHTML = dsuss_WebClient_Register.CityLabel;
		document.getElementById("ZipLabel").innerHTML = dsuss_WebClient_Register.ZipLabel;
		document.getElementById("AdressLabel").innerHTML = dsuss_WebClient_Register.AdressLabel;
		document.getElementById("PhoneLabel").innerHTML = dsuss_WebClient_Register.PhoneLabel;
		document.getElementById("FaxLabel").innerHTML = dsuss_WebClient_Register.FaxLabel;
		document.getElementById("EmailLabel").innerHTML = dsuss_WebClient_Register.EmailLabel;
		document.getElementById("MemberLabel").innerHTML = dsuss_WebClient_Register.MemberLabel;
		
		if (document.getElementById("DsuMemberYes") != null) {
			document.getElementById("DsuMemberYes").value = dsuss_WebClient_Register.DsuMemberYes;
		}
		if (document.getElementById("DsuMemberNo") != null) {
			document.getElementById("DsuMemberNo").value = dsuss_WebClient_Register.DsuMemberNo;
		}
		if (document.getElementById("RegisterButton") != null) {
			document.getElementById("RegisterButton").value = dsuss_WebClient_Register.RegisterButton;
		}
		if (document.getElementById("UpdateButton") != null) {
			document.getElementById("UpdateButton").value = dsuss_WebClient_Register.UpdateButton;
		}
	}
	
	
	if (document.getElementById("ExistingDSUUserIdLabel") != null) {
		document.getElementById("ExistingDSUUserIdLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUUserIdLabel;
	}
	if (document.getElementById("ExistingDSUBirthDateLabel") != null) {
		document.getElementById("ExistingDSUBirthDateLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUBirthDateLabel;
	}
	if (document.getElementById("ExistingDSUUserNameLabel") != null) {
		document.getElementById("ExistingDSUUserNameLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUUserNameLabel;
	}
	if (document.getElementById("ExistingDSUPasswordLabel") != null) {
		document.getElementById("ExistingDSUPasswordLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUPasswordLabel;
	}
	if (document.getElementById("ExistingDSUConfirmLabel") != null) {
		document.getElementById("ExistingDSUConfirmLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUConfirmLabel;
	}
	if (document.getElementById("ActivateButton") != null) {
		document.getElementById("ActivateButton").value = dsuss_WebClient_Register.ActivateButton;
	}
	
	if (document.getElementById("BackToMainPageLabel") != null) {
		document.getElementById("BackToMainPageLabel").innerHTML = dsuss_WebClient_Register.BackToMainPageLabel;
	}
	if (document.getElementById("BackToMainPageLink") != null) {
		document.getElementById("BackToMainPageLink").innerHTML = dsuss_WebClient_Register.BackToMainPageLink;
	}
	
	if (document.getElementById("DsuMemberLabel") != null) {
		document.getElementById("DsuMemberLabel").innerHTML = dsuss_WebClient_Register.DsuMemberLabel;
	}
	if (document.getElementById("ExistingDSUUserIdDescriptionLabel") != null) {
		document.getElementById("ExistingDSUUserIdDescriptionLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUUserIdDescriptionLabel;
	}
	if (document.getElementById("ExistingDSUUserNameDescriptionLabel") != null) {
		document.getElementById("ExistingDSUUserNameDescriptionLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUUserNameDescriptionLabel;
	}
	if (document.getElementById("ExistingDSUEmailLabel") != null) {
		document.getElementById("ExistingDSUEmailLabel").innerHTML = dsuss_WebClient_Register.ExistingDSUEmailLabel;
	}
	
	if (document.getElementById("WelcomeRegistrationLabel") != null) {
		document.getElementById("WelcomeRegistrationLabel").innerHTML = dsuss_WebClient_Register.WelcomeRegistrationLabel;
	}
}

includeStringTable( "dsuss.WebClient.Register" );
