window.onload = function(){
	//loop through forms
	for(var i=0; i<document.forms.length; i++){
		//loop through elements of current form
		for(var j=0; j<document.forms[i].elements.length; j++){
			//easy element reference
			var elm = document.forms[i].elements[j];
			//if element type is "submit" or "button" see if there's allready an onclick event assigned.
			if( elm.type.toLowerCase().match(/submit|button/g) ){
				//if there's no onclick then assign ours to disable button onclick
				if( !elm.onclick ){
					elm.onclick = function(){
						this.disabled = true;
						//disabled styles here, i.e. this.style.backgroundColor = "#333333";
					}
				// if there is an onclick assigned we have to "overload" it.
				}else{
					//grab the event & strip the "function anonamous()" from the beginning
					var oFn=elm.onclick.toString().split("");
					//loop through the array created from the event shifting chars untill "function..." is gone.
					for(var fn=false;!fn;){
						var c=oFn.shift();
						if(c==")"){
							fn=true;
						}
					}
					//create a new attribute ON the element itself for the stripped event string & stash it there.
					elm["onclick2"]=oFn.join("");
					//assign our disable event
					elm.onclick = function(){
						this.disabled = true;
						//disabled styles here, i.e. this.style.backgroundColor = "#333333";
						//evaluating the contents of our new attribute will trigger the original onclicks actions
						eval(this.onclick2);
					}
				}
			}
		}
	}
}
