<inp2:m_NoDebug/>
<inp2:m_Set skip_last_template="1"/>
<inp2:m_include t="browser/browser_header" />
<script language="javascript">

function outputErrorMsg(errorNumber, fileName) {
	switch ( errorNumber )
	{
		case 0 :
			window.parent.frames['frmResourcesList'].Refresh() ;
			break ;
		case 201 :
			window.parent.frames['frmResourcesList'].Refresh() ;
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
			break ;
		case 202 :
			alert( 'Invalid file' ) ;
			break ;
		case 203 :
			alert( 'Invalid file type for this foder' ) ;
			break ;
		case 204 :
			alert( 'A file with the same name is already available' ) ;
			break ;
		default :
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
			break ;
	}
}

function OnUploadCompleted( errorNumber, fileName )
{
	// Reset the Upload Worker Frame.
	window.parent.frames['frmUploadWorker'].location = 'about:blank' ;

	// Reset the upload form (On IE we must do a little trick to avout problems).
	if ( document.all )
		document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
	else
		document.getElementById('frmUpload').reset() ;

	// Reset the interface elements.
	document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder' ;
	document.getElementById('btnUpload').disabled = false ;
	outputErrorMsg(errorNumber, fileName);
}

window.onload = function()
{
	window.top.IsLoadedUpload = true ;
}

function UploadNewFile()
{
		var file_name = document.frmUpload.elements['NewFile'].value;
		if (file_name.length > 0) {

			var ret = window.parent.frames['frmResourcesList'].ValidateFileName(file_name);
			if (!ret)
				return false;
			else {
				//document.frmUpload.elements['fck_event'].value = 'OnUploadFile';
				document.frmUpload.elements['upload_dir'].value = window.top.current_folder;
				document.frmUpload.submit();
			}
   } return false;
}


function SetElementVisibility(upload_visibility, del_rename_visibility) {
	document.getElementById("upload").style.display = upload_visibility;
	document.getElementById("del_rename").style.display = del_rename_visibility;
}

function SetButtonAvalability(button_name, avalability) {
	//alert(button_name+', '+avalability);
	//document.getElementById(button_name).disabled = !avalability;
	if (avalability == false) {
		document.getElementById(button_name).disabled = true;
		document.getElementById(button_name).style.color = '#666666';
	}
	else {
		document.getElementById(button_name).disabled = false;
		document.getElementById(button_name).style.color = '#000000';
	}
}

function RenameFile()
{
	filename = window.parent.frames['frmResourcesList'].GetCheckedFileName('first');
	f=prompt('Rename file "'+filename+'"?',filename);
	if (f) {
		 window.parent.frames['frmResourcesList'].RenameFile(filename,f);
	}
}
function DeleteFiles()
{
	cnt = window.parent.frames['frmResourcesList'].GetCheckedFileName('cnt');
	if (cnt > 0) {
		a = (cnt > 1) ? "Delete "+cnt+" selected files?": "Delete selected file?";
		if (confirm(a)) {
		 window.parent.frames['frmResourcesList'].DeleteFiles(0);
		}
	}
}



</script>
		<form id="frmUpload" name="frmUpload" action="" target="frmUploadWorker" method="post" enctype="multipart/form-data" onsubmit="return OnSubmit();">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
				<tr>
					<td nowrap>
						<div id="upload">
							<span id="eUploadMessage">Upload a new file in this folder</span><br>
							<table cellSpacing="0" cellPadding="0" width="100%" border="0">
								<tr>
									<td width="100%"><input id="NewFile" name="NewFile" size="50" type="file"></td>
									<td nowrap>&nbsp;<input id="btnUpload" type="button" value="Upload" OnClick="UploadNewFile();"></td>
								</tr>
							</table>
						</div>
						<div id="del_rename" style="display : none">
							<img src="img/browser/s.gif" width="1" height="10" /><br />
							<button type="button" id="rename" style="color:#000000; font-size: 11px; font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana" onClick="RenameFile();">Rename</button>
							<button type="button" id="delete" style="color:#000000; font-size: 11px; font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana" onClick="DeleteFiles();">Delete</button>
						</div>
					</td>
				</tr>
			</table>
			<!-- input type="hidden" name="events" value="fck_OnUploadFile" -->
			<input type="hidden" name="events[fck]" value="OnUploadFile">
			<input type="hidden" name="upload_dir" >
		</form>
<inp2:m_include t="browser/browser_footer" />