$(document).ready(function(){
	function getChoice(rdoObj)
		{
			if(!rdoObj)
				return false;
			
			var radioLength = rdoObj.length;
			
			for(var i=0; i<radioLength; i++){
				if(rdoObj[i].checked){
					return rdoObj[i].value;
				}
			}
		
			return false;
		}
		
	function validate(){
		var choice = getChoice(document.forms['frm_vote'].elements['choice']);
		
		return choice;
	}
	
	$("#btn_vote").click(function(){
		/*$('#frm_vote').css({ display:"none" });
		$('#voteResults').css({ display:"block" });
		$('#voteBox_top').css({ background:"url(images/voteBoxResults_top.jpg)" });
		*/
		var choice = validate();
		
		if(choice){
			//alert(choice);
			var surveyId = 500000156;
			var surveyComplete = true;
			
			var resp = Tremor.Ajax.Call('survey','submit',{ surveyId:surveyId, surveyComplete:surveyComplete, q500003209:choice},{sync:true});
			window.location="vote_thanks.html";	
		}
		else{
			$("#msg").html("Please select a product then click 'Vote!'");
			$("#msg").addClass("msg_error");
			return false;
		}
		return false;
	});
});
// JScript File
