function addEngine(engineURL) {
    if (window.external && ("AddSearchProvider" in window.external)) {
        window.external.AddSearchProvider(engineURL);
        return false;
    } else {
        alert(error_opensearch_unsupported);
        return true;
    }
}
function showmap(_firm_,_address_){
        var request=null;
        // пытаемся создать объект для MSXML 2 и старше
        if(!request) try {
                request=new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){}
        // не вышло... попробуем для MSXML 1
        if(!request) try {
                request=new ActiveXObject('Microsoft.XMLHTTP');
        } catch (e){}
        // не вышло... попробуем для Mozilla
        if(!request) try {
                request=new XMLHttpRequest();
        } catch (e){}
        if(!request){
                // ничего не получилось...
                alert('Не удалось открыть данные. Воспользуйтесь более новой версией браузера.');
                return "";
        }
        d = new Date();
        // делаем запрос содержимого
        webadr = "/showmap.php?address="+_address_+"&firm="+_firm_+"&rndtime="+d.getTime();
        //window.alert(webadr);
        request.open('GET', webadr, false);
        request.send(null);
        document.getElementById('map').innerHTML = request.responseText;
        return false;
}

function showLogin(){
  document.getElementById('hidecont').style.display = 'block';
  document.getElementById('alphadiv').style.display = 'block';
  document.getElementById('logindiv').style.display = 'block';
  document.getElementById('bodydiv').style.overflow = 'hidden';
  document.getElementById('bodydiv').style.height   = '100%';
  return false;
}

function closeLogin(){
  document.getElementById('hidecont').style.display = 'none';
  document.getElementById('alphadiv').style.display = 'none';
  document.getElementById('logindiv').style.display = 'none';
  document.getElementById('bodydiv').style.overflow = '';
  return false;
}

function showHelp(_which_){
  if (_which_ == 'search'){
    document.getElementById('helpsearch').style.display = 'block';
  }
  else{
    document.getElementById('help'+_which_).style.display = 'block';
  }
}

function hideHelp(_which_){
  if (_which_ == 'search'){
    document.getElementById('helpsearch').style.display = 'none';
  }
  else{
    document.getElementById('help'+_which_).style.display = 'none';
  }
}


function preload() {
  if (document.images) {
    var imgsrc = preload.arguments;
    arr=new Array(imgsrc.length);
    for (var j=0; j<imgsrc.length; j++) {
      arr[j] = new Image;
      arr[j].src = imgsrc[j];
    }
  }
}

function _openWindow_new(theURL,winName) {
	var r_w = 400
	var r_h = 180
	var w_h = screen.availHeight
	var w_w = screen.availWidth
	var w_l = (screen.availWidth/2)-(r_w/2)
	var w_t = (screen.availHeight/2)-(r_h/2)
	var params = "status=no,width=" + r_w + ",height=" + r_h + ", left=" + w_l + ", top="+ w_t
	window.open(theURL,winName,params);
}

function _openWindow_new2(theURL,winName) {
    var r_w = 400
    var r_h = 350
    var w_h = screen.availHeight
        var w_w = screen.availWidth
        var w_l = (screen.availWidth/2)-(r_w/2)
        var w_t = (screen.availHeight/2)-(r_h/2)

        var params = "scrollbars,status=no,width=" + r_w + ",height=" + r_h + ", left=" + w_l + ", top="+ w_t
  window.open(theURL,winName,params);
}
function _openWindow_prop(theURL,winName,r_w,r_h) {
    var w_h = screen.availHeight
        var w_w = screen.availWidth
        var w_l = (screen.availWidth/2)-(r_w/2)
        var w_t = (screen.availHeight/2)-(r_h/2)

        var params = "scrollbars,status=no,width=" + r_w + ",height=" + r_h + ", left=" + w_l + ", top="+ w_t
  window.open(theURL,winName,params);
}
function _openWindow_new3(theURL,winName) {
    var r_w = 700
    var r_h = 500
    var w_h = screen.availHeight
        var w_w = screen.availWidth
        var w_l = (screen.availWidth/2)-(r_w/2)
        var w_t = (screen.availHeight/2)-(r_h/2)

        var params = "scrollbars,status=no,width=" + r_w + ",height=" + r_h + ", left=" + w_l + ", top="+ w_t
  window.open(theURL,winName,params);
}

function showInfo(_text_) {
  divchik = document.getElementById('basketadddiv');
  _left_ = (document.body.clientWidth-400)/2;
  _top_ = (document.body.clientHeight-300)/2;

  if (window.scrollY) _topY_ = window.scrollY;
  else _topY_ = document.body.scrollTop;

  divchik.innerHTML=_text_;
  divchik.style.left=_left_;
  divchik.style.top=_topY_+_top_;
  divchik.style.display='block';

}

function pasteExample(_example_){
  document.getElementById('s').value  = _example_;
  document.getElementById('s2').value = _example_;

}


function $(id) {return document.getElementById(id);}

function input_rechange(default_value,id,act){
	if (act == 'click'){
		if (document.getElementById(id).value == default_value){
				document.getElementById(id).value = "";
		}
		document.getElementById(id).style.color = "000000";
	}
	if (act == 'blur'){
		if ($(id).value == "") {$(id).value = default_value;}
		if ($(id).value == default_value) {$(id).style.color = "808080";}
	}
}


function ajax_load_to(select_id, url) {
	var xmlhttp;
    if (window.XMLHttpRequest) {
        try {
            xmlhttp= new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
          try {
              xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
          } catch (e){}
        }
    }

	this.http = xmlhttp;
	var http = this.http;
	this.http.open("GET", url, true);
	
	this.http.onreadystatechange = function() {
		if (http.readyState == 4){
			if(select_id!='')$(select_id).innerHTML=http.responseText;
		}
	}
	
	this.http.send(null);
	this.http=null;
}

//-------------------------------------------------------------------------------------------

function firm_focus_count(ip, firm, id){
	var tmp = new Date(); 
	var tmp = tmp.getTime();	
	var url = '/firm_focus_count.php?tmp='+tmp;
	var myAjax = new Ajax(url, {method: 'post', data: {ip : ip,
													   firm : firm,
													   id:id}, update: 'firm_cnt_div', evalScripts: true});
	myAjax.request();
}


//-------------------------------------------------------------------------------------------

function space_focus_count(ip, firm){
	var tmp = new Date(); 
	var tmp = tmp.getTime();	
	var url = '/space_focus_count.php?tmp='+tmp;
	var myAjax = new Ajax(url, {method: 'post', data: {ip : ip,
													   firm : firm}, update: 'firm_cnt_div', evalScripts: true});
	myAjax.request();
}

//-------------------------------------------------------------------------------------------

function send_form(url_from){
	var tmp = new Date(); 
	var tmp = tmp.getTime();	
	var url = '/send_mail.php?tmp='+tmp;
	
	var text = $('ertext').value;
	var comment = $('BoxPromptInput').value;
	
	var myAjax = new Ajax(url, {method: 'post', data: {text : text,
													   comment : comment,
													   url_from : url_from}, update: 'BoxOverlay', evalScripts: true});
	myAjax.request();
}
//-------------------------------------------------------------------------------------------
function spec_count(ip, from, to,fid){
	var tmp = new Date(); 
	var tmp = tmp.getTime();	
	var url = '/special_count.php?tmp='+tmp;
	var myAjax = new Ajax(url, {method: 'post', data: {ip : ip,
													   from : from,  
													   to : to, 
													   fid : fid}, update: 'special', evalScripts: true});
	myAjax.request();
}