
/**
 * JS :: Webusr
 *
 * Webusr.js
 *
 * @version        $1.0$
 * @autor   	   $Peter Benicky$
 * @lastmodified   $06.04.2007$
 */
 
function Webusr(webroot) {
	webThis = this;
	this.server = webroot;
	this.css_images = webroot+'css/user/images/';
	this.axajRequest = null;	
	this.initialize();
}

Webusr.prototype.initialize = function() {
	$("input[@name=Send]").bind('click', webThis.comment);
	$('a.quote_comment').bind('click', webThis.quoteComment);
}
Webusr.prototype.comment = function() {
	var comment = $('textarea[@name=comment]').get(0).value;
	var subject = $('input[@name=subject]').get(0).value;
	var captcha = $('input[@name=answer]').get(0).value;
	if(comment == '' || subject == '' || captca == '') {
		$('div#msg_form').empty().append('<p class="red"><strong>You left some empty fields, fill it first!</strong></p>').fadeIn("slow");
		return false;
	}
}
Webusr.prototype.quoteComment = function() {
	$('textarea[@name=comment]').val('[quote][b]'+$('#comment-'+this.rel + ' .comment_user').text()+' said:[/b]\n'+$('#comment-'+this.rel + ' .comment_body').text().replace(/<&#91;^>&#93;*>/g, "")+'[/quote]');
	var valueT = 0, valueL = 0;
	var element = document.getElementById('msg_form');
	do {
	 	valueT += element.offsetTop  || 0;
	    valueL += element.offsetLeft || 0;
	    element = element.offsetParent;
	} while (element);
	window.scroll(0, valueT);
	return false;
}