function clearSelect(b){b.childElements().each(function(d,c){if(c>0){d.remove()}})}var clearSelects=new Class.create();clearSelects.prototype={_selects:false,initialize:function(){this._selects=new Hash()},clearLower:function(b){clickedId=Event.element(b).readAttribute("id");topLevel=this._selects.get(clickedId);this._selects.each(function(c){if(c.value<topLevel){$(c.key).options.length=0;$(c.key).options[0]=new Option("-- wybierz --",0);$(c.key).fire("otx:fillSelectOnRequest")}})},add:function(b,c){this._selects.set(b,c);Event.observe(b,"change",this.clearLower.bind(this))}};var fillSelectOnRequest=new Class.create();fillSelectOnRequest.prototype={_select_element:false,_selectID:false,_sourceAddress:"/rpc/getParam.php",_showOther:false,_dontSelectSingleElement:false,call:function(b){this.requestAndFill(this._form_url(b))},initialize:function(b,c,d){this._selectID=b;if(!(this._select_element=$(b))){throw new Error('Brak elementu "'+b+'"')}if(d){this._showOther=d}if(c){this._dontSelectSingleElement=true}},requestAndFill:function(b){new Ajax.Request(b,{onSuccess:this._updateMe.bind(this)})},_form_url:function(b){return this._sourceAddress+"?pId="+this._selectID+"&id="+b.value},_updateMe:function(transport,optionsArray){optionsArray=eval(transport.responseText);this._select_element.options.length=0;a=new Object();a.id=0;if(window.location.hostname.match(/^en./)){a.n="-- choose --"}else{a.n="-- wybierz --"}this._addOption(a,-1);if(optionsArray.length==1){this._addOption(optionsArray.first(),0);if(!this._dontSelectSingleElement){this._select_element.selectedIndex=1}this._select_element.fire("otx:fillSelectOnRequest")}else{optionsArray.each(this._addOption.bind(this))}if(this._showOther){o=new Object();o.id="";if(window.location.hostname.match(/^en./)){o.n="other"}else{o.n=this._showOther==2?"inna":"inny"}this._addOption(o,optionsArray.length);if(optionsArray.length!=1){this._select_element.fire("otx:fillSelectOnRequest")}}},_addOption:function(b,c){this._select_element.options[c+1]=new Option(b.n.unescapeHTML(),b.id)}};function initAdvancedSearch(){function d(){if($F("objSearchInvestment_Country_ID")==1){$("objSearchInvestment_Province_ID").up("p").show();$("objSearchInvestment_District_ID").up("p").show();$("objSearchInvestment_ProvinceName").up("p").hide();$("objSearchInvestment_ProvinceName").value=""}else{$("objSearchInvestment_Province_ID").up("p").hide();$("objSearchInvestment_District_ID").up("p").hide();$("objSearchInvestment_ProvinceName").up("p").show();$("objSearchInvestment_Province_ID").value="0";if($("objSearchInvestment_District_ID")){clearSelect($("objSearchInvestment_District_ID"))}}}function c(){if($F("objSearchInvestment_adv_Country_ID")==1){$("objSearchInvestment_adv_Province_ID").up("p").show();$("objSearchInvestment_adv_District_ID").up("p").show();$("objSearchInvestment_adv_ProvinceName").up("p").hide();$("objSearchInvestment_adv_ProvinceName").value=""}else{$("objSearchInvestment_adv_Province_ID").up("p").hide();$("objSearchInvestment_adv_District_ID").up("p").hide();$("objSearchInvestment_adv_ProvinceName").up("p").show();$("objSearchInvestment_adv_Province_ID").value="0";if($("objSearchInvestment_adv_District_ID")){clearSelect($("objSearchInvestment_adv_District_ID"))}}}if($("objSearchInvestment_Country_ID")){$("objSearchInvestment_Country_ID").observe("change",d);document.observe("dom:loaded",d)}if($("objSearchInvestment_adv_Country_ID")){$("objSearchInvestment_adv_Country_ID").observe("change",c);document.observe("dom:loaded",d)}if($("objSearchInvestment_Province_ID")){Event.observe("objSearchInvestment_Province_ID","change",new fillSelectOnRequest("objSearchInvestment_District_ID"))}if($("objSearchInvestment_adv_Province_ID")){Event.observe("objSearchInvestment_adv_Province_ID","change",new fillSelectOnRequest("objSearchInvestment_adv_District_ID"))}function b(){if($F("objSearchQuery_Country_ID")==1){$("objSearchQuery_Province_ID").up("p").show()}else{$("objSearchQuery_Province_ID").up("p").hide()}}if($("objSearchQuery_Country_ID")){$("objSearchQuery_Country_ID").observe("change",b);document.observe("dom:loaded",b)}};
