
function FleischRecBuilder(pPage,pInst,pSelCont,pRecCont,pCatId)
{
this.page=pPage;
this.instanceName=pInst;
this.selContainer=pSelCont;
this.recContainer=pRecCont;
this.cats=Buffer.getRefByCollection("FleischCategorias");
this.setCategoriasFleisch(pCatId);
}
FleischRecBuilder.prototype.setCategoriasFleisch=function(pCatId)
{
if(this.cats==-1) {
this.selContainer.innerHTML="&nbsp;";
return;
}
if (!pCatId) {
pCatId=-1;
}
var index=-1;
var sel=0;
var i,str='<select id="'+this.page+'SelRecFleischmann" class="caption" style="width:180px;" onChange="'+this.instanceName+'.setRecipeList(this.selectedIndex);">';
for(i=0;i<this.cats.length;i++){
if (CATEGORIA_PADRAO.toLowerCase()==this.cats[i].name.toLowerCase()) {
sel=i;
}
if (pCatId==this.cats[i].id) {
index=i;
}
str+='<option value="'+this.cats[i].id+'"'+(i==0 ? 'selected' : '')+'>'+this.cats[i].name;
}
str+='</select>';
this.selContainer.innerHTML=str;
if (pCatId!=-1 && index==-1) {
for (var i=0;i<this.cats.length;i++) {
for(j=0;j<this.cats[i].subCats.length;j++) {
if (this.cats[i].subCats[j].id==pCatId) {
index=this.cats.length-1;
}
}
}
}
if (index!=-1) {
sel=index;
}
try{
window[this.page+'SelRecFleischmann'].selectedIndex=sel;
this.setRecipeList(sel);
}catch(e){}
}
FleischRecBuilder.prototype.setRecipeList=function(pInd)
{
var novaReceita = 60;
var i,str='';
if (pInd>-1) {
for(i=0;i<this.cats[pInd].subCats.length;i++) {
str+='<p style="font-family:Arial;font-size:11px;"><b>'
+this.cats[pInd].subCats[i].name+'</b></p>';
for(j=0;j<this.cats[pInd].subCats[i].receitas.length;j++) {
str+='<p style="text-indent:-10px;padding-left:10px;">'
+'•&nbsp;<a style="color:#000000;" href="javascript:control(\'ctrl\',\'open\',[\'recF\',['+this.cats[pInd].subCats[i].receitas[j].id+'],[\'\',\''+this.cats[pInd].id+'\']]);" class="text">'
+this.cats[pInd].subCats[i].receitas[j].name+'</a>';
if (this.cats[pInd].subCats[i].receitas[j].desc < novaReceita) {
str+='<img src="../imagens/new4.gif" style="margin:0 2px -2px 5px;"> ';
}
}
}
}
this.recContainer.innerHTML=str;
}
