// Application specific script

var validSubmit=false;
var clicks=0;
    
// This function is limited to a JSP which has only 1 form and uses the same field "submitValue" for all buttons on the
// page specifying different values for that field depending on the button which was clicked. For JSPs which have multiple
// forms, or use multiple fields to represent the buttons on the page, the field object representing the clicked button
// should also be passed into this function to enable setting of the value in the "else" clause.
// Note that there is a bug if only 1 field is used to represent all buttons on a page (assumed by the function below). 
// This occurs only if there is more than 1 button on the JSP which has the same text (whether or not they appear at 
// the same time) and when the "back" or "refresh" browser buttons are used. To overcome this problem, ensure that the
// value submitted (the parameter in the function below) is different for all buttons on a page, regardless of what the
// displayed text to the user shows.

function buttonClick(btn)
{
    clicks++; 
    if (clicks>1) {
        this.blur(); 
        validSubmit=false;
    } 
    else {
        document.forms[0].submitValue.value=btn; 
        validSubmit=true;
    }    
}

// submission of the first form on the page
function buttonClickSubmit(submitValue) {
	buttonClick(submitValue);
	document.forms[0].submit();
}