Index: sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js
===================================================================
--- sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js	(revision 2543)
+++ sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js	(revision 2546)
@@ -50,73 +50,27 @@
 
 function beginSpellCheck(){
-if(!blockSpellCheck){
-    position = "body_position_" + currentTab;
-    area = "body_" + currentTab;
-    aba = currentTab;
-
-    //var cp = new cpaint();
-    // alert("Seta globals");
-    //cp = new cpaint();
-    //cp.set_transfer_mode('post');
-    //cp.set_response_type('text');
-    //cp.set_debug(1);
-
-    //var currObj; //the current spell checker being used
-    //var spellingSuggestionsDiv = null;  // Auto-generated suggestions div
-
-    spellingSuggestionsDiv = null;
-    positionEditor = position;
-    areaEditor = area;
-    abaEditor = aba; 
-    
-
-    //alert("Seta globals");
-
-
-// If there are already any onclick handlers loaded in the page, we'll add
-// our onclick handler first and then call the old one, rather than completely
-// overriding it.  The checkClickLocation is used to hide the suggestions div
-// when the user clicks outside it.
-    /*if(document.onclick)
-    {
-	old_onclick = document.onclick;
-       
-	document.onclick = function(e)
-	{
-		checkClickLocation(e);
-		old_onclick(e);
-	}
-}
-else
-{
-	//document.onclick = checkClickLocation;
-}*/
-
-//alert("Inicio");
-// If there are already any onload handlers loaded in the page, we'll add our onload
-// handler first and then call the old one, rather than completely overriding it.
-    if(window.onload)
-    {
-            window.onload = new setupSpellCheckers();
-
-            /*var old_onload = window.onload;
-            window.onload = function(e)
-            {
-                    var test = new setupSpellCheckers(e);
-                    old_onload(e);
-            }*/
+    if(!blockSpellCheck){
+        position = "body_position_" + currentTab;
+        area = "body_" + currentTab;
+        aba = currentTab;
+        spellingSuggestionsDiv = null;
+        positionEditor = position;
+        areaEditor = area;
+        abaEditor = aba;
+
+        if(window.onload)
+        {
+                window.onload = new setupSpellCheckers();
+
+        }
+        else
+        {
+                window.onload = new setupSpellCheckers();
+        }
+
+    } else {
+        alert("O corretor esta executando")
     }
-    else
-    {
-            window.onload = new setupSpellCheckers();
-    }
-
-//window.onload =new setupSpellCheckers();
-//alert("Fim");
-} else {
-    alert("O corretor ja esta rodando.")
-}
-} // fecha funï¿œï¿œo
-
+} // close BeginSpellCheck
 
 
@@ -126,12 +80,12 @@
  * function setupSpellCheckers()
  *
- * This function goes through the page and finds all the 
- * textareas.  It then checks the title attribute for either
- * spellcheck or spellcheck_icons to determine whether or not
- * it should add a spellchecker to that textarea.
+ * This function obtain the iframe of the page (that is the area editor)
+ * and then adds a spellchecker to the iframe.
  *************************************************************/
 function setupSpellCheckers()
 {
     var ifr = document.getElementsByTagName('iframe')[0];
+    //alert(area);
+    //var ifr = document.getElementById(area);
     var numSpellCheckers = abaEditor;
 
@@ -140,4 +94,14 @@
     else
         ifr=ifr.contentDocument;
+
+     if (document.addEventListener) {
+        ifr.addEventListener("click", checkClickLocation , true); //add the click event
+     }   
+     else {
+        ifr.attachEvent("onclick", checkClickLocation); //add the click event
+        
+     }
+    
+
     var texto = ifr.body.innerHTML;
 
@@ -342,6 +306,4 @@
 
         
-
-
       
         
@@ -369,5 +331,5 @@
  *
  * This function is associated with the click event
- *  of all the tags span with correctd_word class.
+ *  of all the span tags with correctd_word class.
  *
  *************************************************************/
@@ -382,37 +344,24 @@
     var browser = checkBrowser();
     if (browser == "ie"){
-        //iframe.body.contentEditable="false" ;
+        
         iframe.body.contentEditable="true" ;
+        var ifr= currObj.objToCheck;
+        if(!e){var e = ifr.contentWindow.event;}
+        if(!e.target){e.target = e.srcElement;}
+        var evento = e.target.onclick.toString();
+
     }
     else {
         iframe.designMode = "off";
         iframe.designMode = "on";
-    }
-    
-    var browser = checkBrowser();
-    if (browser == "ie"){
-         var ifr= currObj.objToCheck;
-         if(!e){var e = ifr.contentWindow.event;}
-            if(!e.target){e.target = e.srcElement;}
-
-            if(ifr.contentWindow)
-            ifr=ifr.contentWindow.document;
-        else
-            ifr=ifr.contentDocument;
-        var evento = ifr.getElementById(e.target.id).onclick.toString();
-    }
-    else {
         var evento = this.onclick.toString();
-    }
-
+    }  
     evento = evento.replace("function onclick(event) {", "");
     evento = evento.replace("}", "");
     var array_func = evento.split(";");
     eval(array_func[0]);
-   eval(array_func[1]);
+    eval(array_func[1]);
     return false;   
-    
-
-    
+       
   
 //
@@ -420,13 +369,11 @@
 
 /*************************************************************
- * showMenu
+ * replaceMenu
  *
  * This function is associated with the click event
- *  of all the tags div with suggestion class.
- *
- *************************************************************/
-function replaceMenu(){
-      //adicionado nathalie
-
+ *  of all the div tags with suggestion class.
+ *
+ *************************************************************/
+function replaceMenu(){     
     var iframe= currObj.objToCheck;
     if(iframe.contentWindow)
@@ -434,28 +381,17 @@
     else
         iframe=iframe.contentDocument;
-
     var browser = checkBrowser();
     if (browser == "ie"){
         iframe.body.contentEditable="false" ;
-        //iframe.body.contentEditable="true" ;
+        var ifr= currObj.objToCheck;
+        if(!e){var e = ifr.contentWindow.event;}
+        if(!e.target){e.target = e.srcElement;}
+        var evento = e.target.onclick.toString();
     }
     else {
         iframe.designMode = "off";
         iframe.designMode = "on";
-    }
-
-
-    
-    var browser = checkBrowser();
-    if (browser == "ie"){
-         var ifr= currObj.objToCheck;
-         if(!e){var e = ifr.contentWindow.event;}
-         if(!e.target){e.target = e.srcElement;}        
-         var evento = e.target.onclick.toString();
-    }
-    else {
         var evento = this.onclick.toString();
     }
-
     evento = evento.replace("function onclick(event) {", "");
     evento = evento.replace("}", "");
@@ -482,5 +418,5 @@
 function spellCheck_cb(new_data)
 {
-	 //adicionado nathalie
+	 
         var ifr= currObj.objToCheck;
         if(ifr.contentWindow)
@@ -503,19 +439,5 @@
 	}
 
-        
-        /*currObj.spellingResultsDiv =  document.createElement('DIV');
-	currObj.spellingResultsDiv.className = 'edit_box';
-        currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie
-	currObj.spellingResultsDiv.style.width =  "99%";//the width of the textarea
-	currObj.spellingResultsDiv.style.height = 300;  //   = height; //currObj.objToCheck.style.height;
-	currObj.spellingResultsDiv.innerHTML = new_data;       
-      	currObj.objToCheck.style.display = "none";
-	currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck);
-	currObj.statusSpan.innerHTML = ""; */
-
-
-
-
-        // Teste de iFrame - Nathalie
+
          var ifr= currObj.objToCheck;
          if(ifr.contentWindow)
@@ -568,10 +490,5 @@
 
 
-//adicionado Paula
-//    currObj.objToCheck.style.display = "none"; //Paula
-        //currObj.objToCheck.parentNode.
-        //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck);
-//	currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); //Paula
-	currObj.statusSpan.innerHTML = "";    
+        currObj.statusSpan.innerHTML = "";
 
         
@@ -694,4 +611,5 @@
             }*/
 
+
             // Obtain the HTML content from iframe (edit area)
              var ifr= currObj.objToCheck;
@@ -783,5 +701,6 @@
 function checkClickLocation(e)
 {
-   
+
+    var browser = checkBrowser();
     if(spellingSuggestionsDiv)
 	{
@@ -789,6 +708,6 @@
 		// on a word to get suggestions starts up a race condition between
 		// showing and hiding the suggestion box, so we'll ignore the first
-		// click.
-		if(spellingSuggestionsDiv.ignoreNextClick){
+		// click. Problem with IE browser                
+		if(spellingSuggestionsDiv.ignoreNextClick && browser == "ie"){
 			spellingSuggestionsDiv.ignoreNextClick = false;
 		}
@@ -801,6 +720,15 @@
 				spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
 				spellingSuggestionsDiv = null;
-			}
-		}
+                               
+                                if (browser == "ie"){
+                                     var iframe= currObj.objToCheck;
+                                    if(iframe.contentWindow)
+                                        iframe=iframe.contentWindow.document;
+                                    else
+                                        iframe=iframe.contentDocument;
+                                    iframe.body.contentEditable="false" ;
+                                }
+                         }
+                }
         }
 	
@@ -826,9 +754,11 @@
 	if(checkBrowser() == "ie")
 	{
-		value = window.event.srcElement;
+            if(!e){var e = ifr.contentWindow.event;}
+            if(!e.target){value = e.srcElement;}
+            
 	}
 	else
 	{
-		value = e.target;
+            value = e.target;
 	}
 	return value;
@@ -899,5 +829,6 @@
  * php's showSuggestions function returns to.  It sets the 
  * suggestions table to contain the new data and then displays
- * the suggestions div.  It also clears the status message.
+ * the suggestions div.  It also adds the event listener - click -
+ * for all the suggestions tags and sets te property to be not editable.
  *
  * @param new_data The suggestions table returned from php.
@@ -911,10 +842,9 @@
 	currObj.statusSpan.innerHTML = "";
 
-        //adicionado os listener - nathalie
-         var ifr= currObj.objToCheck;
-         if(ifr.contentWindow)
-            ifr=ifr.contentWindow.document;
-         else
-            ifr=ifr.contentDocument;
+        var ifr= currObj.objToCheck;
+        if(ifr.contentWindow)
+           ifr=ifr.contentWindow.document;
+        else
+           ifr=ifr.contentDocument;
 
         var nodeArray = ifr.getElementsByTagName("div");
@@ -927,13 +857,9 @@
                     ifr.getElementsByTagName("div")[i].contentEditable="false" ;
                  }
-                else {
+                 else {
                     ifr.getElementsByTagName("div")[i].attachEvent("onclick", replaceMenu);
                     ifr.getElementsByTagName("div")[i].contentEditable="false" ;
-                }
-                    
-
-
-
-                
+                 }
+                 
 
             }
@@ -955,4 +881,5 @@
  * calls the showSuggestions php function with the misspelled word
  * and the id of the span containing it.
+ * This function is only executed when the word is in red (the word id misspelled).
  *
  * @param word The misspelled word that the user clicked on
@@ -961,6 +888,5 @@
 function showSuggestions(word, id)
 {
-        
-        //adicionado nathalie
+                
          var ifr= currObj.objToCheck;
          if(ifr.contentWindow)
@@ -969,7 +895,7 @@
             ifr=ifr.contentDocument;
 
-         if (ifr.getElementById(id).className == "highlight"){ //show the suggestion box only when the words are in red 
-
-    //alterado - colocar ifr
+         if (ifr.getElementById(id).className == "highlight"){ //show the suggestion box only if the words are in red
+
+   
             languageId =  document.getElementById("selectLanguage");
             languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
@@ -1009,12 +935,6 @@
             spellingSuggestionsDiv.style.left = x + 'px';
             spellingSuggestionsDiv.style.top = (y+16-scrollPos) + 'px';
-            spellingSuggestionsDiv.id = 'suggestion_box'; //Adicionado Nathalie
+            spellingSuggestionsDiv.id = 'suggestion_box'; 
             spellingSuggestionsDiv.contentEditable="false" ;
-
-
-
-
-
-
 
 
@@ -1023,16 +943,13 @@
             // showing and hiding the suggestion box, so we'll ignore the first
             // click.
-            //spellingSuggestionsDiv.ignoreNextClick = true; // comentado Nathalie
+            spellingSuggestionsDiv.ignoreNextClick = true; 
 
 
             //document.body.appendChild(spellingSuggestionsDiv);
-            ifr.body.appendChild(spellingSuggestionsDiv); //alterado nathalie
-
-
-
+            ifr.body.appendChild(spellingSuggestionsDiv);
 
 
             cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, languageId);
-        }
+        } // end if - show the suggestion box only if the words are in red
 
 }; // end showSuggestions
@@ -1161,6 +1078,4 @@
        
         with(currObj);
-        //By Nathalie - The Element means that this div belongs to the current tab
-        //var parentElement = Element(currObj.spellingResultsDiv.id); //alterado nathalie
         var ifr= currObj.objToCheck;
         if(ifr.contentWindow)
@@ -1168,7 +1083,5 @@
         else
             ifr=ifr.contentDocument;
-        
-        //var parentElement =ifr.getElementById(currObj.spellingResultsDiv.id); //alterado nathalie
-        //
+     
         // Obtain all span tags which have highlight className or corrected_word className
         var nodeArray = ifr.getElementsByTagName("div");
@@ -1195,5 +1108,5 @@
         }
 
-	var text = ifr.body.innerHTML; //alterado result div
+	var text = ifr.body.innerHTML; 
 
         text = text.replace(/&nbsp;/gi, " %u2026 "); // Replace &nbsp; with the code %u2026
@@ -1220,39 +1133,31 @@
 
 
-//adicionado Paula
     with(currObj);
 
-        new_string = new_string.replace(/ %u2026/gi, "&nbsp;"); // Replace the code %u2026 with &nbsp;
-             
-	new_string = new_string.replace(/~~~/gi, "\n");
-       
-	// Remove the prefixed asterisk that was added in switchText().
-	new_string = new_string.substr(1);
-
-
-	 currObj.objToCheck.style.display = "none";
-	 var ifr= currObj.objToCheck;
-         if(ifr.contentWindow)
-            ifr=ifr.contentWindow.document;
-         else
-            ifr=ifr.contentDocument;
-         var texto = ifr.body.innerHTML;
-
-         ifr.body.innerHTM = ""; //adicionado nathalie
-         ifr.body.innerHTML = new_string;
-         currObj.spellingResultsDiv = null; //adicionado nathalie
-
-         
-
-	currObj.objToCheck.disabled = false;
-        
-	//Removido Nathalie
-        /*if(currObj.spellingResultsDiv)
-	{
-		ifr.removeChild(currObj.spellingResultsDiv); //Alterado nathalie
-		currObj.spellingResultsDiv = null;
-	}*/
-	currObj.objToCheck.style.display = "block";
-	currObj.resetAction();
+    new_string = new_string.replace(/ %u2026/gi, "&nbsp;"); // Replace the code %u2026 with &nbsp;
+
+    new_string = new_string.replace(/~~~/gi, "\n");
+
+    // Remove the prefixed asterisk that was added in switchText().
+    new_string = new_string.substr(1);
+
+
+    currObj.objToCheck.style.display = "none";
+    var ifr= currObj.objToCheck;
+    if(ifr.contentWindow)
+        ifr=ifr.contentWindow.document;
+    else
+        ifr=ifr.contentDocument;
+    var texto = ifr.body.innerHTML;
+
+    ifr.body.innerHTM = "";
+    ifr.body.innerHTML = new_string;
+    currObj.spellingResultsDiv = null;
+
+    currObj.objToCheck.disabled = false;
+
+
+    currObj.objToCheck.style.display = "block";
+    currObj.resetAction();
 }; // end switchText_cb
 
@@ -1324,5 +1229,5 @@
 {
 
-//adicionado Paula
+
 	with(currObj);
 	/*if(currObj.config['useIcons'])
@@ -1351,9 +1256,9 @@
 {
         
-	//adicionado nathalie
+	
         var ifr= currObj.objToCheck;
-         if(ifr.contentWindow)
+        if(ifr.contentWindow)
             ifr=ifr.contentWindow.document;
-         else
+        else
             ifr=ifr.contentDocument;
 
@@ -1368,5 +1273,5 @@
 	if(currObj.spellingResultsDiv)
 	{
-		ifr.removeChild(currObj.spellingResultsDiv); //alterado nathalie
+		ifr.removeChild(currObj.spellingResultsDiv); 
 		currObj.spellingResultsDiv = null;
 	}
@@ -1393,10 +1298,9 @@
     function findPosXById(object)
 {
-        
-        //adicionado Nathalie
+                
         var ifr= currObj.objToCheck;
-         if(ifr.contentWindow)
+        if(ifr.contentWindow)
             ifr=ifr.contentWindow.document;
-         else
+        else
             ifr=ifr.contentDocument;
         var obj = ifr.getElementById(object);
@@ -1404,7 +1308,5 @@
 
         var curleft = 0;
-	//var obj = document.getElementById(object); //removido nathalie
-
-
+	
 	if(obj.offsetParent)
 	{
@@ -1434,17 +1336,13 @@
  *************************************************************/
 function findPosYById(object)
-{
-        
-        //adicionado Nathalie
+{      
         var ifr= currObj.objToCheck;
-         if(ifr.contentWindow)
+        if(ifr.contentWindow)
             ifr=ifr.contentWindow.document;
-         else
+        else
             ifr=ifr.contentDocument;
-        var obj = ifr.getElementById(object); //removido Nathalie
-
+        var obj = ifr.getElementById(object);
     
 	var curtop = 0;var curtop = 0;
-	//var obj = document.getElementById(object); //removido Nathalie
 	if(obj.offsetParent)
 	{
