var oIframeDiv;
var oMainDoc;
var oFile;
var oForm;

function activateUploadForm(sIframeDivId, sFormId, sInputFileId, iIframeHeightParam) {
	oFile = document.getElementById(sInputFileId);
	oForm = document.getElementById(sFormId);
	oIframeDiv = window.parent.document.getElementById(sIframeDivId);
	oIframeDiv.iIframeHeight = iIframeHeightParam;
	addEventHandler(oFile, "change", upload);
}

function upload(oEvent) {
	showProgress(true, "uploadFormPostep", "uploadForm");
	oForm.submit();
}

function setIframe(sFrameSrc, sIframeDivId, sResultDivId, sWidth) {
	if(!sWidth)
		sWidth = "100%";
	var oResultDiv = document.getElementById(sResultDivId);
	var oIframeDiv = document.createElement("div");
	oIframeDiv.id = sIframeDivId;
//	oIframeDiv.style.height = iIframeHeight + "px";
	oIframeDiv.innerHTML = '<iframe src="' + sFrameSrc + '" frameborder="0" width="'+ sWidth +'" height="' + oResultDiv.iIframeHeight + 'px" scrolling="no" allowtransparency="true" id="iframeUpload0"></iframe>';
	oResultDiv.parentNode.replaceChild(oIframeDiv, oResultDiv);
	// wywolanie wczesniej zdefiniowanej funkcji dodatkowej jezeli jest zdefiniowana
	if(document.body.fnOnChange)
		addEventHandler(oIframeDiv.firstChild, "load", document.body.fnOnChange);
}

function setResultIsteadIframe(sIframeDivId, sResultDivId) {
	var oIframeDiv = window.parent.document.getElementById(sIframeDivId);
	var oResultDiv = document.getElementById(sResultDivId);
	oResultDiv.iIframeHeight = oIframeDiv.iIframeHeight;
	
	if(bIsIE) {
		oIframeDiv.outerHTML = oResultDiv.outerHTML;
	}
	else {
		oIframeDiv.parentNode.replaceChild(oResultDiv, oIframeDiv);		
	}
	
}
