var locations = Array();
locations[5] = Array(); locations[5][1] = "Playa Blanca";
locations[8] = Array(); locations[8][1] = "Costa Teguise";
locations[13] = Array(); locations[13][1] = "Puerto del Carmen";
locations[17] = Array(); locations[17][1] = "Arrecife";
locations[18] = Array(); locations[18][1] = "Puerto Calero";
locations[25] = Array(); locations[25][1] = "Yaiza";
locations[31] = Array(); locations[31][1] = "San Bartolomé";
locations[32] = Array(); locations[32][1] = "Teguise";
locations[15] = Array(); locations[15][14] = "Las Palmas";
locations[16] = Array(); locations[16][14] = "San Agustín";
locations[21] = Array(); locations[21][14] = "Playa del Inglés";
locations[22] = Array(); locations[22][14] = "Puerto Rico";
locations[30] = Array(); locations[30][14] = "Maspalomas";
locations[44] = Array(); locations[44][14] = "Mogán";
locations[64] = Array(); locations[64][14] = "Playa Meloneras";
locations[68] = Array(); locations[68][14] = "Vega de San Mateo";
locations[69] = Array(); locations[69][14] = "Tejeda";
locations[38] = Array(); locations[38][20] = "Las Américas";
locations[39] = Array(); locations[39][20] = "Los Cristianos";
locations[40] = Array(); locations[40][20] = "Puerto Santiago";
locations[41] = Array(); locations[41][20] = "Puerto de La Cruz";
locations[42] = Array(); locations[42][20] = "Adeje";
locations[47] = Array(); locations[47][20] = "Garachico";
locations[55] = Array(); locations[55][20] = "S/C Tenerife";
locations[58] = Array(); locations[58][20] = "La Orotava";
locations[71] = Array(); locations[71][20] = "Santa Úrsula";
locations[72] = Array(); locations[72][20] = "San Miguel de Abona";
locations[33] = Array(); locations[33][26] = "Caleta de Fuste";
locations[34] = Array(); locations[34][26] = "Costa Calma";
locations[35] = Array(); locations[35][26] = "Morro Jable";
locations[36] = Array(); locations[36][26] = "Jandía";
locations[37] = Array(); locations[37][26] = "Corralejo";
locations[59] = Array(); locations[59][26] = "Tuineje";
locations[67] = Array(); locations[67][26] = "Puerto del Rosario";
locations[45] = Array(); locations[45][27] = "Fuencaliente";
locations[48] = Array(); locations[48][27] = "Breña Baja";
locations[49] = Array(); locations[49][27] = "Los Llanos de Aridane";
locations[70] = Array(); locations[70][27] = "El Paso";
locations[73] = Array(); locations[73][27] = "Santa Cruz de La Palma";
locations[46] = Array(); locations[46][28] = "San Sebastián";
locations[53] = Array(); locations[53][28] = "Vallehermoso";
locations[54] = Array(); locations[54][28] = "Playa Santiago";
locations[56] = Array(); locations[56][28] = "Valle Gran Rey";
locations[61] = Array(); locations[61][28] = "Alajeró";
locations[65] = Array(); locations[65][28] = "Hermigua";
locations[50] = Array(); locations[50][29] = "El Golfo";
locations[51] = Array(); locations[51][29] = "La Restinga";
locations[57] = Array(); locations[57][29] = "Valverde";
locations[63] = Array(); locations[63][29] = "El Pinar";
locations[66] = Array(); locations[66][29] = "Frontera";
var next = 0;
var rooms_cnt = 5;
var current_rooms_cnt = 1;
function hide(){
  for(i = current_rooms_cnt; i < rooms_cnt; i++){
    document.getElementById('param_'+i).style.display = 'none';
  }
}
function show(){
  current_rooms_cnt = document.forms[1].rooms_cnt.value;
    for(i = 0; i < current_rooms_cnt; i++){
      param = document.getElementById('param_'+i);
      if(param.style.display != 'block'){
        param.style.display = 'block';
      }
    }
  hide();
}
function openCalendar(cForm, param){
  var url = 'http://www.lanzarote.com/netreservas/calendar1.php';
  var separator = '';
  if (url.indexOf('?') == -1){
    separator = '?'; 
  }else{
    separator = '&';
  }
  var start_params = '&day=' + eval('document.forms[1].'+ param + '_day.value') + '&month=' + eval('document.forms[1].'+ param + '_month.value');
  window.open(url + separator + 'return='+param + start_params, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=200,height=150,screenX=150,screenY=150,top=150,left=150');
  return false;
}
function changeTown(){
  var id = document.forms[1].location_id.value;// location_id combobox
  var j = 1;
  var k = 1;
  while(document.forms[1].town_id.options.length > 0){
    document.forms[1].town_id.options[0] = null;
  }
  if(id > 0){
    document.forms[1].town_id.options[0] = new Option('Todas', 0);
    for(i = 1; i < locations.length; i++){
      if(locations[i] != undefined){
        if(locations[i][id] != undefined){
          document.forms[1].town_id.options[j] = new Option(locations[i][id], i);
          j++;
        }
      }
    }
  } else {
    document.forms[1].town_id.options[0] = new Option('Todas', 0);
    for(i = 1; i < locations.length; i++){
      if(locations[i] != undefined){
        for(j = 1; j < locations[i].length; j++){
          if(locations[i][j] != undefined){
            document.forms[1].town_id.options[k] = new Option(locations[i][j], i);
            k++;
          }
        }
      }
    }
  }
}
function changeBeginDate(){
   var cur_month = 4;
  var cur_year = 2009;
  var cur_day = 12;
  var begin_year = document.forms[1].begin_year.value;
  var begin_month = Math.ceil(document.forms[1].begin_month.value) + cur_month - 1;
  begin_year = cur_year;
  while (begin_month > 12){
    begin_year++;
    begin_month = begin_month - 12;
  }
  document.forms[1].begin_year.value = cur_year;
   document.forms[1].begin_month.value = cur_month;
  var begin_day = document.forms[1].begin_day.value;
  tmp_date = new Date(cur_year, cur_month, cur_day);
  var days_qty = tmp_date.getDate();
  var selected = false;
  document.forms[1].begin_day.options.length = days_qty; // clear all elements
  for(i = 1; i <= days_qty; i++){
    document.forms[1].begin_day.options[i] = new Option(i, i);
  }
  if(cur_day <= days_qty){
    document.forms[1].begin_day.options[cur_day].selected = true;
  } else {
    document.forms[1].begin_day.options[days_qty].selected = true;
  }
  document.forms[1].begin_day.options[0] = null;
}
function changeBeginDateOld(){
   var cur_month = 3;
  var cur_year = 2009;  var begin_year = document.forms[1].begin_year.value;
  var begin_month = Math.ceil(document.forms[1].begin_month.value) + cur_month - 1;

  begin_year = cur_year;
  while (begin_month > 12){
    begin_year++;
    begin_month = begin_month - 12;
  }
  document.forms[1].begin_year.value = begin_year;
  document.forms[1].begin_month.value = begin_month;
 
  var begin_day = document.forms[1].begin_day.value;
  tmp_date = new Date(begin_year, begin_month, 0);
  var days_qty = tmp_date.getDate();
  var selected = false;
  document.forms[1].begin_day.options.length = days_qty; // clear all elements

    for(i = 1; i <= days_qty; i++){
    document.forms[1].begin_day.options[i] = new Option(i, i);
  }
  if(begin_day <= days_qty){
    document.forms[1].begin_day.options[begin_day].selected = true;
  } else {
    document.forms[1].begin_day.options[days_qty].selected = true;
  }
  document.forms[1].begin_day.options[0] = null;
}
function cambiarfechaup(){
	if (Math.ceil(document.forms[1].begin_month.value) > Math.ceil(document.forms[1].end_month.value) )
	document.forms[1].end_month.value = document.forms[1].begin_month.value;
}
function cambiarfechadown(){
	if (Math.ceil(document.forms[1].begin_month.value) > Math.ceil(document.forms[1].end_month.value) )
	document.forms[1].begin_month.value = document.forms[1].end_month.value;
}
function changeEndDate(){
  var cur_month = 4;
  var cur_year = 2009;
  var cur_day =19;
  var end_year = cur_year;
  var end_month = Math.ceil(document.search.end_month.value) + cur_month - 1;
  while (end_month > 12){
    end_year++;
    end_month = end_month - 12;
    document.search.end_year.value = end_year
  }
  document.search.end_year.value = end_year;
  document.search.end_month.value = end_month;
  tmp_date = new Date(end_year, end_month, 0);
  var days_qty = tmp_date.getDate();
  var selected = false;
  document.forms[1].end_day.options.length = days_qty;
  for(i = 1; i <= days_qty; i++){
    document.forms[1].end_day.options[i] = new Option(i, i);
  }
  if(cur_day <= days_qty){
    document.forms[1].end_day.options[cur_day].selected = true;
  } else {
    document.forms[1].end_day.options[days_qty].selected = true;
  }
  document.forms[1].end_day.options[0] = null;
}
function changeEndDateOld(){
  var cur_month =3;
  var cur_year =2009;
  var end_year = cur_year;
  var end_month = Math.ceil(document.forms[1].end_month.value) + cur_month - 1;
  while (end_month > 12){
    end_year++;
    end_month = end_month - 12;
    document.forms[1].end_year.value = end_year
  }
  var end_day = document.forms[1].end_day.value;
  tmp_date = new Date(end_year, end_month, 0);
  var days_qty = tmp_date.getDate();
  var selected = false;
  document.forms[1].end_day.options.length = days_qty;
  for(i = 1; i <= days_qty; i++){
    document.forms[1].end_day.options[i] = new Option(i, i);
  }
  if(end_day <= days_qty){
    document.forms[1].end_day.options[end_day].selected = true;
  } else {
    document.forms[1].end_day.options[days_qty].selected = true;
  }
  document.forms[1].end_day.options[0] = null;
}
function change(value,field){
  document.getElementById(field).firstChild.nodeValue=value;
}
function openLocationWindow(){
  if(document.forms[1].location_id.value > 0){
    window.open('destination_description.php'+'?location_id='+document.forms[1].location_id.value, 'popupWindow');
  }
}
function openTownWindow(){
  if(document.forms[1].town_id.value > 0){
    window.open('destination_description.php'+'?location_id='+document.forms[1].town_id.value, 'popupWindow');
  }
}
function poploading() {
test = new popUp(130, 125, 660, 300, "Div", "<iframe frameborder=0 width=630 height=260 marginheight=0 marginwidth=0 scrolling=no   src='http://www.lanzarote.com/lanzarote_pop_es.html'></iframe>", "white", "black", "bold 10pt sans-serif", "Estamos buscando las mejores ofertas de alojamiento para tu estancia. ", "navy", "white", "#dddddd", "gray", "black", true, true, true, true, false)
}
