var Ajax;if(Ajax&&(Ajax!=null)){Ajax.Responders.register({onCreate:function(){if($("spinner")&&Ajax.activeRequestCount>0){Effect.Appear("spinner",{duration:0.5,queue:"end"})}},onComplete:function(){if($("spinner")&&Ajax.activeRequestCount==0){Effect.Fade("spinner",{duration:0.5,queue:"end"})}}})}String.prototype.unescapeHtml=function(){var b=document.createElement("div");b.innerHTML=this;var a=b.childNodes[0].nodeValue;b.removeChild(b.firstChild);return a};function deleter(a){switch(a.id){case"username":if(a.value=="Логин"){a.value=""}break;case"password":if(a.value=="Пароль"){a.value=""}break;case"name":if(a.value=="Имя"){a.value=""}break;case"mail":if(a.value=="е-Мейл"){a.value=""}break}}function inserter(a){switch(a.id){case"username":if(a.value==""){a.value="Логин"}break;case"password":if(a.value==""){a.value="Пароль";this.focus()}break;case"name":if(a.value==""){a.value="Имя"}break;case"mail":if(a.value==""){a.value="е-Мейл"}break}}function updateTable(b,c){if(b){var a=c;new Ajax.Request(a,{parameters:Object.extend({maxDate:b.maxDate,sort:"dateCreated",order:"desc",filter:"all"},b.customQueryString.toQueryParams()),onCreate:function(){if(b.loadingDialog){b.loadingDialog.show()}},onComplete:function(){if(b.loadingDialog){b.loadingDialog.hide()}},onSuccess:function(d){var f=d.responseJSON;if(f==null){condGtLogin(d);return}var e=f.results;if(e.size()>0){b.addRows(e,0);b._notFireRowSelectEvent=true;b.fireEvent("tableNotSelectFirstRow");b.maxDate=f.maxDate;updateCounters()}}})}}function condGtLogin(a){if(a.responseText.indexOf("location.pathname = ")>-1&&window.gtLogin){gtLogin()}}LoadingDialog=function(a,b){this.show=function(){$(a).hide();$(b).show()};this.hide=function(){$(b).hide();$(a).show()}};function initTable(b,a){if(a.idStatic&&a.idDynamic){b.loadingDialog=new LoadingDialog(a.idStatic,a.idDynamic)}var c=b.getDataSource();Object.extend(c.responseSchema.metaFields,{maxDate:"maxDate"});c.subscribe("responseParseEvent",function(e){var d=e.response.results;b.maxDate=e.response.meta.maxDate;if(d.size()>0){}else{if(a.onclickUpdateElem){$(a.onclickUpdateElem).update("")}}this.loadingDialog.hide()});c.subscribe("dataErrorEvent",function(d){condGtLogin(d.response)});b.subscribe("rowSelectEvent",function(d){var f=this.getState().selectedRows;if(f&&f.size()>0){this._selectedRowRecordIndexes=f.collect(function(h){return this.getRecordIndex(h)},this).findAll(function(h){return h!=null})}var g=d.record.getData().id;var e=this;new Ajax.Updater(a.onclickUpdateElem,a.onclickUpdateUrl,{asynchronous:false,evalScripts:true,parameters:{id:g},onComplete:function(){if(a.onComplete){updateRowValues(e,d.record,{id:g,_action_ajaxUpdateRowValue:"ajaxUpdateRowValue"})}}});if(d.record.getData().fresh){new Ajax.Request(a.markAsReadUri,{parameters:{id:g},onSuccess:function(j){var i=j.responseText.evalJSON().data;var h=e.getRecordIndex(d.record);e._notFireRowSelectEvent=true;e.updateRow(h,i)}})}});b.get("paginator").subscribe("changeRequest",function(){this._selectedRowRecordIndexes=null})}function getCurrentRecordId(a){return a.getRecordSet().getRecord(a.getLastSelectedRecord()).getData("id")}function startProgressBar(a){$(a+"_submit_btn").hide();$(a+"_progress_btn").show()}function stopProgressBar(a){$(a+"_submit_btn").show();$(a+"_progress_btn").hide()}function addTextFieldInput(d,c,b){d=$(d);var a=d.getInputs("text");var e=new Element("input",{type:"text",name:b,style:"width:200px; display:block;","class":"mail"});c=$(c);c.insert({bottom:e})}function tableSelectedRowKeepAlive(b,a){b.subscribe("tableRowDeleteEvent",function(){this._selectedRowRecordIndexes=null});b.subscribe("tableNotSelectFirstRow",function(){a=false});b.subscribe("renderEvent",function(){var c=this._selectedRowRecordIndexes;var e;if(c&&c.size()>0){var d=this.getRecord(c[0]);e=this.getTrEl(d)}if(e&&!b._notFireRowSelectEvent){this.selectRow(e)}else{if(a){this.selectRow(this.getFirstTrEl())}}});b.handleDataReturnPayload=function(d,c,e){this._notFireRowSelectEvent=false;e.totalRecords=c.meta.totalRecords;return e}}function getSelectedRowRecordIndexes(b){var c=b.getState().selectedRows;var a;if(c&&c.size()>0){b.unselectAllRows();a=c.collect(function(d){return b.getRecordIndex(d)},b).findAll(function(d){return d!=null})}return a}function deleteRowF(a){a.deleteRow(a.getLastSelectedRecord());a.fireEvent("tableRowDeleteEvent")}function getIdData(b){var a=b.getRecordSet().getRecord(b.getLastSelectedRecord());if(a!=null){return a.getData("id")}return null}function updateRowValues(e,b,d){var a=function(g,f,h){e.updateRow(b,f.results[0])};var c={success:a,failure:a,scope:e,argument:{}};e.getDataSource().sendRequest(Object.toQueryString(d),c);e._notFireRowSelectEvent=true;e.fireEvent("tableNotSelectFirstRow")}function stopPeriodicalExecuters(){if(window.buyerDetails){window.buyerDetails.stop();window.buyerDetails=null}if(window.peProposals){window.peProposals.stop();window.peProposals=null}}function textCounter(b,a,c){if($(b).value.length>c){$(b).value=$(b).value.substring(0,c)}else{$(a).value=c-$(b).value.length}}function checkOn(a){if(a.value=="бесплатно"){a.className="inpt_big fll";a.value="";a.style.color="#6a6a6a"}}function checkOff(a){if(a.value==""||a.value=="0"){a.className="inpt_big fll deliv";a.value="бесплатно";a.style.color="#909090"}};
