



function bookHotel(hotel)
{
  document.result.selectedhotel.value = hotel;
  document.result.submit();
}

function bookTransfer(transfer, vehicle)
{
  document.result.selectedtransfer.value = transfer;
  document.result.selectedvehicle.value = vehicle;
  document.result.action = 'tbook.jsp';
  document.result.submit();
}

function bookApartment(apartment, unit)
{
  document.result.selectedapartment.value = apartment;
  document.result.selectedunit.value = unit;
//  document.result.action = 'abook.jsp';
  document.result.submit();
}

function bookSightseeing(sightseeing, tour)
{
  document.result.selectedsightseeing.value = sightseeing;
  document.result.selectedtour.value = tour;
  document.result.action = 'sbook.jsp';
  document.result.submit();
}

function fillRoomCount(room)
{
  var roomParam = eval('document.search.'+ room); 
  if (roomParam.value == '')
	roomParam.value = 1;
}

function checkHotelSearch()
{
  var bSuccess = false;
  if (document.search.checkindate != null && document.search.checkindate.value == '')
  {
    document.search.checkindate.focus();
    window.alert('Prosím vyplňte dátum nástupu');
  }
  else if (document.search.periodofstay != null && document.search.periodofstay.value == '')
  {
    document.search.periodofstay.focus();
    window.alert('Prosím vyplňte počet nocí');
  } 
  else if (document.search.roomtype1.value == '' &&
  		   document.search.roomtype2.value == '' &&
  		   document.search.roomtype3.value == '' &&
  		   document.search.roomtype4.value == '')
  {
    document.search.roomtype1.focus();
    window.alert('Prosím vyberte si izbu');
  }  		   
  else
  {
    bSuccess = true;
  }
  
  if (bSuccess && window.RegExp)
  {
    var reDateTime = /^\d{1,2}\.\d{1,2}\.\d{4}\ *(\d{2}\:\d{2}(.*))?$/;

    if (bSuccess)
    {
      // check CheckInDate
      if (!reDateTime.test(document.search.checkindate.value))
      {
        document.search.checkindate.focus();
	    window.alert("Nesprávne zadaný dátum nástupu.");
  		bSuccess = false;
      }
      else
      {
        bSuccess = true;
      }
    }
  }  

  return bSuccess;
}

function checkHotelBooking(iPageValue)
{
  var bSuccess = false;
  var bPaxs = true;
  
  if (iPageValue == 1)
  {
    var pax;
    for (var i=document.book.paxs.value; i>=1; i--)
    {
      pax = eval('document.book.paxname'+ i);
      if (pax != null && pax.value == '')
      {
        bPaxs = false;
        pax.focus();
      }
    }

    if (!bPaxs)
    {
      window.alert('Prosím uveďte prvé a posledné meno každého cestujúceho');
    }
    else
    {
      bSuccess = true;
      
      document.book.page.value = 2;
    }

  }
  else if (iPageValue == 2)
  {
    bSuccess = true;
    
    document.book.page.value = 3;

  }

  return bSuccess;
}

function checkApartmentSearch()
{
  var bSuccess = false;
  if (document.apartmanSearch.checkindate != null && document.apartmanSearch.checkindate.value == '')
  {
    document.apartmanSearch.checkindate.focus();
    window.alert('Prosím vyplňte dátum nástupu');
  }
  else if (document.apartmanSearch.periodofstay != null && document.apartmanSearch.periodofstay.value == '')
  {
    document.apartmanSearch.periodofstay.focus();
    window.alert('Prosím vyplňte počet nocí');
  }
  else if (document.apartmanSearch.adultscount != null && document.apartmanSearch.adultscount.value == '')
  {
    document.apartmanSearch.adultscount.focus();
    window.alert('Prosím vyplňte počet dospelých');
  }
  else
  {
    bSuccess = true;
  }
  
  if (bSuccess && window.RegExp)
  {
    var reDateTime = /^\d{1,2}\.\d{1,2}\.\d{4}\ *(\d{2}\:\d{2}(.*))?$/;

    if (bSuccess)
    {
      // check CheckInDate
      if (!reDateTime.test(document.apartmanSearch.checkindate.value))
      {
        document.apartmanSearch.checkindate.focus();
  		window.alert('Nesprávne zadaný dátum nástupu.');
  		bSuccess = false;
      }
      else
      {
        bSuccess = true;
      }
    }
  }
  
  if (bSuccess && document.apartmanSearch.childscount !== null && document.apartmanSearch.childscount.value != '')
  {
    var age;
    var bAges = true;
    
    for (var i=1; i<=document.apartmanSearch.childscount.value; i++)
    {
      age = eval('document.apartmanSearch.childage'+ i);
      if (age != null && age.value == '')
      {
        bAges = false;
        age.focus();
      }
    }

    if (!bAges)
    {
      window.alert('Prosím zadajte vek všetkých detí');
      bSuccess = false;
    }
    else
    {
      bSuccess = true;
    }
  
  }
  return bSuccess;
}

function checkApartmentBooking(iPageValue)
{
  var bSuccess = false;
  var bPaxs = true;
//  var iPageValue = Number(document.book.page.value);
  
  if (iPageValue == 1)
  {
	if (document.book.checkindate != null && document.book.checkindate.value == '')
  	{
      document.book.checkindate.focus();
      window.alert('Prosím vyplňte dátum nástupu');
    }
    else if (document.book.adultscount != null && document.book.adultscount.value == '')
    {
      document.book.adultscount.focus();
      window.alert('Prosím vyplňte počet dospelých');
    }
    else
    {
      bSuccess = true;
    
      document.book.page.value = 2;
    }
  }
  else if (iPageValue == 2)
  {
    var pax;
    for (var i=document.book.paxs.value; i>=1; i--)
    {
      pax = eval('document.book.paxname'+ i);
      if (pax != null && pax.value == '')
      {
        bPaxs = false;
        pax.focus();
      }
    }

    if (!bPaxs)
    {
      window.alert('Prosím uveďte prvé a posledné meno každého cestujúceho');
    }
    else
    {
      bSuccess = true;
      
      document.book.page.value = 3;
    }

  }
  else if (iPageValue == 3)
  {
    bSuccess = true;

    document.book.page.value = 4;
  }

  return bSuccess;
}

function doBackPage()
{
  history.back();
}

function checkTransferSearch()
{
  var bSuccess = false;
  if (document.search.checkindate != null && document.search.checkindate.value == '')
  {
    document.search.checkindate.focus();
    window.alert('Prosím vyplňte dátum nástupu');
  }
  else if (document.search.periodofstay != null && document.search.periodofstay.value == '')
  {
    document.search.periodofstay.focus();
    window.alert('Prosím vyplňte počet nocí');
  } 
  else
  {
    bSuccess = true;
  }
  
  if (bSuccess && window.RegExp)
  {
    var reDateTime = /^\d{1,2}\.\d{1,2}\.\d{4}\ *(\d{2}\:\d{2}(.*))?$/;

    if (bSuccess)
    {
      // check CheckInDate
      if (!reDateTime.test(document.search.checkindate.value))
      {
        document.search.checkindate.focus();
  		window.alert("Nesprávne zadaný dátum nástupu.");
  		bSuccess = false;
      }
      else
      {
        bSuccess = true;
      }
    }
  }

  return bSuccess;
}

function checkTransferBooking(iPageValue)
{
  var bSuccess = false;
  var bPaxs = true;
  
  if (iPageValue == 1)
  {
	if (document.book.arrivehour != null && document.book.arrivehour.value == '')
    {
      document.book.arrivehour.focus();
      window.alert('Prosím uveďte čas príchodu');
    }
    else if (document.book.arriveminute != null && document.book.arriveminute.value == '')
    {
      document.book.arriveminute.focus();
      window.alert('Prosím uveďte čas príchodu');
    }
    else if (document.book.arrivefrom != null && document.book.arrivefrom.value == '')
    {
      document.book.minute.focus();
      window.alert('Prosím vyberte miesto vyzdvihnutia');
    }
	if (document.book.departurehour != null && document.book.departurehour.value == '')
    {
      document.book.departurehour.focus();
      window.alert('Prosím uveďte čas odchodu');
    }
    else if (document.book.departureminute != null && document.book.departureminute.value == '')
    {
      document.book.departureminute.focus();
      window.alert('Prosím uveďte čas odchodu');
    }
    else
    {
      bSuccess = true;
      
      document.book.page.value = 2;
    }
  }
  else if (iPageValue == 2)
  {
	if (document.book.paxname != null && document.book.paxname.value == '')
    {
      document.book.paxname.focus();
      window.alert('Prosím uveďte meno zastupujúceho/cej');
    }
    else
    {
      bSuccess = true;
      
      document.book.page.value = 3;
    }
  }
  return bSuccess;
}

function checkSightseeingSearch()
{
  var bSuccess = false;
  if (document.search.checkindate != null && document.search.checkindate.value == '')
  {
    document.search.checkindate.focus();
    window.alert('Prosím vyplňte dátum nástupu');
  }
  else if (document.search.adultscount != null && document.search.adultscount.value == '')
  {
    document.search.adultscount.focus();
    window.alert('Prosím uveďte aspoň jedného cestujúceho');
  }
  else if (document.search.languagecode != null && document.search.languagecode.value == '')
  {
    document.search.languagecode.focus();
    window.alert('Prosím vyberte konkrétny jazyk');
  }
  else
  {
    bSuccess = true;
  }
  
  if (bSuccess && window.RegExp)
  {
    var reDateTime = /^\d{1,2}\.\d{1,2}\.\d{4}\ *(\d{2}\:\d{2}(.*))?$/;

    if (bSuccess)
    {
      // check CheckInDate
      if (!reDateTime.test(document.search.checkindate.value))
      {
        document.search.checkindate.focus();
  		window.alert("Nesprávne zadaný dátum nástupu.");
  		bSuccess = false;
      }
      else
      {
        bSuccess = true;
      }
    }
  }
  
  if (bSuccess && document.search.childscount !== null && document.search.childscount.value != '')
  {
    var age;
    var bAges = true;
    
    for (var i=1; i<=document.search.childscount.value; i++)
    {
      age = eval('document.search.childage'+ i);
      if (age != null && age.value == '')
      {
        bAges = false;
        age.focus();
      }
    }

    if (!bAges)
    {
      window.alert('Prosím zadajte vek všetkých detí');
      bSuccess = false;
    }
    else
    {
      bSuccess = true;
    }
  
  }
  return bSuccess;
}

function checkSightseeingBooking()
{
  var bSuccess = false;
  var bPaxs = true;
  var iPageValue = document.book.page.value;
  
  if (iPageValue == 1)
  {
    if (document.book.languagecode != null && document.book.languagecode.value == '')
    {
      document.book.languagecode.focus();
      window.alert('Prosím vyberte konkrétny jazyk');
    }
    else if (document.book.departure != null && document.book.departure.value == '')
    {
      document.book.departure.focus();
      window.alert('Prosím vyberte miesto vyzdvihnutia');
    }
    else
    {
      bSuccess = true;
    
      document.book.page.value = 2;
    }
  }
  else if (iPageValue == 2)
  {
    var pax;
    for (var i=document.book.paxs.value; i>=1; i--)
    {
      pax = eval('document.book.paxname'+ i);
      if (pax != null && pax.value == '')
      {
        bPaxs = false;
        pax.focus();
      }
    }

    if (!bPaxs)
    {
      window.alert('Prosím uveďte prvé a posledné meno každého cestujúceho');
    }
    else
    {
      bSuccess = true;
      
      document.book.page.value = 3;
    }

  }

  return bSuccess;
}


function resetHotelSearch()
{
  document.result.resetsearch.value = 'true';
  document.result.action = 'hsearch.jsp';
  document.result.submit();
  return false;
}

function resetApartmentSearch()
{
  document.search.resetsearch.value = 'true';
  document.search.action = 'asearch.jsp';
  document.search.submit();
  return false;
}

function resetTransferSearch()
{
  document.search.resetsearch.value = 'true';
  document.search.page.value = '1';
  document.search.action = 'tsearch.jsp';
  document.search.submit();
  return false;
}

function resetSightseeingSearch()
{
  document.search.resetsearch.value = 'true';
  document.search.page.value = '1';
  document.search.action = 'ssearch.jsp';
  document.search.submit();
  return false;
}

function changeAddressVisibility()
{
  var addressLine;

  if (document.book.address.checked)
  {
    document.book.arriveitemcode.style.visibility = 'hidden';
    document.book.address.style.visibility = 'visible';
  }
  else
  {
    document.book.arriveitemcode.style.visibility = 'visible';
    document.book.address.style.visibility = 'hidden';
  }
}

function changeAddressVisibility2(cb, selectId, addressId)
{
  var addressLine;

  if (cb.checked)
  {
    showHideElement(selectId, false);
    showHideElement(addressId, true);
  }
  else
  {
    showHideElement(selectId, true);
    showHideElement(addressId, false);
  }
}