function popupCalendar(inputBox) {
    var newWindow = window.open("/jsp/calendar.jsp?locale=<%=AccessController.getLocale()%>&inputbox=" + inputBox,
        "myWindow", 'scrollbars=yes,left=10,top=10,width=300,height=300');
    newWindow.focus();
}

function popupCalendar(inputBox, defaultMonth, defaultYear) {
    var newWindow = window.open("/jsp/calendar.jsp?locale=<%=AccessController.getLocale()%>&inputbox=" + inputBox + "&month=" + defaultMonth + "&year=" + defaultYear,
        "myWindow", 'scrollbars=yes,left=10,top=10,width=300,height=300');
    newWindow.focus();
}

function popupSearch(inputBox, serachObjectType, orderType) {
	var url = "/jsp/search.jsp?inputBox=" + inputBox + "&searchObjectType=" + serachObjectType + "&orderType=" + orderType;
    var newWindow = window.open(url, "searchWindow", 'scrollbars=yes,left=10,top=10,width=400,height=427');
    newWindow.focus();
}

function updateDate(value, inputBox) {
    document.forms[0].elements[inputBox].value = value;
	document.forms[0].elements[inputBox].focus();
}

function updateDateNoFocus(value, inputBox) {
    document.forms[0].elements[inputBox].value = value;
}

// Generic method needs to be overriden by child page if body onload is required.
function bodyOnLoad() {

}

function mimicImageSubmit(submitForm, submitId, coordinate) {
    document.forms[submitForm][submitId].disabled = false;
    document.forms[submitForm][submitId].value = coordinate;
    document.forms[submitForm].submit();
}

//Method to display popup help window
function help(helpType, strHelpType) {
	var url;
	var width = "600";
	if (helpType == "oe") {
		url = "/oe/help.ls";
		width = "785";
	}
  	height = window.screen.availHeight - 50;
  	var wnd = window.open(url + "?helptopic=" + strHelpType, "help", "height=" + height + ",width=" + width + ",top=0,menubar=no,titlebar=no,toolbar=no,scrollbars=yes");
  	wnd.focus();
}

var numberOfClicks = 0;
//This function prevents a double click on a link
//Returns false to prevent a click on a button.
//Returns true to allow the button to submit the form.
function preventDoubleClick() {

	if (numberOfClicks > 0) {
		return false;
	}
	else {
		numberOfClicks++;
		return true;
	}
}

//Open a window.
function openWindow(url, name, properties) {
    window.open(url, top.window.name + "_" + name, properties);
}

/*********************************************************
* Auto Tabbing functions gleaned from:                   *
* http://www.idocs.com/tags/forms/index_famsupp_162.html *
**********************************************************/
var downStrokeField;
function autotab_keyDown(theField) { 
	theField.beforeLength=theField.value.length; 
	downStrokeField=theField; 
} 

function autotab_keyUp(theField, nextField) { 

if ( (theField == downStrokeField) && 
	(theField.value.length > theField.beforeLength) && 
	(theField.value.length >= theField.maxLength) ) {
		eval("document.forms[0]['" + nextField + "'].focus()"); 
	}
	
	downStrokeField=null; 
}