function cancelform() {
	this.document.location.href = "adminoptions.asp";
}

function canceloperation() {
	document.forms[0].actionid.value = "x";
	document.forms[0].entryid.value = "";
	document.forms[0].submit();
}

function editentry(id) {
	document.forms[0].actionid.value = "e";
	document.forms[0].entryid.value = id;
	document.forms[0].submit();
}

function updateentry(id) {
	document.forms[0].actionid.value = "u";
	document.forms[0].entryid.value = id;
	document.forms[0].submit();
}

function deleteentry(id) {
	if (confirm("Are you sure you want to delete this entry?")) {
		document.forms[0].actionid.value = "d";
		document.forms[0].entryid.value = id;
		document.forms[0].submit();
	}
}

function newentry() {
	document.forms[0].actionid.value = "n";
	document.forms[0].entryid.value = 0;
	document.forms[0].submit();
}

function addentry() {
	document.forms[0].actionid.value = "a";
	document.forms[0].entryid.value = 0;
	document.forms[0].submit();
}

function displaystatus(strText)
{
	window.defaultStatus = strText;
	return true;
}

function sortorder(vorder, vdesc)
{
	document.forms[0].actionid.value = "o";
	document.forms[0].order.value = vorder;
	document.forms[0].desc.value = vdesc;
	if (document.forms[0].v_search != null)
	{
		document.forms[0].lastsearch.value = document.forms[0].v_search.value;
	}
	mysubmit();
}

function search()
{
	var strsearch = document.forms[0].v_search.value;
	if (strsearch.length != 0)
	{
		document.forms[0].actionid.value = "s";
		document.forms[0].lastsearch.value = document.forms[0].v_search.value;
		setfirstpage();
		mysubmit();
	}
	else
	{
		alert("Please enter a search term.");
		document.forms[0].v_search.focus();
	}
}

function filter()
{
	document.forms[0].actionid.value = "f";
	if (document.forms[0].v_search != null)
	{
		document.forms[0].lastsearch.value = document.forms[0].v_search.value;
	}
	setfirstpage();
	mysubmit();
}

function getfilter(oselect)
{
/*
	var ovals = new Array();
	ovals[0] = "smith,jones,brown,white";
	ovals[1] = "mary,sally,helen,john,peter,paul";
	ovals[2] = "0,5,10,15,20,25,30,35,40";
*/

	var strList;
	var opt;
	var aVals;
	
	opt = oselect.options[oselect.selectedIndex].value;
	if (opt != "-1")
	{
		//alert("selected index = " + oselect.selectedIndex);
		strList = ovals[oselect.selectedIndex - 1];
		aVals = strList.split(",");
		fn_loadList(document.getElementById("v_fval"), aVals);
	}
	else
	{
		fn_clearList(document.getElementById("v_fval"));
	}
}

function fn_loadList(oList, aData)
{
	var aVals;
	fn_clearList(oList); //clear previous data from States

	for(var i=0; i < aData.length; i++)
	{
		aVals = aData[i].split("~");
		if (aVals.length == 1)
		{
			oList.options[i] = new Option(aData[i], aData[i]);
		}
		else
		{
			oList.options[i] = new Option(aVals[0], aVals[1]);
		}
	}
}

function fn_clearList(oList)
{
	var iLength = oList.options.length;
	if(iLength > 0)
	{
		for(i=0; i<iLength; i++)
		{
			oList.remove(oList.options[i]);
		}
	}
	else
	{
		return;
	}
}

function setupform(stage)
{
	switch(stage)
	{
		case 1:
			break;
		case 2:
			break;
		case 3:
			break;
		case 4:
			break;
		case 5:
			break;
		default:
			break;
	}
}

function nextpage(imaxpage) {
	if (document.forms[0].pageid.value < imaxpage) {
		document.forms[0].pageid.value ++;
		mysubmit();
	}
}

function prevpage() {
	if (document.forms[0].pageid.value > 1) {
		document.forms[0].pageid.value --;
		mysubmit();
	}
}

function firstpage() {
	if (document.forms[0].pageid.value > 1) {
		document.forms[0].pageid.value = 1;
		mysubmit();
	}
}

function lastpage(imaxpage) {
	if (document.forms[0].pageid.value < imaxpage) {
		document.forms[0].pageid.value = imaxpage;
		mysubmit();
	}
}

function setfirstpage()
{
	document.forms[0].pageid.value = 1;
}

function setorder(fname) {

	document.forms[0].order.value = fname;
	mysubmit();
}

function mysubmit() {
	document.forms[0].submit();
}
