	function ajax_captcha(szformname,szevent,bshowmsg){
		oform = document.getElementById(szformname);
		if (!oform) return false;
		lvseed = document.getElementById('seed');

		//Lets make sure they entered an author code before we send the check
		if (szevent == 'authcode' && lvseed.value == ''){
			if (bshowmsg){
				alert('Please enter the authorization code that appears in the image.');
			}	
			return false;
		}

		if (!oform.heid) return false;
		oform.heid.value = szevent;

		lvhashimg = document.getElementById('imgvalid');
		if (lvhashimg)
			lvhashimg.src= 'images/loading-please-wait.gif';
		
		
	    http( 'POST' , 'include/ajax/ajax_captcha_server.cfm', ajax_captchacb,oform);
	    
	}

	function ajax_captchacb(obj) {
  	 	var imsgshown = 0;
  	 	var bshowerror = 0;
		lvimgname = document.getElementById('imgname');
		lvhashimg = document.getElementById('hashimg');
		lvimgvalid = document.getElementById('imgvalid');
		lvhash = document.getElementById('hash');

		if (!lvhashimg || !lvhash) return false;

		//Now put the image back
		if (lvimgvalid)
			lvimgvalid.src= 'images/no_star.gif';

		if (obj && obj.error == 2 && obj.hash){
			//New Code
			if (obj.heid == 'newcode'){
				lvimgname.value = obj.imgfilename;
				lvhash.value = obj.hash;
			}	

			if (obj.heid == 'authcode'){
				lvimgvalid = document.getElementById('imgvalid');
				lvauthorok = document.getElementById('authcodeok');
				if (obj.auth == '0'){
					
					lvimgvalid.src = 'images/icon_verify_no_16.gif';
					if (lvauthorok)
						lvauthorok.value = 0;
				}
				else{
					lvimgvalid.src = 'images/icon_verify_yes_16.gif';
					if (lvauthorok)
						lvauthorok.value = 1;
				}	

				lvhashimg.src = obj.imgfilename;
			}	
		}

			
		//Keep hash image same as in form.
		lvhashimg.src = lvimgname.value;

		if (obj && obj.error == 1){
		  	bshowerror = 0;
		}
		else if (obj && obj.error == 0){
		 	bshowerror = 1;
		}

		if (bshowerror){
			alert(obj.errormsg);
		}

		return true;
	}
	
	function checkauthcode(szformname){
		var oform = document.getElementById(szformname);

		if (oform.authcodeok.value == '0'){
			ajax_captcha(szformname,'authcode',false);
		} 

	}