	var decodeText=false;	
	if(typeof(activeImage) == "undefined") var activeImage='<br><img src="/sisim/ajax_active.gif">';
	if(typeof(verboseMode) == "unefine") var verboseMode=true;
	if(typeof(allwaysHidde) == "undefined") var allwaysHidde=false;
	if(typeof(ajaxHeigh) == "undefined") var ajaxHeigh=22;
	if(typeof(ajaxWidth) == "undefined") var ajaxWidth=126;

	function getEl(el){
		if(document.getElementById){
			return document.getElementById(el);
		} else {
			return document.all[el];
		}
	}
	
  function findPos(coord, obj)
  {
	var curleft = 0;
    if (obj.offsetParent){
    	while (obj.offsetParent && obj.tagName != "BODY"){
	        	if (coord == 'x') {curleft += obj.offsetLeft}
    	        else {curleft += obj.offsetTop}
        	   	obj = obj.offsetParent;
    		}
    } else if (obj.coord) curleft += obj.coord;
	return curleft;
  }

    function regObject(){
        // Try to use built-in loaders.
        var req = null;
        if (window.XMLHttpRequest){
            try {  
            	req=new XMLHttpRequest(); // Opera Firefox (может новые IE)
            } catch(e) {}
        } else if (window.ActiveXObject) {
            try { 
            	req=new ActiveXObject("Microsoft.XMLHTTP"); // Експлорер 5.0
            	decodeText=true;
            } catch(e) {}
            if(!req){
            	try { 
            		req=new ActiveXObject("Msxml2.XMLHTTP");
            	} catch (e) {}
            }
        }

        return req;
    }

	function ajaxFormProceed(frmObj,url,name){
		var postdata='';
		
		for(var i=0;i<frmObj.length;i++){
			if(frmObj[i].type=='text' || frmObj[i].type=='textarea' || frmObj[i].type=='hidden'){
				postdata+="&"+frmObj[i].name+"="+escape(frmObj[i].value);
			} else if(frmObj[i].type=='select'){
				postdata+="&"+frmObj[i].name+"="+escape(frmObj[i].options[frmObj[i].selectedIndex].value);
			} else if(frmObj[i].type=='checkbox' || frmObj[i].type=='radio'){
				if(frmObj[i].checked==true){
					postdata+="&"+frmObj[i].name+"="+escape(frmObj[i].value);
				}
			} else {
				postdata+="&"+frmObj[i].name+"="+escape(frmObj[i].value);
			}
		}

		ldr(url,name,postdata);
	}
	
	Array.from = function(ar){ 
      var result = new Array();
      for (var i = 0; i < ar.length; i++)
        result.push(ar[i]);
      return result;
    }
	
	function parseScript(src){
		// save
        document.__write = document.write;
        document.__writeln = document.writeln;
        
        // override
        var writeBuffer  = new Array();
        document.write   = function(value){ writeBuffer.push(value) };
        document.writeln = function(value){ document.write(value + '\n') };

        // do script
        try {
          var scripts = Array.from(src.getElementsByTagName('script'));
         
          for(var i = 0; i < scripts.length; i++)
          {
            var script = scripts[i];
            // eval code
            eval(script.text);
            // if document.write calls writeBuffer will be not empty
            if (writeBuffer.length)
            { 
              // insert HTML
              var tmp = document.createElement('DIV');                  
              tmp.innerHTML = writeBuffer.join('');
              parseScript(tmp);
              var childs = Array.from(tmp.childNodes);
              for (var j = 0; j < childs.length; j++)
                script.parentNode.insertBefore(childs[j], script);
              script.parentNode.removeChild(script);
              // clear buffer
              writeBuffer.length = 0;
            }
          }
        } catch(e) {  }

        // restore
       	document.write = document.__write;
       	document.writeln = document.__writeln;
	}
	
    function ldr(query,name,postdata,infoOnMe){
    	var lod=regObject();
    	
    	if(name==null) var infoPanel='info';
    	else var infoPanel=name;
    	
    	// pokazat' kartinku na objecte
    	if(infoOnMe != null){
    		var obj = document.getElementById(infoOnMe);
    		
    		if(obj != null){
    			img = document.createElement('div');
    			img.innerHTML = activeImage;
    			img.id='divAjaxLoaderImg';
    			img.style.position = 'absolute';
    			img.style.display = 'block';
				img.style.zIndex = 10000001;
    			img.style.top = findPos('y',obj) + ((parseInt(obj.style.height)/2) - ajaxHeight) + 'px';
    			img.style.left = findPos('x',obj) + ((parseInt(obj.style.width)/2) - ajaxWidth) + 'px';
    			obj.appendChild(img);
   			}
    	}
    	
        lod.onreadystatechange = function(){
        	if(lod.readyState==4){
        		if(lod.status==200){
        			// Показывать ли текст
        			if(verboseMode==true) var txtInfo="Готово";
        			else var txtInfo='';
        			
        			if(infoOnMe == null){
	        			if(allwaysHidde==false) showInfo(txtInfo+activeImage,false,infoPanel);
        			}

                    var responseText=lod.responseText;
                    try {
                           // Call associated dataReady().
                           eval(responseText);    
                           
                           // Need to destroy img ajax loader
                           if(infoOnMe != null && obj!=null){                  
                           	obj.removeChild(document.getElementById('divAjaxLoaderImg'));
                           }
                    } catch (e) {
                    	if(infoOnMe == null){
                          if(allwaysHidde==false)  showInfo("Error",null,infoPanel);
                        }
                    }
	        	} else {
	        		if(infoOnMe == null){
	        			if(allwaysHidde==false) showInfo('Info not loaded: '+lod.statusText,null,infoPanel);
        			}
	        	}
        	} else {
        		switch (lod.readyState){
        			case 0:
	        			// Показывать ли текст
	        			if(verboseMode==true) var txtInfo='Идет загрузка...';
	        			else var txtInfo='';
	        		
	        			if(infoOnMe == null){
        					if(allwaysHidde==false) showInfo(txtInfo+activeImage,null,infoPanel);
       					}
        				break;
        			case 1:
        				// Показывать ли текст
	        			if(verboseMode==true) var txtInfo='Идет загрузка...';
	        			else var txtInfo='';
	        			
	        			if(infoOnMe == null){
        					if(allwaysHidde==false) showInfo(txtInfo+activeImage,null,infoPanel);
       					}
       					
        				break;
        			case 2:
        				// Показывать ли текст
	        			if(verboseMode==true) var txtInfo='Информация загружена. Идет обработка.';
	        			else var txtInfo='';
	        			
	        			if(infoOnMe == null){
        					if(allwaysHidde==false) showInfo(txtInfo+activeImage,null,infoPanel);
       					}
        				break;
        			case 3:
	        			// Показывать ли текст
		        		if(verboseMode==true) var txtInfo='Обработка закончена.';
		        		else var txtInfo='';
		        		
		        		if(infoOnMe == null){
        					if(allwaysHidde==false) showInfo(txtInfo+activeImage,null,infoPanel);
       					}
       					
        				break;
        		}
        	}
        }

        if(postdata==null) lod.open("GET", query, true);
        else lod.open("POST", query, true);

        lod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    
	    if(postdata==null) lod.send ('');
	    else lod.send(postdata);
    }
    
    function ord(s){
    	var a=s.charCodeAt(0);
		if(a>0xFF) a-=0x350;
		
		return a;
    }
    
    function truebody(){
		return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	}

    function showInfo(text,show,info,chposit,append){
    	var iP=getEl(info);

		if(chposit==null) chposit=true;
		if(append!='up' && append!=='down' && append!=null) append='up';

	    // Определяем положение панели
	    var wLeft=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth;
		var wTop=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight);
	 
	    iP.innerHTML=(append=="up"?iP.innerHTML+" ":"")+text+(append=="down"?" "+iP.innerHTML:"");
	    iP.style.zIndex=((show==true || show==null)?"1000000":"0");
	    iP.style.display=((show==true || show==null)?'block':'none');

		if(chposit==true){
		 	iP.style.top=10;			
	    	iP.style.left=parseInt(wLeft)-200;
		}
		
		// Execute script into loading text
		parseScript(iP);
		
		if(iP.style.visibility=='hidden'){
			iP.style.top='0';
			iP.style.left='0';
		}
    }
    
    function utf2win1251(s){
 		// Найти рабочий кодировщик!!!
	}
    /*
    HowTo Use
    <a href='#' onclick='ldr("ajax.php")'>Тест</a>
	<div name='info' id='info' style='border: 1px #000 solid; background-color: #fff; color: #000; font-size: 11px; font-family: Arial; width: 200px; height: 50px; visibility: hidden; vertical-align: center; text-align: center; top: 384; left: 612; padding-top: 8%; position: relative;'>InfoText</div>

	<div name='lblText' id='lblText' style='width: 300; height: 200; border: 1px #000 solid; overflow: scroll; background-color: #999999; color: #ffffff; visibility: hidden;'>responseText</div>
	*/
