function ajax(nurl) 
{  this.url=nurl
   this.method='GET'
   this.data=''
   this.selfdestroy=false
   this.out_obj=null
   this.xmlHttp=null
   this.set_post=function(data){this.method='POST';this.data=data}
   this.set_get=function(){this.method='GET'}
   this.request=function(out_obj,url)
  {
   this.url=(url==null||url=='')?this.url:url
   this.out_obj=out_obj
   try
    {
    this.xmlHttp=new XMLHttpRequest()
    if (this.xmlHttp.overrideMimeType && this.method=='POST') this.xmlHttp.overrideMimeType('text/html')
    }
   catch (e)
    {
     var msv=["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]
     for(var j=0;j<=msv.length;j++)
      {
      try 
        { 
        this.xmlHttp=new ActiveXObject(msv[j])
        break
        } 
        catch(e){ } 
      } 
     if (!this.xmlHttp) return false    
    }
    var self = this
    this.xmlHttp.onreadystatechange=function()
    {if(self.xmlHttp.readyState==4)
        {
        if (typeof(show_div)=='function') show_div(self.out_obj,self.xmlHttp.responseText)
        if (self.selfdestroy && typeof(destroy)=='function') {self.xmlHttp=null;destroy()}
        }
    }
    if (this.method=="GET") 
      {this.xmlHttp.open("GET",this.url,true);this.xmlHttp.send(null)}
      else
      {
      this.xmlHttp.open("POST", this.url, true)
      this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
      this.xmlHttp.setRequestHeader("Content-length", this.data.length)
      this.xmlHttp.setRequestHeader("Connection", "close")
      this.xmlHttp.send(this.data)    
      }  
    return true
    }
}
function destroy(ajax)
{// free some resources
for(var k=0;k<ajax_reqs.length;k++) if(ajax_reqs[k].xmlHttp==null){ajax_reqs.splice(k--,1);continue} 
}

var path='/forall/ajax/'
//var path='ajax_files/'
var timeoutOff=850
var div_width=500
var bropacity="filter: alpha(opacity=30);-moz-opacity:0.3;opacity:0.3"
var ltxt="<div id='loader' class='loader'><b><center><img src='"+path+"loader.gif' width=9 height=9>..:Идет загрузка сообщения:..<img src='"+path+"loader.gif' width=9 height=9></center></b></div>"
var timeoutOn=1000
var enable_drag=true
var scl_arw=30
var scl_up=false
var scl_dn=false
var scl_timeout=30
var scl_step=10
var move_obj=true
var agt=navigator.userAgent.toLowerCase();
var is_ie=((agt.indexOf("msie") != -1) && !window.opera);
var overdiv=new Array()
var urls=new Array()
var initurls=new Array()
var dcache=new Array()
var url_names=new Array()
var ajax_reqs=new Array()
var aj_bug_url='topic.cgi?forum=13&topic=1777&glp#lt'
function show_div(id,data)
{
var obj=getById(id)
var div=getById('res'+id)
if (data!='') 
   { var cacheid=cache_id(getid2(id))
     if (!dcache[cacheid]) dcache[cacheid]=data
     enable_drag=str2bool(Get_Cookie("dragdrop"))
     data=data.replace(/(class='flright2'.*?>)/i,'$1'+control_panel('&nbsp;',id,'h'))
     var head=(/<!--head-->/i.test(data))?1:0
     var temp=/<!--clist='(\d+):(\d+)'-->/i.exec(data)
     if (temp!=null)
     {var nmax=parseInt(temp[2])+1
 	  var ncur=parseInt(temp[1])
      var left=(ncur!=1)?"<a href='#' onclick='return mgoto(1,"+ncur+",\""+id+"\")' title='К первому сообщению'>«&nbsp;</a><a href='#' onclick='return mgoto("+(ncur-1)+","+ncur+",\""+id+"\","+head+")' title='К предыдущему сообщению'>‹&nbsp;</a>":"«&nbsp;‹&nbsp;"
      var right=(ncur!=nmax)?"<a href='#' onclick='return mgoto("+(ncur+1)+","+ncur+",\""+id+"\","+head+","+nmax+")' title='К следующему сообщению'>&nbsp;›</a><a href='#' onclick='return mgoto("+nmax+","+ncur+",\""+id+"\","+head+","+nmax+")' title='К последнему сообщению'>&nbsp;»</a>":"&nbsp;›&nbsp;»"
      if (nmax>1) data=data.replace(/(class='flright2'.*?>)/i,'$1'+left+"<a href='#' onclick='return mgoto(1,-1,\""+id+"\")' title='К первоначальному сообщению'>"+ncur+"/"+nmax+"</a>"+right+"&nbsp;&nbsp;")
     } 
     data1=data.replace(/^<div.*?>/i,"<div class='obertka'>")
     div.innerHTML="<div class='shadow' style='"+bropacity+"'><span style='visibility:hidden'>"+data1+"</span></div>"+data
   }
var ws=getScrollXY()
var dx=getposOffset(obj,"left")
var dy=getposOffset(obj,"top")
var dh=div.clientHeight
dx=(dx+div_width<get_ww())?dx:get_ww()-div_width-30
dy=(dy+dh<ws[1]+get_wh())?dy+15:(dh>get_wh()?ws[1]+15:ws[1]+get_wh()-dh-10)
if (move_obj)
{
 div.style.left=dx+"px"
 div.style.top=dy+"px"
 div.style.visibility='visible'
 Drag.init(div)
 if (div.clientHeight>=get_wh()) attach_control(div)
} else 
  if (div.clientHeight+getposOffset(div,"top")>=get_wh()+ws[1]) attach_control(div)
hideselects(div)
}
function str2bool(str)   { return (str=='false')?false:true}
function pin_drag_and_drop()
{
var elems=document.getElementsByName('edit_pic')
enable_drag=(enable_drag)?false:true
for (var i=0;i<elems.length;i++)
if (enable_drag) {elems[i].src=path+'pin_on.gif'; elems[i].title='В режим копирования'}
            else {elems[i].src=path+'pin_off.gif'; elems[i].title='В режим перетаскивания'}
Set_Cookie("dragdrop",enable_drag)
}

function construct_url(url,num,head)
{
var divdr=20
var rtop=/topic=(\d+)/i
var rfor=/forum=(\d+)/i
var rurl=/(.*?\?)/i
var vtop=rtop.exec(url)
var vfor=rfor.exec(url)
var vurl=rurl.exec(url)
var vstart=Math.floor((num-1)/divdr)*divdr
var vanchor=num-vstart
if (head&&vstart) vanchor++
vanchor='#'+vanchor
vstart=vstart?'&start='+vstart:''
return vurl[1]+'forum='+vfor[1]+'&topic='+vtop[1]+((typeof(num)=='number')?vstart+vanchor:num)
}
function cache_id(id,num)
{
var url=urls[id]
var rtop=/topic=(\d+)/i
var rfor=/forum=(\d+)/i
var rstart=/start=(\d+)/i
var rnum=/#(\d+)/i
var rmore=/\Wm=(\d+)/i
var vtop=rtop.exec(url)
var vfor=rfor.exec(url)
var vstart=rstart.exec(url)
var vnum=rnum.exec(url)
var vmore=rmore.exec(url)
vmore=vmore?vmore[1]:''
vstart=vstart?parseInt(vstart[1]):0
vnum=vnum?parseInt(vnum[1]):0 
return vmore+':'+vfor[1]+':'+vtop[1]+':'+vstart+':'+vnum
}
function mgoto(num,cnum,id,head,nmax)
{nmax=typeof(nmax)!='number'?'':nmax
if (num<1 || (num>nmax && nmax!='') || num==cnum) return false;
if (cnum>0)
  urls[getid2(id)]=construct_url(urls[getid2(id)],num,head); 
  else urls[getid2(id)]=initurls[getid2(id)];
hideit(getById('sclres'+id))
move_obj=false
showtopic(id,getid2(id),true)
return false}
function control_panel(separator,id,type)
{
var pastxt=((type=='h')?"<a href='"+aj_bug_url+"' target=_blank><img style='cursor:pointer' width=12 height=12 src='"+path+"bug_rep.gif' alt='' border=0 title='Сообщить об ошибке ajax скрипта'></a>"+separator:"")+(getById('post')?'<img src="'+path+'paste.gif" width=12 height=11 style="cursor:pointer" onmouseover="copyQ()" onclick="pasteQ()" alt="" title="Вставить цитату">'+separator:'')
var txt=pastxt+((type=='h')?"<img style='cursor:pointer' src='"+path+"copy_url.gif' width=9 height=11 alt='' title='Скопировать URL' onclick='copy_url(\""+id+"\")'>"+separator:'')+"<img name='edit_pic' width=12 height=11 src='"+path+
    ((enable_drag)?"pin_on.gif' title='В режим копирования'":"pin_off.gif' title='В режим перетаскивания'")+" style='cursor:pointer' onclick='pin_drag_and_drop()' alt=''>"+separator+
    "<a href='#' onclick='return reply_open(event,this,\""+id+"\")' onmouseover='return reply_open(event,this,\""+id+"\")' name='current' title='Открыть'><img src='"+path+"same.gif' border=0 width=12 height=11 alt=''></a>"+separator+
    "<a href='#' onclick='return reply_open(event,this,\""+id+"\")' onmouseover='return reply_open(event,this,\""+id+"\")' name='new' title='В новом окне'><img src='"+path+"new.gif' border=0 width=12 height=11 alt=''></a>"
return txt
}
function copy_url(id)
{
var obj=getById('m'+id)
var obj2=getById('copy_url')
var obj3=(obj)?getElementByName(obj,'a','tname'):false
if (obj2 && obj3 && obj) 
  {obj2.value='[url='+obj3.href.replace(/http:\/\/.*?\//i,'')+']'+replace_entities(obj3.innerHTML)+'[/url]';obj2.style.top=getposOffset(obj,'top')+3+'px';
   obj2.style.left=getposOffset(obj,'left')+5+'px';obj2.style.width=div_width-10+'px';obj2.style.display='block'
   obj2.overid=id;obj2.focus();obj2.select()}
}
function getElementByName(obj,type,name)
{
var elems=obj.getElementsByTagName(type)
var i=0
for (var j=0;j<elems.length;j++) 
 if (elems[j].name==name) return elems[j]
return false
}
function reply_open(evt,obj,id)
{  
   var obj1=getById('m'+id)
   var obj2=(obj1)?getElementByName(obj1,'a','tname'):false
   evt = (evt) ? evt : (window.event) ? event : null
   if (evt.type=='mouseover') 
     if (evt.shiftKey)
       obj.title=(obj.name=='new')?'Ответить в новом окне':'Ответить'
      else
       obj.title=(obj.name=='new')?'В новом окне':'Открыть'
   if (evt.type=='click' && obj2)
     if (evt.shiftKey) 
      if (obj.name=='new') {obj.href=construct_reply_url(obj2.href); obj.target='_blank'}
         else {obj.href=construct_reply_url(obj2.href); obj.target='_top'}
       else
      if (obj.name=='current') {obj.href=obj2.href;obj.target='_top'}
         else {obj.href=obj2.href;obj.target='_blank'}
return true
}
function construct_reply_url(url)
{
var rurl=/(.*)\//i
var rtop=/topic=(\d+)/i
var rfor=/forum=(\d+)/i
var vtop=rtop.exec(url)
var vfor=rfor.exec(url)
var vurl=rurl.exec(url)
vurl=vurl?vurl[1]:''
return vurl+'/post.cgi?action=reply&forum='+vfor[1]+'&topic='+vtop[1]
}
function getid(obj)  {return obj.id.substring(3)}
function getid2(str) {return str.substring(3)}
function outq(obj)   {mout(obj.id)}
function overr(e)    {overdiv[getid(this)]=true}
function outr(e)     {if (!e) var e = window.event; if (checkIt('safari') || checkML(this,e)) mout(getid(this))}
function mout(id)    {overdiv[id]=false;setTimeout("resclear('"+id+"')",timeoutOff)}
function showt(obj,urlid,cache)
{overdiv[obj.id]=true;setTimeout("showtopic('"+obj.id+"','"+urlid+"',"+cache+")",timeoutOn)}
function checkIt(string)
{var detect=navigator.userAgent.toLowerCase();
 return detect.indexOf(string) + 1;}


function showtopic(id,urlid,cache)
{
if (!overdiv[id]) return
overdiv[id]=false
var obj=getById(id),exists=true,subobj=getById('res'+id)
var request="ajax_engine.cgi?fname=myfunc&url="+encodeURIComponent(urls[urlid])+"&id="+id+"&timeoff="+timeoff
var cachedata=(dcache[cache_id(getid2(id))])?dcache[cache_id(getid2(id))]:''
if (!subobj) 
  {
  subobj=document.createElement("div")
  subobj.id='res'+id
  subobj.onmouseover=overr
  subobj.onmouseout=outr
  subobj.className='content'
  subobj.innerHTML=ltxt
  document.body.appendChild(subobj)
  exists=false
  var  dx=getposOffset(obj,"left")
  dx=(dx+div_width<get_ww())?dx:get_ww()-div_width-30
  subobj.style.left=dx+"px"
  subobj.style.top=getposOffset(obj,"top")+15+"px"
  subobj.style.visibility='visible'
  }
if (!cache || cachedata=='') {exists=false;subobj.innerHTML=ltxt}
request+=is_ie?"&uni=1":""
request+="&fr="+page_info()
request+=(cache)?"":"&"+Math.random() 
if (!exists)
     {
     var l=ajax_reqs.length
     ajax_reqs[l]=new ajax(request)
     ajax_reqs[l].selfdestroy=true
     ajax_reqs[l].request(id)
     }  
  else 
     show_div(id,cachedata) 
}
// hide divs
function resclear(id)
{
 if (!overdiv[id])
  {move_obj=true
   var obj=getById('res'+id)
   if(window.opera)hideit(getById('m'+id))
   hideit(obj);hideselects(obj)
   hideit(getById('sclres'+id))
   hideit(getById('copy_url'),true)
  }                                   
}
function hideit(obj,type) {if (obj){if (type) obj.style.display='none'; else obj.style.visibility='hidden'}}
function containsDOM (container, containee)
{ var isParent = false
try {do {if ((isParent = container == containee)) break; containee = containee.parentNode;} while (containee != null)}
catch(e){}; return isParent} 
function checkME (element, evt)
{ if (element.contains && evt.fromElement) { return !element.contains(evt.fromElement); } else if (evt.relatedTarget) { return !containsDOM(element, evt.relatedTarget); } } 
function checkML (element, evt)
{ if (element.contains && evt.toElement) { return !element.contains(evt.toElement); } else if (evt.relatedTarget) { return !containsDOM(element, evt.relatedTarget); } }
function get_ww()
{var frameWidth=800;
if (self.innerWidth)
	frameWidth = self.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth)
	frameWidth = document.documentElement.clientWidth;
else if (document.body)
	frameWidth = document.body.clientWidth;
return frameWidth;
}
function get_wh()
{var frameHeight=640;
if (self.innerHeight)
	frameHeight = self.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)
	frameHeight = document.documentElement.clientHeight;
else if (document.body)
	frameHeight = document.body.clientHeight;
return frameHeight;
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
// attach scrollers
function attach_control(obj)
{
  if (!obj) return
  var resdiv=getById('scl'+obj.id)
  var temp=getById(getid2(obj.id))
  if (!resdiv) 
   {
    var separator="<span style='line-height: 5pt'><br><br></span>"
    resdiv=document.createElement("span")
    resdiv.id='scl'+obj.id
    resdiv.onmouseover=ctrl_over
    resdiv.onmouseout=ctrl_out
    document.body.appendChild(resdiv)
    set_style(resdiv,'position: absolute; background-color:#dedfdf; border-width: 1px; border-style: dotted')
    resdiv.innerHTML="<span style='cursor:pointer' onmouseover='scl_dn=true;scrolldown(\""+obj.id+"\")' onmouseout='scl_dn=false;mout(\""+getid2(obj.id)+"\")'><font size=+2>&#9650;</font></span><br><center>"+
    '<img src="'+path+'top.gif" style="cursor:pointer" alt="" width=12 height=13 title="Подать сюда шапку" onclick="line_header(\''+obj.id+'\')">'+separator+control_panel(separator,getid2(obj.id))+
    "</center><span style='cursor:pointer' onmouseover='scl_up=true;scrollup(\""+obj.id+"\")' onmouseout='scl_up=false;mout(\""+getid2(obj.id)+"\")'><font size=+2>&#9660;</font></span>";
   }
  var  dx=getposOffset(obj,"left");
  dx=(dx+div_width<get_ww())?dx-scl_arw:get_ww()-div_width-scl_arw
  resdiv.style.left=dx+"px"
  resdiv.style.top=move_obj?getposOffset(temp,"top")-scl_arw+"px":getposOffset(obj,"top")-scl_arw+"px"
  resdiv.style.visibility="visible"
}
function line_header(id) {getById(id).style.top=getposOffset(getById('scl'+id),"top")+scl_arw+"px"}
function ctrl_over(e) {overdiv[getid2(getid(this))]=true}
function ctrl_out(e)  {mout(getid2(getid(this)))}

function scrollup(id)
{if (scl_up) 
{var obj=getById(id)
var dy=getposOffset(obj,"top")
var ws=getScrollXY()
if (dy+obj.clientHeight>35+ws[1])
 {
 obj.style.top=dy-scl_step+'px'
 hideselects(obj)
 overdiv[getid2(id)]=true;setTimeout('scrollup("'+id+'")',scl_timeout)}
 } 
}
function scrolldown(id)
{if (scl_dn) 
{var obj=getById(id)
var dy=getposOffset(obj,"top")
var ws=getScrollXY()
if (dy<ws[1]+get_wh()-35)
 {
 obj.style.top=dy+scl_step+'px'
 hideselects(obj)
 overdiv[getid2(id)]=true;setTimeout('scrolldown("'+id+'")',scl_timeout)}
 }
}
// end of scrollers

//attach ajax to links and images
function attachL() 
{
if (!document.getElementById) return;
var url,cache=true,elems=new Array()
var symbs='<font size="-3">[?]</font>'
elems=getElementbyClass('pusto')
var myreg=/(<span\s+class=\"?small\"?.*<\/span>$)/i
var myregURL=/<a.*?href=\"(http:\/\/.*?\/)?(.*?)\".*?>(.*?)<\/a>/i
var myregURL2=/.*<a.*?href=\"(http:\/\/.*?\/)?(.*?)\".*?>(.*?)<\/a>/i
var temp
var count=0

page=(page_info()=='pr')?'to':page_info()

for (i=0;i<elems.length;i++) 
 { 
  elems[i].innerHTML=elems[i].innerHTML.replace(/\r?\n/mg,'')
  switch(page){
   case "bo":
	url=myregURL2.exec(elems[i].innerHTML);
  	if (url!=null)
  	if (url[2]!='' && url[2]!='undefined')
         {url_names[i]=s_str(url[3]);elems[i].innerHTML=elems[i].innerHTML.replace(/(<img.*?>)/i,"<span id='qst"+i+"' onclick=\"copylink(this,"+i+")\" onmouseout='outq(this)' onmouseover=\"this.style.cursor='pointer';showt(this,"+i+","+cache+")\">$1</span>")
         urls[i]=url[2]}
        else continue
   break;
   case "fo":
	url=myregURL.exec(elems[i].innerHTML);
  	if (url!=null)
  	if (url[2]!='' && url[2]!='undefined')
		{
		temp=getById('lst'+i)
		if (temp){url_names[count]=s_str(url[3]);urls[count]=construct_url(url[2],'&glp#lt');str="<span id='upd"+count+"' onclick=\"copylink(this,"+count+")\" onmouseout='outq(this)' onmouseover=\"showt(this,"+(count++)+","+cache+")\" class='flafter'>"+temp.innerHTML+"</span>";temp.innerHTML=str}
		temp=myreg.exec(elems[i].innerHTML)
		temp2=getById('str'+i)
		urls[count]=url[2]
		if(temp2){url_names[count]=s_str(url[3]);str="<span style='cursor:pointer' id='qst"+count+"' onclick=\"copylink(this,"+count+")\" onmouseout='outq(this)' onmouseover=\"showt(this,"+(count++)+","+cache+")\">"+temp2.innerHTML+"</span>";temp2.innerHTML=str}
		}
   break
   case "to":
	url=myregURL.exec(elems[i].innerHTML);
  	if (url!=null)
  	if (url[2]!='' && url[2]!='undefined')
		{url_names[i]=s_str(url[3]);str="&nbsp;<span id='qst"+i+"' onclick=\"copylink(this,"+i+")\" onmouseout='outq(this)' onmouseover=\"showt(this,"+i+","+cache+")\" class='flafter'>"+symbs+"</span>"
         elems[i].innerHTML=elems[i].innerHTML+str
         urls[i]=url[2].replace(/(.*#[a-z0-9]+).*/i,'$1')}
   break
   default:
   continue
   }
 }
for (i=0;i<urls.length;i++) initurls[i]=urls[i]
// add 'id' numbers to all <select>s
if (is_ie) 
 {var elems=document.getElementsByTagName("select")
  if (elems) for (i=0;i<elems.length;i++) elems[i].snum=i}
}

function copylink(obj,lnkid){
var x=getposOffset(obj,'left'),y=getposOffset(obj,'top'),old=getById('lnk_prompt')
if(!old)
 {var div=document.createElement('div')  
  div.id='lnk_prompt'
  set_style(div,'padding:4px;z-index:1001;position:absolute;background:#dddddd;cursor:pointer;text-align:center;border:#828282 solid 1px;visibility:hidden')
  div.innerHTML="<b><small>Скопируйте ссылку и потом щелкните тут</small></b><br><input type=text readonly size=40 id='lnk_data' value='url'>"
  div.onclick=function(evt){if(typeof qt=="object") qt.sel_started=false;this.style.visibility='hidden'}
  document.body.appendChild(div)
 } else div=old
var data=getById('lnk_data'),xr=x+div.clientWidth/2,xl=x-div.clientWidth/2  
data.value=replace_entities("[url="+urls[lnkid]+"]"+url_names[lnkid]+"[/url]").replace(/\\\'/g,"'") 
div.style.left=(get_ww()>xr+20?(xl<10?10:xl):get_ww()-20-div.clientWidth)+'px';div.style.top=y-div.clientHeight/2+'px'
div.style.visibility='visible'    
data.focus();data.select()
outq(obj)}
function s_str(str){return str.replace(/\\/g,'&amp;#92;').replace(/\r?\n/g,'').replace(/\"/g,'&quot;').replace(/\'/g,'\\\'').replace(/<\/?[^>]+>/g,'').replace(/\s{2,}/g,' ')}


function getElementbyClass(classname){  
var inc=0;  
var customc=new Array();  
var alltags=document.all? document.all : document.getElementsByTagName("*");  
for (i=0; i<alltags.length; i++){  
if (alltags[i].className==classname)  
customc[inc++]=alltags[i];  
} 
return customc;  
} 

function page_info()
{
var page=/.*\/(.{2,2}).*?\.cgi/i.exec(window.location.href);
if (page!=null)  return page[1];
 else return "bo";
}

var enable_drag=true
var Drag = {
	obj : null,
	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;
		hideselects(o)
		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;
		o.root = oRoot && oRoot != null ? oRoot : o ;
		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";
		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;
		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;
		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},
	start : function(e)
	{
 		if (!enable_drag) return
		var o = Drag.obj = this;
		e = Drag.fixE(e);
//	remove drag&drop for Opera middle button click
		if( typeof( e.which ) == 'number' && window.opera) {
		       if(e.which==2) return
    		} 		
        var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);
		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;
		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}
		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}
		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;
		return false;
	},
	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;
		hideselects(o)
		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;
		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);
		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)
		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;
        if (enable_drag)
         { var temp=getById('scl'+Drag.obj.id)
		if (temp) 
        {var ws=getScrollXY();
         temp.style.left=ws[0]+nx - scl_arw + 'px';
         temp.style.top=ws[1]+ey-scl_arw+'px';}
		}
	    temp=getById('copy_url')
		if (temp) temp.style.display='none'
		Drag.obj.root.onDrag(nx, ny);        
		return false;
	},
	end : function()
	{
		hideselects(Drag.obj)
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},
	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
}
function hideselects(o)
{
if(!is_ie||!o) return
var elems=document.getElementsByTagName("select")
if(!elems) return
var ieFix = hitTest(o, elems)
  for(var i = 0; i<elems.length; i++)
  {var hit=false;
	for (var j=0; j<ieFix.length;j++)
	if (ieFix[j].snum==elems[i].snum&&o.style.visibility!='hidden') {ieFix[j].style.visibility="hidden"; hit=true}
  	if (!hit) elems[i].style.visibility="visible";
  }
}
hitTest = function(o, l){
    function getOffset(o){
        for(var r = {l: o.offsetLeft, t: o.offsetTop, r: o.offsetWidth, b: o.offsetHeight};
            o = o.offsetParent; r.l += o.offsetLeft, r.t += o.offsetTop);
	    r.r+=r.l; r.b+=r.t; r.l-=8; r.t-=8;
        return r
    }
    for(var b, s, r = [], a = getOffset(o), j = isNaN(l.length), i = (j ? l = [l] : l).length; i;
        b = getOffset(l[--i]), (a.l == b.l || (a.l > b.l ? a.l <= b.r : b.l <= a.r))
        && (a.t == b.t || (a.t > b.t ? a.t <= b.b : b.t <= a.b)) && (r[r.length] = l[i]));
    return j ? !!r.length : r
}
document.write('<input type=text onmouseover="overdiv[this.overid]=true" onmouseout="mout(this.overid)" onclick="this.style.display=\'none\'" readonly id="copy_url" class="copyurl">')
attachL()
var ajax_loaded=true
//
var els=document.getElementsByTagName('textarea')
if(els)for(var i=0;i<els.length;i++)
{var img=document.createElement('img'),img2=document.createElement('img')
 img2.src=path+"lock_open.gif"
 img.src=path+"resize.gif"
 set_style(img,'position:relative;top:7px;left:-9px;cursor:se-resize')
 set_style(img2,'display:none;position:relative;top:8px;left:-3px;cursor:pointer')
 img.title='Изменить размер поля'
 img2.onclick=function(){fix_textar_size(this)}
 img2._status=false;img2.title='Фиксировать размер'
 var el=els[i],szs=Get_Cookie('ta_sz_'+el.name)
 el.parentNode.insertBefore(img,els[i].nextSibling)
 el.parentNode.insertBefore(img2,img.nextSibling)
 if(szs&&(szs=szs.split(':'))!=null)
  {img2.style.display='';img2._status=false;el.style.width=(img2._w=szs[0])+'px';el.style.height=(img2._h=szs[1])+'px';fix_textar_size(img2)}
 //el.parentNode.style.whiteSpace="nowrap"
 img.onmousedown=function(){
    document.onmousemove=function(ev){resize_textar(el,ev);return false}
    document.onmouseup=function(){document.onmousemove=null;document.onmouseup=null}
    return false}
}
function resize_textar(obj,e)
{e=get_e(e),ws=getScrollXY()
 var w=e.clientX-getposOffset(obj,'left'),h=e.clientY-getposOffset(obj,'top')+ws[1]
 if(w>50)obj.style.width=w+'px';if(h>50)obj.style.height=h+'px'
 obj2=obj.nextSibling.nextSibling;if(obj2.style.display=='none')obj2.style.display='';obj2._w=w;obj2._h=h
 if(obj2._status)Set_Cookie('ta_sz_'+obj.name,w+':'+h,31)}
function fix_textar_size(t)
{var ta=t.previousSibling.previousSibling.name
 if(!t._status){t.title='Снять фиксацию размера';t._status=true;t.src=path+"lock.gif";Set_Cookie('ta_sz_'+ta,t._w+':'+t._h,31)}
 else{t._status=false;t.src=path+"lock_open.gif";t.title='Фиксировать размер';Set_Cookie('ta_sz_'+ta,0,-1)}}