function ResetAll()
{
document.getElementById('txtQuestionText').value="";
document.getElementById('txtChoice1').value="";
document.getElementById('txtChoice2').value="";
document.getElementById('txtChoice3').value="";
document.getElementById('txtChoice4').value="";
document.getElementById('txtChoice5').value="";
document.getElementById('ddlNoofChoices').value="5";
var ErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
ErrorsDiv.style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
return(false);
}
function VoteOpinionPoll()
{
var rdo=document.getElementsByName("optPollChoice");
for(i=0;i<rdo.length;i++)
{
if(rdo[i].checked)
{
flag=true;
return(flag);
break;
}
else
{
flag=false;
}
}
if(flag==false)
{
document.getElementById("WarningMsgs_RegistrationErrors").innerHTML=" Please select an option to cast your vote.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(flag);
}
}
function ValidateFields()
{
if(!ValidateQuestionText())
{
return(false);
}
if(!ValidateChoice1())
{
return(false);
}
if(!ValidateChoice2())
{
return(false);
}
iNoofChoice=document.getElementById('ddlNoOfChoices').value;
if(iNoofChoice>2)
{
if(!ValidateChoice3())
{
return(false);
}
}
if(iNoofChoice>3)
{
if(!ValidateChoice4())
{
return(false);
}
}
if(iNoofChoice>4)
{
if(!ValidateChoice5())
{
return(false);
}
}
}
function ValidateQuestionText()
{
var Name="Question Text";
var Value=document.getElementById('txtQuestionText').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,1024)))
{
document.getElementById('txtQuestionText').setfocus;
return(false);
}
return(true);
}
function ValidateChoice1()
{
var Name="Choice 1";
var Value=document.getElementById('txtChoice1').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,255)))
{
document.getElementById('txtChoice1').setfocus;
return(false);
}
return(true);
}
function ValidateChoice2()
{
var Name="Choice 2";
var Value=document.getElementById('txtChoice2').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,255)))
{
document.getElementById('txtChoice2').setfocus;
return(false);
}
return(true);
}
function ValidateChoice3()
{
var Name="Choice 3";
var Value=document.getElementById('txtChoice3').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,255)))
{
document.getElementById('txtChoice3').setfocus;
return(false);
}
return(true);
}
function ValidateChoice4()
{
var Name="Choice 4";
var Value=document.getElementById('txtChoice4').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,255)))
{
document.getElementById('txtChoice4').setfocus;
return(false);
}
return(true);
}
function ValidateChoice5()
{
var Name="Choice 5";
var Value=document.getElementById('txtChoice5').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,255)))
{
document.getElementById('txtChoice5').setfocus;
return(false);
}
return(true);
}
function ValidateLength(vFldName,vFieldVal,vFieldSize)
{
errors="";
errors+=vFldName+' cannot contain more than '+vFieldSize+'<br/>';
if(trim(vFieldVal).length>vFieldSize)
{
var ErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
ErrorsDiv.style.display="block";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
ErrorsDiv.innerHTML="";
ErrorsDiv.innerHTML=errors;
return(false);
}
else
{
var ErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
ErrorsDiv.style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
return(true);
}
}
function ValidateMandatory(vFldName,vFieldVal)
{
errors="";
errors+=vFldName+' cannot be empty.'+'<br/>';
if(trim(vFieldVal)=='')
{
var ErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
ErrorsDiv.style.display="block";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
ErrorsDiv.innerHTML="";
ErrorsDiv.innerHTML=errors;
return(false);
}
else
{
var ErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
ErrorsDiv.style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
return(true);
}
}
function DisplayPollOpinionChoices()
{
var iNoofChoice;
if(document.getElementById('ddlNoofChoices')!=null)
{
iNoofChoice=document.getElementById('ddlNoofChoices').value;
if(iNoofChoice==2)
{
document.getElementById("divChoice3").style.visibility="hidden";
document.getElementById("lblChoice3").style.visibility="hidden";
document.getElementById("txtChoice3").style.visibility="hidden";
document.getElementById("divChoice4").style.visibility="hidden";
document.getElementById("lblChoice4").style.visibility="hidden";
document.getElementById("txtChoice4").style.visibility="hidden";
document.getElementById("divChoice5").style.visibility="hidden";
document.getElementById("lblChoice5").style.visibility="hidden";
document.getElementById("txtChoice5").style.visibility="hidden";
}
if(iNoofChoice==3)
{
document.getElementById("divChoice3").style.visibility="visible";
document.getElementById("lblChoice3").style.visibility="visible";
document.getElementById("txtChoice3").style.visibility="visible";
document.getElementById("divChoice4").style.visibility="hidden";
document.getElementById("lblChoice4").style.visibility="hidden";
document.getElementById('txtChoice4').style.visibility="hidden";
document.getElementById("divChoice5").style.visibility="hidden";
document.getElementById("lblChoice5").style.visibility="hidden";
document.getElementById("txtChoice5").style.visibility="hidden";
}
if(iNoofChoice==4)
{
document.getElementById("divChoice3").style.visibility="visible";
document.getElementById("lblChoice3").style.visibility="visible";
document.getElementById("txtChoice3").style.visibility="visible";
document.getElementById("divChoice4").style.visibility="visible";
document.getElementById("lblChoice4").style.visibility="visible";
document.getElementById("txtChoice4").style.visibility="visible";
document.getElementById("divChoice5").style.visibility="hidden";
document.getElementById("lblChoice5").style.visibility="hidden";
document.getElementById("txtChoice5").style.visibility="hidden";
}
if(iNoofChoice==5)
{
document.getElementById("divChoice3").style.visibility="visible";
document.getElementById("lblChoice3").style.visibility="visible";
document.getElementById("txtChoice3").style.visibility="visible";
document.getElementById("divChoice4").style.visibility="visible";
document.getElementById("lblChoice4").style.visibility="visible";
document.getElementById("txtChoice4").style.visibility="visible";
document.getElementById("divChoice5").style.visibility="visible";
document.getElementById("lblChoice5").style.visibility="visible";
document.getElementById("txtChoice5").style.visibility="visible";
}
}
}
function LoadOpinionPollResult()
{
window.pollID1=document.getElementById('pollID1');
document.pollID1.SetVariable("LegendText",document.getElementById('hidLegendText').value);
document.pollID1.SetVariable("LegendValues",document.getElementById('hidLegendValues').value);
}
function loadUPEventHandler()
{
window.pollID1=document.getElementById('pollID1');
var prm=Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(UPEndRequestHandler);
if(document.getElementById('hidPollId').value!=null)
{
if(document.getElementById('hidPollId').value!=0)
{
LoadOpinionPollResult();
}
}
}
function UPEndRequestHandler(sender,args)
{
var err=args.get_error();
if(err)
{
if(err.name=="Sys.WebForms.PageRequestManagerServerErrorException")
{
args.set_errorHandled(true);
}
if(err.name=="Sys.WebForms.PageRequestManagerParserErrorException")
{
e.set_errorHandled(true);
}
}
var UserMessage=null;
var EditMessage=null;
UserMessage=document.getElementById("hidUserMessage");
if(UserMessage!=null&&UserMessage!="")
{
var UserMessageVal=UserMessage.value;
}
switch(UserMessageVal)
{
case"CallFlashFile":
LoadOpinionPollResult();
break;
case"ReloadFlashFile":
LoadOpinionPollResult();
break;
case"ErrorCallFlashFile":
closepopup();
alert("Error in loading flash file");
break;
default:
return;
}
UserMessage.value="";
}

