// Common scripts
function centerbox(width, height) {
	var pageXOffset = 0;
	var pageYOffset = 0;
	
	if (document.all) { // IE
		pageXOffset = document.documentElement.scrollLeft || document.body.scrollLeft;
		pageYOffset = document.documentElement.scrollTop || document.body.scrollTop;
	}
	
	var ret = {left:   (document.body.clientWidth-width)/2 + pageXOffset + "px", 
						 top:    (document.body.clientHeight-height)/2  + pageYOffset + "px",
						 width:  width + "px",
						 height: height + "px"};
	return ret;
}	

function handleEnter() {
	var handler = function(e) {
		// If user presses enter, submit the form:
		// if the page defines submit(), doSubmit() or mySubmit() then call it, else do standard form submit
		// This is supposed to be used only for pages containing a form
		var submitFn = document.forms[0].submit
		var whichASC = 0
		
		if (typeof submit == 'function')
				submitFn = submit
		else if (typeof doSubmit == 'function')
				submitFn = doSubmit
		else if (typeof mySubmit == 'function')
				submitFn = mySubmit
	
		if (document.all) // IE
			whichASC = window.event.keyCode
		else if (e.which)
			whichASC = e.which

		if (whichASC == 13) {
			submitFn()
		}
		return 0
	}
	
	if (document.all) // IE
		 document.onkeydown = handler
	else // FF, Opera
		 window.onkeypress = handler
}
