                                  

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="20";
	this.SurveyVotes=1690;
	this.OtherVotes=76;
	this.OtherVotesPct=4.5;
	this.Question="Vote for your favorite protein?";
	this.Answers=new Array(7);
	this.AnswerIDs[0]=198; 	this.AnswerVotes[0]=15; 	this.AnswerPct[0]=0.89; this.Answers[0]="SNI Pro Whey";
	this.AnswerIDs[1]=199; 	this.AnswerVotes[1]=1; 	this.AnswerPct[1]=0.06; this.Answers[1]="Pure Protein Bar";
	this.AnswerIDs[2]=200; 	this.AnswerVotes[2]=18; 	this.AnswerPct[2]=1.07; this.Answers[2]="New Whey Liquid Protein Shots";
	this.AnswerIDs[3]=201; 	this.AnswerVotes[3]=3; 	this.AnswerPct[3]=0.18; this.Answers[3]="Nectar Whey Protein Isolate";
	this.AnswerIDs[4]=202; 	this.AnswerVotes[4]=3; 	this.AnswerPct[4]=0.18; this.Answers[4]="Hyperdrive 3.0+ 90ct";
	this.AnswerIDs[5]=203; 	this.AnswerVotes[5]=0; 	this.AnswerPct[5]=0; this.Answers[5]="Tri-o-plex Bar";
	this.AnswerIDs[6]=204; 	this.AnswerVotes[6]=5; 	this.AnswerPct[6]=0.3; this.Answers[6]="Pure Protein RTD Shake";
	this.UserAnswers=new Array(76);
this.UserAnswers[0]="EAS";
this.UserAnswers[1]="EAS whey";
this.UserAnswers[2]="on";
this.UserAnswers[3]="Recovery 2:1:1";
this.UserAnswers[4]="VPX Zero Carb Graham Cracker";
this.UserAnswers[5]="Optimum Pro Complex";
this.UserAnswers[6]="Isopure";
this.UserAnswers[7]="NXcare iso XP";
this.UserAnswers[8]="100% gold standard";
this.UserAnswers[9]="Smart gainer";
this.UserAnswers[10]="american whey";
this.UserAnswers[11]="Syntha-6";
this.UserAnswers[12]="MRI Pro-Nos";
this.UserAnswers[13]="ON 100% Gold Standard WHEY";
this.UserAnswers[14]="natures best isopure";
this.UserAnswers[15]="Syntrax Nectar Sweets chocolate Truffle";
this.UserAnswers[16]="NO shotgun";
this.UserAnswers[17]="Optimum 100% Whey";
this.UserAnswers[18]="gold Standard Wheyby Optimum Nutrition";
this.UserAnswers[19]="Isopure - unflavored";
this.UserAnswers[20]="gaspari myofusion";
this.UserAnswers[21]="Bio Whey";
this.UserAnswers[22]="VPX";
this.UserAnswers[23]="ON";
this.UserAnswers[24]="muscleology nitro-pro";
this.UserAnswers[25]="N-Large 2";
this.UserAnswers[26]="isopure";
this.UserAnswers[27]="syntha -6";
this.UserAnswers[28]="Optimum nutrition Gold standard";
this.UserAnswers[29]="isopure zero carb";
this.UserAnswers[30]="ISOPURE";
this.UserAnswers[31]="Dymatize Iso-100";
this.UserAnswers[32]="EAS 100%";
this.UserAnswers[33]="IDS New Whey Liquid Protein";
this.UserAnswers[34]="tylenol";
this.UserAnswers[35]="optimum nutrition whey";
this.UserAnswers[36]="VPX protein rush";
this.UserAnswers[37]="IDS New Whey Protein 42g";
this.UserAnswers[38]="worldwide protein shake - cookies and cream";
this.UserAnswers[39]="myogenix";
this.UserAnswers[40]="Myogenix Evolution";
this.UserAnswers[41]="MYOGENIX";
this.UserAnswers[42]="cell technitro tech!!!";
this.UserAnswers[43]="Optimum Nutrition 100% Whey";
this.UserAnswers[44]="ON Gold Standard";
this.UserAnswers[45]="Whey gold standart";
this.UserAnswers[46]="BSNs syntha-6";
this.UserAnswers[47]="syntha-6";
this.UserAnswers[48]="VPX Stealth";
this.UserAnswers[49]="isagenix";
this.UserAnswers[50]="syntha 6";
this.UserAnswers[51]="gold standard whey";
this.UserAnswers[52]="IDS PROTEIN";
this.UserAnswers[53]="American Whey is horrible";
this.UserAnswers[54]="Syntha 6";
this.UserAnswers[55]="SYNTHA 6";
this.UserAnswers[56]="Gaspari Myofusion";
this.UserAnswers[57]="Isopure Zero Carb";
this.UserAnswers[58]="American Whey is TERRIBLE";
this.UserAnswers[59]="Dont waste your money on American Whey!";
this.UserAnswers[60]="Bargin Whey";
this.UserAnswers[61]="Optimum Whey";
this.UserAnswers[62]="optimum nutrition whey protein";
this.UserAnswers[63]="optimum nutrition";
this.UserAnswers[64]="Metabolic Drive";
this.UserAnswers[65]="tttttttttttttttt";
this.UserAnswers[66]="champion nutrition pure whey";
this.UserAnswers[67]="Opitium nutrition";
this.UserAnswers[68]="american whey.  where is it";
this.UserAnswers[69]="Amway nutrilite powder";
this.UserAnswers[70]="optimum";
this.UserAnswers[71]="Muscle Milk";
this.UserAnswers[72]="sample answer here";
this.UserAnswers[73]="G2G bars";
this.UserAnswers[74]="jillian michaels";
this.UserAnswers[75]="myofusion";
	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 );
}
