function over(mesic, rok) {
	dnes = new Date();
	if(rok <= dnes.getYear() && mesic < (dnes.getMonth() + 1)) {
		window.alert("Zadali jste chybné datum.");
		return false;
	}
	else return true;
}
function otevriOknoHned(cesta, sirka, vyska) {
  window.open("../" + cesta + ".html", "Rezervace", "resizable=auto,status=no,menubar=no,toolbar=no,scrollbars=yes,width=" + sirka + ",height=" + vyska );
}
function otevriOkno() {
	window.open("../../../volter.php","","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=400, height=450, top=100, left=100");
}
function odkazOkno(cesta, sirka, vyska) {
	window.open("../../../obr/" + cesta,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=" + sirka + ", height=" + vyska + ", top=100, left=100");	
}
function funkce(tdID) {
  zmena = false;
	pomoc = tdID.split("-");
	tdID_den = pomoc[0];
	tdID_pozice = pomoc[1];
	obsazenost_den = form2.elements[tdID_den-1].value.split("-");
  if(tdID_pozice == '3') {
    obsazenost = obsazenost_den[2];
  }
  else {
    obsazenost = obsazenost_den[0];
  }
  if(obsazenost == 3 && !zmena) {
    with(document) {
      if (tdID_pozice == '3') {
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(255, 205, 151)";
        getElementById(tdID_den+'-2').style.backgroundColor = "rgb(255, 205, 151)";
        form2.elements[tdID_den-1].value = obsazenost_den[0]+"-0-0";
        tdID_den++;
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(255, 205, 151)";
        getElementById(tdID_den+'-2').style.backgroundColor = "rgb(255, 205, 151)";
        form2.elements[tdID_den-1].value = "0-0-"+form2.elements[tdID_den-1].value.split("-")[2];
        tdID_den--;
      }
      else {
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(255, 205, 151)";
        getElementById(tdID_den+'-2').style.backgroundColor = "rgb(255, 205, 151)";
        form2.elements[tdID_den-1].value = "0-0-"+obsazenost_den[2];
        tdID_den--;
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(255, 205, 151)";
        getElementById(tdID_den+'-2').style.backgroundColor = "rgb(255, 205, 151)";
        form2.elements[tdID_den-1].value = form2.elements[tdID_den-1].value.split("-")[0]+"-0-0";
        tdID_den++;
      }        
    }
    zmena = true;
  }
	if(obsazenost == 2 && !zmena) {
	  with(document) {
      if (tdID_pozice == '3') {
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(255, 255, 255)";
        getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-1').style.backgroundColor;
        form2.elements[tdID_den-1].value = obsazenost_den[0]+"-"+obsazenost_den[0]+"-3";
        //window.alert(form2.elements[tdID_den-1].value);
        tdID_den++;
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(255, 255, 255)";
        getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-3').style.backgroundColor;
        form2.elements[tdID_den-1].value = "3-"+form2.elements[tdID_den-1].value.split("-")[2]+"-"+form2.elements[tdID_den-1].value.split("-")[2];
        tdID_den--;
      }
      else {
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(255, 255, 255)";
        getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-3').style.backgroundColor;
        form2.elements[tdID_den-1].value = "3-"+obsazenost_den[2]+"-"+obsazenost_den[2];
        tdID_den--;
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(255, 255, 255)";
        getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-1').style.backgroundColor;
        form2.elements[tdID_den-1].value = form2.elements[tdID_den-1].value.split("-")[0]+"-"+form2.elements[tdID_den-1].value.split("-")[0]+"-3";
        tdID_den++;
      }        
    }
    zmena = true;
	}
	if(obsazenost == 1 && !zmena) {
	  with(document) {
      if (tdID_pozice == '3') {
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(134, 116, 81)";
        if (obsazenost_den[0] == '3') {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(134, 116, 81)";
          form2.elements[tdID_den-1].value = "3-2-2";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-1').style.backgroundColor;
          form2.elements[tdID_den-1].value = obsazenost_den[0]+"-"+obsazenost_den[0]+"-2";
        }
        tdID_den++;
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(134, 116, 81)";
        if (form2.elements[tdID_den-1].value.split("-")[2] == '3') {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(134, 116, 81)";
          form2.elements[tdID_den-1].value = "2-2-3";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-3').style.backgroundColor;
          form2.elements[tdID_den-1].value = "2-"+form2.elements[tdID_den-1].value.split("-")[2]+"-"+form2.elements[tdID_den-1].value.split("-")[2];
        }
        tdID_den--;
      }
      else {
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(134, 116, 81)";
        if (obsazenost_den[2] == '3') {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(134, 116, 81)";
          form2.elements[tdID_den-1].value = "2-2-3";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-3').style.backgroundColor;
          form2.elements[tdID_den-1].value = "2-"+obsazenost_den[2]+"-"+obsazenost_den[2];
        }
        tdID_den--;
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(134, 116, 81)";
        if (form2.elements[tdID_den-1].value.split("-")[0] == '3') {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(134, 116, 81)";
          form2.elements[tdID_den-1].value = "3-2-2";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = getElementById(tdID_den+'-1').style.backgroundColor;
          form2.elements[tdID_den-1].value = form2.elements[tdID_den-1].value.split("-")[0]+"-"+form2.elements[tdID_den-1].value.split("-")[0]+"-2";
        }
        tdID_den++;
      }        
    }
		zmena = true;
	}
	if(obsazenost == 0 && !zmena) {
	  with(document) {
      if (tdID_pozice == '3') {
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(217, 167, 107)";
        if (obsazenost_den[0] == '0') {
          form2.elements[tdID_den-1].value = "0-0-1";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(217, 167, 107)";
          form2.elements[tdID_den-1].value = obsazenost_den[0]+"-1-1";
        }
        tdID_den++;
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(217, 167, 107)";
        if (form2.elements[tdID_den-1].value.split("-")[2] == '0') {
          form2.elements[tdID_den-1].value = "1-0-0";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(217, 167, 107)";
          form2.elements[tdID_den-1].value = "1-1-"+form2.elements[tdID_den-1].value.split("-")[2];
        }
        tdID_den--;
      }
      else {
        getElementById(tdID_den+'-1').style.backgroundColor = "rgb(217, 167, 107)";
        if (obsazenost_den[2] == '0') {
          form2.elements[tdID_den-1].value = "1-0-0";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(217, 167, 107)";
          form2.elements[tdID_den-1].value = "1-1-"+obsazenost_den[2];
        }
        tdID_den--;
        getElementById(tdID_den+'-3').style.backgroundColor = "rgb(217, 167, 107)";
        if (form2.elements[tdID_den-1].value.split("-")[0] == '0') {
          form2.elements[tdID_den-1].value = "0-0-1";
        }
        else {
          getElementById(tdID_den+'-2').style.backgroundColor = "rgb(217, 167, 107)";
          form2.elements[tdID_den-1].value = form2.elements[tdID_den-1].value.split("-")[0]+"-1-1";
        }
        tdID_den++;
      }        
    }
		zmena = true;
	}
}

function barva(cislo,tdID) {
	switch(cislo) {
		case 0: document.getElementById(tdID).style.backgroundColor = "#FFCD97"; break;
		case 1: document.getElementById(tdID).style.backgroundColor = "#D9A76B"; break;
		case 2: document.getElementById(tdID).style.backgroundColor = "#867451"; break;
		case 3: document.getElementById(tdID).style.backgroundColor = "#FFFFFF"; break;
	}
}

