	// Captcha: comprobacion y regeneracion. Se pasa el id del captcha original y el valor del captcha indicado por el suuario
	function compruebaCaptcha(captchaOriginal,captchaUsuario)
	{
		var res = $.ajax({
		type: "GET",
		url: "/modulo/comprobarCaptcha.html",
		data: "idCaptcha="+captchaOriginal+"&captchaCode="+captchaUsuario,
		async:false
		}).responseText;
		return res;
	}

	function cambiaCaptcha(id,color)
	{		
		$("#"+id).attr({
			src: "/captcha.html?id="+id+"&color="+color+"&rand=" + Math.random()
		});
	}
	// Creacion del captcha
	function generarCaptcha(id,color,idForm)
	  {
	    var imagenCaptcha;
	    imagenCaptcha = "<img id='"+id+"' value='1' src='/captcha.html?id="+id+"&color="+color+" ' />";
	  	//document.write(imagenCaptcha);
	  	if (!$("img#"+id).attr("id"))
	  		$("#"+idForm+" .captcha").prepend(imagenCaptcha);
	  }
	
$(document).ready(function()
{
	// Se regenera el captcha. Para que funcione correctamente el link debe de tener en su id el nombre del captcha con este formato xxxxxxxxx_<nombre_captcha_a_cambiar>_<color_guia>
		$(".cambiarCaptcha").click(
			function(event)
			{	
				cambiaCaptcha(this.id.split("_")[1],this.id.split("_")[2]);
				return false;
			}
		);	
});
