
function pm_comments_quote(comment_id,comment_user){
   
   comment_bounds = pm_comments_get_selection();
   
   if( comment_bounds['strHTML'].length==0 || comment_bounds['strHTML']==0 ){
      
	  comment_bounds['strHTML'] = document.getElementById('pm_comment_'+comment_id).innerHTML;
	  
   }
   
   quote_code = '<div class=quote><b>'+comment_user+':</b><br><i>'+comment_bounds['strHTML']+'</i></div><br>';
   
   if( 0<wysiwyg_areas.length ){
      
	  comment_window = document.getElementById(wysiwyg_areas[0]).contentWindow.document;
	  
	  comment_window.body.innerHTML += quote_code;
	  
   }
   else{
      
	  comment_window = document.getElementById('comment_form');
	  
	  comment_window.value += quote_code;
	  
   }
   
}

function pm_comments_get_selection(){
   
   if( window.getSelection ){
      
	  var selection = window.getSelection();
      str = window.getSelection();
      strHTML = window.getSelection();

      return {
         str: str,
		 strHTML: strHTML
      }
	  
   }
   else if( document.selection ){ 
      
	  range = document.selection.createRange();
	  if( !range.duplicate ){ return null; }
	  str = range.text;
	  strHTML = range.htmlText;
	  
      return {
         str: str,
		 strHTML: strHTML
      }
	  
   }
   
   return null;
   
} 
