function SelectZone(){this.filters=new Object();this.id=arguments[0]?arguments[0]:1;this.sourceSel=arguments[1]?arguments[1]:null;this.targetSel=arguments[2]?arguments[2]:null;this.priceObj=arguments[3]?arguments[3]:null;this.filename=location.href.substring((location.href.lastIndexOf("/"))+1,location.href.lastIndexOf("?"))+"?is_ajax=1";var a=this;this.loadOptions=function(b,c){Ajax.call(this.filename+"&act="+b,c,this.loadOptionsResponse,"GET","JSON")};this.loadOptionsResponse=function(c,b){if(!c.error){a.createOptions(a.sourceSel,c.content)}if(c.message.length>0){alert(c.message)}return};this.check=function(){if(!this.sourceSel){alert("source select undefined");return false}else{if(this.sourceSel.nodeName!="SELECT"){alert("source select is not SELECT");return false}}if(!this.targetSel){alert("target select undefined");return false}else{if(this.targetSel.nodeName!="SELECT"){alert("target select is not SELECT");return false}}if(this.id==2&&!this.priceObj){alert("price obj undefined");return false}return true};this.addItem=function(h,b){if(!this.check()){return}var f=new Array();for(var e=0;e<this.sourceSel.length;e++){if(!this.sourceSel.options[e].selected&&h==false){continue}if(this.targetSel.length>0){var g=false;for(var d=0;d<this.targetSel.length;d++){if(this.targetSel.options[d].value==this.sourceSel.options[e].value){g=true;break}}if(!g){f[f.length]=this.sourceSel.options[e].value}}else{f[f.length]=this.sourceSel.options[e].value}}if(f.length>0){var c=new Array();for(var e=2;e<arguments.length;e++){c[c.length]=arguments[e]}Ajax.call(this.filename+"&act="+b+"&add_ids="+$.toJSON(f),c,this.addRemoveItemResponse,"GET","JSON")}};this.dropItem=function(f,c){if(!this.check()){return}var b=new Array();for(var e=this.targetSel.length-1;e>=0;e--){if(this.targetSel.options[e].selected||f){b[b.length]=this.targetSel.options[e].value}}if(b.length>0){var d=new Array();for(var e=2;e<arguments.length;e++){d[d.length]=arguments[e]}Ajax.call(this.filename+"&act="+c+"&drop_ids="+$.toJSON(b),d,this.addRemoveItemResponse,"GET","JSON")}};this.addRemoveItemResponse=function(c,b){if(!c.error){a.createOptions(a.targetSel,c.content)}if(c.message.length>0){alert(c.message)}};this.createOptions=function(e,b){e.length=0;for(var d=0;d<b.length;d++){var c=document.createElement("OPTION");c.value=b[d].value;c.text=b[d].text;c.id=b[d].data;e.options.add(c)}}};
