function validate()
{
	var obj=document.competition.Answer;
	if(obj)
		if(obj.length)
		{
			for(var i=0; i<obj.length;i++)
			{
				if(obj[i].value.length==0)
				{
					obj[i].focus();
					alert("Please enter a answer for the competition.");
					return false;
				}
				else
				{
					if(obj[i].value.length>=500)
					{
						obj[i].focus();
						alert("The answer is too long(max 500)");
						return false
					}
				}
			}
		}
		else
			if(obj.value.length==0)
			{
				obj.focus();
				alert("Please enter a answer for the competition.");
				return false;
			}
	
	
	if(!document.competition.terms.checked || !document.competition.privacy.checked)
	{
		alert('You must read Terms & Conditions and Privacy Policy before submitting (both check boxes must be checked)');
		return false;
	}

	encodeAnswer();
	return true;
}

function TruncateTextArea(obj)
{
	obj.value = obj.value.substring( 0,parseInt(obj.maxlength) );
}

function IsTextAreaTooLong(obj)
{
	return (obj.value.length > parseInt(obj.maxlength));
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
}

function encodeAnswer()
{
	var objForm = document.competition.Answer;
	if(objForm)
	{
		if(objForm.length)
		{
			for(var i=0; i<objForm.length; i++)
				if(objForm[i].value.length>0)
					objForm[i].value = objForm[i].value.replace(/,/g, String.fromCharCode(130));
		}
		else
			if(objForm.value.length>0)
				objForm.value = objForm.value.replace(/,/g, String.fromCharCode(130));
	}	

}