CX.Controls.BrowseProfiles=Class.create({initialize:function(c,a,d,b){this.element=$(c);
this.baseUrl=d;
this.listUrl=b||d;
this.browseBy=$("profBrowseBy");
this.onlyPhotos=$("profOnlyPhotos");
if(this.choices=a){this.questionSelect=$("filter_question");
this.questionText=$("filter_question_text");
this.answerSelect=$("like_answer");
this.questionRow=this.questionText.up("li");
this.answerRow=this.answerSelect.up("li");
Event.observe(this.questionSelect,"change",this.onQuestionChanged.bind(this));
Event.observe(this.answerSelect,"change",this.onAnswerChanged.bind(this));
}Event.observe(this.browseBy,"change",this.onBrowseByChanged.bind(this));
Event.observe(this.onlyPhotos,"click",this.onOnlyPhotosClicked.bind(this));
this.active=true;
},onOnlyPhotosClicked:function(){if(this.active){this.navigateTo({photos:$F(this.onlyPhotos)});
}},onBrowseByChanged:function(){if(this.active){this.navigateToList({browse:$F(this.browseBy)});
}},onQuestionChanged:function(){if(!this.active){return;
}var b=this.questionSelect,a=b.options[b.selectedIndex],d=null;
if(a.value&&a.value.length>0){d=this.choices[a.value];
}if(d&&d.length>0){var c=this.answerSelect;
this.questionText.update(a.text);
c.options.length=0;
c.options[c.options.length]=new Option("");
$A(d).each(function(f){c.options[c.options.length]=new Option(f,f);
});
this.questionRow.show();
this.answerRow.show();
}else{this.questionRow.hide();
this.answerRow.hide();
if(b.selectedIndex==0){this.navigateToList({},{clear_params:["filter[question]","like[answer]"]});
}}},onAnswerChanged:function(){if(!this.active){return;
}var a=$F(this.answerSelect);
if(a&&a.length>0){this.navigateToList({"filter[question]":$F(this.questionSelect),"like[answer]":a});
}},navigateTo:function(c,b,a){c=c||{};
c.page=c.page||1;
b=b||{};
b.ensure_hash_params=["filter","like","band"];
CX.navigateTo(a||this.baseUrl,c,b);
this.active=false;
},navigateToList:function(b,a){return this.navigateTo(b,a,this.listUrl);
}});
ASSET_MANIFEST=["/javascripts/cx/app/network.js"];
try{GLOBAL_ASSET_MANIFEST=GLOBAL_ASSET_MANIFEST.concat(ASSET_MANIFEST);
}catch(e){GLOBAL_ASSET_MANIFEST=ASSET_MANIFEST;
}
