var OrderInterface=new Class({initElements:function(){var suggest_options={url:$URL.ModPublic.onSubjectSuggest({}).options.url,list:subjects_list,suggest:{minLength:1,customChoices:$("suggest-subject-container"),delay:100,parentContainer:$("suggest-parent-container"),postVar:'letters',filterSubset:true}};this.element={title:new Field("order-title",this.dialog),type:new FieldSelect("order-type",this.dialog),language:new FieldSelect("order-language",this.dialog),subject:new FieldSuggest("order-subject",this.dialog,suggest_options),volume_from:new Field("order-volume-from",this.dialog),volume_to:new Field("order-volume-to",this.dialog),task:new Field("order-task",this.dialog),order_attache:new Field("order_attache",this.dialog)};this._initErrors();},_initErrors:function(){this.field("title").addError("CRuleNotEmpty").addRule(new CRuleNotEmpty("order-title"));this.field("subject").addError("CRuleNotEmpty").addRule(new CRuleNotEmpty("order-subject"));this.field("volume_from").addError("CRuleNumberFormat").addRule(new CRuleNumberFormat("order-volume-from"));this.field("volume_to").addError("CRuleNumberFormat").addRule(new CRuleNumberFormat("order-volume-to"));this.field("task").addError("CRuleValueLength").addRule(new CRuleValueLength("order-task",0,validate_json.task_max_length));this.field("order_attache").addError("CRuleFileMaxSize");this.field("order_attache").addError("CRuleMimeType");},_validate:function(){var result=this.validate();if($('order-volume-to-CRuleNumberFormat').visible()){$('order-volume-from-CRuleNumberFormat').show();}
if($('order-volume-from-CRuleNumberFormat').visible()){$('order-volume-to-CRuleNumberFormat').show();}
this.errors_visible=!result;return result;},checkDuplicateOrder:function(){var data={title:this.field("title").value(),subject:this.field("subject").value(),type:this.field("type").value()};var self=this;$URL.ModOrder.onCheckDuplicateOrder({data:data,onComplete:function(response){self.onCheckDuplicateOrder_cb(response);}}).send();},onCheckDuplicateOrder_cb:function(json){if(json.status=="OK"){return this.submitClick(true);}else{this.setDuplicateError(json);}},setDuplicateError:function(json){if(json.error==null){alert($Locale.ModOrder.ON_DUPLICATE_ORDER());return false;}
if(json.error.class_name==$E.ExAclDeny){$getInstance($Application).location("/");return false;}
if(json.error.class_name==$E.ExValidateFails){this.validate();return false;}}})