// JavaScript Document
virtual1_off = new Image(); virtual1_off.src = "img/exterior_off.gif";
virtual2_off = new Image(); virtual2_off.src = "img/reception_off.gif";
virtual3_off = new Image(); virtual3_off.src = "img/double_off.gif";
virtual4_off = new Image(); virtual4_off.src = "img/suite_off.gif";
virtual5_off = new Image(); virtual5_off.src = "img/suitede1_off.gif";
virtual6_off = new Image(); virtual6_off.src = "img/suitede2.gif";
virtual7_off = new Image(); virtual7_off.src = "img/room1_off.gif";
virtual8_off = new Image(); virtual8_off.src = "img/bathroom_off.gif";
virtual9_off = new Image(); virtual9_off.src = "img/room2_off.gif";
virtual10_off = new Image(); virtual10_off.src = "img/room3_off.gif";
virtual11_off = new Image(); virtual11_off.src = "img/room4_off.gif";
virtual12_off = new Image(); virtual12_off.src = "img/restaurant1_off.gif";
virtual13_off = new Image(); virtual13_off.src = "img/restaurant2_off.gif";
virtual1_on = new Image(); virtual1_on.src = "img/exterior_on.gif";
virtual2_on = new Image(); virtual2_on.src = "img/reception_on.gif";
virtual3_on = new Image(); virtual3_on.src = "img/double_on.gif";
virtual4_on = new Image(); virtual4_on.src = "img/suite_on.gif";
virtual5_on = new Image(); virtual5_on.src = "img/suitede1_on.gif";
virtual6_on = new Image(); virtual6_on.src = "img/suitede2.gif";
virtual7_on = new Image(); virtual7_on.src = "img/room1_on.gif";
virtual8_on = new Image(); virtual8_on.src = "img/bathroom_on.gif";
virtual9_on = new Image(); virtual9_on.src = "img/room2_on.gif";
virtual10_on = new Image(); virtual10_on.src = "img/room3_on.gif";
virtual11_on = new Image(); virtual11_on.src = "img/room4_on.gif";
virtual12_on = new Image(); virtual12_on.src = "img/restaurant1_on.gif";
virtual13_on = new Image(); virtual13_on.src = "img/restaurant2_on.gif";


function kontrola(){
  text = "";

  if (!(document.getElementById('pocet_osob').value.length))
    text += "\n - Invalid number of persons.";

  text += "\n";

  if (!(document.getElementById('jmeno').value.length))
    text += "\n - Invalid name.";
  if (!(document.getElementById('prijmeni').value.length))
    text += "\n - Invalid surname.";
  if (!(document.getElementById('email').value.length))
    text += "\n - Invalid e-mail.";
  if (!(document.getElementById('zeme').value.length))
    text += "\n - Invalid country.";

  text += "\n";
  
  if (document.getElementById('email').value.length){
    chyba = 1;
    for(i=0; i<document.getElementById('email').value.length; i++){
      c = document.getElementById('email').value.charAt(i);
      if (c == "@")
        chyba = 0;
      }
    if (chyba)
      text += "\n - Invalid e-mail format.";
  }
    
  pom_pocet = 0;
  if (document.getElementById('ck_typ').value == 1)
    pom_pocet = 15;
  if (document.getElementById('ck_typ').value == 2)
    pom_pocet = 14;
  if (document.getElementById('ck_typ').value == 3)
    pom_pocet = 16;
  if (document.getElementById('ck_typ').value == 4)
    pom_pocet = 16;
  if (document.getElementById('ck_typ').value == 5)
    pom_pocet = 16;
    
  if(document.getElementById('ck_cislo1').value.length != pom_pocet)
    text += "\n - Invalid credit card number format (expected" +pom_pocet+ " digits).";
  if (!(document.getElementById('ck_ex_month').value.length) || !(document.getElementById('ck_ex_year').value.length))
    text += "\n - Incorrect credit card expiry date.";

  if (text.length > 2)
    alert("The form could not be sent because it contains errors.\nPlease check for errors and send again.\n\nList of errors:\n" + text);
  else
    document.getElementById('form1').submit();
}

function kontrola2(){
  text = "";

  if (!(document.getElementById('pocet_dni').value.length))
    text += "\n - Invalid days.";

  text += "\n";

  if (!(document.getElementById('jmeno').value.length))
    text += "\n - Invalid name.";
  if (!(document.getElementById('prijmeni').value.length))
    text += "\n - Invalid surname.";
  if (!(document.getElementById('email').value.length))
    text += "\n - Invalid e-mail.";

  text += "\n";
  
  if (document.getElementById('email').value.length){
    chyba = 1;
    for(i=0; i<document.getElementById('email').value.length; i++){
      c = document.getElementById('email').value.charAt(i);
      if (c == "@")
        chyba = 0;
      }
    if (chyba)
      text += "\n - Invalid email format.";
  }
    
  pom_pocet = 0;
  if (document.getElementById('ck_typ').value == 1)
    pom_pocet = 15;
  if (document.getElementById('ck_typ').value == 2)
    pom_pocet = 14;
  if (document.getElementById('ck_typ').value == 3)
    pom_pocet = 16;
  if (document.getElementById('ck_typ').value == 4)
    pom_pocet = 16;
  if (document.getElementById('ck_typ').value == 5)
    pom_pocet = 16;
    
  if(document.getElementById('ck_cislo1').value.length != pom_pocet)
    text += "\n - Invalid credit card number format (expected" +pom_pocet+ " digits).";
  if (text.length > 2)
    alert("The form could not be sent because it contains errors.\nPlease check for errors and send again.\n\nList of errors:\n" + text);
  else
    document.getElementById('form1').submit();
}

function virtual_all_on(id){
  pole = new Array("exterior","reception","doubleroom","suite","suitedeluxe1","suitedeluxe2","room1","bathroom","room2","room3","room4","restaurant1","restaurant2");
  for(i=0; i<pole.length; i++)
    document.getElementById(pole[i]).style.color = "white";
  document.getElementById(id).style.color = "black";
}

function online_on(o, x, y, n){
  document.getElementById("ilustracni_foto").style.visibility = "visible";
//  document.getElementById("ilustracni_foto").style.top = y; 
  document.getElementById("ilustracni_foto").style.left = x+10;
  document.getElementById("ilustracni_foto_img").src = "img/" + o.id + ".jpg";
//  document.getElementById("ilustracni_foto_virtual").src = "virtual_tours/" + o.id + ".html";
    document.getElementById("ilustracni_foto_text").value = n;
}

function online_out(o){
  document.getElementById("ilustracni_foto").style.visibility = "hidden";
}
