function dle_ajax(a){this.AjaxFailedAlert="AJAX not supported.\n";this.requestFile=a;this.method="POST";this.URLString="";this.encodeURIString=true;this.execute=false;this.add_html=false;this.loading_fired=0;this.centerdiv=null;this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onShow=function(a){if(!this.loading_fired){this.loading_fired=1;if(a){document.getElementById("loading-layer-text").innerHTML=a}this.centerdiv=new center_div;this.centerdiv.divname="loading-layer";this.centerdiv.move_div()}return};this.onHide=function(){try{if(this.centerdiv&&this.centerdiv.divobj){this.centerdiv.clear_div()}}catch(a){}this.loading_fired=0;return};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(a){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){this.xmlhttp=null}}if(!this.xmlhttp&&typeof XMLHttpRequest!="undefined")this.xmlhttp=new XMLHttpRequest;if(!this.xmlhttp){this.failed=true}};this.setVar=function(a,b){if(this.URLString.length<3){this.URLString=a+"="+b}else{this.URLString+="&"+a+"="+b}};this.encVar=function(a,b){var c=encodeURIComponent(a)+"="+encodeURIComponent(b);return c};this.encodeURLString=function(a){varArray=a.split("&");for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(urlVars[0].indexOf("amp;")!=-1){urlVars[0]=urlVars[0].substring(4)}varArray[i]=this.encVar(urlVars[0],urlVars[1])}return varArray.join("&")};this.encodeVAR=function(a){a=a.toString();var b=a.match(/[\x90-\xFF]/g);if(b){for(var c=0;c<c.length;c++){a=a.replace(b[c],"%u00"+(b[c].charCodeAt(0)&255).toString(16).toUpperCase())}}return escape(a).replace(/\+/g,"%2B")};this.runResponse=function(){var a=new Date;var b=false;a=a.getTime();var c=/<script.*?>(.|[\r\n])*?<\/script>/ig;var d=c.exec(this.response);if(d!=null){var e=new Array(d.shift());var b=true;while(d){d=c.exec(this.response);if(d!=null)e.push(d.shift())}for(var f=0;f<e.length;f++){this.response=this.response.replace(e[f],'<span id="'+a+f+'" style="display:none;"></span>')}}if(this.add_html){this.elementObj.innerHTML+=this.response}else{this.elementObj.innerHTML=this.response}if(b){var g=/<script.*?>((.|[\r\n])*?)<\/script>/ig;for(f=0;f<e.length;f++){var h=document.getElementById(a+""+f);var i=h.parentNode;i.removeChild(h);g.lastIndex=0;var j=g.exec(e[f]);var k=i.appendChild(document.createElement("script"));k.text=j[1];var l=e[f].substring(e[f].indexOf(" ",0),e[f].indexOf(">",0));var m=l.split(" ");if(m.length>1){for(var n=0;n<m.length;n++){if(m[n].length>0){var o=m[n].split("=");o[1]=o[1].substr(1,o[1].length-2);k.setAttribute(o[0],o[1])}}}}}};this.sendAJAX=function(a){this.responseStatus=new Array(2);if(this.failed&&this.AjaxFailedAlert){alert(this.AjaxFailedAlert)}else{if(a){if(this.URLString.length){this.URLString=this.URLString+"&"+a}else{this.URLString=a}}if(this.encodeURIString){var b=(new Date).getTime();this.URLString=this.encodeURLString(this.URLString);this.setVar("rndval",b)}if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var c=this;if(this.method=="GET"){var d=this.requestFile+"?"+this.URLString;this.xmlhttp.open(this.method,d,true)}else{this.xmlhttp.open(this.method,this.requestFile,true)}if(this.method=="POST"){try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.send(this.URLString);this.xmlhttp.onreadystatechange=function(){switch(c.xmlhttp.readyState){case 1:c.onLoading();break;case 2:c.onLoaded();break;case 3:c.onInteractive();break;case 4:c.response=c.xmlhttp.responseText;c.responseXML=c.xmlhttp.responseXML;c.responseStatus[0]=c.xmlhttp.status;c.responseStatus[1]=c.xmlhttp.statusText;c.onHide();c.onCompletion();if(c.elementObj){var a=c.elementObj.nodeName;a=a.toLowerCase();if(a=="input"||a=="select"||a=="option"||a=="textarea"){if(c.response=="error"){alert("Доступ отклонен")}else{if(c.add_html){c.elementObj.value+=c.response}else{c.elementObj.value=c.response}}}else{if(c.response=="error"){alert("Доступ отклонен")}else{if(c.execute){c.runResponse()}else{if(c.add_html){c.elementObj.innerHTML+=c.response}else{c.elementObj.innerHTML=c.response}}}}}c.URLString="";break}}}}};this.createAJAX()}function ajax_cancel_showcomm(a){document.getElementById("nn"+a).innerHTML="";return false}function ShowCommf(a,b,c){var d=new dle_ajax;d.onShow("");var e="n_id="+a;d.setVar("action",b);d.setVar("page",c);d.setVar("skin",dle_skin);d.requestFile=dle_root+"engine/ajax/files/shcommf.php";d.method="GET";d.element="nn"+a;d.sendAJAX(e);d.onCompletion=function(){$("#navhide").hide();$("#commentsh").hide()};return false}function ShowCommg(a,b,c){var d=new dle_ajax;d.onShow("");var e="n_id="+a;d.setVar("action",b);d.setVar("page",c);d.setVar("skin",dle_skin);d.requestFile=dle_root+"engine/gallery/ajax/shcommg.php";d.method="GET";d.element="nn"+a;d.sendAJAX(e);d.onCompletion=function(){$("#navhide").hide();$("#commentsh").hide()};return false}function ShowComm(a,b,c,d,e){var f=new dle_ajax;f.onShow("");var g="n_id="+a;f.setVar("action",b);f.setVar("page",e);f.setVar("shortlink",c);f.setVar("altname",d);f.setVar("skin",dle_skin);f.requestFile=dle_root+"engine/ajax/shcomm.php";f.method="GET";f.element="nn"+a;f.sendAJAX(g);f.onCompletion=function(){$("#navhide").hide();$("#commentsh").hide()};return false}function center_div(){this.divname="";this.divobj=""}function _get_obj_toppos(a){var b=a.offsetTop;while((a=a.offsetParent)!=null){b+=a.offsetTop}return b}function hideBusyLayer(){var a=document.getElementById("busy_layer");if(a!=null){a.style.visibility="hidden";a.style.height="0px"}}function showBusyLayer(){var a=document.getElementById("busy_layer");if(window.innerHeight&&window.scrollMaxY){yScroll=window.innerHeight+window.scrollMaxY;var b=document.documentElement;var c=b&&b.clientHeight||document.body.clientHeight||window.innerHeight||self.innerHeight;yScroll-=window.innerHeight-c}else if(document.body.scrollHeight>document.body.offsetHeight||document.body.scrollWidth>document.body.offsetWidth){yScroll=document.body.scrollHeight}else{yScroll=document.body.offsetHeight}if(a!=null){a.style.visibility="visible";a.style.height=yScroll}}center_div.prototype.clear_div=function(){try{if(!this.divobj){return}else{this.divobj.style.display="none"}}catch(a){return}};center_div.prototype.Ywindow=function(){var a=0;if(document.documentElement&&document.documentElement.scrollTop){a=document.documentElement.scrollTop}else if(document.body&&document.body.scrollTop){a=document.body.scrollTop}else if(window.pageYOffset){a=window.pageYOffset}else if(window.scrollY){a=window.scrollY}return a};center_div.prototype.move_div=function(){try{this.divobj=document.getElementById(this.divname)}catch(a){return}var b=0;var c=0;if(typeof window.innerWidth=="number"){b=window.innerWidth;c=window.innerHeight}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){b=document.documentElement.clientWidth;c=document.documentElement.clientHeight}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){b=document.body.clientWidth;c=document.body.clientHeight}this.divobj.style.position="absolute";this.divobj.style.display="block";this.divobj.style.zIndex=99;var d=parseInt(this.divobj.style.Height);var e=parseInt(this.divobj.style.Width);d=d?d:50;e=e?e:200;var f=this.Ywindow();var g=(b-e)/2;var h=(c-d)/2+f;g=g<0?0:g;h=h<0?0:h;this.divobj.style.left=g+"px";this.divobj.style.top=h+"px"};
