// JavaScript Documentvar poll_id = null;
var poll_name = null;
$(document).ready(function(){
	if (ultimateHeight!=null) { var t=setTimeout("caculateHeight()",300); }
	$("input:radio").select();
	var show_result = $(".show_result").length > 0;
	poll_id = $("input#id").val();
	poll_name = $("input#pollname").val();
	if(show_result)
		getResult({});

	// When clicking the vote button in vote widget
	$("input#btn_vote").click(function(){
		// Pick up the selected value as JSON-object
		var data = $("input:radio").serializeArray();

		getResult(data);
		// if (parent.pollTracking) parent.pollTracking(poll_name, poll_id);
		// Prevent the form for actually posting
		return false;
	});
	
})
function caculateHeight(){
	$("#dummy_height").height(0);
	var diffHeight = ultimateHeight - $("#text_poll").height();
	if (diffHeight > 0)
	{ $("#dummy_height").height(diffHeight).show();}

}

function getResult(data) {
	// Start by adding the loader
	$("div#dynamic_content").html('<img src="img/ajax-loader.gif" id="loader"/>');

	// Load the result
	$("div#dynamic_content").load("result.php?id=" + poll_id, data, refreshAd);
	
	// Reset Height after load result
	var t= setTimeout("caculateHeight()",300);
}

function refreshAd(){
	//$('#poll_under_inner').html($('#poll_under_inner').html());
	if (document.getElementById('poll_under_inner')) {document.getElementById('poll_under_inner').innerHTML = document.getElementById('poll_under_inner').innerHTML;}
}
