function sample(element, value, array)
{
  if(array)
    for(id in value)
      document.getElementById('form_field_'+element+'_'+id).checked = value[id];
  else
    document.getElementById('form_field_'+element).value = value;
}

function sample_add(element, value)
{
  document.getElementById('form_field_'+element).value += value;
}

function geo_cities_(ad_id)
{
  region = document.getElementById('ad_'+ad_id+'_field_geo_cities_closed');
  region.style.display = region.style.display == 'inline'? 'none': 'inline';

  region = document.getElementById('ad_'+ad_id+'_field_geo_cities_opened');
  region.style.display = region.style.display == 'inline'? 'none': 'inline';
}

function geo_cities_prepare(ad_id)
{
  region = document.getElementById('ad_'+ad_id+'_field_geo_cities_closed');
  region.style.display = 'inline';
  region = document.getElementById('ad_'+ad_id+'_field_geo_cities_opened');
  region.style.display = 'none';
}

function metro_line_(ad_id, station_id)
{
  line = document.getElementById('ad_'+ad_id+'_metro_line_'+station_id+'_closed');
  line.style.display = line.style.display == 'inline'? 'none': 'inline';

  line = document.getElementById('ad_'+ad_id+'_metro_line_'+station_id+'_opened');
  line.style.display = line.style.display == 'inline'? 'none': 'inline';
}

function metro_line_prepare(ad_id, station_id)
{
  line = document.getElementById('ad_'+ad_id+'_metro_line_'+station_id+'_closed');
  line.style.display = 'inline';
  line = document.getElementById('ad_'+ad_id+'_metro_line_'+station_id+'_opened');
  line.style.display = 'none';
}

function photo_(index)
{
  PhotoIndex = index;
  
  if(PhotoIndex == Photos.length)
    PhotoIndex = 0;

  document.getElementById('photo').src = Photos[PhotoIndex];
}

function rooms_switch(value)
{
  document.getElementById('form_field_rooms_div_').style.display = value? 'block': 'none';
}

