Index: branches/2.2/filemanager/js/common_functions.js
===================================================================
--- branches/2.2/filemanager/js/common_functions.js	(revision 3569)
+++ branches/2.2/filemanager/js/common_functions.js	(revision 3610)
@@ -20,4 +20,10 @@
 }
 
+function loadXtools()
+{
+	if( Xtools == null )
+		Xtools = new xtools( path_filemanager + "tp/expressowindow/" );
+}
+
 function check(element)
 {
@@ -83,26 +89,50 @@
 }
 
-function newUpload(data)
-{
-	if (data == null)
-	{
-		address = document.location.toString();
-		address = address.split("?");
-		var url = address[0]+"?menuaction=filemanager.uifilemanager.showUploadboxes&path="+base64_encode(currentPath);
-		cExecute_(url,newUpload);
-	}
-	else{
-		draw_window(data);
-	}
+function newUpload( )
+{
+	var _newUpload = function(data)
+	{
+		loadXtools();
+		
+		var pArgs = unserialize(data);
+			pArgs.lang_add_file		= get_lang("Add file");
+			pArgs.lang_click_here	= get_lang("Click here");
+			pArgs.lang_more_files	= get_lang("More files");
+			pArgs.height 			= 210;
+			pArgs.path_filemanager	= path_filemanager;
+			pArgs.width 			= 450;
+		
+		var _html = Xtools.parse( Xtools.xml("upload_files"), "upload.xsl", pArgs );
+		
+		draw_window( _html, 490, 350, get_lang("upload files") );
+	}
+	
+	address = document.location.toString();
+	address = address.split("?");
+	var url = address[0]+"?menuaction=filemanager.uifilemanager.showUploadboxes&path="+base64_encode(currentPath);
+	cExecute_( url, _newUpload );
 }
 
 function newAdvancedUpload()
 {
-	for (i=0; i < navigator.plugins.length; i++)
-	{
-		if (navigator.plugins[i].name.match('Java'))
+	for ( var i = 0 ; i < navigator.plugins.length; i++ )
+	{
+		if ( navigator.plugins[i].name.match('Java') )
 		{
 			close_window();
-			draw_window("<iframe width=\"515\" height=\"320\" src='/filemanager/inc/uploadApp.php?id="+parseInt(Math.random()*Math.pow(10,15))+"'></iframe>",530,345);
+
+			loadXtools();
+			
+			var pArgs = 
+			{
+				'iframe_width'		: 515,
+				'iframe_height'		: 320,
+				'iframe_src'		: path_filemanager + "inc/uploadApp.php?id="+parseInt(Math.random()*Math.pow(10,15))
+			};
+			
+			var _html = Xtools.parse( Xtools.xml("upload_files_advanced"), "uploadAdvanced.xsl", pArgs);
+			
+			draw_window( _html, 530, 345, get_lang("Advanced Upload") );
+			
 			return;
 		}
@@ -243,7 +273,6 @@
 	else
 	{
-		if( Xtools == null )
-			Xtools = new xtools( path_filemanager + "tp/expressowindow/" );
-	
+		loadXtools();
+		
 		var pTools = 
 		{
@@ -316,48 +345,74 @@
 
 }
-function borkb(size){
-                kbyte = 1024;
-                mbyte = kbyte*1024;
-                gbyte = mbyte*1024;
-                if (!size)
-                        size = 0;
-                if (size < kbyte)
-                        return size + 'B';
-                else if (size < mbyte)
-                        return parseInt(size/kbyte) + 'KB';
-                else if (size < gbyte)
-			if (size/mbyte > 100)
-	                        return (size/mbyte).toFixed(0) + 'MB';
-			else
-				return (size/mbyte).toFixed(1) + 'MB';
-                else
-                        return (size/gbyte).toFixed(1) + 'GB';
-}
-function addNewInput(){
-	var line = document.getElementById('uploadOption');
-	var newElement = document.createElement('TR');
-	var newElement2 = document.createElement('TD');
-	var newElement3 = document.createElement('TD');
-	newElement2.innerHTML = '<input onchange="javascript:addNewInput();" maxlength="255" name="upload_file[]" type="file">';
-	newElement3.innerHTML = '<input name="upload_comment[]" type="text">';
-	newElement.appendChild(newElement2);
-	newElement.appendChild(newElement3);
-	line.parentNode.appendChild(newElement);
-	document.getElementById('show_upload_boxes').value +=1;
-}
-
-function sendNotification(){
-	var winEl = document.getElementById('uploadOption').parentNode;
-	var emailTo = document.createElement("INPUT");
-	emailTo.name="notifTo[]";
-	emailTo.type="text";
-	emailTo.size="38";
-	var labelTo = document.createElement("SPAN");
-	labelTo.innerHTML = get_lang("Send Notification email to:");
-	winEl.insertBefore(labelTo,document.getElementById('uploadOption'));
-	winEl.insertBefore(emailTo,document.getElementById('uploadOption'));
-}
-
-function sendFiles(){
+
+function borkb(size)
+{
+	var kbyte = 1024;
+	var mbyte = kbyte*1024;
+	var gbyte = mbyte*1024;
+	
+	if (!size)
+	{
+		size = 0;
+	}
+
+	if (size < kbyte)
+	{
+		return size + 'B';
+	}
+	else if (size < mbyte)
+	{
+		return parseInt(size/kbyte) + 'KB';
+	}
+	else if (size < gbyte)
+	{
+		if ( size/mbyte > 100)
+			return (size/mbyte).toFixed(0) + 'MB';
+		else
+			return (size/mbyte).toFixed(1) + 'MB';
+	}
+	else
+	{
+		return (size/gbyte).toFixed(1) + 'GB';
+	}
+}
+
+function addNewInput()
+{
+	var newElement = document.createElement('div');
+		newElement.innerHTML  = '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' +
+								'<input name="upload_comment[]" type="text" style="margin-right:2px;" />' +
+								'<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>';
+	
+	document.getElementById('uploadOption').parentNode.appendChild(newElement);
+}
+
+function removeInput()
+{
+	if( arguments.length > 0 )
+	{
+		var _parent = arguments[0].parentNode;
+		
+		_parent.parentNode.removeChild(_parent);
+	}
+}
+
+function sendNotification()
+{
+	var _div = document.getElementById('sendNotifcation');
+
+	loadXtools();
+		
+	var pArgs = 
+	{
+		'lang_delete' : get_lang('delete'),
+		'lang_send_notification_email_to' :	get_lang("Send Notification email to:")
+	};
+		
+	_div.innerHTML += Xtools.parse( Xtools.xml("teste"), "send_notification.xsl", pArgs);
+}
+
+function sendFiles()
+{
 		cExecuteForm_(document.getElementById('form_up'),handler.upload);
 		document.getElementById('button_up').style.visibility = "hidden";
