
function initform(id) {
	var ihgt_1, ihgt_2, iwth_1, iwth_2, ioff_l, ioff_t, strText, ileft, itop;
	var iHeight, iWidth;
	
	
	iHeight = screen.availHeight;
	iWidth = screen.availWidth;


	document.getElementById("inputform").style.left = 0;
	document.getElementById("inputform").style.top = 0;
	
	document.getElementById("inputform").style.height = iHeight / 4;
	document.getElementById("inputform").style.width = iWidth / 4;
	
	ioff_l = Number(document.getElementById("maintable").offsetLeft);
	ioff_t = Number(document.getElementById("maintable").offsetTop);
/*
	ileft = Math.round((iWidth - (iWidth/4))/2) - ioff_l;
	itop = Math.round((iHeight - (iHeight/4))/2) - ioff_t;


	document.getElementById("inputform").style.left = ileft;
	document.getElementById("inputform").style.top = itop;
*/
	document.getElementById("inputform").style.display = "block";

	
	ihgt_1 = Number(document.getElementById("maintable").offsetHeight);
	iwth_1 = Number(document.getElementById("maintable").offsetWidth);
	ihgt_2 = Number(document.getElementById("inputform").offsetHeight);
	iwth_2 = Number(document.getElementById("inputform").offsetWidth);

	
	if (iwth_1 >= iwth_2)
		ileft = ioff_l + (iwth_1 - iwth_2)/2;
	else
		ileft = ioff_l + (iwth_2 - iwth_1)/2;

	if (ihgt_1 >= ihgt_2)
		itop = ioff_t + (ihgt_1 - ihgt_2)/2;
	else
		itop = ioff_t + (ihgt_2 - ihgt_1)/2;
	
	/*
	alert("ileft = " + Math.round(ileft) + "\nitop = " + itop);
	*/
	
	ileft = Math.round(ileft);
	itop = Math.round(itop);
	
//	document.getElementById("inputform").style.top = itop;
//	document.getElementById("inputform").style.left = ileft;
	
	
}

function cancelform(strExitPage) {
	this.document.location.href = strExitPage;
}

function canceloperation() {
	document.forms[0].actionid.value = "x";
	document.forms[0].entryid.value = "";
	mysubmit();
//	document.forms[0].submit();
}

function viewentry(id) {
	document.forms[0].actionid.value = "v";
	document.forms[0].entryid.value = id;
	mysubmit();
//	document.forms[0].submit();
}

function editentry(id) {
	document.forms[0].actionid.value = "e";
	document.forms[0].entryid.value = id;
	mysubmit();
//	document.forms[0].submit();
}

function updateentry(id) {
	document.forms[0].actionid.value = "u";
	document.forms[0].entryid.value = id;
	mysubmit();
//	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;
		mysubmit();
//		document.forms[0].submit();
	}
}

function newentry() {
	document.forms[0].actionid.value = "n";
	document.forms[0].entryid.value = 0;
	mysubmit();
//	document.forms[0].submit();
}

function addentry() {
	document.forms[0].actionid.value = "a";
	document.forms[0].entryid.value = 0;
	mysubmit();
//	document.forms[0].submit();
}

function nextpage(imaxpage) {
	if (document.forms[0].pageid.value < imaxpage) {
		document.forms[0].pageid.value ++;
		mysubmit();
		//document.forms[0].submit();
	}
}

function prevpage() {
	if (document.forms[0].pageid.value > 1) {
		document.forms[0].pageid.value --;
		mysubmit();
//		document.forms[0].submit();
	}
}

function firstpage() {
	if (document.forms[0].pageid.value > 1) {
		document.forms[0].pageid.value = 1;
		mysubmit();
//		document.forms[0].submit();
	}
}

function lastpage(imaxpage) {
	if (document.forms[0].pageid.value < imaxpage) {
		document.forms[0].pageid.value = imaxpage;
		mysubmit();
//		document.forms[0].submit();
	}
}

function searchfor() {
	var strsearch;
//	strsearch = document.forms[0].searcharg.value;
//		if (strsearch.length != 0) {
		document.forms[0].actionid.value = "s";
		mysubmit();
		//document.forms[0].submit();
//		}
}

function setorder(icol) {
		if (document.forms[0].icol.value == icol)
		{
			//Flip the sort order
			if (document.forms[0].iorder.value == "d")
			{
				document.forms[0].iorder.value = "a";
			}
			else
			{
				document.forms[0].iorder.value = "d";
			}
		}
		else
			document.forms[0].icol.value = icol;
			
		mysubmit();
}

function mysubmit() {
	document.forms[0].lastsearch.value = document.forms[0].searcharg.value;
	document.forms[0].submit();
}
