function Ajax() {
  this.req = null;
  this.url = null;
  this.status = null;
  this.statusText = '';
  this.method = 'GET';
  this.async = true;
  this.dataPayload = null;
  this.readyState = null;
  this.responseText = null;
  this.responseXML = null;
  this.handleResp = null;
  this.responseFormat = 'text', // 'text', 'xml', 'object'
  this.mimeType = null;
  this.headers = [];

  
  this.init = function() {
    var i = 0;
    var reqTry = [ 
      function() { return new XMLHttpRequest(); },
      function() { return new ActiveXObject('Msxml2.XMLHTTP') },
      function() { return new ActiveXObject('Microsoft.XMLHTTP' )} ];
      
    while (!this.req && (i < reqTry.length)) {
      try { 
        this.req = reqTry[i++]();
      } 
      catch(e) {}
    }
    return true;
  };
  this.doGet = function(url, hand, format,id) {
    this.url = url;
    this.id = id;
    this.handleResp = hand;
    this.responseFormat = format || 'text';
    this.doReq(id);
  };
  this.doReq = function(id) {
    var self = null;
    var req = null;
    var headArr = [];
    
    if (!this.init()) {
      alert('Could not create XMLHttpRequest object.');
      return;
    }
    req = this.req;
    req.open(this.method, this.url, this.async);
    if (this.method == "POST") {
      this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
    self = this;
    req.onreadystatechange = function() {
      var resp = null;
      self.readyState = req.readyState;
      if (req.readyState == 4) {
        
        self.status = req.status;
        self.statusText = req.statusText;
        self.responseText = req.responseText;
        self.responseXML = req.responseXML;
        
        switch(self.responseFormat) {
          case 'text':
            resp = self.responseText;
            break;
          case 'xml':
            resp = self.responseXML;
            break;
          case 'object':
            resp = req;
            break;
        }
      self.handleResp(resp,id);
      }
    }
    req.send(this.dataPayload);
  };
  
}
function MsgDialogBox(id,zn)
{
 m_url="forma/?digit=status&id="+id+"&zn="+zn;
 var popup=window.open(m_url,'','toolbar=no,scrollbars=on,width=300, height=100, top=50, left=50, resizeable=no');
 popup.focus();
}
 var hand = function(str,r){
 window.document.getElementById('response_span_'+r).innerHTML=str;
}
 var hand_region = function(str,r){
//  alert('Íå áîëüøå 10000 òûñ.ðóá.'+str);
  window.document.getElementById('region_ajax_t').innerHTML=str;
}
  var hand00 = function(str){
  if(!str){document.add.T100.className=' ';document.getElementById('List1').style.display = 'none'; return;}
  frm = document.add.mySelect;
  ii=0;
  subar = str.split('^');
  si = subar.length;
  frm.length = si;
  for(i=0; i<si; i++)
  {
   subar1 = subar[i].split('~');
   subar2 = subar1[1].split(';');
   si2 = subar2.length;
   l='';
   for(i2=0; i2<si2; i2++)
   {
    m='';
    if(subar2[i2]=='&#3000')m=' ';
    if(subar2[i2]=='&#3001')m=',';
    if(subar2[i2]=='&#3002')m='-';
    if(subar2[i2]=='&#3003')m='.';
    if(subar2[i2]=='&#3004')m='/';
    if(subar2[i2]=='&#3005')m='/';
    if(subar2[i2]=='&#1040')m='À';
    if(subar2[i2]=='&#1041')m='Á';
    if(subar2[i2]=='&#1042')m='Â';
    if(subar2[i2]=='&#1043')m='Ã';
    if(subar2[i2]=='&#1044')m='Ä';
    if(subar2[i2]=='&#1045')m='Å';
    if(subar2[i2]=='&#1025')m='¨';
    if(subar2[i2]=='&#1046')m='Æ';
    if(subar2[i2]=='&#1047')m='Ç';
    if(subar2[i2]=='&#1048')m='È';
    if(subar2[i2]=='&#1049')m='É';
    if(subar2[i2]=='&#1050')m='Ê';
    if(subar2[i2]=='&#1051')m='Ë';
    if(subar2[i2]=='&#1052')m='Ì';
    if(subar2[i2]=='&#1053')m='Í';
    if(subar2[i2]=='&#1054')m='Î';
    if(subar2[i2]=='&#1055')m='Ï';
    if(subar2[i2]=='&#1056')m='Ð';
    if(subar2[i2]=='&#1057')m='Ñ';
    if(subar2[i2]=='&#1058')m='Ò';
    if(subar2[i2]=='&#1059')m='Ó';
    if(subar2[i2]=='&#1060')m='Ô';
    if(subar2[i2]=='&#1061')m='Õ';
    if(subar2[i2]=='&#1062')m='×';
    if(subar2[i2]=='&#1063')m='×';
    if(subar2[i2]=='&#1064')m='Ø';
    if(subar2[i2]=='&#1065')m='Ù';
    if(subar2[i2]=='&#1066')m='Ú';
    if(subar2[i2]=='&#1067')m='Û';
    if(subar2[i2]=='&#1068')m='Ü';
    if(subar2[i2]=='&#1069')m='Ý';
    if(subar2[i2]=='&#1070')m='Þ';
    if(subar2[i2]=='&#1071')m='ß';
    if(subar2[i2]=='&#1072')m='à';
    if(subar2[i2]=='&#1073')m='á';
    if(subar2[i2]=='&#1074')m='â';
    if(subar2[i2]=='&#1075')m='ã';
    if(subar2[i2]=='&#1076')m='ä';
    if(subar2[i2]=='&#1077')m='å';
    if(subar2[i2]=='&#1105')m='¸';
    if(subar2[i2]=='&#1078')m='æ';
    if(subar2[i2]=='&#1079')m='ç';
    if(subar2[i2]=='&#1080')m='è';
    if(subar2[i2]=='&#1081')m='é';
    if(subar2[i2]=='&#1082')m='ê';
    if(subar2[i2]=='&#1083')m='ë';
    if(subar2[i2]=='&#1084')m='ì';
    if(subar2[i2]=='&#1085')m='í';
    if(subar2[i2]=='&#1086')m='î';
    if(subar2[i2]=='&#1087')m='ï';
    if(subar2[i2]=='&#1088')m='ð';
    if(subar2[i2]=='&#1089')m='ñ';
    if(subar2[i2]=='&#1090')m='ò';
    if(subar2[i2]=='&#1091')m='ó';
    if(subar2[i2]=='&#1092')m='ô';
    if(subar2[i2]=='&#1093')m='õ';
    if(subar2[i2]=='&#1094')m='ö';
    if(subar2[i2]=='&#1095')m='÷';
    if(subar2[i2]=='&#1096')m='ø';
    if(subar2[i2]=='&#1097')m='ù';
    if(subar2[i2]=='&#1098')m='ú';
    if(subar2[i2]=='&#1099')m='û';
    if(subar2[i2]=='&#1100')m='ü';
    if(subar2[i2]=='&#1101')m='ý';
    if(subar2[i2]=='&#1102')m='þ';
    if(subar2[i2]=='&#1103')m='ÿ';
    if(m)l=l+m;
    else l=l+subar2[i2];
   }
   frm.options[i].text = l;
   frm.options[i].value = subar1[0];
  }
  frm.selectedIndex = 0;
  document.add.T100.className=' ';
}
 var hand01 = function(str,r){
  ii=0;
  subar = str.split('^');
  si = subar.length;
  frm.length = si;
  for(i=0; i<si; i++)
  {
   subar2 = subar[i].split(';');
   si2 = subar2.length;
   l='';
   for(i2=0; i2<si2; i2++)
   {
    m='';
    if(subar2[i2]=='&#3000')m=' ';
    if(subar2[i2]=='&#3001')m=',';
    if(subar2[i2]=='&#3002')m='-';
    if(subar2[i2]=='&#3003')m='.';
    if(subar2[i2]=='&#3004')m='/';
    if(subar2[i2]=='&#3005')m='/';
    if(subar2[i2]=='&#1040')m='À';
    if(subar2[i2]=='&#1041')m='Á';
    if(subar2[i2]=='&#1042')m='Â';
    if(subar2[i2]=='&#1043')m='Ã';
    if(subar2[i2]=='&#1044')m='Ä';
    if(subar2[i2]=='&#1045')m='Å';
    if(subar2[i2]=='&#1025')m='¨';
    if(subar2[i2]=='&#1046')m='Æ';
    if(subar2[i2]=='&#1047')m='Ç';
    if(subar2[i2]=='&#1048')m='È';
    if(subar2[i2]=='&#1049')m='É';
    if(subar2[i2]=='&#1050')m='Ê';
    if(subar2[i2]=='&#1051')m='Ë';
    if(subar2[i2]=='&#1052')m='Ì';
    if(subar2[i2]=='&#1053')m='Í';
    if(subar2[i2]=='&#1054')m='Î';
    if(subar2[i2]=='&#1055')m='Ï';
    if(subar2[i2]=='&#1056')m='Ð';
    if(subar2[i2]=='&#1057')m='Ñ';
    if(subar2[i2]=='&#1058')m='Ò';
    if(subar2[i2]=='&#1059')m='Ó';
    if(subar2[i2]=='&#1060')m='Ô';
    if(subar2[i2]=='&#1061')m='Õ';
    if(subar2[i2]=='&#1062')m='×';
    if(subar2[i2]=='&#1063')m='×';
    if(subar2[i2]=='&#1064')m='Ø';
    if(subar2[i2]=='&#1065')m='Ù';
    if(subar2[i2]=='&#1066')m='Ú';
    if(subar2[i2]=='&#1067')m='Û';
    if(subar2[i2]=='&#1068')m='Ü';
    if(subar2[i2]=='&#1069')m='Ý';
    if(subar2[i2]=='&#1070')m='Þ';
    if(subar2[i2]=='&#1071')m='ß';
    if(subar2[i2]=='&#1072')m='à';
    if(subar2[i2]=='&#1073')m='á';
    if(subar2[i2]=='&#1074')m='â';
    if(subar2[i2]=='&#1075')m='ã';
    if(subar2[i2]=='&#1076')m='ä';
    if(subar2[i2]=='&#1077')m='å';
    if(subar2[i2]=='&#1105')m='¸';
    if(subar2[i2]=='&#1078')m='æ';
    if(subar2[i2]=='&#1079')m='ç';
    if(subar2[i2]=='&#1080')m='è';
    if(subar2[i2]=='&#1081')m='é';
    if(subar2[i2]=='&#1082')m='ê';
    if(subar2[i2]=='&#1083')m='ë';
    if(subar2[i2]=='&#1084')m='ì';
    if(subar2[i2]=='&#1085')m='í';
    if(subar2[i2]=='&#1086')m='î';
    if(subar2[i2]=='&#1087')m='ï';
    if(subar2[i2]=='&#1088')m='ð';
    if(subar2[i2]=='&#1089')m='ñ';
    if(subar2[i2]=='&#1090')m='ò';
    if(subar2[i2]=='&#1091')m='ó';
    if(subar2[i2]=='&#1092')m='ô';
    if(subar2[i2]=='&#1093')m='õ';
    if(subar2[i2]=='&#1094')m='ö';
    if(subar2[i2]=='&#1095')m='÷';
    if(subar2[i2]=='&#1096')m='ø';
    if(subar2[i2]=='&#1097')m='ù';
    if(subar2[i2]=='&#1098')m='ú';
    if(subar2[i2]=='&#1099')m='û';
    if(subar2[i2]=='&#1100')m='ü';
    if(subar2[i2]=='&#1101')m='ý';
    if(subar2[i2]=='&#1102')m='þ';
    if(subar2[i2]=='&#1103')m='ÿ';
    if(m)l=l+m;
    else l=l+subar2[i2];
   }
  }
 window.document.add.C26.value=1;
}
function checkPageAct(id,zn,ad15,p1){
 var ajax = new Ajax();
 ajax.doGet('forma/?digit=blok_act&id='+id+'&zn='+zn+'&ad15='+ad15+'&p1='+p1,hand,'text',id);
}
function checkPageRank(id,zn){
 var ajax = new Ajax();
 ajax.doGet('forma/?digit=status&id='+id+'&zn='+zn,hand,'text',id);
}
function checkPageRanu(m3,zn){
 var ajax = new Ajax();
 ajax.doGet('forma/?digit=a5ballov&m3='+m3+'&zn='+zn,hand,'text',m3);
}
function checkstrit(zn){
 var ajax = new Ajax();
 ajax.doGet('../forma/?digit=checkstrit&zn='+zn,hand00,'text');
}

function cena_a(id,ad15,th)
{
 digits='-0123456789';
 len=th.value;
 var err=0;
 if(len > 10000)
 {
  alert('Íå áîëüøå 10000 òûñ.ðóá.');
  th.value='';
  err=1;
  th.focus();
 }
 if(len < -10000)
 {
  alert('Íå ìåíüøå -10000 òûñ.ðóá.');
  th.value='';
  err=1;
  th.focus();
 }
 for(i=0; i<6; i++)
 {
  if (digits.indexOf(th.value.charAt(i))<0)
  {
   alert('Ýòî äîëæíû áûòü öèôðû');
   th.value='';
   th.focus();
   err=1;
  }
 }
 if(err!=1)
 {
  ajax = new Ajax();
  ajax.doGet('forma/?digit=cena_n&id='+id+'&ad15='+ad15+'&zn='+th.value,hand00,'text');
 }
}
function act_d(id,ad15,zn)
{
 var ajax = new Ajax();
 ajax.doGet('forma/?digit=act_d&id='+id+'&zn='+zn+'&ad15='+ad15,hand,'text',id);
}
function NTh1 (event)
{
 if(document.activeElement.id=='y7')
 {
  if (!document.getElementById) return;
  if (window.event) event = window.event;
  var link = null;
  var key = event.keyCode;
  if (key==13)
  {
   document.add.mySelect.focus();
   return false; 
  }
  switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
  {
   case 0x28:
   document.add.mySelect.focus()
   break;
  }
 }
}
function city_dom(th)
{
// window.document.add.C26.value=th.value;
 var ajax = new Ajax();
// ajax.doGet('forma/?digit=city_dom,hand,'text',th.value);
 ajax.doGet('http://istok74.ru/www/php/?n=4&mn=grym&id='+th.value,hand01,'text');
}
function ChLipr(vt)
{
 if(window.document.add.D1.value==315) window.document.add.D1.value=202;
 window.document.add.D1_1.value=315;
 ChLi11(315);ChLi01(); 
}
function ChLiob(vt)
{
 if(window.document.add.D1.value==315) window.document.add.D1.value=202;
 if(window.document.add.D1_1.value==315) window.document.add.D1_1.value=202;
 ChLi11(0);ChLi01();
}
function ChLiku(vt)
{
 window.document.add.D1.value=315;
 if(window.document.add.D1_1.value==315) window.document.add.D1_1.value=202;
  ChLi11(0); ChLi01(315);
}

function ChLi70(vt){ChLi01(vt); ChLi3();}
function ChLi01(vt)
{
 if(vt==315 || vt==300) 
 {
  document.getElementById('st00').style.display = 'none';
  document.getElementById('st01').style.display = 'none';
  document.getElementById('st02').style.display = 'none';
  document.getElementById('st03').style.display = 'none';
  document.getElementById('st04').style.display = 'none';
  document.getElementById('st06').style.display = 'none';
  document.getElementById('st08').style.display = 'none';
 }
 else 
 {
  document.getElementById('st00').style.display = '';
  document.getElementById('st01').style.display = '';
  document.getElementById('st02').style.display = '';
  document.getElementById('st03').style.display = '';
  document.getElementById('st04').style.display = '';
  document.getElementById('st06').style.display = '';
  document.getElementById('st08').style.display = '';
 }
 if(vt==300) 
 {
  document.getElementById('st06').style.display = '';
 }
}
function ChLi1(vt){ ChLi11(vt); ChLi3();}
function ChLi11(vt)
{
 if(vt==315) document.getElementById('st07').style.display = 'none'; 
 else document.getElementById('st07').style.display = ''; 
}
function ChLi3()
{
 if(window.document.add.D1.value!=315 && window.document.add.D1_1.value!=315) document.add.R1[1].checked=true;
 if(window.document.add.D1.value==315 && window.document.add.D1_1.value==315) document.add.R1[1].checked=true;
 if(window.document.add.D1.value!=315 && window.document.add.D1_1.value==315) document.add.R1[0].checked=true;
 if(window.document.add.D1.value==315 && window.document.add.D1_1.value!=315) document.add.R1[2].checked=true;
}
function MDi(l)
{
 document.add.T2.value=l;
 document.getElementById('st0000').style.display = 'none';
}
function NTh(event)
{
 if(!document.getElementById) return;
 if(window.event) event = window.event;
 if(document.activeElement.id=='y7')
 {
  if(document.activeElement.value.length>1)
  {
   document.getElementById('List1').style.display = ''; 
   document.add.T100.className='ui';
   checkstrit(document.activeElement.value);
  }
  else document.getElementById('List1').style.display = 'none'; 
 }
 if(document.activeElement.id=='List1' && event.keyCode==13) {  odc(); }
}                                                 
function odc()
{
 document.add.T100.value=document.add.mySelect.options[document.add.mySelect.options.selectedIndex].text;
 document.add.T1.value=document.add.mySelect.options[document.add.mySelect.options.selectedIndex].value;
 document.getElementById('List1').style.display = 'none'; 
}                                                 
function odc1_0(red)
{
 if(document.getElementById(red+'_01_0').value.length>1)
 {
  document.getElementById('city_01_0').className='ui';
  check_ajax('city',document.getElementById(red+'_01_0').value,0,0);
 }
 else
 {
  document.getElementById(red+'_00').style.display = 'none';
 } 
}                                                 
function odc2_0(red,ncity,city)
{
 document.getElementById(red+'_00').style.display = 'none';
 document.add.Dncity_0.value=ncity;
 document.add.Dcity.value=city;
}                                                 
function odc3_0(red)
{
 var nn=document.getElementById('city_01_0').value.split(',');
//    document.add.Dncity_0.value=nn[0];
//      document.getElementById('city_01').className='ui';
  check_ajax('city',nn[0],1,0);
//    document.add.Dcity.value=subar1[0];
    ob2v = document.add.ob2.value.split('# ');
    
    var pattern = /#/;
  var result = pattern.exec(document.add.ob2.value); 
//  alert (result);


    if(!result) ob2v[1]=ob2v[0];
    if(document.add.Dncity_0.value!="Äðóãèå" && document.add.Dcity.value==1000)document.add.ob2.value=document.add.Dncity_0.value+'# '+ob2v[1];
    if(document.add.Dcity.value>0 && document.add.Dcity.value!=1000)document.add.ob2.value=ob2v[1];
}                                                 
// ---
function ttlOut()
{
	var div = ttlGetTooltipDiv();
	if(!div) return false;
	ttl_visible=false;
	if(ttl_ontimer) { clearTimeout(ttl_ontimer); ttl_ontimer=0; }
	ttl_offtimer=setTimeout("ttlHideTooltip()",ttl_offtimeout);
	return false;
}
function ttlOver(e,text,attrs)
{
	var div = ttlGetTooltipDiv();
	if(!div) return true;
	if (ttl_checkmousecapture) ttlMouseCapture(e);
	e = e || window.event;
	ttl_allowmove = e.type=='mousemove';
	var delay = e.type=='mouseover';
	if(!ttl_visible && (text!='' || ttl_showempty)) {
		ttlSetTooltipStyle(div,text,attrs);
		if(ttl_offtimer) { clearTimeout(ttl_offtimer); ttl_offtimer=0; }
		if(!delay) ttlShowTooltip(div)
		else {
			if(ttl_visible) ttlHideTooltip(div);
			ttl_visible=true;
			ttl_ontimer=setTimeout("ttlPopupTooltip()",ttl_ontimeout);
		}
	}
	return false;
}
function ttlPopupTooltip()
{
	var div=ttlGetTooltipDiv();
	if(!div) return;
	ttlShowTooltip(div);
	ttlPlaceTooltip(div);
}
function ttlMouseCapture(e) {
	capExtent = document;
	var fN, str = '', l, k, f, wMv, sS, mseHandler = ttlMouseMove;
	var re = /function[ ]*(\w*)\(/;
	
	wMv = (!ttl_Ie4 && window.onmousemove);
	if (document.onmousemove || wMv) {
		if (wMv) capExtent = window;
		f = capExtent.onmousemove.toString();
		fN = f.match(re);
		if (fN == null) {
			str = f+'(e); ';
		} else if (fN[1] == 'anonymous' || fN[1] == 'ttlMouseMove' || (wMv && fN[1] == 'onmousemove')) {
			if (!ttl_Op && wMv) {
				l = f.indexOf('{')+1;
				k = f.lastIndexOf('}');
				sS = f.substring(l,k);
				if ((l = sS.indexOf('(')) != -1) {
					sS = sS.substring(0,l).replace(/^\s+/,'').replace(/\s+$/,'');
					if (eval("typeof " + sS + " == 'undefined'")) window.onmousemove = null;
					else str = sS + '(e);';
				}
			}
			if (!str) {
				ttl_checkmousecapture = false;
				return;
			}
		} else {
			if (fN[1]) str = fN[1]+'(e); ';
			else {
				l = f.indexOf('{')+1;
				k = f.lastIndexOf('}');
				str = f.substring(l,k) + '\n';
			}
		}
		str += 'ttlMouseMove(e); ';
		mseHandler = new Function('e', str);
	}
	capExtent.onmousemove = mseHandler;
	var div = ttlGetTooltipDiv();
	if(!div) return;
	div.onmouseover = ttlTooltipOver;
	ttlMouseMove(e);
}
function ttlTooltipOver()
{
	if(ttl_offtimer) clearTimeout(ttl_offtimer);
	ttl_offtimer=0;
	ttl_hoveringswitch=1;
}
function ttlHideTooltip(div)
{
	if(!div) div=ttlGetTooltipDiv();
	if(!div) return;
	div.style.visibility = 'hidden';
	ttl_visible=false;
	if(ttl_offtimer) { clearTimeout(ttl_offtimer); ttl_offtimer=0; }
	ttl_allowmove=false;
}
function ttlShowTooltip(div)
{
	if(!div) div=ttlGetTooltipDiv();
	if(!div) return;
	ttlPlaceTooltip(div);
	div.style.visibility = 'visible';
	ttl_visible=true;
	if(ttl_offtimer) { clearTimeout(ttl_offtimer); ttl_offtimer=0; }
	if(ttl_ontimer) { clearTimeout(ttl_ontimer); ttl_ontimer=0; }
}
function ttlPlaceTooltip(div)
{
	if(!div) div=ttlGetTooltipDiv();
	if(!div) return false;
	var widthFix=0;
	if (self.innerWidth) widthFix=18; 
	var iwidth = ttlWindowWidth();
	var winoffset=(ttl_Ie4) ? eval('self.'+ttl_docRoot+'.scrollLeft') : self.pageXOffset;
	var iheight;
	if (self.innerHeight) {
		iheight=self.innerHeight;
	} else if (eval("typeof "+ttl_docRoot+".clientHeight=='number'")&&eval(ttl_docRoot+'.clientHeight')) { 
		iheight=eval(ttl_docRoot+'.clientHeight');
	}			

	// Vertical scroll offset
	var scrolloffset=(ttl_Ie4) ? eval(ttl_docRoot+'.scrollTop') : self.pageYOffset;
	var x=ttlPlaceHorizontal(div,ttl_x,iwidth,winoffset,widthFix);
	var y=ttlPlaceVertical(div,ttl_y,iheight,scrolloffset);
	div.style.left=x+'px';
	div.style.top=y+'px';
	return true;
}
function ttlPlaceVertical(div,y,winheight,winoffset)
{
	var divheight=div.style.height;
	if(!divheight) divheight = div.offsetHeight;
	// From mouse
	if (ttl_vpos == ABOVE) {
		y = y - (divheight+ttl_offsety);
		if (y<winoffset) y = winoffset;
	} else {
		// BELOW
		y = y+ttl_offsety;
	} 
	return y;
}
function ttlPlaceHorizontal(div,x,winwidth,winoffset,widthfix)
{

	var divwidth = parseInt(div.style.width,10);
	if(!divwidth) divwidth = div.offsetWidth;
	if(ttl_hpos == CENTER) { // Center
		x = x+ttl_offsetx-(divwidth/2);
		if (x < winoffset) x = winoffset;
		if((x+divwidth) > (winoffset+winwidth - widthfix)) {
			x = winwidth+winoffset - divwidth - widthfix;
			if(x<0) x=0;
		}
	}

	if(ttl_hpos == RIGHT) { // Right
		x = x+ttl_offsetx;
		if((x+divwidth) > (winoffset+winwidth - widthfix)) {
			x = winwidth+winoffset - divwidth - widthfix;
			if(x<0) x=0;
		}
	}
	if (ttl_hpos == LEFT) { // Left
		x = x-ttl_offsetx-divwidth;
		if(x<winoffset) x=winoffset;
	}
	return x;
}
// get Browser window width
function ttlWindowWidth() {
	var w;
	if (self.innerWidth) w=self.innerWidth;
	else if(eval("typeof "+ttl_docRoot+".clientWidth=='number'")) 
		w=eval(ttl_docRoot+'.clientWidth');
	return w;			
}

function ttlMouseMove(e)
{
	e = e || window.event;
	if(!e) return;
	if (e.pageX) {
		ttl_x = e.pageX;
		ttl_y = e.pageY;
	}
	else if (e.clientX) {
		ttl_x = eval('e.clientX + '+ttl_docRoot+'.scrollLeft');
		ttl_y = eval('e.clientY + '+ttl_docRoot+'.scrollTop');
	}
	if(ttl_visible && ttl_allowmove) ttlPlaceTooltip();
	if (ttl_hoveringswitch && ttlCursorOff()) {
		ttlHideTooltip();
		ttl_hoveringswitch = 0;
	}
}
function ttlCursorOff(div) {
	if(!div) div=ttlGetTooltipDiv();
	if(!div) return;
	var left = parseInt(div.style.left,10);
	var top = parseInt(div.style.top,10);
	var right = left + (parseInt(div.style.width,10) ? parseInt(div.style.width,10) : div.offsetWidth );
	var bottom = top + (parseInt(div.style.height,10) ? parseInt(div.style.height,10) : div.offsetHeight );
	if (ttl_x < left-1 || ttl_x > right+1 || ttl_y < top-1 || ttl_y > bottom+1) return true;
	return false;
}
function ttlSetTooltipStyle(div,text,attrs)
{
	if(!div) return false;
	if(!ttl_customdiv) {
		var color=ttl_color;
		var background=ttl_background;
		var width=ttl_width;
		var fontsize=ttl_fontsize;
		var fontname=ttl_fontname;
		var textalign=ttl_textalign;
		var opacity=ttl_opacity;

		if(attrs) {
			if(attrs.color) color=attrs.color;
			if(attrs.background) background=attrs.background;
			if(attrs.width!=undefined) width=attrs.width;
			if(attrs.fontsize) fontsize=attrs.fontsize;
			if(attrs.fontname) fontname=attrs.fontname;
			if(attrs.textalign) textalign=attrs.textalign;
			if(attrs.opacity!=undefined) opacity=attrs.opacity;
		}
		if(width) 
			if(width==parseInt(width,10)) {
				div.style.width=width+'px';
			} else {
				div.style.width=width;
			}
		else div.style.width='';
		var html='';
		if(ttl_rounded) {
			html+='<div style="margin:0px"><div style="margin:0px 1px;height:1px;overflow:hidden;font-size:1px;';
			if(background) html+='background:'+background+';';
			html+='"></div></div>';
		}
		html+='<div id="tooltipDivContent" style="padding:'+ttl_paddingy+' '+ttl_paddingx+';';
		if(background) html+='background:'+background+';';
		if(color) html+='color:'+color+';';
		if(fontsize) html+='font-size:'+fontsize+';';
		if(fontname) html+='font-family:'+fontname+';';
		if(textalign) html+='text-align:'+textalign+';';
		html+='"></div>';
		if(ttl_rounded) {
			html+='<div style="margin:0px"><div style="margin:0px 1px;height:1px;overflow:hidden;font-size:1px;';
			if(background) html+='background:'+background+';';
			html+='"></div></div>';
		}
		div.innerHTML=html;
		if(opacity!=undefined) { 
			div.style.opacity=opacity;
			div.style.filter='alpha(opacity='+(opacity*100)+')';
		}
	}
	var div = ttlGetById(ttl_innerdivid);
	if(!div) return false;
	if(attrs && attrs.copyfrom) {
		var source = ttlGetById(attrs.copyfrom);
		if(source) div.innerHTML=source.innerHTML;
	}
	else {
		if(text!=undefined) div.innerHTML=text;
	}
	return true;
}
function ttlGetTooltipDiv()
{
	var div = ttl_div;
	if(div) return div;
	div = ttlGetById(ttl_divid);
	if(div) return div;
	div=ttlCreateTooltipDiv();
	ttlSetTooltipStyle(div);
	return div;
}
function ttlCreateTooltipDiv()
{
	var div = document.createElement('DIV');
	div.setAttribute('id',ttl_divid);
	if(ttl_width) 
		if(ttl_width==parseInt(ttl_width,10)) {
			div.style.width=ttl_width+'px';
		} else {
			div.style.width=ttl_width;
		}
	else div.style.width='';
	div.style.overflow='hidden';
	div.style.position='absolute';
	div.style.zIndex=1000;
	div.style.top='0px';
	div.style.left='0px';
	div.style.visibility='hidden';
	document.body.appendChild(div);
	ttl_customdiv=false;
	ttl_div=div;
	return div;
}
// Capture the mouse and chain other scripts.

function ttlGetById(id)
{
	return ttl_Ie4?document.all[id]:document.getElementById(id);
}

// ---
function check_ajax(modul,p1,p2,p0)
{
 if(modul=='city') var url = '../forma/?digit=checkcity&zn='+p1+'&poz='+p2;
// if(modul=='tags') var url = '';
 if(modul=='tags') var url = '../forma/?digit=checktags&rub='+p1+'&digit_0='+p2;
 if(modul=='rub_digit') var url = '../forma/?digit=check_rub_digit&rub='+p1+'&digit_0='+p2+'&id='+p0;
 var post = '';
 var ajaxObj;
 if(window.XMLHttpRequest)ajaxObj = new XMLHttpRequest(); 
 else if(window.ActiveXObject) ajaxObj = new ActiveXObject("Microsoft.XMLHTTP");  
 else return; 
 ajaxObj.open ((post?'POST':'GET'), url);
 if (post&&ajaxObj.setRequestHeader)
 ajaxObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1251;");
 ajaxObj.onreadystatechange = ajaxCallBack(ajaxObj,modul,p0);
 ajaxObj.send(post); 
 return false;
} 
function ajaxCallBack(ajaxObj,modul,p0)
{
 return function()
 {
  if(modul=='rub_digit')
  {
   if(ajaxObj.readyState == 4)
   {
    if (ajaxObj.status==200) updateObj_rd(ajaxObj.responseText,modul,p0);
    else updateObj_rd(ajaxObj.status+' '+ajaxObj.statusText,modul,p0);
   }
  }
  else
  {
   if(ajaxObj.readyState == 4)
   {
    if (ajaxObj.status==200) updateObj(ajaxObj.responseText,modul,p0);
    else updateObj(ajaxObj.status+' '+ajaxObj.statusText,modul,p0);
   }
  }
 } 
}
function updateObj_rd(data,modul,p0)
{ 
}
function updateObj(data,modul,p0)
{ 
// var mk0='- !"#$%&"()*+,-./0123456789:;';
// var mk1='§¨©ª«¬ ®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
 var mk0='-| |!|"|#|$|%|&|"|(|)|*|+|,|-|.|/|0|1|2|3|4|5|6|7|8|9|:|;';
 var mk1='§|¨|©|ª|«|¬| |®|¯|°|±|²|³|´|µ|¶|·|¸|¹|º|»|¼|½|¾|¿|À|Á|Â|Ã|Ä|Å|Æ|Ç|È|É|Ê|Ë|Ì|Í|Î|Ï|Ð|Ñ|Ò|Ó|Ô|Õ|Ö|×|Ø|Ù|Ú|Û|Ü|Ý|Þ|ß|à|á|â|ã|ä|å|æ|ç|è|é|ê|ë|ì|í|î|ï|ð|ñ|ò|ó|ô|õ|ö|÷|ø|ù|ú|û|ü|ý|þ|ÿ';
 mk0 = mk0.split('|');
 mk1 = mk1.split('|');
 ii=0;
 var data1='';
 subar = data.split('^');
 if(modul=='city') document.getElementById('city_01_0').className='';
 if(modul=='tags') $selected1=' selected';
 if(!data)
 {
  if(modul=='city') document.getElementById('city_00').style.display = 'none'; 
  if(modul=='tags') document.getElementById('city_05').style.display = 'none'; 
  return;
 }
 else
 {
  if(modul=='city') document.getElementById('city_00').style.display = '';
  if(modul=='tags') document.getElementById('city_05').style.display = '';
 }
 si = subar.length;
 if(data)
 {
  for(i=0; i<si; i++)
  {
   subar1 = subar[i].split('~');
   subar2 = subar1[1].split(';');
   si2 = subar2.length;
   l='';
   for(i2=0; i2<si2; i2++)
   {
    m='';
    if(mk0[subar2[i2]-4000])m=mk0[subar2[i2]-4000];
    if(mk1[subar2[i2]-1025])m=mk1[subar2[i2]-1025];
    if(m)l=l+m;
    else l=l+subar2[i2];
   }
  if(modul=='city') 
  {
    document.add.Dcity.value=1000;
   if(si==1)
   {
    document.getElementById('city_00').style.display = 'none'; 
    document.add.Dncity_0.value=l;
    document.add.Dcity.value=subar1[0];
    document.add.Dregion.value=subar1[2];
   }
    data1 = data1+'<a href=\'#\' onMouseDown=\'odc2_0(\"city\",\"'+l+'\",\"'+subar1[0]+'\")\'>'+l+'</a><br>';
   }
    if(modul=='tags')
    {
     if(p0==subar1[0]){ $selected=' selected'; $selected1='';}
     else $selected='';
     data1 = data1+'<option value='+subar1[0]+$selected+'>'+l+'</option>';
    }
//alert(l);
  }
 }
 if(modul=='city') document.getElementById('city_04').innerHTML = data1;
 if(modul=='tags') document.getElementById('city_06').innerHTML = "<option value=0"+$selected1+">Âûáåðèòå ôðàçó</option>"+data1;
} 
// ---
function sale_add_tags(p0)
{
 var p1=window.document.add.Drub.value;
 var p2=window.document.add.Ddigit.value;
 if(p0+p1+p2)check_ajax('tags',p1,p2,p0);
}
// ---
function checkPageRank(rub,digit,id)
{
 if(document.getElementById('r_d_'+rub+'_'+digit).className=='s1') document.getElementById('r_d_'+rub+'_'+digit).className='s2';
 else document.getElementById('r_d_'+rub+'_'+digit).className='s1';
 check_ajax('rub_digit',rub,digit,id)
 // var ajax = new Ajax();
 // ajax.doGet('".$url_da."forma/?digit=status&id='+id+'&zn='+zn,hand,'text',id);
}

