var smsubmCounter=0;
function smartSubmit(oForm, callback, params) {
	if (oForm.smartSubmitLoad) return false;
	oForm.smartSubmitLoad=true;
	var iframe=document.body.appendChild(document.createElement("iframe"));
	iframe.style.width="0px";
	iframe.style.height="0px";
	iframe.style.border="0px";
	smsubmCounter++;
	var framewin=iframe.contentWindow?iframe.contentWindow:iframe;
	framewin.name="smartSubmitIframe_"+smsubmCounter;
	oForm.target=framewin.name;
	
	myAttachEvent(iframe, "load",
		function() {
			if(framewin.document.URL && framewin.document.URL!="about:blank" && oForm.smartSubmitLoad) {
				if (callback) {
					var innerHTML=iframe.contentDocument?(iframe.contentDocument.body?iframe.contentDocument.body.innerHTML:"")
						:framewin.document?(framewin.document.body?framewin.document.body.innerHTML:"")
						:"FATAL ERROR: Can't get iframe content";				
					oForm.smartSubmitLoad=false;
					callback(innerHTML, oForm, params);
				}
				setTimeout(function() {iframe.parentNode.removeChild(iframe)}, 1000);
			}
		}
	);
	if (window.opera && window.frames) while (!window.frames[framewin.name]);	//wait to get in frames	- Opera
	return true;
}

function submiterror(msg) {
	if (msg) {
		alert(msg.replace("|","\n"));
	}
}

function submitform(form, into, callback) {
	return smartSubmit(form, 
		function(src, form) {
			into.innerHTML=src;
			form=into.getElementsByTagName("form").item(0);	//visszakapott form
			if (form.error) submiterror(form.error.value);
			else callback(form);
		}
	)
}
