function JSTransferDone(filelist){
	window.setTimeout(function() {//avoid Mac Firefox crashing
		with (window.parent) {
			FR.UI.uploadDialog.hide();
			FR.utils.reloadGrid();
			FR.UI.tree.reloadNode(FR.UI.tree.currentSelectedNode);
			FR.UI.reloadStatusBar();
		}
	}, 500);
}
function JSAppletInitialized(version){}
function JSTransferFailed(errormsg){alert(labels[2]);}
function JSTransferTriggered(filelist){}
function JSTransferStarted(filename, filesize){}
function JSTransferCompleted(filename, response){}
function JSTransferCancelled(){}
function JSSplitTriggered(filename, size, chunksize, amount){}
function JSSplitStarted(chunkid, chunksize){}
function JSSplitCompleted(chunkid){}
function JSSplitFailed(chunkid, errormsg){}
function JSFilterStarting(filename){}
function JSFilterStarted(filename){}
function JSFilterCompleted(filteredfilename){}
function JSFilterFailed(errormsg){}
function JSChecksumStarted(type){}
function JSChecksumCompleted(checksum){}

function destroyApplet() {
	Ext.get('placeHolder').update('');
}
function insertApplet() {
	var url = postURL+'&path='+encodeURIComponent(window.parent.FR.currentPath);
	var html = '';
	html += '<APPLET CODE="jfileupload.upload.client.JSMApplet.class" JAVA_CODEBASE="./" ARCHIVE="java/jfileupload.jar,java/httpimpl.jar,java/chttpclient.jar,java/clogging.jar,java/jsapi.jar" WIDTH="378" HEIGHT="290" NAME="fileupload" MAYSCRIPT>';
	html += '<PARAM NAME="CODE" VALUE="jfileupload.upload.client.JSMApplet.class">';
	html += '<PARAM NAME="CODEBASE" VALUE="./">';
	html += '<PARAM NAME="ARCHIVE" VALUE="java/jfileupload.jar,java/httpimpl.jar,java/chttpclient.jar,java/clogging.jar,java/jsapi.jar">';
	html += '<PARAM NAME="NAME" VALUE="fileupload">';
	html += '<PARAM NAME="type" VALUE="application/x-java-applet;version=1.6">';
	html += '<PARAM NAME="scriptable" VALUE="true">';;
	html += '<PARAM NAME="mayscript" VALUE="true">';
	html += '<PARAM NAME="url" VALUE="'+url+'">';
	html += '<PARAM NAME="resources" VALUE="java_upload_locale">';
	html += '<PARAM NAME="localeresourcesextension" VALUE=".php">';
	html += '<PARAM NAME="hidebar" VALUE="true">';
	html += '<PARAM NAME="paramfile" VALUE="uploadfile">';
	html += '<PARAM NAME="localeresources" VALUE="false">';
	html += '<PARAM NAME="mode" VALUE="http">';
	html += '<PARAM NAME="httpmethod" VALUE="POST">';
	html += '<PARAM NAME="folderdepth" VALUE="-1">';
	html += '<PARAM NAME="authentication" VALUE="auto">';
	if (blockedFileTypes) {
		html += '<PARAM NAME="blacklist" VALUE="'+blockedFileTypes+'">';
	}
	html += '<PARAM NAME="buffersize" VALUE="16384">';
	html += '<PARAM NAME="retry" VALUE="5">';
	html += '<PARAM NAME="retrydelay" VALUE="10">';
	//html += '<PARAM NAME="username" VALUE="">';
	//html += '<PARAM NAME="password" VALUE="">';
	html += '<PARAM NAME="encoding" VALUE="UTF-8">';
	html += '<PARAM NAME="chunksize" VALUE="'+chunkSize+'">';
	html += '<PARAM NAME="chunkmode" VALUE="onflyrange">';
	html += '<PARAM NAME="resume" VALUE="true">';
	html += '<PARAM NAME="param1" VALUE="relativefilename">';
	html += '<PARAM NAME="value1" VALUE="true">';
	html += '<PARAM NAME="param2" VALUE="errorheader">';
	html += '<PARAM NAME="value2" VALUE="custommessage">';
	html += '<PARAM NAME="param3" VALUE="emptydirectory">';
	html += '<PARAM NAME="value3" VALUE="true">';
	html += '<PARAM NAME="param4" VALUE="retryonerrorheader">';
	html += '<PARAM NAME="value4" VALUE="true">';
	html += '<PARAM NAME="param5" VALUE="cookieheader">';
	html += '<PARAM NAME="value5" VALUE="singleline">';
	if (Ext.isSafari) {
		html += '<PARAM NAME="param6" VALUE="cookiename">';
		html += '<PARAM NAME="value6" VALUE="'+SessionCookieName+'">';
		html += '<PARAM NAME="param7" VALUE="cookievalue">';
		html += '<PARAM NAME="value7" VALUE="'+SessionCookieValue+'">';
	} else {
		html += '<PARAM NAME="param6" VALUE="cookiesource">';
		html += '<PARAM NAME="value6" VALUE="jse">';
	}
	if (useProxy) {
		html += '<PARAM NAME="param8" VALUE="httpproxyhost">';
		html += '<PARAM NAME="value8" VALUE="'+proxyHost+'">';
		html += '<PARAM NAME="param9" VALUE="httpproxyport">';
		html += '<PARAM NAME="value9" VALUE="'+proxyPort+'">';
	}
	if (proxyUsername) {
		html += '<PARAM NAME="param10" VALUE="httpproxyusername">';
		html += '<PARAM NAME="value10" VALUE="'+proxyUsername+'">';
		html += '<PARAM NAME="param11" VALUE="httpproxypassword">';
		html += '<PARAM NAME="value11" VALUE="'+proxyPassword+'">';
	}
	if (proxyNTMLdomain) {
		html += '<PARAM NAME="param12" VALUE="httpproxyntlmdomain">';
		html += '<PARAM NAME="value12" VALUE="'+proxyNTMLdomain+'">';
	}
	if (NTMLdomain) {
		html += '<PARAM NAME="param13" VALUE="httpntlmdomain">';
		html += '<PARAM NAME="value13" VALUE="'+NTMLdomain+'">';
	}
	html += '</APPLET>';
	Ext.get('placeHolder').update(html);
}

Ext.onReady(function() {
	with (window.parent) {FR.UI.uploadDialog.javacard.el.unmask();}
	if (navigator.javaEnabled()) {
		insertApplet();
	}
});