function popupImage(url, title){

  var imageFile = "/public/html/img.html"

  var map, geoResult;
  
  var img = new Image;
  img.src =  url;

  if(img.complete){
    var window_w = img.width  + 30;
    var window_h = img.height + 30;	
    var screen_w = window.screen.width;
    var screen_h = window.screen.height;

    var scrollbars = 'no';

    if(window_w > screen_w - 50){ window_w = screen_w - 50; scrollbars = 'yes'; }
    if(window_h > screen_h - 50){ window_h = screen_h - 50; scrollbars = 'yes'; }
			
    var t  = (screen_h/2) - (window_h/2);
    var l = (screen_w/2) - (window_w/2);

    var win = window.open(imageFile + "?" + "" + escape(url) + "&" + escape(title), "win", "resizable,scrollbars="+scrollbars+",width="+window_w+",height="+window_h+",top="+t+",left="+l);
    win.focus();	
  }
  img.onload = function(){
    var window_w = img.width  + 30;
    var window_h = img.height + 30;	
    var screen_w = window.screen.width;
    var screen_h = window.screen.height;

    var scrollbars = 'no';

    if(window_w > screen_w - 50){ window_w = screen_w - 50; scrollbars = 'yes'; }
    if(window_h > screen_h - 50){ window_h = screen_h - 50; scrollbars = 'yes'; }

    var t  = (screen_h/2) - (window_h/2);
    var l = (screen_w/2) - (window_w/2);

    var win = window.open(imageFile + "?" + "" + escape(url) + "&" + escape(title), "win", "resizable,scrollbars="+scrollbars+",width="+window_w+",height="+window_h+",top="+t+",left="+l);
    win.focus();				
  };
  if(img.complete) delete(img);			
  return false;
 
}


function processList(id) {
      if (document.all&&document.getElementById(id)) {
            navRoot = document.getElementById(id);
            if (navRoot) {
            for (i=0; i < navRoot.childNodes.length; i++) {
                  node = navRoot.childNodes[i];
                  if (node.nodeName == "LI") {
                        node.onmouseover = function() {
                              this.className+=" over";
                        }
                        node.onmouseout = function() {
                              this.className = this.className.replace(" over", "");
                        }
                  }
            }
            }
      }
}



 function initmap () {

 map = new YMaps.Map(document.getElementById("YMapsID"));
 //map.setCenter(new YMaps.GeoPoint(30.15, 59.52), 12); 
 map.setCenter(new YMaps.GeoPoint(30.290167, 59.966363), 14);  
 map.addControl(new YMaps.TypeControl());
 map.addControl(new YMaps.SmallZoom(), new YMaps.ControlPosition(YMaps.ControlPosition.TOP_LEFT, new YMaps.Size(10, 2)));         
 map.enableScrollZoom(); 

}


function showAddress (value) {
    // Удаляем все оверлеи
    map.removeAllOverlays(); 
    // Запускаем процесс геокодирования    
    //var geocoder = new YMaps.Geocoder("Москва");
    //YMaps.GeocoderResult (geocoder);
    var geocoder = new YMaps.Geocoder(value, {results: 1, boundedBy: map.getBounds()});
    
    YMaps.Events.observe(geocoder, geocoder.Events.Load, function () {
    
    //Если поиск прошел без ошибок и найден хотя бы один результат
      //var check = this.length();  
       
        if (this.length()) { 
            // Добавляем оверлей на карту
            map.addOverlay(this.get(0));
            //this.get(0).setBalloonContent(this.get(0).text);
            
            // Открываем балун
            //this.get(0).openBalloon('<font size=1>'+this.get(0).text+'</font>', {margin: [50, 20, 30, 40]}); 
            this.get(0).openBalloon('<font size=1>'+value+'</font>', {margin: [50, 20, 30, 40]}); 
          //  this.get(0).openBalloon(); 

        }else {
            alert("Ничего не найдено");
        } 
    });
    
    // Если при геокодировании произошла ошибка, то сообщаем о ней
    YMaps.Events.observe(geocoder, geocoder.Events.Fault, function (error) {alert("Произошла ошибка: " + error.message)});

}

