/* Copyright (C) 2007 - 2010 YOOtheme GmbH, YOOtheme License (http://www.yootheme.com/license) */

function selectZooItem(b,a,c){$(c+"_id").value=b;$(c+"_name").value=a;$("sbox-window").close()}
var ZooApplication=new Class({initialize:function(b){this.setOptions({element:null,url:null,msgSelectItem:"Select Item"},b);this.element=$(this.options.element);this.content_panel=null;$$("div.content").each(function(c){if(c.getElement("#"+this.options.element))this.content_panel=c}.bind(this));if(this.element){this.app=this.element.getElement("select.application");this.categories=this.element.getElement("div.categories");this.types=this.element.getElement("div.types");this.item=this.element.getElement("div.item");
var a=this.element.getElement("select.mode");if(a){this.mode=a.getProperty("value");a.addEvent("change",function(){this.mode=a.getProperty("value");this.setValues()}.bind(this))}else if(this.categories)this.mode="categories";else if(this.types)this.mode="types";else if(this.item)this.mode="item";this.setValues();this.app.addEvent("change",function(){this.setValues();if(this.item){this.item.getElement('input[type="hidden"]').setProperty("value","");this.item.getElement('input[type="text"]').setProperty("value",
this.options.msgSelectItem)}this.content_panel&&this.content_panel.setStyle("height","")}.bind(this))}},setValues:function(){var b=this.app.getProperty("value");if(this.categories){b&&this.mode=="categories"?this.categories.removeClass("hidden"):this.categories.addClass("hidden");this.element.getElements("select.category").each(function(a){if(a.hasClass("app-"+b)){a.removeClass("hidden");a.setProperty("name",a.getProperty("role"))}else{a.addClass("hidden");a.setProperty("name","")}})}if(this.types){b&&
this.mode=="types"?this.types.removeClass("hidden"):this.types.addClass("hidden");this.element.getElements("select.type").each(function(a){if(a.hasClass("app-"+b)){a.removeClass("hidden");a.setProperty("name",a.getProperty("role"))}else{a.addClass("hidden");a.setProperty("name","")}})}if(this.item){b&&this.mode=="item"?this.item.removeClass("hidden"):this.item.addClass("hidden");this.item.getElement("a").setProperty("href",this.options.url+"&app_id="+b)}}});ZooApplication.implement(new Options); 
