/**
 * Copyright (c) 2009 Really Helsinki Oy, All rights reserved.
 */
//>>built
ReallyProductQuery=function(_1){this.formId=_1.form;this.widgetId=_1.target;this.resultsId=_1.results;this.loadingId=_1.loading;this.updateFields=_1.updateFields;this.init();};ReallyProductQuery.prototype={};ReallyProductQuery.prototype.init=function(){this.initElements();};ReallyProductQuery.prototype.reset=function(){this.ignoreChanges=true;this._values={"do":"reset"};this.refresh();delete this.ignoreChanges;return (false);};ReallyProductQuery.prototype.initElements=function(){this.formElement=ReallyHtml.byId(this.formId);var _2="file|submit|image|button|reset|";var _3=this.formElement.elements;for(var _4=0;_4<_3.length;_4++){var e=_3.item(_4);if(!e||!e.type||!e.name){continue;}var _5=e.name;var _6=(e.type||"").toLowerCase();if(_2.indexOf(_6)!=-1){continue;}if(_6=="radio"||_6=="checkbox"){ReallyEvent.addDomListener(e,"click",ReallyEvent.callback(this,function(_7){this.onChange(_7);},_5));}else{ReallyEvent.addDomListener(e,"change",ReallyEvent.callback(this,function(_8){this.onChange(_8);},_5));}}};ReallyProductQuery.prototype.onChange=function(_9){if(this.ignoreChanges){return;}this._values=ReallyXhr.getFormValues(this.formElement);this.refresh();};ReallyProductQuery.prototype.refresh=function(){if(this.xhr){this.xhr.cancel();delete this.xhr;}this.onLoadingBegin();this._values["method"]="update";this._values["target"]=this.widgetId;var _a=this.formElement.getAttributeNode("action");var _b=(_a?_a.value:null);this.xhr=ReallyXhr.get({url:_b,content:this._values,load:ReallyEvent.callback(this,"_handleResponse")});};ReallyProductQuery.prototype._handleResponse=function(_c){if(this.xhr){delete this.xhr;}try{var _d=ReallyHtml.byId(this.resultsId);if(_d){ReallyHtml.replace(_c,_d);}}catch(e){}this.initElements();this.onLoadingEnd();};ReallyProductQuery.prototype.onLoadingBegin=function(){if(this.loadingId){var e=ReallyHtml.byId(this.loadingId);if(e){e.style.visibility="visible";}}};ReallyProductQuery.prototype.onLoadingEnd=function(){if(this.loadingId){var e=ReallyHtml.byId(this.loadingId);if(e){e.style.visibility="hidden";}}};
