function JSONscriptRequest(_1){
this.fullUrl=_1;
this.noCacheIE="&noCacheIE="+(new Date()).getTime();
this.headLoc=document.getElementsByTagName("head").item(0);
this.scriptId="JscriptId"+JSONscriptRequest.scriptCounter++;
}
JSONscriptRequest.scriptCounter=1;
JSONscriptRequest.prototype.buildScriptTag=function(){
this.scriptObj=document.createElement("scr"+"i"+"pt");
this.scriptObj.setAttribute("type","text/javascript");
this.scriptObj.setAttribute("charset","utf-8");
this.scriptObj.setAttribute("src",this.fullUrl+this.noCacheIE);
this.scriptObj.setAttribute("id",this.scriptId);
};
JSONscriptRequest.prototype.removeScriptTag=function(){
this.headLoc.removeChild(this.scriptObj);
};
JSONscriptRequest.prototype.addScriptTag=function(){
this.headLoc.appendChild(this.scriptObj);
};
var poll=null;
function Poll(){
this.poll_entries=new Array();
this.poll_entries_hash=new Object();
this.guide_id=null;
this.register=null;
this.cookie=null;
this.vote_base_url="http://nm3.wescompapers.com/restaurants/";
}
Poll.init=function(){
if(poll==null){
return;
}
poll.init();
};
Poll.vote_values=[{"id":0,"name":"F","value":0},{"id":1,"name":"D-","value":1},{"id":2,"name":"D","value":2},{"id":3,"name":"D+","value":3},{"id":4,"name":"C-","value":4},{"id":5,"name":"C","value":5},{"id":6,"name":"C+","value":6},{"id":7,"name":"B-","value":7},{"id":8,"name":"B","value":8},{"id":9,"name":"B+","value":9},{"id":10,"name":"A-","value":10},{"id":11,"name":"A","value":11},{"id":12,"name":"A+","value":12}];
Poll.prototype.init=function(){
var _2=document.getElementById("rest_poll_guide_id");
this.rest_poll_guide_id=_2;
var _3=document.getElementById("rest_poll_vote");
this.rest_poll_vote=_3;
var _4=document.getElementById("rest_poll_register_decline");
this.rest_poll_register_decline=_4;
var _5=document.getElementById("ratings_table");
this.ratings_table=_5;
var _6=document.getElementById("message_table");
this.message_table=_6;
var _7=document.getElementById("rest_poll_thanks");
this.rest_poll_thanks=_7;
var _8=document.getElementById("rest_poll_entry1");
this.rest_poll_entry1=_8;
var _9=document.getElementById("rest_poll_entry2");
var _a=document.getElementById("rest_poll_entry3");
var _b=document.getElementById("rest_poll_entry4");
var _c=document.getElementById("rest_poll_entry_total");
this.rest_poll_entry_total=_c;
var _d=document.getElementById("rest_poll_result1");
this.rest_poll_result1=_d;
var _e=document.getElementById("rest_poll_result2");
this.rest_poll_result2=_e;
var _f=document.getElementById("rest_poll_result3");
this.rest_poll_result3=_f;
var _10=document.getElementById("rest_poll_result4");
this.rest_poll_result4=_10;
var _11=document.getElementById("rest_poll_result_total");
this.rest_poll_result_total=_11;
var _12=document.getElementById("rest_poll_tally");
this.rest_poll_tally=_12;
var _13=document.getElementById("rest_poll_count");
this.rest_poll_count=_13;
var _14=document.getElementById("rest_poll_ask");
this.rest_poll_ask=_14;
var _15=document.getElementById("rest_poll_be_the_first");
this.rest_poll_be_the_first=_15;
if(_2==null||_3==null||_8==null||_9==null||_a==null||_b==null||_12==null||_d==null||_e==null||_f==null||_10==null||_11==null||_c==null||_7==null||_15==null||_14==null||_13==null||_4==null||_5==null||_6==null){
setTimeout(Poll.init,150);
return;
}
guide_id="";
while(_2.childNodes.length){
var _16=_2.removeChild(_2.firstChild);
if(_16.nodeType==3){
guide_id+=_16.data;
}
}
this.guide_id=guide_id.replace(/[^0-9]/,"");
_2.parentNode.removeChild(_2);
_3.parent=this;
_3.onclick=PollEntry.vote;
var _17=new Array();
_17.push(_8);
_17.push(_9);
_17.push(_a);
_17.push(_b);
for(var i=0;i<_17.length;i++){
var _19=_17[i];
var _1a=new PollEntry(this);
_1a.element=_19;
this.poll_entries.push(_1a);
var _1b="";
while(_1a.element.childNodes.length){
var _16=_1a.element.removeChild(_1a.element.firstChild);
if(_16.nodeType==3){
_1b+=_16.data;
}
}
_1a.type=_1b.replace(/[^0-9]/,"");
this.poll_entries_hash[_1a.type]=_1a;
var _1c=document.createElement("span");
_1a.label=_1c;
_1a.element.appendChild(_1c);
for(var _1d=0;_1d<Poll.vote_values.length;_1d++){
var a=document.createElement("a");
a.href="#";
a.onmouseover=PollEntry.highlight;
a.onmouseout=PollEntry.release;
a.onclick=PollEntry.clicked;
a.position=_1d;
a.parent=_1a;
_1a.element.appendChild(a);
_1a.ticks.push(a);
}
_1a.setLabel(null);
}
_5.style.display="block";
var _1f=this.readCookies();
var _20=_1f["PBCSSESSIONID"];
var _21=_1f["rest_poll"];
if(_21==null){
_21=_20;
}else{
_20=_21;
}
var _22=new Date();
_22.setFullYear(_22.getFullYear()+10);
document.cookie="rest_poll="+_20+"; path=/; expires="+_22.toGMTString();
this.cookie=_20;
var _23=this.vote_base_url+"register?callback=Poll.register_init_callback&cookie="+this.cookie;
this.json_register_init=new JSONscriptRequest(_23);
this.json_register_init.buildScriptTag();
this.json_register_init.addScriptTag();
};
Poll.prototype.readCookies=function(){
var _24=document.cookie.split("; ");
var _25=new Object();
for(var i=0;i<_24.length;i++){
var _27=_24[i];
var _28=_27.split("=");
var _29=_28[0];
var _2a=_28[1];
if(_29==null||_2a==null){
continue;
}
_25[_29]=_2a;
}
return _25;
};
Poll.prototype.registerInit=function(_2b){
if(this.json_register_init!=null){
this.json_register_init.removeScriptTag();
this.json_register_init=null;
}
this.register=_2b;
var _2c=this.vote_base_url+"report?callback=Poll.fetch_ratings_callback&guide_id="+this.guide_id+"&cookie="+this.cookie;
this.json_fetch_ratings=new JSONscriptRequest(_2c);
this.json_fetch_ratings.buildScriptTag();
this.json_fetch_ratings.addScriptTag();
};
Poll.prototype.Register=function(_2d){
if(this.json_register!=null){
this.json_register.removeScriptTag();
this.json_register=null;
}
this.register=_2d;
this.hideRegisterMenu();
this.rest_poll_vote.onclick();
};
Poll.prototype.fetchRatings=function(_2e){
if(this.json_fetch_ratings!=null){
this.json_fetch_ratings.removeScriptTag();
this.json_fetch_ratings=null;
}
if(_2e==null||_2e.votes==null){
this.rest_poll_be_the_first.style.display="block";
this.rest_poll_ask.style.display="none";
this.rest_poll_count.style.display="none";
return;
}
var _2f=new Array();
_2f.push(this.rest_poll_result1);
_2f.push(this.rest_poll_result2);
_2f.push(this.rest_poll_result3);
_2f.push(this.rest_poll_result4);
_2f.push(this.rest_poll_result_total);
_2f.push(this.rest_poll_tally);
for(var i=0;i<_2f.length;i++){
var e=_2f[i];
while(e.childNodes.length){
e.removeChild(e.firstChild);
}
}
var _32=0;
for(var _33=0;_33<_2e.votes.length;_33++){
var _34=_2e.votes[_33];
if(_32<_34.tally){
_32=_34.tally;
}
var _35=Poll.vote_values[Math.round(_34.average)].name;
if(_34.type==1){
this.rest_poll_result1.appendChild(document.createTextNode(_35));
}
if(_34.type==2){
this.rest_poll_result2.appendChild(document.createTextNode(_35));
}
if(_34.type==3){
this.rest_poll_result3.appendChild(document.createTextNode(_35));
}
if(_34.type==4){
this.rest_poll_result4.appendChild(document.createTextNode(_35));
}
if(_34.type==0){
this.rest_poll_result_total.appendChild(document.createTextNode(_35));
}
}
if(_32>0){
this.rest_poll_tally.appendChild(document.createTextNode(_32));
}
var _36=0;
var _37=0;
if(_2e.user_votes!=null){
for(var _33=0;_33<_2e.user_votes.length;_33++){
var _34=_2e.user_votes[_33];
var _35=Poll.vote_values[Math.round(_34.average)].name;
var _38=this.poll_entries_hash[_34.type];
if(_38!=null){
_38.setLabel(_35);
_38.redraw("selected",Math.round(_34.average));
_36++;
_37+=_34.average;
if(_34.type==1){
_36++;
_37+=_34.average;
}
}
}
}
if(_2e.user_votes!=null&&_2e.user_votes.length>1){
for(var i=0;i<this.poll_entries.length;i++){
var _38=this.poll_entries[i];
_38.Lock();
}
}
if(_36>0){
this.rest_poll_vote.style.display="none";
this.rest_poll_thanks.style.display="block";
this.rest_poll_count.style.display="block";
this.rest_poll_ask.style.display="none";
this.rest_poll_be_the_first.style.display="none";
var _39=Math.round(_37/_36);
_39=Poll.vote_values[_39].name;
while(this.rest_poll_entry_total.childNodes.length){
this.rest_poll_entry_total.removeChild(this.rest_poll_entry_total.firstChild);
}
this.rest_poll_entry_total.appendChild(document.createTextNode(_39));
}
if(_32<=0&&_36<=0){
this.rest_poll_be_the_first.style.display="block";
this.rest_poll_count.style.display="none";
this.rest_poll_ask.style.display="none";
}
if(_32>0&&_36<=0){
this.rest_poll_be_the_first.style.display="none";
this.rest_poll_ask.style.display="block";
this.rest_poll_count.style.display="block";
}
};
Poll.prototype.Vote=function(_3a){
if(this.json_poll!=null){
this.json_poll.removeScriptTag();
this.json_poll=null;
}
this.rest_poll_vote.style.display="none";
this.rest_poll_thanks.style.display="block";
var _3b=this.vote_base_url+"report?callback=Poll.fetch_ratings_callback&guide_id="+this.guide_id+"&cookie="+this.register.cookie;
this.json_fetch_ratings=new JSONscriptRequest(_3b);
this.json_fetch_ratings.buildScriptTag();
this.json_fetch_ratings.addScriptTag();
};
Poll.prototype.UpdateEntryTotal=function(_3c,_3d){
if(this.poll_entries[0].locked){
return;
}
var _3e=this.poll_entries;
var _3f=0;
var _40=0;
if(_3c!=null&&_3d!=null){
_3f=1;
_40=Poll.vote_values[_3d].value;
}
var _41=false;
for(var i=0;i<_3e.length;i++){
var _43=_3e[i];
if(_3c!=null&&_43.type==_3c.type){
continue;
}
if(_43.clicked>-1){
_3f++;
_40+=Poll.vote_values[_43.clicked].value;
if(_43.type==1){
_3f++;
_40+=Poll.vote_values[_43.clicked].value;
}
_41=true;
}
}
if(_41){
var _44=Math.round(_40/_3f);
_44=Poll.vote_values[_44].name;
while(this.rest_poll_entry_total.childNodes.length){
this.rest_poll_entry_total.removeChild(this.rest_poll_entry_total.firstChild);
}
this.rest_poll_entry_total.appendChild(document.createTextNode(_44));
}
};
Poll.prototype.showRegisterMenu=function(){
this.message_table.style.display="block";
this.ratings_table.style.display="none";
};
Poll.prototype.hideRegisterMenu=function(){
this.message_table.style.display="none";
this.ratings_table.style.display="block";
};
Poll.prototype.RegisterRequest=function(_45){
var _46=this.vote_base_url+"register?callback=Poll.register_callback&cookie="+this.cookie;
if(_45!=null){
for(var i=0;i<_45.elements.length;i++){
var _48=_45.elements[i];
_46+="&"+_48.name+"="+_48.value;
}
}else{
_46+="&email=bulletin@bendbulletin.com&first_name=none&last_name=none";
}
this.json_register=new JSONscriptRequest(_46);
this.json_register.buildScriptTag();
this.json_register.addScriptTag();
return false;
};
Poll.fetch_ratings_callback=function(_49){
if(poll==null){
return;
}
poll.fetchRatings(_49);
};
Poll.vote_callback=function(_4a){
if(poll==null){
return;
}
poll.Vote(_4a);
};
Poll.register_callback=function(_4b){
if(poll==null){
return;
}
poll.Register(_4b);
};
Poll.register_init_callback=function(_4c){
if(poll==null){
return;
}
poll.registerInit(_4c);
};
Poll.register_request=function(_4d){
if(poll==null){
return;
}
poll.RegisterRequest(_4d);
};
function PollEntry(_4e){
this.parent=_4e;
this.element=null;
this.label=null;
this.type=null;
this.ticks=new Array();
this.clicked=-1;
this.locked=false;
}
PollEntry.vote=function(){
if(this.parent.register==null||this.parent.register.hash==null||this.parent.register.hash.length<1){
this.parent.showRegisterMenu();
return false;
}
var _4f=this.parent.poll_entries;
var _50="";
var _51="";
var _52=false;
for(var i=0;i<_4f.length;i++){
var _54=_4f[i];
if(_54.clicked>-1){
_50+=_54.type+",";
_51+=Poll.vote_values[_54.clicked].value+",";
_52=true;
}
}
if(!_52){
return false;
}
_50=_50.replace(/,$/,"");
_51=_51.replace(/,$/,"");
var _55=this.parent.vote_base_url+"vote?callback=Poll.vote_callback&guide_id="+this.parent.guide_id+"&type="+_50+"&value="+_51+"&cookie="+this.parent.register.cookie+"&hash="+this.parent.register.hash;
this.parent.json_poll=new JSONscriptRequest(_55);
this.parent.json_poll.buildScriptTag();
this.parent.json_poll.addScriptTag();
return false;
};
PollEntry.highlight=function(){
this.parent.redraw("highlight",this.position);
this.parent.setLabel(Poll.vote_values[this.position].name);
this.parent.parent.UpdateEntryTotal(this.parent,this.position);
};
PollEntry.release=function(){
if(this.parent.clicked<0){
this.parent.setLabel(null);
}else{
this.parent.setLabel(Poll.vote_values[this.parent.clicked].name);
}
this.parent.redraw("selected",this.parent.clicked);
};
PollEntry.clicked=function(){
this.parent.setClick(this.position);
this.parent.redraw("selected",this.parent.clicked);
return false;
};
PollEntry.prototype.setLabel=function(_56){
if(this.locked){
return;
}
while(this.label.childNodes.length){
this.label.removeChild(this.label.firstChild);
}
if(_56!=null){
this.label.appendChild(document.createTextNode(_56));
}else{
this.label.appendChild(document.createTextNode("\xa0"));
}
};
PollEntry.prototype.redraw=function(_57,_58){
if(this.locked){
return;
}
for(i=0;i<this.ticks.length;i++){
var a=this.ticks[i];
if(_58>-1&&i<=_58){
a.className=_57;
}else{
a.className="release";
}
}
};
PollEntry.prototype.setClick=function(_5a){
if(this.locked){
return;
}
this.clicked=_5a;
};
PollEntry.prototype.Lock=function(){
this.locked=true;
};
poll=new Poll();
poll.init();


