// jQuery for captcha refresh on the forms 
$(document).ready(function() {
	// display refresh image after page loads 
	$('.CaptchaRefreshImage').css('display', 'inline');
	
	// onclick event for the CaptchaRefresh image
	$('.CaptchaRefreshImage').click(function(event) {
		// get next number for unique image file name
		// if use same file name, image display does not refresh 
		intImageIndex = 1;
		arrImageSrc = $('.CaptchaImage img').attr('src').split('.');
		if (arrImageSrc.length > 0)
		{
			arrImage = arrImageSrc[0].split('_');
			if (arrImage.length > 1) 
			{
				intImageIndex = arrImage[1] - 0 + 1;
			}
		}
		$.ajax({
			type: "POST",
			url: "captcha_regenerate.cfm",
			data: ({ Index : intImageIndex }), 
			dataType: "xml",
			success: function(data) {  
				$('.CaptchaImage').html('');
				$('.CaptchaImage').html($('imageHtml', data).text());
				$('#checksum').val($('checksum', data).text());
				$('#CaptchaIndex').val(intImageIndex);
			},
			error: function(request, status, error) {
				alert("CAPTCHA image could not be refreshed.  Please refresh the page.");
			}
		});   		
	});
});

