/*
	use this function as onsubmit-event to form
	it will disable all submit buttos found in the document
	to preven a second submit of any other form
*/
function dsbl_sbmt_btns_disable()
{
	// we can't disable the buttons immediately, before we submit the form
	// because they will not be part of the post/get if disabled
	// windows.setTimeout() will give us the minimal delay we need, to
	// submit before disabling the buttons
	window.setTimeout(function() {
		// iterate all forms
		for(f = 0; f < document.forms.length; ++f)
		{
			frm = document.forms[f];
			// disable all submit buttons
			for (i = 0; i < frm.elements.length; ++i)
				if(frm.elements[i].type)
					if (frm.elements[i].type.toLowerCase() == 'submit')
				frm.elements[i].disabled = true;
		}
	}, 0);
}


/*
	sets onsubmit of all forms to dsbl_sbmt_btns_disable()
*/
function dsbl_sbmt_btns_window_onload()
{
	// process all forms
	for(f = 0; f < document.forms.length; ++f)
	{
		// and set the the onsubmit event
		if(document.forms[f].addEventListener)
			document.forms[f].addEventListener('submit', dsbl_sbmt_btns_disable, false);
		if(document.forms[f].attachEvent)
			document.forms[f].attachEvent('onsubmit', dsbl_sbmt_btns_disable);
	}
}

/*
	register window.onload event
*/
// Mozilla, Safarai, ...
if(window.addEventListener)
	window.addEventListener('load', dsbl_sbmt_btns_window_onload, false);
// IE
if(window.attachEvent)
	window.attachEvent('onload', dsbl_sbmt_btns_window_onload);
