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

window.relateditems={};function selectRelateditem(a,c,b){document.getElementById("sbox-window").close();window.relateditems[b].addItem(a,c)}
var ElementRelateditems=new Class({initialize:function(a,c){this.setOptions({variable:null,msgDeleteItem:"Delete Item",msgSortItem:"Sort Item"},c);this.list=$(a).getElement("ul");this.list.getElements("li").each(function(b){b.getElement("div.item-delete").addEvent("click",function(){this.deleteItem(b)}.bind(this))}.bind(this));this.sort=new SortableList({handle:"div.item-sort",opacity:0.5});this.sort.addList(this.list)},addItem:function(a,c){var b=false;this.list.getElements("li input").each(function(e){if(e.getProperty("value")==
a)b=true});if(!b){var d=new Element("li");d.setHTML('<div class="item-name">'+c+'</div><div class="item-sort" title="'+this.options.msgSortItem+'"></div><div class="item-delete" title="'+this.options.msgDeleteItem+'"></div><input type="hidden" name="'+this.options.variable+'" value="'+a+'"/>');d.injectInside(this.list).getElement("div.item-delete").addEvent("click",function(){this.deleteItem(d)}.bind(this));this.sort.addItems(new Array(d))}},deleteItem:function(a){this.sort.removeItems(new Array(a));
a.effects({duration:100,transition:Fx.Transitions.linear}).start({height:0,opacity:0}).chain(function(){a.remove()})}});ElementRelateditems.implement(new Options); 
