function searchHotelAdv(pref)
{
  if (document.getElementById("hotel_miasto"+pref).value == "") 
  {
    alert(city_error);
	return false;
  }
  document.getElementById("showhotel"+pref).value = 'hoteladv';
  return true;
}

function searchRestauracjaAdv()
{
  if (document.getElementById("rest_miasto").value == "") 
  {
    alert(city_error);
	return false;
  }  
  document.getElementById("showrestauracja").value = 'restauracjaadv';
  return true;
}

function searchPubAdv()
{
  if (document.getElementById("pub_miasto").value == "") 
  {
    alert(city_error);
	return false;
  }  
  document.getElementById("showpub").value = 'pubadv';
  return true;
}

function searchWydarzenia()
{
 if (document.getElementById("fast_wydarzenia_miasto").value == "") 
 {
  alert(city_error);
  return false;
 }
 return true;
}

function displayEval(show)
{
 if (show != 1) 
 {
  document.getElementById("ocena").style.display = "none";
  document.getElementById("evaluation").style.display = "";
 }
}

function switchReservation(pos)
{
  switch (pos) {
    case "hotel": 
	  document.getElementById("reservation_caption").className = "text_rezerwacja_hotel";
	  document.getElementById("reservation_hotel").style.display = "";
	  document.getElementById("reservation_wycieczka").style.display = "none";
	  document.getElementById("reservation_samochod").style.display = "none";
	  break;
	case "wycieczka":
	  document.getElementById("reservation_caption").className = "text_rezerwacja_wycieczka";
	  document.getElementById("reservation_hotel").style.display = "none";
	  document.getElementById("reservation_wycieczka").style.display = "";
	  document.getElementById("reservation_samochod").style.display = "none";
	  break;
	case "samochod": 
	  document.getElementById("reservation_caption").className = "text_rezerwacja_samochod";
	  document.getElementById("reservation_hotel").style.display = "none";
	  document.getElementById("reservation_wycieczka").style.display = "none";
	  document.getElementById("reservation_samochod").style.display = "";
	  break;
  }
}

function voteHotel(ev)
{
 if (ev == 0) return false;
 if ((ev < 6) && (ev > 0)) 
 {
   document.voteh.vote.value = ev;
   document.voteh.submit();
 }
}

function voteRestaurant(ev)
{
 if (ev == 0) return false;
 if ((ev < 6) && (ev > 0)) 
 {
   document.voter.vote.value = ev;
   document.voter.submit();
 }
}

function votePub(ev)
{
 if (ev == 0) return false;
 if ((ev < 6) && (ev > 0)) 
 {
   document.votep.vote.value = ev;
   document.votep.submit();
 }
}

function switchMainPhoto(srcimg)
{
  var s = "galerie/" + srcimg;
  document.getElementById("mainphoto").src = s;
}

function switchGallery(val)
{
  var act = parseInt(document.getElementById("galact").value);
  if ((act == 1) && (val < 0)) return false;
  var m = parseInt(document.getElementById("maxgal").value);
  if ((act == m) && (val > 0)) return false;
  var s = act + val;
  document.getElementById("gal"+act).style.display = 'none';
  document.getElementById("gal"+s).style.display = '';
  document.getElementById("galact").value = s;
  return false;
}

licz=0;

function windowPhoto(nazwa, xx, yy, desc) 
{
config='left=10,top=10,height='+yy+',width='+xx+',innerheight='+yy+',innerwidth='+xx+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
kitekSC='okno' + licz;
stadion=window.open('',kitekSC,config)
stadion.document.write('<HTML><HEAD>');
stadion.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">');
stadion.document.write('<TITLE>Image</title>');

stadion.document.write('<script language="javascript">');
stadion.document.write('setTimeout(');
stadion.document.write('"self.close()');
stadion.document.write(';",70000)');
stadion.document.write('</');
stadion.document.write('script>');
stadion.document.write('</HEAD>');
stadion.document.write('<body bgcolor=white leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>');
stadion.document.write('<DIV align=center><a href=# onclick="javascript:self.close();"><img src=galerie/'+nazwa+' border=0></A>');
if ((desc != '') && (desc != 'NULL'))
{
  stadion.document.write('<DIV style="background-color: #FFFFFF; position: absolute; bottom: 0px; left: 0px; width: '+xx+'px; font-family: Tahoma; font-size: 12px; opacity: 0.7; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70); padding-top: 5px; padding-bottom: 5px"><DIV><b>'+desc+'</b></DIV></DIV>');
}
stadion.document.write('</DIV>');
stadion.document.write('</body></html>');
stadion.focus();
licz+=1;
}

function openWin(link, x, y)
{
config='left=10,top=10,height='+y+',width='+x+',innerheight='+y+',innerwidth='+x+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
kitekSC='okno' + licz;
stadion=window.open(link,kitekSC,config)
stadion.focus();
licz+=1;	
}

function trySubmit(f, v)
{
  valid = true;
  if (f.res_city.value<1) valid = false;
  if (v == 0)
  {
    if (f.res_data_start.value == "")  valid = false;
    if (f.res_data_stop.value == "")  valid = false;
	if (f.res_lozek.value > f.res_osob.value)  valid = false;
  }
  if (v == 1)
  {
    if (f.res_data.value == "")  valid = false;
  }
  if (!valid)
    alert(error_mesg);
  if (valid) f.submit();
}

function reservation(f, rid)
{
  f.roomid.value = rid;
  f.submit();
}

function ChangeCalendar(datestr, okreg, lang)
{
  $.getJSON("getCalendar.php?d="+datestr+'&o='+okreg+'&l='+lang, function(data){
  				document.getElementById('calendarDiv').innerHTML = '';
				$.each(data, function(i,field){
				$('#calendarDiv').append(field);
			   });
		   	})	 
  
}
