Index: /branches/2.2/expressoMail1_2/index.php
===================================================================
--- /branches/2.2/expressoMail1_2/index.php	(revision 3053)
+++ /branches/2.2/expressoMail1_2/index.php	(revision 3068)
@@ -168,17 +168,14 @@
 	if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages']) 
 		echo "<script src='js/gears_init.js'></script>";
-	echo $obj -> getFilesJs("js/abas.js," .
-							"js/doiMenuData.js," .
+	echo '<script src="../phpgwapi/js/dftree/dftree.js"></script>';
+	echo $obj -> getFilesJs(			"js/abas.js," .
+							"js/main.js," .
 							"js/drag_area.js," .
 							"js/draw_api.js," .
 							"js/DropDownContacts.js," .
-							"js/InfoContact.js," .
-							"js/main.js," .
-							"js/local_messages.js," .
-							"js/messages_controller.js," .
-							"js/rich_text_editor.js," .
-//							"js/mail_sync.js," .
-							"js/wfolders.js,",
+							"js/doiMenuData.js," .
+							"js/connector.js," .
 							$GLOBALS['phpgw_info']['flags']['update_version']);
+	echo '<script type="text/javascript">init();</script>';
 
 	if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'])
@@ -199,6 +196,4 @@
 </body>
 </html>
-<script src="js/connector.js?<?=$update_version?>" type="text/javascript"></script>
-<script src="../phpgwapi/js/dftree/dftree.js?<?=$update_version?>" type="text/javascript"></script>
-<script language="Javascript">connector.updateVersion = "<?=$update_version?>";init();</script>
+<script type="text/javascript">connector.updateVersion = "<?=$update_version?>";</script>
 <!-----Expresso Mail - Version Updated:<?=$update_version?>-------->
Index: /branches/2.2/expressoMail1_2/js/abas.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/abas.js	(revision 3018)
+++ /branches/2.2/expressoMail1_2/js/abas.js	(revision 3068)
@@ -67,4 +67,8 @@
 			if(ID){
 				connector.loadScript("rich_text_editor");
+				if(typeof(RichTextEditor) == 'undefined'){
+					setTimeout('alernate_border(\''+ID+'\');',500);
+					return false;
+				}
 				RichTextEditor.loadEditor(ID);
 			}
Index: /branches/2.2/expressoMail1_2/js/common_functions.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/common_functions.js	(revision 3064)
+++ /branches/2.2/expressoMail1_2/js/common_functions.js	(revision 3068)
@@ -505,4 +505,8 @@
 			{
 				connector.loadScript("QuickCatalogSearch");
+				if (typeof(QuickCatalogSearch) == 'undefined'){
+					setTimeout('emQuickSearch("'+emailList+'", "'+field+'", "'+ID+'")',500);
+					return false;
+				}
 				QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd);
 			}
@@ -510,4 +514,8 @@
 			{
 				connector.loadScript("QuickSearchUser");
+				if (typeof(QuickSearchUser) == 'undefined'){
+					setTimeout('emQuickSearch("'+emailList+'", "'+field+'", "'+ID+'")',500);
+					return false;
+				}
 				QuickSearchUser.showList(data);
 			}
@@ -548,4 +556,8 @@
 function folderbox(){
 	connector.loadScript("TreeS");
+	if (typeof(ttree) == 'undefined'){
+		setTimeout('folderbox()',500);
+		return false;
+	}
 	ttree.make_Window();
 }
@@ -554,4 +566,9 @@
 	connector.loadScript("filter");
 	connector.loadScript("filters");
+	if (typeof(filters) == 'undefined')
+	{
+		 setTimeout('filterbox()',500);
+	         return false;
+	}
 	filters.Forms();
 }
@@ -566,4 +583,9 @@
 		}
 		connector.loadScript("sharemailbox");
+		if (typeof(sharemailbox) == 'undefined')
+		{
+			setTimeout('sharebox()',500);
+			return false;
+		}
 		sharemailbox.makeWindow(options);
 	}
@@ -576,5 +598,10 @@
 
 function search_emails(value){
+	connector.loadScript("TreeS");
 	connector.loadScript("search");
+	if (typeof(EsearchE) == 'undefined' || typeof(ttree) == 'undefined'){
+		setTimeout('search_emails("'+value+'")',500);
+		return false;
+	}
 	EsearchE.showForms(value);
 }
@@ -589,35 +616,35 @@
 
 function url_encode(str){
-    var hex_chars = "0123456789ABCDEF"; 
-    var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
-    var n, strCode, hex1, hex2, strEncode = ""; 
-
-    for(n = 0; n < str.length; n++) { 
-        if (noEncode.test(str.charAt(n))) { 
-            strEncode += str.charAt(n); 
-        } else { 
-            strCode = str.charCodeAt(n); 
-            hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
-            hex2 = hex_chars.charAt(strCode % 16); 
-            strEncode += "%" + (hex1 + hex2); 
-        } 
-    } 
-    return strEncode; 
-}  
-
-function url_decode(str) { 
-
-	var n, strCode, strDecode = ""; 
-	for (n = 0; n < str.length; n++) { 
-	    if (str.charAt(n) == "%") { 
-	        strCode = str.charAt(n + 1) + str.charAt(n + 2); 
-	        strDecode += String.fromCharCode(parseInt(strCode, 16)); 
-	        n += 2; 
-	    } else { 
-	        strDecode += str.charAt(n); 
-	    } 
-	} 
-	return strDecode; 
-}  
+    var hex_chars = "0123456789ABCDEF";
+    var noEncode = /^([a-zA-Z0-9\_\-\.])$/;
+    var n, strCode, hex1, hex2, strEncode = "";
+
+    for(n = 0; n < str.length; n++) {
+        if (noEncode.test(str.charAt(n))) {
+            strEncode += str.charAt(n);
+        } else {
+            strCode = str.charCodeAt(n);
+            hex1 = hex_chars.charAt(Math.floor(strCode / 16));
+            hex2 = hex_chars.charAt(strCode % 16);
+            strEncode += "%" + (hex1 + hex2);
+        }
+    }
+    return strEncode;
+}
+
+function url_decode(str) {
+
+	var n, strCode, strDecode = "";
+	for (n = 0; n < str.length; n++) {
+	    if (str.charAt(n) == "%") {
+	        strCode = str.charAt(n + 1) + str.charAt(n + 2);
+	        strDecode += String.fromCharCode(parseInt(strCode, 16));
+	        n += 2;
+	    } else {
+	        strDecode += str.charAt(n);
+	    }
+	}
+	return strDecode;
+}
 
 function Element (el) {
Index: /branches/2.2/expressoMail1_2/js/connector.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/connector.js	(revision 3018)
+++ /branches/2.2/expressoMail1_2/js/connector.js	(revision 3068)
@@ -451,6 +451,6 @@
 
 	cConnector.prototype.loadAllScripts = function(scripts) {	
-		for(var i = 0; i < scripts.length; i++){
-			this.loadScript(scripts[i]);
+	for(var i = 0; i < scripts.length; i++){
+		this.loadScript(scripts[i]);
 		}
 	}
@@ -464,13 +464,11 @@
 		script.id = 'uploadscript_'+scriptPath;
 		script.type = 'text/javascript';
-  		
   		if(is_ie) {
-		
 			this.oxmlhttp.open("GET", "js/"+scriptPath+".js?"+this.updateVersion, false);
-    	    this.oxmlhttp.setRequestHeader('Content-Type','text/plain');
+			this.oxmlhttp.setRequestHeader('Content-Type','text/plain');
 			this.oxmlhttp.send(null);
 			if(this.oxmlhttp.status != 0 && this.oxmlhttp.status != 200 || 	this.oxmlhttp.status == 0 && this.oxmlhttp.responseText.length == 0)
 				throw new Error("Error " + this.oxmlhttp.status + "("+this.oxmlhttp.statusText+") when loading script file '"+scriptPath+"'");
-			script.text = this.oxmlhttp.responseText;				
+			script.text = this.oxmlhttp.responseText;
 		}
 		else {
@@ -479,5 +477,5 @@
 
 		head.appendChild(script);
-		return;	
+		return;
 	}
 //------------------------------------  END: Functions for Progress Bar  -------------------------------------------------//
Index: /branches/2.2/expressoMail1_2/js/mail_sync.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/mail_sync.js	(revision 1969)
+++ /branches/2.2/expressoMail1_2/js/mail_sync.js	(revision 3068)
@@ -11,4 +11,6 @@
 	 */
 	function mail_sync() {
+		if (typeof(google) == 'undefined')
+			return false;
 //		this.dbGears = null;
 //		this.localServer = null;
Index: /branches/2.2/expressoMail1_2/js/draw_api.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/draw_api.js	(revision 3064)
+++ /branches/2.2/expressoMail1_2/js/draw_api.js	(revision 3068)
@@ -778,22 +778,8 @@
 		Element('msg_number').value = '';
 	}
-
-	if(!is_ie) {
-		var scripts = new Array("ccQuickAdd",
-					"color_palette",
-					"filter",
-					"filters",
-					"html2xhtml",
-					"preferences",
-					"QuickCatalogSearch",
-					"QuickSearchUser",
-					"rich_text_editor",
-					"sharemailbox",
-					"search",
-					"TreeS",
-					"TreeShow");
-
-		connector.loadAllScripts(scripts);
-	}
+	var scripts = new Array("InfoContact",
+				"messages_controller",
+				"local_messages");
+	connector.loadAllScripts(scripts);
 }
 
@@ -2024,4 +2010,11 @@
 }
 function draw_new_message(border_ID){
+	connector.loadScript("rich_text_editor");
+	connector.loadScript("color_palette");
+	if(typeof(RichTextEditor) == 'undefined' || typeof(ColorPalette) == 'undefined'){
+		setTimeout('draw_new_message(\''+border_ID+'\');',500);
+		return false;
+	}
+
 	var ID = create_border("",border_ID);
 	if (ID == false)
@@ -2571,5 +2564,4 @@
 	table_message.appendChild(tbody_message);
 	form.appendChild(table_message);
-	connector.loadScript("rich_text_editor");
 	RichTextEditor.loadEditor(ID);
 //////////////////////////////////////////////////////////////////////////////////////////////////////
