// returns the form object of the management form
function __getForm() {
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		theform = document.masterForm;
	} else {
		theform = document.forms["masterForm"];
	}
	return theform;
}

// this is set to true if a postback is being executed
var __doingPostback = false;

// executes a form postback
function __doPostBack(eventTarget, eventArgument) {
	if (__doingPostback)
		return false;
	
	__doingPostback = true;
	
	var theform = __getForm();
	theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
	theform.__EVENTARGUMENT.value = eventArgument;

	// check for an onsubmit event handler
	if (theform.onsubmit != null) {		
		var res = theform.onsubmit();
		if (res == null || !res) {
			__doingPostback = false;
			return;
		}
	}
	theform.submit();
}

// creates a new hidden form variable
function __registerHiddenField(name, value) {
	var theform = __getForm();
	var ih = document.createElement("INPUT");
	ih.type = "hidden";
	ih.id = name;
	ih.name = name;
	ih.value = value;
	theform.appendChild(ih);
}

// sets the value of a hidden form variable
function __setHiddenField(name, value) {
	var hid = document.getElementById(name);
	hid.value = value;
}

// gets the value of a hidden form variable
function __getHiddenField(name) {
	var hid = document.getElementById(name);
	return hid.value;
}
