var request = false;
var can_ajax=true;

function create_ajax() 
{
 try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
   try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }
 }
create_ajax();  
if (!request){
    //  alert("Ошибка инициализации обьекта XMLHttpRequest!\n Просмотр страниц будет происходить в обычном режиме!");
	  can_ajax=false;
	}
preloadimages('/sourses/ajax.gif');
timerajax=null;
function gettingdate(url)
{       
     request.open("POST", url, true);	 
     request.onreadystatechange = updatePage;
	 timerajax=null;
     request.send('');
	 
}
var URL_tec='';
function GetContent(url)
{ 
  if (!hs.allowMultipleInstances) {
		try { hs.expanders[key - 1].close(); } catch (e){}
		try { hs.expanders[hs.focusKey].close(); } catch (e){} // preserved
	} 
 if(can_ajax)
  { 
	//alert(encodeURIComponent(url));
	//url = encodeURI(url);
   if(timerajax!=null) {clearTimeout(timerajax);}    
     dr=dURL;
	 dURL='http://moykimira.ru/'+url;	   
	 elements('content').align='center'; 	     	  
	 strok_='<img src="/sourses/indicator.black.gif" width="16" height="16"><font style="font-size:12px;"><b> ЗАГРУЗКА...</b></font>';
	 elements('content').innerHTML=strok_; 	
/*     URL_tec = escape(url);
	 unFocus.History.addHistory(escape(url));
	 url=escape(url);
*/
     URL_tec = url; // правка
	 unFocus.History.addHistory(url); // правка
	 
     timerajax=setTimeout('gettingdate("'+url+'")',100);     
  }
else
  {
    if(!request)
     {
       document.location=url; 
     }   
   }   
  return false;
}

function updatePage()
 {   
     if (request.readyState == 4) {       
       if (request.status == 200) {
         var response = request.responseText;
          elements('content').innerHTML=content(response)+liveinternet();  	
          elements('menu_').innerHTML=menu(response);	 
          top.document.title=pagetitle(response); 
                            		  
       } /*else  {
	   if((request.status == 504)||(request.status == 503)||(request.status == 502)||(request.status == 504))
	    {
		  if(timerajax==null) 
		    {timerajax=setTimeout('gettingdate("'+unescape(URL_tec)+'")',10000);}
		}
	   else
	    {
	     if(request.status==404){alert('Запрашиваемая страница не найдена');
		  } else {
		 if(request.status==403){alert('Доступ запрещен');
		 }else{
		 alert("Ошибка! server status is " + request.status);}
		 }
        } 
		
     }*/
	}
  }
  
function pagetitle(response)
{
str='<title>';
start=response.indexOf(str);
num1=start+str.length;
str='</title>';
fine=response.indexOf(str);
return response.substring(num1,fine);
}

function title(response)
{
str='<h1 id="title" style="color:yellow;text-transform:uppercase;font-size:21px;display:inline;">';
start=response.indexOf(str);
num1=start+str.length;
str='</h1>';
fine=response.indexOf(str);
return response.substring(num1,fine);
}

function menu(response)
{
str='<!-- menu -->';
start=response.indexOf(str);
num1=start+str.length;
str='<!-- /menu -->';
fine=response.indexOf(str);
return response.substring(num1,fine);
}

function content(response)
{
str='<!-- content ---->';
start=response.indexOf(str);
num1=start+str.length;
str='<!-- /content -->';
fine=response.indexOf(str);
return response.substring(num1,fine);
}

function parseUrl()
{
location_=document.location.hash;
num=location_.indexOf('#');
len=location_.length;
if(num==0){location_=location_.substring(1,len);}
location_=unescape(location_);
if(location_!=''){
/*	URL_tec=escape(location_);
	GetContent(location_); 
*/
	URL_tec=location_; // правка
	GetContent(location_); // правка
}
}

if(URL_tec==''){
mainDocument=document.location+'';
st_=mainDocument.lastIndexOf('/');
len=mainDocument.length
mainDocument=mainDocument.substring(st_,len);
}else{
mainDocument='/';
}
if(mainDocument==''){mainDocument='/';}
function URL_tec_()
{
return URL_tec;
}
function Listener() {
	this.historyListener = function(historyHash) {
	     f=unescape(historyHash+'');
		 if(f!=unescape(URL_tec_())){
		 if(f==''){GetContent(mainDocument);
		 }else{
		 GetContent(unescape(historyHash));
		 }
		}
	};
	unFocus.History.addEventListener('historyChange', this.historyListener);	
};

dr=document.referrer;
dURL=document.URL;

function liveinternet(){
str_="<div style='visibility:hidden'><a href='http://www.liveinternet.ru/click' "+
"target=_blank><img src='http://counter.yadro.ru/hit?t14.1;r"+escape(dr)+((typeof(screen)=="undefined")?"":
";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+";u"+escape(dURL)+
";"+Math.random()+"' alt='' title='LiveInternet: показано число просмотров за 24"+
" часа, посетителей за 24 часа и за сегодня' "+"border=0 width=88 height=31><\/a></div>";

return str_;
   }

