
//----------------AJAKS-----------------

function getrandom() { 

var min_random = 0;
var max_random = 5000;

max_random++;

var range = max_random - min_random;
var n=Math.floor(Math.random()*range) + min_random;

return n;
}

            var ro;
            try {ro = new ActiveXObject("Msxml2.XMLHTTP");}
            catch(e)
                  {
                    try
                       {
                        ro = new ActiveXObject("Microsoft.XMLHTTP");
                       }
                    catch(f)
                       {
                        ro = null;
                       }
                  }
            if(!ro && typeof(XMLHttpRequest) != 'undefined')
                {
                 ro = new XMLHttpRequest();
                }

        function smenaj(tip,podtip,country,fabrik)
            {
            try {            	
                fabrik=escape(fabrik);//replace(/&/g, "%26");
                tip=escape(tip);
                podtip=escape(podtip);
                country=escape(country);
                //alert('/topsearch.php?tip=' + tip + '&podtip=' + podtip + '&country=' + country + '&fabrik=' + fabrik + '&ran='+getrandom());
                ro.open('GET', '/topsearch.php?tip=' + tip + '&podtip=' + podtip + '&country=' + country + '&fabrik=' + fabrik + '&ran='+getrandom());// + '&ran='+getrandom()  //открываем наш XML - фаил
                ro.onreadystatechange = response_callback;//Выполняем функцию response_callback которая написана ниже
                ro.send(null);
                }
            catch(e)
                {
                }
            }

        function response_callback()
            {
                  try {
                        if((ro.readyState == 4) && (ro.status == 200))//проверяем эти 2-а значения
                            {
  				var response = ro.responseText;//Получаем в переменную response весь код XML - фаила
                                //alert("получен XML-фаил следующего содержания:\n\n" + response); //Выводим его содержимое, только для себя.
                                document.getElementById('reload').innerHTML = response;//эта DHTML, с помощью него мы присвоим свойству
                                                                                      // id с именем reload наше содержимое XML-файла
                            }
                      }
                  catch(e)
                      {
                      }
            }

      
//-----------------------------TOPSEARCH---------------------------------            

function perekl(id)
{
	var i;
	//document.getElementById("search"+ id).style.display='block';
	for(i=1;i<5;i++)
	{
	    if(i==id&&document.getElementById("search"+ id).style.display=='block') continue;
	    document.getElementById("search"+ i).style.display='none';
	}
	if(document.getElementById("search"+ id).style.display=='none') document.getElementById("search"+ id).style.display='block';
	else  document.getElementById("search"+ id).style.display='none';
}

  
      function html_entity_decode(str) {
        var ta = document.createElement("textarea");
        ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
        toReturn = ta.value;
        ta = null;
        return toReturn
      }
      
// Инициализируем таблицу перевода
var trans = [];
for (var i = 0x410; i <= 0x44F; i++)
  trans[i] = i - 0x350; // А-Яа-я
trans[0x401] = 0xA8;    // Ё
trans[0x451] = 0xB8;    // ё

// Сохраняем стандартную функцию escape()
var escapeOrig = window.escape;

// Переопределяем функцию escape()
window.escape = function(str)
{
  var ret = [];
  // Составляем массив кодов символов, попутно переводим кириллицу
  for (var i = 0; i < str.length; i++)
  {
    var n = str.charCodeAt(i);
    if (typeof trans[n] != 'undefined')
      n = trans[n];
    if (n <= 0xFF)
      ret.push(n);
  }
  return escapeOrig(String.fromCharCode.apply(null, ret));
}
      

//---------------------------------IMGvspl-------------------------------------------------
/*//ширина клиенской области
function getClientWidthPop(){
return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth :document.body.clientWidth;
}

//высота клиентской области
function getClientHeightPop(){
return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight :document.body.clientHeight;
}

//смешение по высоте
function getClientSTopPop(){
return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop)
}

//смещение по горизонтали
function getClientSLeftPop(){
return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}
var scroll=(navigator.userAgent.indexOf('Firefox')!=-1?scrollY:document.body.scrollTop);
*/

function pok(img)
           {	
			    document.getElementById('knopkz').innerHTML='<img onClick="document.getElementById(\'popup\').style.visibility=\'hidden\'" src="/art/main/zakr.gif" alt="закрыть" width="17" height="17">';
			    
				  document.getElementById("popupinf").style.left=((document.body.clientWidth-200)/2)+document.body.scrollLeft;
				  document.getElementById("popupinf").style.top=((document.body.clientHeight-80)/2)+document.body.scrollTop;
				  document.getElementById('waitprint').src='/art/main/wait.gif'; 	
				  document.getElementById('popupinf').style.visibility="visible"; 	
				  document.getElementById('poppol').innerHTML='<img id="imgpop" onerror="document.getElementById(\'waitprint\').src=\'/art/main/0.gif\'" onLoad="otkrpic(this.width,this.height)" src="'+img+'">';
	}

function otkrpic(widthmin,heightmin)
           {
           	var widthpop=0;
           	
				widthpop=((document.body.clientWidth-widthmin)/2)+document.body.scrollLeft;
				if(widthpop<0||widthpop==(document.body.clientWidth/2)) widthpop=0;
						
				heightpop=((document.body.clientHeight-heightmin)/2)+document.body.scrollTop;
				if(heightpop<0||heightpop==(document.body.clientHeight/2)) widthpop=0;
			   	
				
				document.getElementById("popup").style.left=widthpop;
			   	document.getElementById("popup").style.top=heightpop;
			   				   	
          	
			    	document.getElementById('popupinf').style.visibility="hidden";
				document.getElementById("popup").style.visibility="visible";           	
           }	



