Index: sandbox/expressoMail1_2/corretor_ortografico/spell_checker/spell_checker.php
===================================================================
--- sandbox/expressoMail1_2/corretor_ortografico/spell_checker/spell_checker.php	(revision 2430)
+++ sandbox/expressoMail1_2/corretor_ortografico/spell_checker/spell_checker.php	(revision 2477)
@@ -75,5 +75,5 @@
 
 //$pspell_link = pspell_new_config($pspell_config);
-$pspell_link = pspell_new("pt_BR");
+
 
 require_once("cpaint/cpaint2.inc.php"); //AJAX library file
@@ -98,8 +98,9 @@
  *
  *************************************************************/
-function showSuggestions($word, $id)
+function showSuggestions($word, $id, $language)
 {
 	global $editablePersonalDict; //bool to set editability of personal dictionary
-	global $pspell_link; //the global link to the pspell module
+	//global $pspell_link; //the global link to the pspell module
+        $pspell_link = pspell_new($language);
 	global $cp; //the CPAINT object
 	
@@ -160,7 +161,8 @@
  *
  *************************************************************/
-function spellCheck($string, $varName)
-{
-	global $pspell_link; //the global link to the pspell module
+function spellCheck($string, $varName, $language)
+{
+	//global $pspell_link; //the global link to the pspell module
+        $pspell_link = pspell_new($language);
 	global $cp; //the CPAINT object
 	$retVal = "";
@@ -287,5 +289,6 @@
 {
 	global $editablePersonalDict;
-	global $pspell_link; //the global link to the pspell module
+	//global $pspell_link; //the global link to the pspell module
+        $pspell_link = pspell_new("pt_BR");
 	global $cp; //the CPAINT object
 	$retVal = "";
Index: sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js
===================================================================
--- sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js	(revision 2430)
+++ sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js	(revision 2477)
@@ -43,11 +43,14 @@
 var positionEditor;
 var areaEditor;
-var abaEditor; 
+var abaEditor;
+var blockSpellCheck = false;
 cp = new cpaint();
 cp.set_transfer_mode('post');
 cp.set_response_type('text');
-function beginSpellCheck(position, area, aba){
-
-    
+function beginSpellCheck(){
+if(!blockSpellCheck){
+    position = "body_position_" + currentTab;
+    area = "body_" + currentTab;
+    aba = currentTab;
     //var cp = new cpaint();
     // alert("Seta globals");
@@ -109,4 +112,7 @@
 //window.onload =new setupSpellCheckers();
 //alert("Fim");
+} else {
+    alert("O corretor ja esta rodando.")
+}
 } // fecha funï¿œï¿œo
 
@@ -140,4 +146,60 @@
 	
 }; // end setInit
+
+function setupSpellChecker(){
+
+
+        currObj = this;
+
+        currObj.config               = new Array();
+        
+        currObj.config['divId'] = "body_position_" + currentTab;
+        currObj.config['width'] = "99%";
+        currObj.config['id'] = "body_" + currentTab;
+
+        spellContainer = document.createElement('DIV');
+	spellContainer.id = currObj.config['divId'];
+	spellContainer.className = 'spell_container';
+	spellContainer.style.width = currObj.config['width'];
+
+	oldElement = document.getElementById(currObj.config['id']);
+
+	//oldElement.parentNode.replaceChild(spellContainer, oldElement);
+
+	//generate the div to hold the spell checker controls
+	currObj.controlPanelDiv = document.createElement('DIV');
+	currObj.controlPanelDiv.className = 'control_panel';
+        currObj.controlPanelDiv.id = 'control_panel_' + currentTab;
+	document.getElementById(currObj.config['divId']).appendChild(currObj.controlPanelDiv);
+
+	//the span that toggles between spell checking and editing
+	currObj.actionSpan = document.createElement('SPAN');
+	currObj.actionSpan.className = "action";
+	currObj.actionSpan.id = "action";        
+	/*if(currObj.config['useIcons'])
+	{
+		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia \" border=\"0\" /></a>";
+	}
+	else
+	{
+		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
+	}*/
+	currObj.controlPanelDiv.appendChild(currObj.actionSpan);
+
+	//the span that lets the user know of the status of the spell checker
+	currObj.statusSpan = document.createElement('SPAN');
+	currObj.statusSpan.className = "status";
+	currObj.statusSpan.id = "status";
+	currObj.statusSpan.innerHTML = "";
+        currObj.controlPanelDiv.style.display = "none";
+	currObj.controlPanelDiv.appendChild(currObj.statusSpan);
+
+        //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox"));
+	//the textarea to be spell checked
+	//oldElement.value = currObj.config['value'];
+	//document.getElementById(currObj.config['divId']).appendChild(oldElement);
+        currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab));
+
+ }
 
 
@@ -161,6 +223,6 @@
 function ajaxSpell(varName, width, height, spellUrl, divId, name, id, title, value)
 {
-	
-        currObj = this;
+        
+       currObj = this;
 
 	currObj.config               = new Array();         //the array of configuration options
@@ -185,5 +247,5 @@
 	}
 	
-	spellContainer = document.createElement('DIV');
+	/*spellContainer = document.createElement('DIV');
 	spellContainer.id = currObj.config['divId'];
 	spellContainer.className = 'spell_container';
@@ -192,5 +254,5 @@
 	oldElement = document.getElementById(currObj.config['id']);
 
-	oldElement.parentNode.replaceChild(spellContainer, oldElement);
+	//oldElement.parentNode.replaceChild(spellContainer, oldElement);
 	
 	//generate the div to hold the spell checker controls
@@ -203,5 +265,5 @@
 	currObj.actionSpan.className = "action";
 	currObj.actionSpan.id = "action";
-	if(currObj.config['useIcons'])
+	/*if(currObj.config['useIcons'])
 	{
 		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia \" border=\"0\" /></a>";
@@ -210,6 +272,6 @@
 	{
 		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
-	}
-	currObj.controlPanelDiv.appendChild(currObj.actionSpan);
+	}*/
+	/*currObj.controlPanelDiv.appendChild(currObj.actionSpan);
 	
 	//the span that lets the user know of the status of the spell checker
@@ -219,10 +281,16 @@
 	currObj.statusSpan.innerHTML = "";
 	currObj.controlPanelDiv.appendChild(currObj.statusSpan);
-	
+
+        //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox"));
 	//the textarea to be spell checked
 	oldElement.value = currObj.config['value'];
-	document.getElementById(currObj.config['divId']).appendChild(oldElement);
-
-	
+	//document.getElementById(currObj.config['divId']).appendChild(oldElement);
+        currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab));
+	*/
+
+        currObj.controlPanelDiv = document.getElementById('control_panel_' + currentTab);
+        currObj.statusSpan = currObj.controlPanelDiv.childNodes[1];
+        currObj.actionSpan = currObj.controlPanelDiv.childNodes[0] ;
+
 	currObj.objToCheck              = document.getElementById(currObj.config['id']);      //the actual object we're spell checking
 	currObj.spellingResultsDiv      = null;                                               // Auto-generated results div
@@ -276,5 +344,6 @@
 function spellCheck_cb(new_data)
 {
-	with(currObj);
+
+        with(currObj);
 	new_data = new_data.toString();
 	var isThereAMisspelling = new_data.charAt(0);
@@ -295,5 +364,7 @@
 
        	currObj.objToCheck.style.display = "none";
-	currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck);
+        //currObj.objToCheck.parentNode.
+        //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck);
+	currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab));
 	currObj.statusSpan.innerHTML = "";    
         
@@ -320,4 +391,7 @@
 		currObj.objToCheck.disabled = false;
 	}
+
+       currObj.controlPanelDiv.style.display = "block";
+
 }; // end spellCheck_cb
 
@@ -332,49 +406,56 @@
  *************************************************************/
 function spellCheck() {
-       	with(currObj);
-	var query;
-
-	if(currObj.spellingResultsDiv)
-	{
-		currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
-		currObj.spellingResultsDiv = null;
-	}
-	
-	if(currObj.config['useIcons'])
-	{
-		currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
-	}
-	else
-	{
-		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
-	}
-	
-	if(currObj.config['useIcons'])
-	{
-		currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
-	}
-	else
-	{
-		currObj.statusSpan.innerHTML = "Verificando Ortografia...";
-	}
-	
-        
-        // Obtain the HTML content from iframe (edit area)
-         var ifr= currObj.objToCheck;
-         if(ifr.contentWindow)
-            ifr=ifr.contentWindow.document;
-         else
-            ifr=ifr.contentDocument;
-         var texto = ifr.body.innerHTML;
-        
-        
-        query = texto;
-        //query = currObj.objToCheck.value;        
-        
-	//query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie
-        query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie
-       
-	
-	cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName']);
+
+        if(!blockSpellCheck) {
+            blockSpellCheck = true;
+
+         language =  document.getElementById("selectLanguage");
+            language = language[document.getElementById("selectLanguage").selectedIndex].value;
+
+            with(currObj);
+            var query;
+
+            currObj.controlPanelDiv.style.display = "block";
+
+            if(currObj.spellingResultsDiv)
+            {
+                    currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
+                    currObj.spellingResultsDiv = null;
+            }
+
+            /*if(currObj.config['useIcons'])
+            {
+                    currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
+            }
+            else
+            {
+                    currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
+            }*/
+
+            /*if(currObj.config['useIcons'])
+            {
+                    currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
+            }
+            else
+            {
+                    currObj.statusSpan.innerHTML = "Verificando Ortografia...";
+            }*/
+
+            // Obtain the HTML content from iframe (edit area)
+             var ifr= currObj.objToCheck;
+             if(ifr.contentWindow)
+                ifr=ifr.contentWindow.document;
+             else
+                ifr=ifr.contentDocument;
+             var texto = ifr.body.innerHTML;
+
+            query = texto;
+            //query = currObj.objToCheck.value;
+
+            //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie
+            query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie
+
+            cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], language);
+        }
 }; // end spellcheck
 
@@ -400,5 +481,7 @@
 		spellingSuggestionsDiv = null;
 	}
-	
+
+        currObj.controlPanelDiv.style.display = "block";
+
 	if(currObj.config['useIcons'])
 	{
@@ -595,5 +678,7 @@
 function showSuggestions(word, id)
 {
-
+        language =  document.getElementById("selectLanguage");
+        language = language[document.getElementById("selectLanguage").selectedIndex].value;
+        
         with(currObj);
 	if(currObj.config['useIcons'])
@@ -633,5 +718,5 @@
 	document.body.appendChild(spellingSuggestionsDiv);
 	
-	cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id);
+	cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, language);
 }; // end showSuggestions
 
@@ -682,8 +767,6 @@
 
         with(currObj);
-
         //By Nathalie - The Element means that this div belongs to the current tab
         var parentElement = Element(currObj.spellingResultsDiv.id); 
-
         // Obtain all span tags which have highlight className or corrected_word className
         var nodeArray = parentElement.getElementsByTagName("span");
@@ -691,4 +774,5 @@
         var nodeRemove = new Array(totArray);
         var j = -1;
+
         for (var i = 0 ; i < totArray ; i++) {
             var node = nodeArray[i];
@@ -708,8 +792,10 @@
             parent.replaceChild(fake, document.getElementById(nodeRemove[i]));            
         }
-	var text = currObj.spellingResultsDiv.innerHTML;
+
+       var text = currObj.spellingResultsDiv.innerHTML;
 
         text = text.replace(/&nbsp;/gi, " %u2026 "); // Replace &nbsp; with the code %u2026
         text = '*' + text;
+
         cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text);
         
@@ -730,5 +816,5 @@
 function switchText_cb(new_string)
 {
-
+    
         with(currObj);
 
@@ -775,4 +861,6 @@
 	
         with(currObj);
+
+        currObj.controlPanelDiv.style.display = "block";
 	if(currObj.config['useIcons'])
 	{
@@ -812,7 +900,6 @@
 function resetAction()
 {
-       
 	with(currObj);
-	if(currObj.config['useIcons'])
+	/*if(currObj.config['useIcons'])
 	{
 		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" /></a>";
@@ -821,7 +908,10 @@
 	{
 		currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
-	}
-
+	}*/
+
+        currObj.actionSpan.innerHTML = "";
 	currObj.statusSpan.innerHTML = "";
+        currObj.controlPanelDiv.style.display = "none";
+        blockSpellCheck = false;
 }; // end resetAction
 
