                                  

function radio_value(el) {
  for (var i=0;i<el.length; i++) { 
	if (el[i].checked) { return el[i].value; }
  }
}
function on_vote(frm, frmlink) {
	var f0 = document.forms[frm.name];
	var a1=frmlink, a2=radio_value(f0.newchannel_survey), a3=f0.newchannel_own.value;
	window.newchannelfrm.location.href=frmlink+'&newchannel_survey='+a2+'&newchannel_own='+a3+'&surveyvote=1';
	_NCP.UserAnswer=a2; 
	setTimeout( "_NCP.ShowResults()", 2000 );
	return false;
}

function roundTo(inputNum, precision){
var guide = Math.pow(10, precision);
var inputnum = ( Math.round(inputNum * guide) / guide );
var numString = inputNum + "";
if ( numString.search(/\./) < 0 ) {
	numString += ".";	
	for ( var j =0; j<precision; j++ ) numString += "0";
}
var afterDecimal = numString.substring(numString.search(/\./) + 1);
if ( afterDecimal.length > precision ) {
	return numString.substring( 0, numString.search(/\./) + 1 + precision )
}
while (afterDecimal.length < precision) {
	afterDecimal += "0";
	numString += "0";
}
return (numString);
}

NewChannelResults.prototype.Parent = null;
NewChannelResults.prototype.Div = null;
NewChannelResults.prototype.IsActive=false;
NewChannelResults.prototype.Domain="";
NewChannelResults.prototype.classQuestion="";
NewChannelResults.prototype.classAnswer="";
NewChannelResults.prototype.classOwnAnswer="";
NewChannelResults.prototype.classVoteButton="";
NewChannelResults.prototype.classLinks="";
NewChannelResults.prototype.SurveyID="";
NewChannelResults.prototype.SurveyVotes="";
NewChannelResults.prototype.OtherVotes="";
NewChannelResults.prototype.OtherVotesPct=0;
NewChannelResults.prototype.UserAnswer=-1;
NewChannelResults.prototype.Question="";
NewChannelResults.prototype.AnswerIDs=new Array();
NewChannelResults.prototype.Answers=new Array();
NewChannelResults.prototype.AnswerVotes=new Array();
NewChannelResults.prototype.AnswerPct=new Array();
NewChannelResults.prototype.UserAnswers=new Array();

var _NCP = null;
function NewChannelResults(){
	this.Domain = "";
	this.SurveyID="19";
	this.SurveyVotes=1382;
	this.OtherVotes=6;
	this.OtherVotesPct=0.43;
	this.Question="Do you feel that taking health supplements helps you avoid swine flu?";
	this.Answers=new Array(2);
	this.AnswerIDs[0]=108; 	this.AnswerVotes[0]=721; 	this.AnswerPct[0]=52.17; this.Answers[0]="Yes";
	this.AnswerIDs[1]=109; 	this.AnswerVotes[1]=655; 	this.AnswerPct[1]=47.4; this.Answers[1]="No";
	this.UserAnswers=new Array(6);
this.UserAnswers[0]="the swine flu is beyond the control of the average individual";
this.UserAnswers[1]="Not related with each other.";
this.UserAnswers[2]="while health products do increase the immune system, they are not enough to prevent such an epidemic";
this.UserAnswers[3]="improving your health is best defense against any illness";
this.UserAnswers[4]="not sure oink";
this.UserAnswers[5]="The swine flu is like any other flu. So whatever applies.";
	this.IsActive=true;
	_NCP = this;
}
NewChannelResults.prototype.gid=function(id){
	var d=document; if(d.getElementById){return d.getElementById(id);}else if(d.all){return d.all[id];}else if(d.layers){return d.layers[id];}
	return null;
}
NewChannelResults.prototype.cl = function(cls) {
	if(cls=="")return "";return " class="+cls;
}
NewChannelResults.prototype.DisplayResults=function(parent) {
	var div = document.createElement("div");                     
	var o = "";

	o += "<b"+this.cl(this.classQuestion)+">" + this.Question + "</B>";
	for ( var i=0; i<this.AnswerIDs.length; i++ ) {
		var pct = parseInt( this.AnswerPct[i] );

		o += "<div style='margin-top:5px;'"+this.cl(this.classAnswer)+"><B>"+this.Answers[i]+"</B> &nbsp;"
		   + this.AnswerPct[i] + "%, <span style='font-size:9px;color:gray'>("+this.AnswerVotes[i]+" votes)</span>"
		   + "<table width=95% cellspacing=0 cellpadding=0 style='height:6px;border:1px #bcbcbc solid'><TR>";
		if ( pct > 0 ) o += "<TD width=" + parseInt(pct) + "% bgcolor=red style='font-size:4px;'>&nbsp;</TD>";
		if ( pct < 100 ) o += "<TD width=" + parseInt(100-pct) + "% bgcolor=white style='font-size:4px;'>&nbsp;</TD>";
		o += "</TR></TABLE>";
		   + "</div>\n";
	}
	if ( this.OtherVotes > 0 ) {
		pct = this.OtherVotesPct;
		o += "<div style='margin-top:5px;'"+this.cl(this.classAnswer)+"><B>Own Answer</B> &nbsp;"
		   + pct + "%, <span style='font-size:9px;color:gray'>("+this.OtherVotes+" votes)</span>"
		   + "<table width=95% cellspacing=0 cellpadding=0 style='height:6px;border:1px #bcbcbc solid'><TR>";
		if ( pct > 0 ) o += "<TD width=" + parseInt(pct) + "% bgcolor=red style='font-size:4px;'>&nbsp;</TD>";
		if ( pct < 100 ) o += "<TD width=" + parseInt(100-pct) + "% bgcolor=white style='font-size:4px;'>&nbsp;</TD>";
		o += "</TR></TABLE>";
		   + "</div>\n";
	}
	for ( var i=0; i<this.UserAnswers.length; i++ ) {
		o += "<div style='margin-top:5px;'"+this.cl(this.classOwnAnswer)+"><B>"+this.UserAnswers[i]+"</B></div>\n";
	}

	
	div.innerHTML = o; this.Div = div; this.Parent = parent;
	parent.appendChild( div );
}
