if (xajax)
{
    xajax.initFileInputs = function ()
    {
        inputs = document.getElementsByTagName('input');
        for( var i=0; i < inputs.length; i++)
        {
            inp=inputs[i];
            if (!inp.className)
                continue; //doesnt have a class defined
            if (inp.className.indexOf('xajax_file')==-1)
                continue; //not an xajax file upload
            if (inp.style.visibility=='hidden')
                continue; //already converted this file upload
            xajax.newFileUpload(inp.id, inp.id+'-'+xajax.workId);
            inp.style.visibility = 'hidden';
            inp.style.height = '0';
            inp.style.width = '0';
        } 
    }
    xajax.newFileUpload = function(sParentId, sId)
    {
        xajax.insertAfter(sParentId, 'iframe', sId);
        newFrame = xajax.$(sId);
        newFrame.name=sId;
        newFrame.style.height="22px";
        newFrame.style.width="250px";
        newFrame.style.overflow="hidden";
        newFrame.position="absolute";
        newFrame.scrolling="no";
        newFrame.allowtransparency=true;
        newFrame.style.backgroundColor="";
        //need to wait for Mozilla to notice there's an iframe
        setTimeout('xajax._fileUploadContinue("'+sId+'");', 20);
    }
    xajax._fileUploadContinue = function(sId)
    {
        //uploadIframe = window.frames[sId];
        uploadIframe = xajax.$(sId);
        if (!uploadIframe.contentDocument)
        {
            //fix for internet explorer
            uploadIframe.contentDocument = window.frames[sId].document;
        }
        uploadIframe.contentDocument.body.style.backgroundColor="transparent";
        uploadIframe.contentDocument.xajax=this;
        uploadIframe.contentDocument.body.innerHTML='<span id="workId" style="font-size: 11px; height: 0px; position: absolute;">'+xajax.workId+'</span><form style="position:absolute;top:0;left:0;height:98%;width:98%;margin:0;padding:0;overflow:hidden;" name="iform" action="'+xajaxRequestUri+'" method="post" enctype="multipart/form-data"><input id="file" type="file" name="file" onchange="document.xajax._fileUploading(\''+sId+'\');document.iform.submit();" onmouseout="if(this.value)document.iform.submit();"/><input type="hidden" name="xajax" value="file_upload" /></form>';
        uploadIframe.style.border='0';
    }
    xajax._fileUploading = function(sId)
    {
        uploadIframe = xajax.$(sId);
        xajax.insertAfter(sId, 'div', sId+'-progress');
        uploadProgress = xajax.$(sId+'-progress');
        uploadIframe.style.visibility='hidden';
        uploadIframe.style.width='0';
        uploadIframe.style.height='0';
        uploadProgress.innerHTML='Wysylanie...';
        uploadProgress.style.fontSize="25";
        setTimeout('xajax._fileProgressCheck("'+sId+'");', 100);
    }
    xajax._fileProgressCheck = function(sId)
	{
		uploadIframe = xajax.$(sId);
		uploadProgress = xajax.$(sId+'-progress');
		if (uploadIframe.innerHTML.indexOf('</xjx>') == -1)
		{
			//this isn't a proper detection, but we'll work on it later
			uploadProgress.innerHTML='Teraz kliknij wyslij!';
		} else {
			setTimeout('xajax._fileProgressCheck("'+sId+'");', 100);
		}
	}
}