//<!--
//\include\js\syi\CategoryController.js@@\main\3

function CategoryController(formName){this.form=eval("document."+formName);function __selectHandler(fieldIndex,maxDepth,menuObject,updateFieldName){var selectedValue=menuObject.options[menuObject.selectedIndex].value;if(typeof(selectedValue)!="undefined"&&selectedValue!=""){if(this.clearChildren(fieldIndex,maxDepth)){node=this.changeMenu(menuObject.name);this.updateField(updateFieldName,node);if(node&&node.instanceOf(node.TYPE_LEAF)){this.blockChildren(fieldIndex,maxDepth);}}}
else{menuObject.selectedIndex=-1;}}
this.selectHandler=__selectHandler;function __loadPage(pHasLeaf,pMetaNode,pLeafId,pLeafDepth,pMaxDepth,pStyle){if(pHasLeaf){this.reverseLoad(parseInt(pLeafId),true,0);this.blockChildren(parseInt(pLeafDepth)-1,parseInt(pMaxDepth));}
else{this.loadMenu('CategoryMenu1',pMetaNode.getChildren());}}
this.loadPage=__loadPage;function __loadMenu(menuName,nodes,selectedValue){var menu=eval("this.form."+menuName);var count=nodes.length;if(count>0){menu.length=count+1;if(typeof(menu.style)!="undefined"){menu.style.background="#fff";}
var text;for(var i=0;i<count;i++){node=nodes[i];text=node.getName()+node.getPointer();menu.options[i]=new Option(text,node.getId());if(selectedValue&&selectedValue==node.getId()){menu.options[i].selected="selected";}}
menu.options[menu.length-1]=new Option(blankText,blankValue);}}
this.loadMenu=__loadMenu;function __reverseLoad(nodeID,notLeaf,pFieldOffset){var CategoriesAsString=","+LeafCategories.toString()+",";if(notLeaf||CategoriesAsString.indexOf(","+nodeID+",")!=-1){var node=eval("n"+nodeID);var parent=node.parent;var countDown=node.getDepth()+(typeof(pFieldOffset)!="undefined"?pFieldOffset:0);this.loadMenu("CategoryMenu"+countDown,parent.getChildren(),node.getId());if(countDown>1){this.reverseLoad(parent.getId(),true,pFieldOffset);}}}
this.reverseLoad=__reverseLoad;function __changeMenu(fieldName){var field=eval("this.form."+fieldName);if(field.length<=1||field.selectedIndex==-1){return;}
var oValue=field.options[field.selectedIndex].value;if(oValue==null||oValue<=0){return;}
var nextField="CategoryMenu"+(new Number(fieldName.substring(fieldName.length-1,fieldName.length))+1);var chosenNode=eval("n"+oValue);if(chosenNode.instanceOf(chosenNode.TYPE_BRANCH)){this.loadMenu(nextField,chosenNode.getChildren());}
return chosenNode;}
this.changeMenu=__changeMenu;function __updateField(fieldName,node){if(node!=null){var field=eval("this.form."+fieldName);if(node.instanceOf(node.TYPE_LEAF)){field.value=node.getId();}
else{field.value="";}}
else{var field=eval("this.form."+fieldName);field.value="";}}
this.updateField=__updateField;function __switchMeta(field){this.form.ButtonLoad.value="Load";if(field!=null){field.value='';}
if(syiClientInfo.getOS()==syiClientInfo.OS_MAC){var btn_Back=syiForm.getForm().elements["ButtonBack"];var btn_Cancel=syiForm.getForm().elements["ButtonCancel"];if(btn_Back){btn_Back.name="ButtonRemoved";}
if(btn_Cancel){btn_Cancel.name="ButtonRemoved";}}
this.form.submit();}
this.switchMeta=__switchMeta;function __clearChildren(fieldIndex,maxDepth){var clicked=eval("this.form.CategoryMenu"+fieldIndex);for(var i=fieldIndex+1;i<maxDepth;i++){var menu=eval("this.form.CategoryMenu"+i);menu.length=0;if(menu.style){menu.style.background="#fff";}}
return true;return false;}
this.clearChildren=__clearChildren;function __blockChildren(fieldIndex,maxDepth){for(var i=fieldIndex+1;i<maxDepth;i++){var menu=eval("this.form.CategoryMenu"+i);menu.length=0;menu.options[0]=new Option("");menu.options[3]=new Option("   "+text_CategoryComplete01);menu.options[4]=new Option("   "+text_CategoryComplete02);if(menu.style){menu.style.background=blockedBG;}}}
this.blockChildren=__blockChildren;}
blankText="---------------------------------------------------------";blankValue="-1";blockedBG="rgb(220,220,220)";
// -->
