// JavaScript Document
function tableOrdering( order, dir, task ) {
	var form = document.adminForm;
     
	form.order.value     = order;
	form.order_dir.value    = dir;

	document.adminForm.submit( task );
}


function displayDiv (divname, spanname, showtext, hidetext) { 
	var div = document.getElementById(divname);
	var span = document.getElementById(spanname);
	

	if (div.style.display == "none")	{
		div.style.display = "";
		span.innerHTML = hidetext;
	} else {
		div.style.display = "none";
		span.innerHTML = showtext;
	}
}

function submitForm(form, task, id) {   
	// do field validation
		if (task == "validatefields") {
				if (!form.accept.checked) { 
					alert("You must accept our terms to submit this form.");
				}
				else if (form.question1.value == form.question2.value) { 
					alert("You must select two different questions.");
				}
				else if (form.answer1.value == form.answer2.value) { 
					alert("You must submit two different answers.");
				}
				else if (!form.answer1.value || !form.answer2.value) { 
					alert("You complete the entire form.");
				}
				else {
					form.task.value = task;
					form.id.value = id;
					form.submit();
				}
		} 
		else if (task == "processticket") {
				if (!form.subject.value || form.subject.value == " ") { 
					alert("Invalid Subject.");
				}
				else if (!form.description.value || form.description.value == " ") { 
					alert("Invalid Description.");
				}
				else {
					form.task.value = task;
					form.id.value = id;
					form.submit();
				}
		} 
		else {
			form.task.value = task;
			form.id.value = id;
			form.submit();
		}
}