	
	var bMode = false;
	
	function FormatText(command, option){
	    if (bMode)
		  return;
		 
		frames.message.focus();
        if (event.srcElement.name.length > 0)
 		  event.srcElement.style.borderColor = (event.srcElement.currentStyle.borderColor=="#ffffff") ? "#B5B6EB" : "#ffffff";  
		frames.message.document.execCommand(command, true, option);
		frames.message.focus();
	}
	
	//Function to add image
	function AddImage(){	
		imagePath = prompt('Enter the web address of the image', 'http://');				
		
		if ((imagePath != null) && (imagePath != "")){					
			frames.message.focus();
			frames.message.document.execCommand('InsertImage', false, imagePath);
		}
		frames.message.focus();			
	}
	
	function addEmo(imagePath) {
		if ((imagePath != null) && (imagePath != "")){						
			frames.message.focus();
			frames.message.document.execCommand('InsertImage', false, imagePath);
			emoticons.style.display = "none";
			//emo.src = "img/emo/lafhard.gif";
		}
		//frames.message.focus();			
	}
	//if parent.document.frames.message.focus();
	//emoticons.style.display = "none";
	
	//Function to clear form
	function ResetForm(){
	
		if (window.confirm('Are you sure you want to clear the message you have entered?')){
			frames.message.focus();
			frames.message.document.body.innerHTML = ''; 
			return true;
		 } 
		 return false;		
	}
	
	function subContent() {
		myForm.msgContent.value = frames.message.document.body.innerHTML;
	}
	
	function setMode() 
	{ 
    contbut.style.filter="alpha(opacity='"+(bMode ? 30 : 100)+"')";
	if(bMode){ 
	  bm.innerText = "WYSIWYG Mode";
	  message.document.body.innerText=message.document.body.innerHTML;
      emoticons.style.display = "none"; 
	}else{
      if (document.getElementById('emo').src.search('emo/lafhard-on.gif') > 0)
        emoticons.style.display  = "";
         
	  bm.innerText = "Source Code";
	  message.document.body.innerHTML= message.document.body.innerText; 
	} 	
	message.focus(); 	
	}
    
    //message.document.body.style.fontSize = "11px";
    //message.document.body.style.fontType = "Verdana,Arial,Helvetica,Sans-serif";
    
 /*   function emoToggle(objDiv, objImg)
    {
      var popup = window.createPopup();      
       
      var oDiv = popup.document.createElement('DIV');
      oDiv.innerHTML = document.getElementById(objDiv, objImg).innerHTML;
      popup.document.body.appendChild(oDiv);
      objImg.src = "img/emo/lafhard-on.gif";
      popup.document.body.children[0].style.display = "";
      popup.document.body.attachEvent('onunload', new function() { objImg.src = "img/emo/lafhard.gif"; });
     // popup.document.body.onunload();
      popup.show(121,230, 282, 135, document.body);
     }
   */   
          
    function toggleEmo(objDiv,objImg)
    {
       if (bMode)         
         return;

       var myElement = document.getElementById(objDiv,objImg); 
       if (myElement.style.display == "none")
       {
           myElement.style.display = "";
           objImg.src = "emo/lafhard-on.gif";
       }
       else
       {
           myElement.style.display = "none";
           objImg.src = "emo/lafhard.gif";
       }
    }
