function validate_form(the_form) {
	for (i = 0; i < the_form.elements.length-1; i++) {
		var the_element = the_form.elements[i];
		var the_tagName = the_element.tagName != null?the_element.tagName:'';
		var the_text = the_element.value != null?the_element.value:'';
		var the_alt = the_element.alt != null?the_element.alt.toUpperCase():'';
		var the_title = the_element.title != null?the_element.title:'';
		var the_type = the_element.type != null?the_element.type.toUpperCase():'';
		
		if (the_tagName == 'INPUT') {
			if (the_type == 'TEXT' || the_type == 'PASSWORD') {
				if (the_text == '' && the_alt == 'REQUIRED') {
					if(the_title != '') {
						alert(the_title + ' must not be left blank.');
					} else {
						alert('Please complete the form.');
					}
					return false;
				}
			} else if (the_type == 'CHECKBOX') {
				if (the_alt == 'REQUIRED' && the_element.checked == false) {
					if(the_title != '') {
						alert(the_title + ' must be checked.');
					} else {
						alert('Please complete the form.');
					}
					return false;
				}
			}
		}
	}
	return true;
}

function check_pass(pass,repass) {
	if (pass.value != repass.value) {
		alert('Passwords must match.');
		return false;
	}
	return true;
}

function MoveUp(combo_name)
{
	var combo=document.getElementById(combo_name);
	i=combo.selectedIndex;
	if (i>0)
	{
		swap(combo,i,i-1);
		combo.options[i-1].selected=true;
		combo.options[i].selected=false;
	}
}

function MoveDown(combo_name)
{
	var combo=document.getElementById(combo_name);
	i=combo.selectedIndex;

	if (i<combo.length-1 && i>-1)
	{
		swap(combo,i+1,i);
		combo.options[i+1].selected=true;
		combo.options[i].selected=false;
	}
}

function swap(combo,index1, index2)
{
	var savedValue=combo.options[index1].value;
	var savedText=combo.options[index1].text;

	combo.options[index1].value=combo.options[index2].value;
	combo.options[index1].text=combo.options[index2].text;

	combo.options[index2].value=savedValue;
	combo.options[index2].text=savedText;
}

function MoveToTop(combo_name)
{
	var combo=document.getElementById(combo_name);
	i=combo.selectedIndex;
	
	for (;i>0;i--)
	{
		swap(combo,i,i-1);
		combo.options[i-1].selected=true;
		combo.options[i].selected=false;
	}
}

function MoveToBottom(combo_name)
{
	var combo=document.getElementById(combo_name);
	i=combo.selectedIndex;
	
	if (i>-1)
	{
		for (;i<combo.length-1;i++)
		{
			swap(combo,i+1,i);
			combo.options[i+1].selected=true;
			combo.options[i].selected=false;
		}
	}
}
