

function addComment( formobj ){
	//AjaxEngine.debugMode = true;
	AjaxEngine.setPreHook( function(){working('Adding your comment, please wait.');} );
	AjaxEngine.setPostHook( function(){stoppedworking();} );
	AjaxEngine.sendForm( handleAddComment, formobj);
}

function handleAddComment( comm ){
	clearInfoBox();
	if(comm.error.length){					
		buildContainer('errormsgcontainer','alert',comm.error);
	}else{
		var c = '<span class="note">Posted by ';
			if( comm.website.length )
				c += '<a href="'+ comm.website +'">'+ comm.name +'</a>';
			else
				c += comm.name;
		c += ' on '+ comm.date +'</span><br><br>'+ comm.comment +'<br><br>';	
		var li = document.createElement('li');
			li.innerHTML = c;
		var commentlist = document.getElementById("commentlist");
		commentlist.appendChild( li );
		buildContainer('infomsgcontainer','ok','Your comment was added.');   
		document.commentsform.comments.value = '';
		if( document.commentsform.answer )
			document.commentsform.answer.value = ''; 
	}
	try{
		refreshCaptcha( comm.hash, document.commentsform );
	}catch(e ){ /* do nothing */}
	
}

function refreshCaptcha( hash, formobj ){
	var img = new Image();
		img.src = '/lefthandpath/index.cfm/event/createCaptcha/hashReference/'+ hash ;
	document.getElementById('captcha').src = img.src;
	formobj.math.value = hash;
}

