window.addEvent( 'domready', function() {

	if( $('form_comment') )
	{
		$('form_comment').addEvent( 'submit', function(evt) {
			new Event(evt).stop();
			this.set( 'action', '/layout/set/ajax' + this.get('action') );
			new Request({
					method: this.method,
					url: this.action,
					onSuccess: function(responseText, responseXML) {
							$('add_comment').innerHTML = responseText.replaceAll('/layout/set/ajax', '');
					},
					onRequest: function() {
						$('add_comment').innerHTML = '<div id="ajax_loader"><img src="/extension/frefred/design/nespring/images/ajax-loader.gif" alt="" /></div>';
					},
			}).send(this.toQueryString());
		});
	}
} );

String.prototype.replaceAll = function(strTarget, strSubString)
{
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );

	while (intIndexOfMatch != -1)
	{
		strText = strText.replace( strTarget, strSubString )
		intIndexOfMatch = strText.indexOf( strTarget );
	}

	return( strText );
}
