/* © 2009-11 Hortensia International Associates, Inc */
document.addEventListener && document.addEventListener('DOMContentLoaded', function(){

	var	$form = $('update'),
		$body = $('body'),
		$replies = getElementsByClassName('reply');

	for (var i in $replies)
		$replies[i].addEventListener('click', reply, true);
	
	function reply(e){
		e.preventDefault && e.preventDefault();
		e.stopPropagation && e.stopPropagation();
		
		var $postId = $('postId');
		$postId && $form.removeChild($postId);
		$postId = document.createElement('input');
		$postId.type = 'hidden';
		$postId.id = $postId.name = 'postId';
		$postId.value = this.rel;
		$form.appendChild($postId);
		$form.style.display = 'block';
		
		$body.value = '@' + this.name + ' ';
		$body.focus();
		
		return false;
	}
	
}, false);

function $(id){
	return document.getElementById(id);
}

function getElementsByClassName(classname, node)  {
    if (!node) node = document.getElementsByTagName('body')[0];
    var a = [],
    	re = new RegExp('\\b' + classname + '\\b'),
    	els = node.getElementsByTagName("*");
    for (var i = 0, j = els.length; i < j; i++)
        if (re.test(els[i].className)) a.push(els[i]);
    return a;
}
