/*
 * @package Component jVoteSystem for Joomla! 1.5
 * @projectsite www.joomess.de/projekte/18
 * @author Johannes Meßmer
 * @copyright (C) 2010- Johannes Meßmer
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
function jVoteSystemAlertError(msg, box) {
	document.getElementById('jVoteSystemAlert' + box).style.display='block';
	document.getElementById('jVoteSystemAlert' + box).className = 'alert_Error';
	document.getElementById('jVoteSystemAlert' + box + 'Error').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'Success').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Question').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Captcha').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonOK').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonYES').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonNO').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonSUBMIT').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Message').innerHTML = msg;
}

function jVoteSystemAlertSuccess(msg, box) {
	document.getElementById('jVoteSystemAlert' + box).style.display='block';
	document.getElementById('jVoteSystemAlert' + box).className = 'alert_Success';
	document.getElementById('jVoteSystemAlert' + box + 'Error').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Success').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'Question').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Captcha').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonOK').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonYES').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonNO').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonSUBMIT').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Message').innerHTML = msg;
}

var jVoteSystemAlertQuestionFunction;
function jVoteSystemAlertQuestion(msg, box, f) {
	jVoteSystemAlertQuestionFunction = f;
	document.getElementById('jVoteSystemAlert' + box).style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonYES').onclick = new Function("jVoteSystemAlertQuestionAnsweredYes('" + box + "')");
	document.getElementById('jVoteSystemAlert' + box).className = 'alert_Question';
	document.getElementById('jVoteSystemAlert' + box + 'Error').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Success').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Question').style.display='block'
	document.getElementById('jVoteSystemAlert' + box + 'Captcha').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonOK').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonYES').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonNO').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonSUBMIT').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Message').innerHTML = msg;
}

function jVoteSystemAlertQuestionAnsweredYes(box) {
   document.getElementById('jVoteSystemAlert' + box).style.display='none';
   var strFun = jVoteSystemAlertQuestionFunction;
   var ret = eval(strFun);
}

var jVoteSystemAlertCaptchaURL;
function jVoteSystemAlertCaptcha(url, box, call) {
	code = 'Captcha is loading..';

	jVoteSystemAlertCaptchaURL = url;
	document.getElementById('jVoteSystemAlert' + box).style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonSUBMIT').onclick = new Function("jVoteSystemAlertCaptchaEntered('" + box + "','" + call + "')");
	document.getElementById('jVoteSystemAlert' + box).className = 'alert_Question';
	document.getElementById('jVoteSystemAlert' + box + 'Error').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Success').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Question').style.display='none'
	document.getElementById('jVoteSystemAlert' + box + 'Captcha').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonOK').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonYES').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonNO').style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'ButtonSUBMIT').style.display='block';
	document.getElementById('jVoteSystemAlert' + box + 'Container').innerHTML = code;
	document.getElementById('jVoteSystemAlert' + box + 'Message').style.display='none';
	
	showRecaptcha('jVoteSystemAlert' + box + 'Container', 'red');
}

function jVoteSystemAlertCaptchaEntered(box, call) {
	document.getElementById('jVoteSystemAlert' + box + 'Container').style.display='none';
	document.getElementById('jVoteSystemAlert' + box).style.display='none';
	document.getElementById('jVoteSystemAlert' + box + 'Message').style.display='block';
   
   var captcha = document.getElementById('recaptcha_response_field').value;
   var challenge = document.getElementById('recaptcha_challenge_field').value;
   do_http_post_request(jVoteSystemAlertCaptchaURL, call, 'captcha=' + captcha + '&recaptcha_challenge_field=' + challenge, box, 'ohne');
}
