// For Showing Poll Results - S
function ShowPollRes(PollId){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		var url =  "../poll/ajaxpoll_result.php?PollId="+PollId;
		httpObject.onreadystatechange = HandlePollResults
		httpObject.open("GET",url , true);
		httpObject.send(null);
	}
}

function HandlePollResults(){
	if(httpObject.readyState == 4){
		var resp_string = httpObject.responseText;
		var divWdth = 1000;
		var divHght = 223;
		shwHideAllCmbNFlash(1);
		showDiv('greyOverlay');showDiv('poll_res');
		//document.getElementById("poll_res").style.display="block";//comment by tapan
		//document.getElementById("poll_res").style.visibility="visible";//comment by tapan
		document.getElementById("poll_res").innerHTML = resp_string;
		setContentDivInCenter('poll_res', divWdth, divHght);
	}
}
// For Showing Poll Results - E

function hidepoll(){
	shwHideAllCmbNFlash(2);
	hideDiv('poll_res');
	hideDiv('greyOverlay');
	//document.getElementById("poll_res").style.display="none";//comment by tapan
//	document.getElementById("poll_res").style.visibility="hidden";//comment by tapan
}

function ValidatePoll(PollId){
	var rad_val = null;
	for (var i=0; i < document.PollResForm.Poll.length; i++) {
		if (document.PollResForm.Poll[i].checked) {
			rad_val = document.PollResForm.Poll[i].value;
		}
	}

	if (rad_val == null){
		alert("Please Select One Option");
	}else {
		InsUpdPollRes(PollId,rad_val);
	}
}

function InsUpdPollRes(PollId,OptionVal){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		var url =  "../poll/insupdPollRes.php?PollId="+PollId+"&OptionVal="+OptionVal;
		httpObject.onreadystatechange = HandleInsUpdPollRes
		httpObject.open("GET",url , true);
		httpObject.send(null);
	}
}

function HandleInsUpdPollRes(){
	if(httpObject.readyState == 4){
		var resp_string = httpObject.responseText;
		var Arr_Res = resp_string.split('||');
		if (Arr_Res['0']=='1') {
			var PollId = Arr_Res['1'];
			ShowPollRes(PollId);
		}else if (Arr_Res['0']=='0'){
			alert("You Have Already Done With It.Thank You.");
			return false;
		}
	}
}