function AddEventTypeFormSubmit() {
	var myForm = document.forms['AddEventTypeForm'];

	var myName = trim(myForm.newEventType.value);

	if (myName.length == 0) {
		alert("You must specify the event type.");
		myForm.newEventType.focus();
	} else {
		//alert("Submit");
		myForm.submit();
	}
}

function ModifyEventTypeFormSubmit() {
	var myForm = document.forms['ModifyEventTypeForm'];
	
	var myName = trim(myForm.modifyEventType.value);
	
	if (myName.length == 0) {
		alert("You must specify the event type.");
		myForm.modifyStatus.focus();
	} else {
		//alert("Submit");
		myForm.submit();
	}
}

function AddEventFormSubmit() {
	var myForm = document.forms['AddEventForm'];

	var myName = trim(myForm.newName.value);

	if (myName.length == 0) {
		alert("You must specify the event name.");
		myForm.newName.focus();
	} else if (myForm.country.value == "") {
		alert("You must specify the country.");
		myForm.country.focus();
	} else {
		//alert("Submit");
		ae_onSubmit();
		if(myForm.list2 == "[object]")
			selectAllOptions(myForm.list2);

		if(myForm.list2a == "[object]")
			selectAllOptions(myForm.list2a);

		selectAllOptions(myForm.list4);
		CheckDates(AddEventForm);
		//myForm.submit();
	}
}

function ModifyEventFormSubmit() {
	var myForm = document.forms['ModifyEventForm'];
	
	var myName = trim(myForm.modifyName.value);
	
	if (myName.length == 0) {
		alert("You must specify the event name.");
		myForm.modifyName.focus();
	} else if (myForm.country.value == "") {
		alert("You must specify the country.");
		myForm.country.focus();
	} else {
		ae_onSubmit();

		if(myForm.list2 == "[object]")
			selectAllOptions(myForm.list2);
			
		if(myForm.list2a == "[object]")
			selectAllOptions(myForm.list2a);

		selectAllOptions(myForm.list4);
		CheckDates(ModifyEventForm);
//		myForm.submit();
	}
}

function AddEventTypeFormSubmit() {
	var myForm = document.forms['AddEventTypeForm'];

	var myName = trim(myForm.newEventType.value);

	if (myName.length == 0) {
		alert("You must specify the event type name.");
		myForm.newEventType.focus();
	} else {
		//alert("Submit");
		myForm.submit();
	}
}

function ModifyEventTypeFormSubmit() {
	var myForm = document.forms['ModifyEventTypeForm'];

	var myName = trim(myForm.modifyStatus.value);

	if (myName.length == 0) {
		alert("You must specify the event type name.");
		myForm.modifyStatus.focus();
	} else {
		//alert("Submit");
		myForm.submit();
	}
}

function CloseAllWindows () {
	return;
}

function setAllInVisible()
{
	document.getElementById("listbox1").style.display = "none";
	document.getElementById("listbox2").style.display = "none";
	document.getElementById("listbox3").style.display = "none";
	document.getElementById("listbox4").style.display = "none";
	document.getElementById("listbox5").style.display = "none";
	document.getElementById("listbox6").style.display = "none";
	document.getElementById("non_selected").style.display = "none";
	document.getElementById("controls").style.display = "none";
	document.getElementById("controls_usa").style.display = "none";
	document.getElementById("controls_ireland").style.display = "none";
}

function loadIt(option)
{
	if(option == "United States")
	{
		document.getElementById("listbox1").style.display = "block";
		document.getElementById("listbox2").style.display = "none";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "block";

		if(AddEventForm.list2a != "[object]")
		{
			// Delete them from original
			for (var i=(AddEventForm.list2.options.length-1); i>=0; i--)
			{
				//var o = AddEventForm.list2.options[i];
				//AddEventForm.list2.options[i] = null;
				moveAllOptions(document.AddEventForm.list2, document.AddEventForm.list1a, true, document.AddEventForm.movepattern1.value);
			}
		}
		else
		{
			// Delete them from original
			for (var i=(AddEventForm.list2a.options.length-1); i>=0; i--)
			{
				//var o = AddEventForm.list2a.options[i];
				//AddEventForm.list2a.options[i] = null;
				moveAllOptions(document.AddEventForm.list2a, document.AddEventForm.list1a, true, document.AddEventForm.movepattern1.value);
			}
		}

		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "block";
		document.getElementById("controls_ireland").style.display = "none";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "State";
	}
	else if(option == "Ireland")
	{
		document.getElementById("listbox1").style.display = "none";
		document.getElementById("listbox2").style.display = "block";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "block";

		if(AddEventForm.list2a != "[object]")
		{
			// Delete them from original
			for (var i=(AddEventForm.list2.options.length-1); i>=0; i--)
			{
				//var o = AddEventForm.list2.options[i];
				//AddEventForm.list2.options[i] = null;
				moveAllOptions(document.AddEventForm.list2, document.AddEventForm.list1, true, document.AddEventForm.movepattern1.value);
			}
		}
		else
		{
			// Delete them from original
			for (var i=(AddEventForm.list2a.options.length-1); i>=0; i--)
			{
				//var o = AddEventForm.list2a.options[i];
				//AddEventForm.list2a.options[i] = null;
				moveAllOptions(document.AddEventForm.list2a, document.AddEventForm.list1, true, document.AddEventForm.movepattern1.value);
			}
		}

		document.getElementById("listbox5").style.display = "block";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "none";
		document.getElementById("controls_ireland").style.display = "block";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "County";
	}
	else
	{
		document.getElementById("listbox1").style.display = "none";
		document.getElementById("listbox2").style.display = "none";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "none";
		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "none";
		document.getElementById("controls_usa").style.display = "none";
		document.getElementById("controls_ireland").style.display = "none";
		document.getElementById("non_selected").style.display = "none";
		document.all["state_region"].innerText = "";								
	}
}

function loadItNeutral(option)
{
	if(option == "United States")
	{
		document.getElementById("listbox1").style.display = "block";
		document.getElementById("listbox2").style.display = "none";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "block";
		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "block";
		document.getElementById("controls_ireland").style.display = "none";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "State";
	}
	else if(option == "Ireland")
	{
		document.getElementById("listbox1").style.display = "none";
		document.getElementById("listbox2").style.display = "block";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "block";
		document.getElementById("listbox5").style.display = "block";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "none";
		document.getElementById("controls_ireland").style.display = "block";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "County";
	}
	else
	{
		document.getElementById("listbox1").style.display = "none";
		document.getElementById("listbox2").style.display = "none";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "none";
		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "none";
		document.getElementById("controls_usa").style.display = "none";
		document.getElementById("controls_ireland").style.display = "none";
		document.getElementById("non_selected").style.display = "none";
		document.all["state_region"].innerText = "";								
	}
}

function loadIt_view3(option)
{
	if(option == "United States")
	{
		document.getElementById("listbox1").style.display = "block";
		document.getElementById("listbox2").style.display = "none";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "block";

		if(ModifyEventForm.list2a != "[object]")
		{
			// Delete them from original
			for (var i=(ModifyEventForm.list2.options.length-1); i>=0; i--)
			{
				//var o = ModifyEventForm.list2.options[i];
				//ModifyEventForm.list2.options[i] = null;
				moveAllOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
			}
		}
		else
		{
			// Delete them from original
			for (var i=(ModifyEventForm.list2a.options.length-1); i>=0; i--)
			{
				//var o = ModifyEventForm.list2a.options[i];
				//ModifyEventForm.list2a.options[i] = null;
				moveAllOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
			}
		}

		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "block";
		document.getElementById("controls_ireland").style.display = "none";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "State";
	}
	else if(option == "Ireland")
	{
		document.getElementById("listbox1").style.display = "none";
		document.getElementById("listbox2").style.display = "block";
		document.getElementById("listbox3").style.display = "none";
		document.getElementById("listbox4").style.display = "block";

		if(ModifyEventForm.list2a != "[object]")
		{
			// Delete them from original
			for (var i=(ModifyEventForm.list2.options.length-1); i>=0; i--)
			{
				//var o = ModifyEventForm.list2.options[i];
				//ModifyEventForm.list2.options[i] = null;
				moveAllOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
			}
		}
		else
		{
			// Delete them from original
			for (var i=(ModifyEventForm.list2a.options.length-1); i>=0; i--)
			{
				//var o = ModifyEventForm.list2a.options[i];
				//ModifyEventForm.list2a.options[i] = null;
				moveAllOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
			}
		}

		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "none";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "none";
		document.getElementById("controls_ireland").style.display = "block";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "County";
	}
	else
	{
		document.getElementById("listbox1").style.display = "none";
		document.getElementById("listbox2").style.display = "none";
		document.getElementById("listbox3").style.display = "block";
		document.getElementById("listbox4").style.display = "block";

		if(ModifyEventForm.list2a != "[object]")
		{
			// Delete them from original
			for (var i=(ModifyEventForm.list2.options.length-1); i>=0; i--)
			{
				var o = ModifyEventForm.list2.options[i];
				ModifyEventForm.list2.options[i] = null;
			}
		}
		else
		{
			// Delete them from original
			for (var i=(ModifyEventForm.list2a.options.length-1); i>=0; i--)
			{
				var o = ModifyEventForm.list2a.options[i];
				ModifyEventForm.list2a.options[i] = null;
			}
		}

		document.getElementById("listbox5").style.display = "none";
		document.getElementById("listbox6").style.display = "block";
		document.getElementById("controls").style.display = "block";
		document.getElementById("controls_usa").style.display = "none";
		document.getElementById("controls_ireland").style.display = "none";
		document.getElementById("non_selected").style.display = "block";
		document.all["state_region"].innerText = "";								
	}
}

function SortAllHeaders(mySort) {
	var formFlag = 0;
	
	if (document.all) {
		myForm = document.forms['SortForm'];
		formFlag = 1;
	} else if (document.getElementById) {
		myForm = document.forms['SortForm'];
		formFlag = 1;
	}
	
	if (formFlag == 1) {
		myForm.sort.value = mySort;
		myForm.submit();	
	}
}

function SearchFormSubmit() {
	var myForm;
	var formFlag = 0;
	
	// Set form variable
	if (document.all) {
		myForm = document.forms['SearchForm'];
		formFlag = 1;
	}
	else if (document.getElementById) {
		myForm = document.forms['SearchForm'];
		formFlag = 1;
	}

	// Submit form
	if (formFlag == 1) {
		myForm.submit();
	}
}

function pass_right()
{
	if (document.getElementById("listbox1").style.display == "none")
	{
		moveSelectedOptions(document.AddEventForm.list1a, document.AddEventForm.list2, true, document.AddEventForm.movepattern1.value);
	}
	else if(document.getElementById("listbox2").style.display == "none")
	{
		moveSelectedOptions(document.AddEventForm.list1, document.AddEventForm.list2, true, document.AddEventForm.movepattern1.value);
	}
}

function pass_all_right()
{
	if (document.getElementById("listbox1").style.display == "none")
	{
		moveAllOptions(document.AddEventForm.list1a, document.AddEventForm.list2, true, document.AddEventForm.movepattern1.value);
	}
	else if(document.getElementById("listbox2").style.display == "none")
	{
		moveAllOptions(document.AddEventForm.list1, document.AddEventForm.list2, true, document.AddEventForm.movepattern1.value);
	}
}

function pass_left()
{
	if (document.getElementById("listbox1").style.display == "none")
	{
		moveSelectedOptions(document.AddEventForm.list2, document.AddEventForm.list1a, true, document.AddEventForm.movepattern1.value);
	}
	else if(document.getElementById("listbox2").style.display == "none")
	{
		moveSelectedOptions(document.AddEventForm.list2, document.AddEventForm.list1, true, document.AddEventForm.movepattern1.value);
	}
}

function pass_all_left()
{
	if (document.getElementById("listbox1").style.display == "none")
	{
		moveAllOptions(document.AddEventForm.list2, document.AddEventForm.list1a, true, document.AddEventForm.movepattern1.value);
	}
	else if(document.getElementById("listbox2").style.display == "none")
	{
		moveAllOptions(document.AddEventForm.list2, document.AddEventForm.list1, true, document.AddEventForm.movepattern1.value);
	}
}

function pass_right_usa(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);
		}
	}
	else
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);
		}
	}
}

function pass_all_right_usa(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);	
		}
	}
	else
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list1, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);	
		}
	}
}

function pass_left_usa(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
	}
	else
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
	}
}

function pass_all_left_usa(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
	}
	else
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1, true, document.ModifyEventForm.movepattern1.value);
		}
	}
}

function pass_right_ireland(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);
		}
	}
	else
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
	}
}

function pass_all_right_ireland(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2, true, document.ModifyEventForm.movepattern1.value);	
		}
	}
	else
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list1a, document.ModifyEventForm.list2a, true, document.ModifyEventForm.movepattern1.value);	
		}
	}
}

function pass_left_ireland(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
	}
	else
	{
		if(option == "United States")
		{
			moveSelectedOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveSelectedOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
	}
}

function pass_all_left_ireland(option, country)
{
	if(country == "United States")
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list2, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
	}
	else
	{
		if(option == "United States")
		{
			moveAllOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
		else
		{
			moveAllOptions(document.ModifyEventForm.list2a, document.ModifyEventForm.list1a, true, document.ModifyEventForm.movepattern1.value);
		}
	}
}

function CheckDates(myForm)
{
	var mySDateString = "'" + myForm.sMonth.value + "/" + myForm.sDay.value + "/" + myForm.sYear.value + "'";
	var myEDateString = "'" + myForm.eMonth.value + "/" + myForm.eDay.value + "/" + myForm.eYear.value + "'";
	var myDateFormat = "'%m/%d/%yyyy'";
	var mySDate = buildDate(mySDateString, myDateFormat);
	var myEDate = buildDate(myEDateString, myDateFormat);
	if (typeof mySDate == "object")
	{
		// We got a Date object, so good.
		if (typeof myEDate == "object")
		{
			// We got a Date object, so good.
			if (mySDate >= myEDate)
			{
				alert("The end date must be after the start date.");
				myForm.eMonth.focus();
				return false;
			}
			else
			{
				myForm.submit();
			}
		}
		else
		{
			// We got an error string.
			alert(myEDate);
			myForm.eMonth.focus();
			return false;
		}
	}
	else
	{
		// We got an error string.
		alert(mySDate);
		myForm.sMonth.focus();
		return false;
	}
}

function EventsSearchFormSubmit()
{
	var myForm = document.forms['EventsSearchForm'];
	//document.EventsSearchForm.state_region1.value = document.getElementById("state_region").innerText;
	//alert(document.EventsSearchForm.state_region1.value);

	var mySDateString = "'" + myForm.sMonth.value + "/" + myForm.sDay.value + "/" + myForm.sYear.value + "'";
	var myEDateString = "'" + myForm.eMonth.value + "/" + myForm.eDay.value + "/" + myForm.eYear.value + "'";
	var myDateFormat = "'%m/%d/%yyyy'";
	var mySDate = buildDate(mySDateString, myDateFormat);
	var myEDate = buildDate(myEDateString, myDateFormat);

	if (myForm.myDates[0].checked)
	{
		//alert("Submit");
		myForm.submit();
	}
	else
	{
		if (typeof mySDate != "object")
		{
			alert(mySDate);
			myForm.sMonth.focus();
			return 0;
		}
		else if (typeof myEDate != "object")
		{
			alert(myEDate);
			myForm.eMonth.focus();
			return 0;
		}
		else if (mySDate >= myEDate)
		{
			alert("The end date must be after the start date.");
			myForm.eMonth.focus(); 
			return 0;
		}
		else
		{
			//alert("Submit");
			myForm.submit();
		}
	}
}

function NextClick(myForm, myDir)
{
	if (document.layers) {
		document.layers["MainDiv"].document.forms[myForm].Next.value = myDir;
		document.layers["MainDiv"].document.forms[myForm].submit();
	}
	else {
		document.forms[myForm].Next.value = myDir;
		document.forms[myForm].submit();
	}
}