function quote(username, quoteID)
{    
	var qcomment;
	qcomment = document.getElementById('comment' + quoteID).innerHTML;
	if (qcomment.match("<blockquote>") != null)
  { 
      qcomment = stripQuote(qcomment);
  }
  qcomment = stripHTML(qcomment);
	qcomment = stripWhiteSpace(qcomment)
	//alert(qcomment);
	document.getElementById("comment").value = "[quote=" + username + "]" + br2nl(qcomment) + "[/quote]";
	document.getElementById("comment").focus();
}

function br2nl(txt) {
	var re = /(<br\/>|<br>|<BR>|<BR\/>)/g;
	var s = txt.replace(re, "\n");
	return s;									
}

function stripQuote(qComment){
    var startblock;
    var endblock;
    startblock = qComment.indexOf('<blockquote');
    endblock = qComment.indexOf('</blockquote');
    
    newcomment = qComment.substr(endblock+13);
    
    return newcomment;
}

function stripHTML(qComment){
    // This simply replaces anything in the string that is an HTML tag and replaces that with a blank space 
    var pattern = new RegExp("<[^>]*>", "g");
    qComment = qComment.replace(pattern, "");
    
    return qComment;

}

function stripWhiteSpace(qComment){
    /* 
    The way this works is, we strip out any newlines that got into the string with the Regex that just searches for \n
    We then check to see if there is any whitespace at the beginning of the string by doing substring 0,1 (the first character after the start of the string)
    and checking if it's equal to ' ' and keeping everything after that first character if it is whitespace.  
    Lastly, we check if the length of the string - 1 is a whitespace and if it is, substring everything into a variable until the end of the string - 1 
    (which elliminates the whitespace if it is the last character)
    */   
    
    //qComment = qComment.replace(new RegExp( "\\n", "g" ), "");
    while (qComment.substring(0,1) == ' ') qComment = qComment.substring(1);
    while (qComment.substring(qComment.length-1,qComment.length) == ' ') qComment = qComment.substring(0,qComment.length-1);
    return qComment; 

}