function R7encodeURIComponent(str) 
{
	if (encodeURIComponent)
		return encodeURIComponent(str);
	else
		return escape(str);
}

function R7getXmlHttpObject() 
{
	var httpObj = null;

	if (window.XMLHttpRequest)
		httpObj = new XMLHttpRequest();
	else
		httpObj = new ActiveXObject("Microsoft.XMLHTTP");

	return httpObj;
}

var numberOfCaptchas = 0;

function R7refreshCaptcha(imgCaptchaName) 
{
	var imgCaptcha = document.getElementById (imgCaptchaName);
	var strImgCaptcha = "/captcha.jpg?" + numberOfCaptchas;

	if (imgCaptcha)
	{
		imgCaptcha.src = strImgCaptcha;
	}
	
	numberOfCaptchas = numberOfCaptchas + 1;
}

function R7refreshCaptchaImage(imgCaptcha) 
{
	var strImgCaptcha = "/captcha.jpg?" + numberOfCaptchas;

	if (imgCaptcha)
	{
		imgCaptcha.src = strImgCaptcha;
	}
	
	numberOfCaptchas = numberOfCaptchas + 1;
}

function execCaptchaDivTeleport(divTeleport, imgCaptchaName, divIdToEnableName, clearVoteOption)
{
	var divCaptchaTeleport = document.getElementById (divTeleport);
	var divToEnable = document.getElementById (divIdToEnableName);
	var divComment1 = document.getElementById ("f_commentCaptcha_1");
	var divComment2 = document.getElementById ("f_commentCaptcha_2");
	var divVote = document.getElementById ("f_votecaptcha_1");

	if (divCaptchaTeleport && divToEnable && (divToEnable.style.display == 'none' || divToEnable.style.display == ''))
	{
		var captchas = new Array();

		captchas[0] = divComment1;
		captchas[1] = divComment2;
		captchas[2] = divVote;

		//clear all captchas
		for (var i=0; i<=captchas.length -1; i++)
		{
			if (captchas[i])
			{
				captchas[i].innerHTML = "";
				captchas[i].style.display="none";
			}
		}

		//reset captcha image
		var imgCaptcha = document.getElementById (imgCaptchaName);
		if (imgCaptcha)
		{
			imgCaptcha.src = "/captcha.jpg?" + numberOfCaptchas;
		}
		
		//display the enabled captcha div
		for (var i=0; i<=captchas.length -1; i++)
		{
			if (captchas[i])
			{
				if (captchas[i].id == divIdToEnableName)
				{
					captchas[i].innerHTML = divCaptchaTeleport.innerHTML;
					captchas[i].style.display="block";
					break;
				}
			}
		}
		
		numberOfCaptchas = numberOfCaptchas + 1;
		
		//clear all vote options.
		if (clearVoteOption)
		{
			var voteForm = document.getElementById('formVote');
			if (voteForm)
			{
				var optionId = voteForm.elements["optionId"];
				for (var i=0; i<= optionId.length -1; i++)
				{
					optionId[i].checked = false;
				}
			}
		}

		
	}
}

