function decode_string(coded_string){var out;out='';for(k in coded_string){out+='&#'+(255-coded_string[k])+';';}
return out;}
function isValidEmail(email){return(/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);}
function check_comments_form(form_id,is_registered){var err;err='';form_obj=document.getElementById(form_id);if(!is_registered){if(document.getElementById('username_warning').innerHTML!=''){err+='Это имя уже занято!\n';}
if(form_obj.nickname.value==''){err+='Введите имя!\n';}
if(!isValidEmail(form_obj.email.value)){err+='Введите правильный e-mail!\n';}}
if(form_obj.comment_text.value==''){err+='Введите текст комментария!\n';}
if(err!=''){window.alert(err);return false;}
return true;}
function our_common_ajax_processor(object_link,is_inner,ajax_data,loading_callback,url){var req=new Subsys_JsHttpRequest_Js();req.onreadystatechange=function(){if((req.readyState==4)||(req.readyState=="complete")){if(req.responseJS){if(is_inner){object_link.innerHTML=req.responseJS.out;}else{object_link.innerHTML='';object_link.outerHTML=req.responseJS.out;}}}
if(typeof loading_callback!='undefined'&&loading_callback.length>0){var fn=window[loading_callback];if(typeof fn=='function'){fn(object_link,is_inner,req);}}}
req.caching=true;req.open('POST',(typeof url).toLowerCase()=='string'?url:'http://www.drom.ru/process_ajax_request.php',true);if(ajax_data){req.send(ajax_data);}}
function post_our_email(email,text,what_event){if(what_event!='onMouseOver')
what_event='onClick';if(email[1]&&email[2]){document.write('<span '+what_event+'="our_common_ajax_processor(this, true, { \'mode\' : \'get_email\', \'m1\' : \''+email[0]+'\', \'m2\' : \''+email[1]+'\', \'m3\' : \''+email[2]+'\' }); return false;"><a href="mailto:">'+text+'</a></span>');}else if(email[0]){document.write('<span '+what_event+'="our_common_ajax_processor(this, true, { \'mode\' : \'get_email\', \'m1\' : \''+email[0]+'\' }); return false;"><a href="mailto:">'+text+'</a></span>');}}
function post_email(email,text,what_event){if(what_event!='onMouseOver')
what_event='onClick';if(email[1]&&email[2]){document.write('<span '+what_event+'="our_common_ajax_processor(this, true, { \'mode\' : \'get_email\', \'m1\' : \''+email[0]+'\', \'m2\' : \''+email[1]+'\', \'m3\' : \''+email[2]+'\' }); return false;"><a href="mailto:">'+text+'</a></span>');}else if(email[0]){document.write('<span '+what_event+'="our_common_ajax_processor(this, true, { \'mode\' : \'get_email\', \'m1\' : \''+email[0]+'\' }); return false;"><a href="mailto:">'+text+'</a></span>');}}
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+
this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}
return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=Base64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;}}
function Subsys_JsHttpRequest_Js(){this._construct()}
(function(){var COUNT=0;var PENDING={};var CACHE={};Subsys_JsHttpRequest_Js.dataReady=function(id,text,js){var undef;var th=PENDING[id];delete PENDING[id];if(th){delete th._xmlReq;if(th.caching)CACHE[th.hash]=[text,js];th._dataReady(text,js);}else if(typeof(th)!=typeof(undef)){alert("ScriptLoader: unknown pending id: "+id);}}
Subsys_JsHttpRequest_Js.prototype={onreadystatechange:null,readyState:0,responseText:null,responseXML:null,status:200,statusText:"OK",session_name:"PHPSESSID",responseJS:null,caching:false,_span:null,_id:null,_xmlReq:null,_openArg:null,_reqHeaders:null,dummy:function(){},abort:function(){if(this._xmlReq)return this._xmlReq.abort();if(this._span){this.readyState=0;if(this.onreadystatechange)this.onreadystatechange();this._cleanupScript();}},open:function(method,url,asyncFlag,username,password){this._openArg={'method':method,'url':url,'asyncFlag':asyncFlag,'username':username,'password':password};this._id=null;this._xmlReq=null;this._reqHeaders=[];return true;},send:function(content){var id=(new Date().getTime())+""+COUNT++;var query=this._hash2query(content);var url=this._openArg.url;var sid=this._getSid();if(sid)url+=(url.indexOf('?')>=0?'&':'?')+this.session_name+"="+this.escape(sid);var hash=this.hash=url+'?'+query;if(this.caching&&CACHE[hash]){var c=CACHE[hash];this._dataReady(c[0],c[1]);return false;}
this._xmlReq=this._obtainXmlReq(id,url);var hasSetHeader=this._xmlReq&&(window.ActiveXObject||this._xmlReq.setRequestHeader);var href,body;if(this._xmlReq&&hasSetHeader&&(""+this._openArg.method).toUpperCase()=="POST"){this._openArg.method="POST";href=url;body=query;}else{this._openArg.method="GET";href=url+(url.indexOf('?')>=0?'&':'?')+query;body=null;}
href=href+(href.indexOf('?')>=0?'&':'?')+id;PENDING[id]=this;if(this._xmlReq){var a=this._openArg;this._xmlReq.open(a.method,href+"-xml",a.asyncFlag,a.username,a.password);if(hasSetHeader){for(var i=0;i<this._reqHeaders.length;i++)
this._xmlReq.setRequestHeader(this._reqHeaders[i][0],this._reqHeaders[i][1]);this._xmlReq.setRequestHeader('Content-Type','application/octet-stream');}
return this._xmlReq.send(body);}else{this._obtainScript(id,href);return true;}},getAllResponseHeaders:function(){if(this._xmlReq)return this._xmlReq.getAllResponseHeaders();return'';},getResponseHeader:function(label){if(this._xmlReq)return this._xmlReq.getResponseHeader(label);return'';},setRequestHeader:function(label,value){this._reqHeaders[this._reqHeaders.length]=[label,value];},_construct:function(){},_dataReady:function(text,js){with(this){if(text!==null||js!==null){readyState=4;responseText=responseXML=text;responseJS=js;}else{readyState=0;responseText=responseXML=responseJS=null;}
if(onreadystatechange)onreadystatechange();_cleanupScript();}},_obtainXmlReq:function(id,url){if(url.match(new RegExp('^[a-z]+://','i')))return null;var req=null;if(window.XMLHttpRequest){try{req=new XMLHttpRequest()}catch(e){}}else if(window.ActiveXObject){try{req=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}
if(!req)try{req=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}}
if(req){var th=this;req.onreadystatechange=function(){var s=req.readyState;if(s==4){req.onreadystatechange=th.dummy;var responseText=req.responseText;try{eval(responseText);}catch(e){Subsys_JsHttpRequest_Js.dataReady(id,"JavaScript code generated by backend is invalid!\n"+responseText,null);}}else{th.readyState=s;if(th.onreadystatechange)th.onreadystatechange()}};this._id=id;}
return req;},_obtainScript:function(id,href){with(document){var span=null;with(document){var span=null;span=body.appendChild(createElement("SPAN"));span.innerHTML='text for ie';span.appendChild(createElement("SCRIPT"));span.style.display='none';setTimeout(function(){var s=span.getElementsByTagName("script")[0];s.type='text/javascript';if(s.setAttribute){s.setAttribute('src',href);}else{s.src=href;}},10);}
this._id=id;this._span=span;}},_cleanupScript:function(){var span=this._span;if(span){this._span=null;setTimeout(function(){span.parentNode.removeChild(span);},50);}
return false;},_hash2query:function(content,prefix){if(prefix==null)prefix="";var query=[];if(content instanceof Object){for(var k in content){var v=content[k];if(v==null||((v.constructor||{}).prototype||{})[k])continue;var curPrefix=prefix?prefix+'['+this.escape(k)+']':this.escape(k);if(v instanceof Object)
query[query.length]=this._hash2query(v,curPrefix);else
query[query.length]=curPrefix+"="+this.escape(v);}}else{query=[content];}
return query.join('&');},_getSid:function(){var m=document.location.search.match(new RegExp('[&?]'+this.session_name+'=([^&?]*)'));var sid=null;if(m){sid=m[1];}else{var m=document.cookie.match(new RegExp(s='(;|^)\\s*'+this.session_name+'=([^;]*)'));if(m)sid=m[2];}
return sid;},escape:function(s){return escape(s).replace(new RegExp('\\+','g'),'%2B');}}})();
