var isIE = navigator.appName == 'Microsoft Internet Explorer';


function  Form_hookup () 
{
	var form = document.forms [document.forms.length-1];

	form._event = 
		function  submitEvent (event, doSubmit) 
		{
			doSubmit = doSubmit != false;  // default value: true
            this.$event$.value = event;
			this.$event$.name = '$event';
			if (typeof this.onsubmit == 'function')  doSubmit = this.onsubmit() && doSubmit;
			if (doSubmit)  this.submit ();
		};

	form._toggle = 
		function  toggleCheckbox (name, value)
		{
			for (i=0; i<this.elements.length; ++i) {
				var e = this.elements[i];
				if (e.name == name  &&  (value == null  ||  e.value == value)) {
					if (!e.disabled) {
						e.checked = !e.checked;
						if (e.onclick)  e.onclick (event);
					}
					break;
				}
			}
		};

	document.write ('<input type="hidden" name="$event$">');
	return  form;
}


window.popup = 
function  Window_popup (url, name, args) 
{
	var w = args.width ? args.width : 333;
	var h = args.height ? args.height : 444;
	var x = (screen.availWidth - w)/2;
	var y = (screen.availHeight - h)/2;

	var features = 'resizable' 
		+  (isIE ? ',left=' : ',screenX=') + x
		+  (isIE ? ',top=' : ',screenY=') + y
		+  ',width=' + w
		+  ',height=' + h;

	if (args.features)  features += ","+args.features;

	var popup = window.open (url, name, features);
	popup.focus ();
	return popup;
};

