Index: trunk/phpgwapi/inc/class.common.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.common.inc.php	(revision 2611)
+++ trunk/phpgwapi/inc/class.common.inc.php	(revision 2616)
@@ -392,4 +392,5 @@
 					$GLOBALS[ 'phpgw' ] -> js -> validate_file( 'wz_dragdrop', 'wz_dragdrop', NULL, true );
 					$GLOBALS[ 'phpgw' ] -> js -> validate_file( 'expressoAjax', 'expressoAjax', NULL, true );
+					$GLOBALS[ 'phpgw' ] -> js -> validate_file( 'expressoAjax', 'dom', NULL, true );
 					$GLOBALS[ 'phpgw' ] -> js -> validate_file( 'tools','xlink', NULL, true );
 					$GLOBALS[ 'phpgw' ] -> js -> validate_file( 'tools','xconnector', NULL, true );
Index: trunk/phpgwapi/js/expressoAjax/dom.js
===================================================================
--- trunk/phpgwapi/js/expressoAjax/dom.js	(revision 1999)
+++ trunk/phpgwapi/js/expressoAjax/dom.js	(revision 2616)
@@ -1,3 +1,36 @@
-dom.prototype.config_events = function (pObj, pEvent, pHandler)
+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 parseInt(size/gbyte).toFixed(1) + ' GB';
+}
+
+function url_encode(str){
+    return escape(str);
+}
+function url_decode(str) {
+        return unescape(str);
+}
+
+function replaceAll(string, token, newtoken) {
+        while (string.indexOf(token) != -1) {
+                string = string.replace(token, newtoken);
+        }
+        return string;
+}
+
+function config_events(pObj, pEvent, pHandler)
 {
     if( typeof pObj == 'object')
@@ -14,193 +47,54 @@
 
 
-var _beforeunload_ = window.onbeforeunload;
-
-window.onbeforeunload = function()
-{
-	return unloadMess();
+// Make decimal round, using in size message
+function round(value, decimal){
+        var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal );
+        return( return_value );
 }
 
-dom.prototype.unloadMess = function (){
-	var mess = get_lang("All change you made has not been saved and will be discarted.");
-	for (var i = 0; i < BordersArray.length; i++) {
-		var body = Element('body_' + BordersArray[i].sequence);
-		if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') {
-			return mess;
-		}
-	}
+function removeAll(id){
+        do
+        {
+                if (typeof(Element(id)) == 'undefined')
+                        break;
+                Element(id).parentNode.removeChild(Element(id));
+        }
+        while(Element(id));
+}
+function validateEmail(email){
+        if (typeof(email) != 'string')
+                return false;
+        var validName = /^[a-z][a-z-_0-9\.]*/i;
+        emailParts = email.split('@');
+        return (validName.test(emailParts[0]) && validateDomain(emailParts[1]));
+}
+function validateDomain(domain){
+        var domainReg = /^(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/i;
+        return (domainReg.test(domain));
 }
 
-// Make decimal round, using in size message
-dom.prototype.round = function (value, decimal){
-	var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal );
-	return( return_value );
+function validateUrl(url){
+        var urlReg = /([A-Za-z]{2,7}:\/\/)(.*)/i;
+        urlParts = url.split(urlReg);
+        return (urlParts[1].length > 4 &&  validateDomain(urlParts[2]));
 }
 
-
-dom.prototype.removeAllById = function (id){
-	do
-	{
-		if (typeof(Element(id)) == 'undefined')
-			break;
-		Element(id).parentNode.removeChild(Element(id));
-	}
-	while(Element(id));
-}
-// Add Input File Dynamically.
-dom.prototype.addFile = function (id_border){
-	divFiles = document.getElementById("divFiles_"+id_border);
-	if (! divFiles)
-		return false;
-	
-	if (divFiles.lastChild)
-		var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1;
-
-	if (! countDivFiles)
-		var countDivFiles = 1;
-	
-	divFile = document.createElement('DIV');
-	
-	
-	divFile.innerHTML = "<input type='file' id_border='"+id_border+"' size='50' maxLength='255' onchange=\"function () {validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));};\" id='"+"inputFile_"+id_border+"_"+countDivFiles+"' name='file_"+countDivFiles+"'>";
-
-	
-	var linkFile = document.createElement("A");
-	linkFile.id = "linkFile_"+id_border+"_"+countDivFiles;
-	linkFile.href='javascript:void(0)';
-	linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;};
-	linkFile.innerHTML=get_lang("Remove");	
-	//divFile.innerHTML += "&nbsp;&nbsp;";
-	divFile.appendChild(linkFile);
-	divFile.id = "divFile_"+id_border+"_"+countDivFiles;	
-	divFiles.appendChild(divFile);
-
-	
-
-	return document.getElementById("inputFile_"+id_border+"_"+countDivFiles);
-}
-//	Remove Input File Dynamically.
-dom.prototype.removeFile = function (id){
-	var border_id = id.substr(8,1);
-	var el = Element(id);
-	el.parentNode.removeChild(el);
-}
-
-var denyFileExtensions = new Array('exe','com','reg','chm','cnf','hta','ins',
-					'jse','job','lnk','pif','src','scf','sct','shb',
-					'vbe','vbs','wsc','wsf','wsh','cer','its','mau',
-					'mda','mar','mdz','prf','pst');
-dom.prototype.validateFileExtension = function (fileName){
-	var error_flag = false;
-	var fileExtension = fileName.split(".");
-	fileExtension = fileExtension[(fileExtension.length-1)];
-	for(var i=0; i<denyFileExtensions.length; i++)
-	{
-		if(denyFileExtensions[i] == fileExtension)
-		{
-			error_flag = true;
-			break;
-		}
-
-	}
-
-	if ( error_flag == true )
-	{
-		write_error(get_lang('File extension forbidden or invalid file') + '.');
-		return false;
-	}
-	return true;
-}
-
-
-dom.prototype.validatePath = function (fileName, id, id_border){
-	
-	var error_flag  = false;
-
-	if ( fileName.indexOf('/') != -1 )
-	{
-		if (fileName[0] != '/'){ // file name is windows format?
-			var file = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length);
-			if ((fileName.indexOf(':\\') != 1) && (fileName.indexOf('\\\\') != 0)) // Is stored in partition or a network file?
-				error_flag = true;	
-		}
-		else // is Unix
-			var file = fileName.substr(fileName.lastIndexOf('/') + 1, fileName.length);						
-	}
-	else  // is Firefox 3
-		var file = fileName;
-	return (validateFileExtension(file));
-}
-
-var setTimeout_write_msg = 0;
-var old_msg = false;
-// Funcao usada para escrever mensagem
-// notimeout = True : mensagem nao apaga
-dom.prototype.write_msg = function (msg, notimeout){	
-	
-	if (setTimeout_write_msg)
-		clearTimeout(setTimeout_write_msg);
-	
-	var msg_div = Element('em_div_write_msg');
-	var old_divStatusBar = Element("divStatusBar");
-
-	if(!msg_div) {
-		msg_div = document.createElement('DIV');
-		msg_div.id = 'em_div_write_msg';
-		msg_div.className = 'em_div_write_msg';
-		old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar);
-	}
-	
-	if( document.getElementById('JabberMessenger'))
-		loadscript.adIcon();
-
-	msg_div.innerHTML = '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><th width="40%"></th><th noWrap class="action_info_th">'+msg+'</th><th width="40%"></th></tr></tbody></table>';
-
-	old_divStatusBar.style.display = 'none';
-	msg_div.style.display = '';	
-	// Nao ponha var na frente!! jakjr
-	handle_write_msg = function(){
-		try{
-			if(!old_msg)
-				clean_msg();
-			else
-				write_msg(old_msg, true);			
-		}
-		catch(e){}
-	}
-	if(notimeout)
-		old_msg = msg;
-	else
-		setTimeout_write_msg = setTimeout("handle_write_msg();", 5000);
-}
-// Funcao usada para apagar mensagem sem timeout
-dom.prototype.clean_msg = function (){
-	old_msg = false;
-	var msg_div = Element('em_div_write_msg');
-	var old_divStatusBar = Element("divStatusBar");
-	if(msg_div)
-		msg_div.style.display = 'none';
-	old_divStatusBar.style.display = '';	
-}
-function Element (el) {
-	return	document.getElementById(el);
-}
-
-dom.prototype.trim = function (inputString) {
+function trim(inputString) {
    if (typeof inputString != "string") 
-   	return inputString;
- 
+        return inputString;
+      
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ") { 
-	  retValue = retValue.substring(1, retValue.length);
-	  ch = retValue.substring(0, 1);
+          retValue = retValue.substring(1, retValue.length);
+          ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == " ") { 
-	  retValue = retValue.substring(0, retValue.length-1);
-	  ch = retValue.substring(retValue.length-1, retValue.length);
+          retValue = retValue.substring(0, retValue.length-1);
+          ch = retValue.substring(retValue.length-1, retValue.length);
    }
    while (retValue.indexOf("  ") != -1) { 
-	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
+          retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
    }
    return retValue; 
@@ -208,52 +102,42 @@
 
 
-dom.prototype.LTrim = function (value){
-	var w_space = String.fromCharCode(32);
-	var strTemp = "";
-	var iTemp = 0;
+function LTrim(value){
+        var w_space = String.fromCharCode(32);
+        var strTemp = "";
+        var iTemp = 0;
 
-	var v_length = value ? value.length : 0;
-	if(v_length < 1)
-		return "";
+        var v_length = value ? value.length : 0;
+        if(v_length < 1)
+                return "";
 
-	while(iTemp < v_length){
-		if(value && value.charAt(iTemp) != w_space){
-			strTemp = value.substring(iTemp,v_length);
-			break;
-		}
-		iTemp++;
-	}
-	return strTemp;
+        while(iTemp < v_length){
+                if(value && value.charAt(iTemp) != w_space){
+                        strTemp = value.substring(iTemp,v_length);
+                        break;
+                }
+                iTemp++;
+        }
+        return strTemp;
 }
 
 
-dom.prototype.array_search = function (needle, haystack) {
-	var n = haystack.length;
-	for (var i=0; i<n; i++) {
-		if (haystack[i]==needle) {
-			return true;
-		}
-	}
-	return false;
+function add_className(obj, className){
+        if (obj && !exist_className(obj, className))
+                obj.className = obj.className + ' ' + className;
+}
+
+function remove_className(obj, className){
+        var re = new RegExp("\\s*"+className);
+        if (obj)
+                obj.className = obj.className.replace(re, ' ');
+}
+
+function exist_className(obj, className){
+        return ( obj && obj.className.indexOf(className) != -1 );
 }
 
 
-dom.prototype.add_className = function (obj, className){
-	if (obj && !exist_className(obj, className))
-		obj.className = obj.className + ' ' + className;
-}
 
-dom.prototype.remove_className = function (obj, className){
-	var re = new RegExp("\\s*"+className);
-	if (obj)
-		obj.className = obj.className.replace(re, ' ');
-}
-
-dom.prototype.exist_className = function (obj, className){
-	return ( obj && obj.className.indexOf(className) != -1 )
-}
-
-
-dom.prototype.validate_date = function (date){
+function validate_date(date){
     if (date.match(/^[0-3][0-9]\/[0-1][0-9]\/\d{4,4}$/))
     {
@@ -280,4 +164,4 @@
             return false;
         }
-}
+};
 
