function hide_menu(menu_id, img_id) {
  menu = document.getElementById(menu_id);  
  img = document.getElementById(img_id);

  menu.style.display = 'none';         
  img.src = img.src.replace(/_minus/, '_plus');
}

function show_menu(menu_id, img_id) {
  menu = document.getElementById(menu_id);  
  img = document.getElementById(img_id);

  menu.style.display = 'block';
  img.src = img.src.replace(/_plus/, '_minus');
}

function switch_menu(type) {  
  if (type != 'mo') {
    if (type != 'region') { hide_menu('region_menu', 'region_img'); }
    if (type != 'districts') { hide_menu('districts_menu', 'districts_img'); }
    if (type != 'cities') { hide_menu('cities_menu', 'cities_img'); } 
  }

  menu_id = type + '_menu';
  img_id = type + '_img';

  menu = document.getElementById(menu_id);  
  img = document.getElementById(img_id);
  
  if (menu.style.display == 'block') {             
    hide_menu(menu_id, img_id);
  } else {
    show_menu(menu_id, img_id);  
  }
}

function search_focus(search) {
  if (search.value == 'Другое') {
    search.value='';
    search.className = 'searchblack';
  }
}

function search_blur(search) {
  if (search.value == '') {
    search.value = 'Другое';
    search.className = 'searchgray';
  }
}

function Play(path_player, filePath){ 
  var link = '<div style="text-align: left;"><a href="' + filePath.replace(/flv/, 'avi') + '">Скачать видео</a></div>';
  document.write(link); document.close();
}

function view_photo (imgSrc, imgWidth, imgHeight, imgTitle) {
  if (!imgWidth || !imgHeight) {
    imgWindow = window.open('', 'image', '');
    var html = '<html><head><title></title></head><body style="margin: 0; padding: 0;">' +
               '<img alt="' + imgTitle + '" src="' + imgSrc + '">' +
               '</body></html>';
    imgWindow.document.write(html);
    return;
  }

  var screenWidth = screen.availWidth;
  var screenHeight = screen.availHeight;
  var titleHeight = 30;
  if (imgTitle) { imgHeight = imgHeight + titleHeight; }
  var windowLeft, windowTop;
  if ((screenWidth - imgWidth) > 0) { windowLeft = (screenWidth - imgWidth) / 2 } else { windowLeft = 0; }
  if ((screenHeight - imgHeight) > 0) { windowTop = (screenHeight - imgHeight) / 2 } else { windowTop = 0; }
  var imgWindow = window.open('', 'image',
                  'width=' + imgWidth + ', height=' + imgHeight +
                  ', left=' + windowLeft + ', top=' + windowTop
  );
  var html = '<html><head><title>' + imgTitle + '</title></head><body style="margin: 0; padding: 0;">' +
             '<img alt="' + imgTitle + '" src="' + imgSrc + '">' +
             '<div style="heigth: ' + titleHeight + 'px; width: 100%; text-align: center; font: 10px Arial;">'+ imgTitle +'</div>' +
             '</body></html>';
  imgWindow.document.write(html);
  imgWindow.document.close();
  return;
}