function mod_blog_reloadCaptcha ( )
{
	var j = new bajax ( );
	var l = document.location + '';
	j.openUrl ( l.split ( '#' )[0] + '?captcha=true', 'get', true );
	j.onload = function ( )
	{
		var img = document.getElementById ( 'mod_blog_captcha_image' ).getElementsByTagName ( 'img' )[0];
		img.src = this.getResponseText ( );
	} 
	j.send ( );
}

function mod_blog_submitComment ( )
{
	var frm = document.getElementById ( 'mod_blog_commentform' );
	if ( frm.Name.value.length < 2 )
	{
		alert ( i18n ( 'You have to enter your name.' ) );
		frm.Name.focus ( );
		return false;
	}
	if ( frm.Message.value.length < 2 )
	{
		alert ( i18n ( 'You have to write your comment.' ) );
		frm.Message.focus ( );
		return false;
	}
	var cjax = new bajax ( );
	var l = document.location + '';
	cjax.openUrl ( 
		l.split ( '#' )[0] + '?checkcaptcha=true&c=' + frm.Captcha.value, 
		'get', true 
	);
	cjax.onload = function ( )
	{
		if ( this.getResponseText ( ) == 'ok' )
		{
			frm.submit ( );
		}
		else
		{ 
			alert ( i18n ( 'Wrong spam control text, please try again.' ) );
			mod_blog_reloadCaptcha ( );
			frm.Captcha.focus ( );
			return false;
		}
	}
	cjax.send ( );
}
