var captcha;

function captchaImageHide() {
	document.getElementById("v2").focus();
	document.getElementById('captchaImageToggle').style.visibility = 'hidden';
	document.getElementById('captchaImageShow').style.display = 'block';
	
}

function captchaImageShow() {
	document.getElementById("v2").focus();
	document.getElementById('captchaImageToggle').style.visibility = 'visible';
	document.getElementById('captchaImageShow').style.display = 'none';
	document.getElementById('repeatAudioCaptcha').style.display = 'none';
	captcha.initCaptchaImage();
	
}

function captchaErrorMessage() {
	document.getElementById('captchaErrorMessage').style.display = 'block';
}

function initCaptcha() {
    captcha = new Captcha("captchaImage","captchaAudio", "v2");
    captcha.initCaptchaImage();
	
}

function playCaptcha() {
	document.getElementById("v2").focus();
    captcha = new Captcha("captchaImage","captchaAudio", "v2");
    captcha.initCaptchaAudio();
    document.getElementById('repeatAudioCaptcha').style.display = 'block';
	
}

function repeatAudioCaptcha() {
	document.getElementById("v2").focus();
     var embedCode = '<EMBED SRC=' + captcha.audioSrc + ' HIDDEN="true" AUTOSTART="true" >';
     document.getElementById(captcha.audioElementId).innerHTML = embedCode; 
}

function verifyKey() {
    document.getElementById('repeatAudioCaptcha').style.display = 'none';
    var verified = captcha.verifyKey();
    
    if (!verified) {
        captcha.initCaptchaImage();
		captchaErrorMessage();
    } else {
        document.getElementById("v1").value = captcha.captchaId;
    }
    
    return verified;
}
