<!--
  var pngMap = function(blockId, name, mapFolder){
    this.name = name;
    this.blockId = blockId;
    this.areas = new Array();
    this.ratio = 1;
    this.overImg;
    this.area;
    this.mapFolder = mapFolder;
    this.imgMap = new Array();
    this.imgBase = new Array();
    this.overImg = new Array();
    this.selectorLink = new Array();
    this.countries = new Array();
    
    this.construct = function(){
      this.block = document.getElementById(this.blockId);
      this.blockWidth = this.block.clientWidth;
      this.blockHeight = this.block.clientHeight;
      this.ratio = this.blockWidth/1000;
      var insertBlock = document.createElement("DIV");
      insertBlock.style['width'] = this.blockWidth+"px";
      insertBlock.style['height'] = this.blockHeight+"px";
      insertBlock = this.block.appendChild(insertBlock);
      insertBlock.innerHTML='<img src="'+this.mapFolder+"world.png"+'" style="width: 100%; height: 100%; margin-bottom: -'+(this.blockHeight)+'px; display: block;" id="'+this.blockId+'_base0"/>'+
                            '<img src="'+this.mapFolder+"europe.png"+'" style="width: 100%; height: 100%; margin-bottom: -'+(this.blockHeight)+'px; display: none;" id="'+this.blockId+'_base1"/>'+
                            '<img src="'+this.mapFolder+"plain.png"+'" style="width: 100%; height: 100%; display: block; margin-bottom: -'+(this.blockHeight)+'px;" usemap="#'+this.blockId+'_area0" id="'+this.blockId+'_over0"/>'+
                            '<map name="'+this.blockId+'_area0" id="'+this.blockId+'_area0"></map>'+
                            '<img src="'+this.mapFolder+"plain.png"+'" style="width: 100%; height: 100%; display: block; margin-bottom: -'+(this.blockHeight)+'px; display: none;" usemap="#'+this.blockId+'_area1" id="'+this.blockId+'_over1"/>'+
                            '<map name="'+this.blockId+'_area1" id="'+this.blockId+'_area1"></map>';    
      this.imgMap[0] = document.getElementById(this.blockId+'_area0');
      this.imgMap[1] = document.getElementById(this.blockId+'_area1');
      this.imgBase[0] = document.getElementById(this.blockId+'_base0');
      this.imgBase[1] = document.getElementById(this.blockId+'_base1');
      this.overImg[0] = document.getElementById(this.blockId+'_over0');
      this.overImg[1] = document.getElementById(this.blockId+'_over1');
      this.selectorLink[0] = document.getElementById('map-selector-0');
      this.selectorLink[1] = document.getElementById('map-selector-1');
    }
    
    this.addArea = function(area_array){
      var coords = area_array['coords'].split(',');
      var areaCoords =''; 
      for (i=0; i<coords.length; i++){
        areaCoords = areaCoords + Math.ceil(coords[i]*this.ratio) + ',';
      }
      areaCoords += Math.ceil(coords[0]*this.ratio)+','+Math.ceil(coords[1]*this.ratio);
      this.imgMap[area_array['map_selector']].innerHTML += '<area shape="poly" href="'+area_array['href']+'" title="'+area_array['title']+'" coords="'+areaCoords+'"onmouseover="'+area_array['onmouseover']+'" onmouseover_="'+this.name+'.display(\''+area_array['name']+'\')" onmouseout_="'+this.name+'.hide(\''+area_array['name']+'\')" title="area">';
      if (area_array['map_selector']==0){
        this.countries.push(area_array);  
      } 
    }
    
    this.display = function (area_name, map_selector){
      this.selectMap(map_selector);
      this.overImg[map_selector].src=this.mapFolder+area_name+".png";
      showPharase(area_name);
      document.getElementById('country-link-1').href="/countries/"+area_name+"/";
      document.getElementById('country-link-2').href="/countries/"+area_name+"/review/";
      document.getElementById('country-link-3').href="/countries/"+area_name+"/towns/";
      document.getElementById('country-link-4').href="/countries/"+area_name+"/excursions/";
    }
    
    this.selectMap = function (map_selector){
      for (i=0; i<=1; i++){
        this.imgBase[i].style.display = 'none';
        //this.imgMap[i].style.display = 'none';
        this.overImg[i].style.display = 'none';
        this.selectorLink[i].className = 'selector_gr';
      this.overImg[i].src = this.mapFolder+"plain.png"
      }  
      this.imgBase[map_selector].style.display = 'block';
      this.overImg[map_selector].style.display = 'block';
      this.selectorLink[map_selector].className = 'selector';
    }
    
    this.hide = function (){
      this.overImg.src=this.mapFolder+"plain.png";
    }
    
    this.random_display = function(){
      r=Math.floor(Math.random()*(this.countries.length-1));
      this.display(this.countries[r]['name'], this.countries[r]['map_selector']);
    }
  }
  
  function showPharase(country){
    blocks = document.getElementById('index-country-phrase-content').getElementsByTagName('DIV');
    for (i=0; i<blocks.length; i++){
      if (blocks[i].id=="phrase-"+country){
        blocks[i].style.display = "block";
      }
      else{
        blocks[i].style.display = "none";
      }
    }
  }
  
  
  function openTourBlock(name){
    if (name == 'search'){
      document.getElementById('tour-order-block').style.display='none';
      document.getElementById('tour-search-block').style.display='block';
      document.getElementById('left-form-selector-buttons').className='selector-1';
    }
    else{
      document.getElementById('tour-order-block').style.display='block';
      document.getElementById('tour-search-block').style.display='none';
      document.getElementById('left-form-selector-buttons').className='selector-2';
    }
  }
  
  var currency = new Array();
  function calculate_currency(cur){
  
    val = document.getElementById('currency_val')
    inn = document.getElementById('currency_in')
    
    sel = document.getElementById('currency_type');
    val_type = sel.options[sel.selectedIndex].value;
   
    if (cur=='val'){
      inn.value = (val.value*currency[val_type]).toFixed(1)
    } 
    else{
      val.value = (inn.value/currency[val_type]).toFixed(1)
    }
  }

function check_form(form_id){
  j=0;
  error=new Array();
  items=document.getElementById(form_id).getElementsByTagName("INPUT");
  for(i=0; i<items.length; i++)
  {
     if (items[i].getAttribute('check')==1 && trim(items[i].value)=='')
     {
        j++;
        error[j]=str_replace('data[', '', items[i].name);
        error[j]=str_replace(']', '', error[j]);
     }
  }
  if (error.length>0)
  {
    message='Пожалуйста, заполните следующие поля:\n\n';
    for (j=1;j<(error.length-1); j++)
    {
       message+=error[j]+', ';
    }
    message+=error[j]+'.';
    alert(message);
    return false;
  }
  else
  {
    return true();
  }
}

/* Yandex map */
function place_map(coords, small_scale, large_scale){
  coords_ = coords.split(',');
  var map = new YMaps.Map(document.getElementById("small_country_map"));
  map.setCenter(new YMaps.GeoPoint(coords_[0],coords_[1]), small_scale);
  map.disableDragging();
  map.disableDblClickZoom();
  YMaps.Events.observe(map,map.Events.Click, function () {show_large_map(coords, large_scale);});
}

function show_large_map(coords, scale){
  document.getElementById('large_country_map_outher').style.display = 'table';
  coords_ = coords.split(',');
  var map = new YMaps.Map(document.getElementById("large_country_map"));
  //map.enableScrollZoom();
  var zoomControl = new YMaps.Zoom();
  map.addControl(zoomControl);
  var typeControl = new YMaps.TypeControl(); 
  map.addControl(typeControl);
  map.setCenter(new YMaps.GeoPoint(coords_[0],coords_[1]), scale);
}

function delete_large_map(coords, scale){
  document.getElementById('large_country_map_outher').style.display = 'none';
}


/* GAllery */
function openGalleryPhoto(id){

    openedPhotoId=id;
    document.getElementById('photo_'+openedPhotoId).className='gallery-photo-table-visible';
    showGalleryBg();
    return false;
}

function hideGalleryPhoto(){
    document.getElementById('photo_'+openedPhotoId).className='gallery-photo-table';
   // hideGalleryBg();
}

function showGalleryBg(){
    var html = document.documentElement;

    photo=document.getElementById('lphoto_'+openedPhotoId);
    var top=(document.body.scrollTop>document.documentElement.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop
    document.getElementById('photo_'+openedPhotoId).style.height=html.clientHeight+'px';
    document.getElementById('photo_'+openedPhotoId).style.marginTop=top+'px';
    document.getElementById('photo_'+openedPhotoId).style.left = -photo.clientWidth/2-20+'px';

    var delta=(window.innerHeight<900)?900-window.innerHeight:0;
    var height=(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
    height=height+delta;
}


function hideGalleryBg(){

}


function move_footer(){
}


function getElementsByClassName(elem, cl) { 
    var retnode = []; 
    var myclass = new RegExp('\\b'+cl+'\\b'); 
    var elem = elem.getElementsByTagName('*'); 
    for (var i = 0; i < elem.length; i++) {         var classes = elem[i].className; 
      if (myclass.test(classes)) retnode.push(elem[i]); 
    } 
    return retnode;
};

function trim(str){
  if (str.length>0){
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
  }
  else{
    return '';
  }
}

function str_replace ( search, replace, subject ) {
    if(!(replace instanceof Array)){
        replace=new Array(replace);
        if(search instanceof Array){
            while(search.length>replace.length){
                replace[replace.length]=replace[0];
            }
        }
    }
     if(!(search instanceof Array))search=new Array(search);
    while(search.length>replace.length){
        replace[replace.length]='';
    }
     if(subject instanceof Array){
        for(k in subject){
            subject[k]=str_replace(search,replace,subject[k]);
        }
        return subject;
    }
     for(var k=0; k<search.length; k++){
        var i = subject.indexOf(search[k]);
        while(i>-1){
            subject = subject.replace(search[k], replace[k]);
            i = subject.indexOf(search[k],i);
        }
    }
    return subject;
}


var answer_scenario = new Array(0);

function displayBlock(id){
    el=document.getElementById('c_'+id);
    if (el.clientHeight>50){
      hideBlock(id);
    }
    else{
      content=document.getElementById('cd_'+id);
      var height = content.clientHeight;
      answer_scenario[id]=new jetMove;
      scene1=new Array(
       {element:el, property:'height', nowValue:0, newValue:height, dim: 'px'}
      );    
      answer_scenario[id].addScene(scene1);
      answer_scenario[id].playScenario();
    }
}

function hideBlock(id){
    el=document.getElementById('c_'+id);
    content=document.getElementById('cd_'+id);
    var height = content.clientHeight;
    answer_scenario[id]=new jetMove;
    scene1=new Array(
     {element:el, property:'height', nowValue:height, newValue:0, dim: 'px'}
    );    
    answer_scenario[id].addScene(scene1);
    answer_scenario[id].playScenario();
}






var jetMove = function(){   
    this.scenario=new Array();
    this.scene=0;
    this.delay=20;
    this.ratio=.20;
    this.pow=.9;
    this.stopFlag=false
  
    this.addScene=function(sceneArray){
      this.scenario.push(sceneArray);
      this.stopFlag=false;
    }

    this.stopScenario=function(){ 
      this.stopFlag=true; 
    } 
    
    this.playScenario=function(){   
      for (i=0; i<this.scenario[this.scene].length; i++){   
        endFlag=true;
        if (this.scenario[this.scene][i].nowValue!=this.scenario[this.scene][i].newValue){
          endFlag=false;
          if(typeof(this.scenario[this.scene][i].element)=='string'){
            this.scenario[this.scene][i].element=document.getElementById(this.scenario[this.scene][i].element);  
          }
          delta=Math.round(this.ratio*Math.pow(Math.abs((this.scenario[this.scene][i].newValue-this.scenario[this.scene][i].nowValue)),this.pow));
          delta=(delta<1)?1:delta;
          delta=(this.scenario[this.scene][i].newValue<this.scenario[this.scene][i].nowValue)?-delta:delta;
          if(typeof(this.scenario[this.scene][i].element)=='object'){
            this.scenario[this.scene][i].nowValue=this.scenario[this.scene][i].nowValue+delta;
            switch(this.scenario[this.scene][i].property){
              case 'opacity':
                this.setOpacity(this.scenario[this.scene][i].element, this.scenario[this.scene][i].nowValue);
              break;
              default:
                this.setStyle(this.scenario[this.scene][i].element, this.scenario[this.scene][i].property, this.scenario[this.scene][i].nowValue+this.scenario[this.scene][i].dim);
              break;
            }
          }
        }
      }
      if (endFlag==false && this.stopFlag==false){
        var obj=this;
        setTimeout(function(){obj.playScenario()},this.delay); 
      }
      else if (this.scene<(this.scenario.length-1)){
        this.scene++;
        this.playScenario();
      } 
    }
    
    this.setOpacity=function(element, opacity){
      element.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity+")";  
      element.style.MozOpacity=(opacity/100);
      element.style.KhtmlOpacity=(opacity/100);
      element.style.opacity=(opacity/100);
    }

    this.setStyle=function(element, propetry_name, prorerty_value){
      eval("element.style."+propetry_name+"='"+prorerty_value+"'");
    } 
}

  
-->
