/**
 *  functions.js
 *  
 * obsahuje
 *  1. obecne fce a pomocne fce
 *  2. kontrolni fce - funkce pro overeni spravneho vyplneni formulare
 *     (samotna logika pro overeni spravnosti vyplneni formulare a chybovych
 *     hlasek je obsazena v souboru checkForm.js)
 *  3. "write" fce - unkce pro vypsani ceny do prislusnych policek
 *  4. "calculate" fce 
 *
 */
 
 
//===============  puvodni fce pro kontrolu ===========================


//================ 1. =====================================
//================ obecne fce =============================

/**
 * int convertMonth(str)
 * prevede mesic z nazvu na jeho cislo
 * @param enum - nazev mesice [leden, unor,...,prosinec]
 * @return int 1-12 jinak -1 pri chybe
 */
function convertMonth(str) {
  var returnVal;
  switch (str) {
    case "leden":
    returnVal = 1;
    break;
    case "unor":
    returnVal = 2;
    break;
    case "brezen":
    returnVal = 3;
    break;
    case "duben":
    returnVal = 4;
    break;
    case "kveten":
    returnVal = 5;
    break;
    case "cerven":
    returnVal = 6;
    break;
    case "cervenec":
    returnVal = 7;
    break;
    case "srpen":
    returnVal = 8;
    break;
    case "zari":
    returnVal = 9;
    break;
    case "rijen":
    returnVal = 10;
    break;
    case "listopad":
    returnVal = 11;
    break;
    case "prosinec":
    returnVal = 12;
    break;
    default:
    returnVal = -1;
  }
  return returnVal;    
}


//================ 2. =====================================
//================ kontrolni fce ==========================

/**
 * Boolean checkSumary () - kontrola formulare v souboru sumary.php + chybova hlaseni uzivateli + focus
 * @return true/false
 */
function checkSumary() {
  var chyby = new Array;
  var focus = new Array;
  
  // nejprve zjistim, co vsechno je spatne
  
  if (!checkName(document.getElementById("jmeno").value)) {
    chyby.push(msgs["spatneJmeno"]);
    focus.push("jmeno");
  }
  var mobil = checkMobil(document.getElementById("mobil").value);
  var email = checkEmail(document.getElementById("email").value);
  var emailVal = document.getElementById("email").value;
  var mobilVal = document.getElementById("mobil").value;
  
  if (mobilVal=="" && emailVal=="") {  // oba jsou prazdne
    chyby.push(msgs["zadejteAlesponJedenKontakt"]);
    focus.push("email");
  }
  if (email && !mobil && mobilVal!="") {
    chyby.push(msgs["zadejteSpravneTelCislo"]);
    focus.push("mobil");
  }
  if (mobil && !email && emailVal!="") {
    chyby.push(msgs["zadejteSpravnyEmail"]);
    focus.push("email");
  }
  if (!mobil && !email && emailVal!="" && mobilVal!="") {
    chyby.push(msgs["zadejteSpravnyEmailAMobil"]);
    focus.push("email");
  }
  if (mobilVal=="" && !email) {
    chyby.push(msgs["zadejteSpravnyEmail"]);
    focus.push("email");
  }
  if (emailVal=="" && !mobil) {
    chyby.push(msgs["zadejteSpravneTelCislo"]);
    focus.push("mobil");
  }
  // nyni osetreni chyb
  if (chyby.length == 0) { // zadne chyby - vse OK
    return true;
  } else {                 // chyby jsou
    window.alert(chyby.join("\n") + "\n");
    if (focus.length > 0 && focus[0]!="noFocus") {
      document.getElementById(focus[0]).focus();
      document.getElementById(focus[0]).style.background = "yellow";
    }
    return false;
  }
}  




/**
 * Boolean checkForm () - kontrola celeho formulare + chybova hlaseni uzivateli + focus
 * @return true/false
 */
function checkForm() {
  var chyby = new Array;
  var focus = new Array;
  if (calculateAllWithoutDiscount() == 0) {
    chyby.push(msgs["prazdnaObjednavka"]);
    focus.push("noFocus");
  }
  // nejprve zjistim, co vsechno je spatne
  if (!checkSchool()) {
    chyby.push(msgs["chybneDatumSkola"]);
    focus.push("skolaOdDen");
  }
  if (!checkPackets()) {
    chyby.push(msgs["chybneDatumPakety"]);
    focus.push("paketyOdDen");
  }
  if (!checkRental()) {
    chyby.push(msgs["chybneDatumPujcovna"]);
    focus.push("pujcovnaOdDen");
  }
  if (!checkFunAway()) {
    chyby.push(msgs["chybneDatumRadovanky"]);
    focus.push("radovankyOdDen");
  }
  if (!checkName(document.getElementById("jmeno").value)) {
    chyby.push(msgs["spatneJmeno"]);
    focus.push("jmeno");
  }
  var mobil = checkMobil(document.getElementById("mobil").value);
  var email = checkEmail(document.getElementById("email").value);
  var emailVal = document.getElementById("email").value;
  var mobilVal = document.getElementById("mobil").value;
  
  if (mobilVal=="" && emailVal=="") {  // oba jsou prazdne
    chyby.push(msgs["zadejteAlesponJedenKontakt"]);
    focus.push("email");
  }
  if (email && !mobil && mobilVal!="") {
    chyby.push(msgs["zadejteSpravneTelCislo"]);
    focus.push("mobil");
  }
  if (mobil && !email && emailVal!="") {
    chyby.push(msgs["zadejteSpravnyEmail"]);
    focus.push("email");
  }
  if (!mobil && !email && emailVal!="" && mobilVal!="") {
    chyby.push(msgs["zadejteSpravnyEmailAMobil"]);
    focus.push("email");
  }
  if (mobilVal=="" && !email) {
    chyby.push(msgs["zadejteSpravnyEmail"]);
    focus.push("email");
  }
  if (emailVal=="" && !mobil) {
    chyby.push(msgs["zadejteSpravneTelCislo"]);
    focus.push("mobil");
  }
  // nyni osetreni chyb
  if (chyby.length == 0) { // zadne chyby - vse OK
    return true;
  } else {                 // chyby jsou
    window.alert(chyby.join("\n") + "\n");
    if (focus.length > 0 && focus[0]!="noFocus") {
      document.getElementById(focus[0]).focus();
      document.getElementById(focus[0]).style.background = "yellow";
    }
    return false;
  }
}  



/**
 * Boolean checkSchool()
 *  - neco objednano? - pak musi byt zadane spravne datum
 * @return false jedine tehdy, kdyz si neco vybral a je spatne datum 
 */
function checkSchool() {
  var i = calculateSchool();
  if (i>0) {
    var dOd = document.getElementById("skolaOdDen").value;    //string nebo int
    var mOd = document.getElementById("skolaOdMesic").value;  //string
    var rOd = document.getElementById("skolaOdRok").value;    //string nebo int
    
    mOd = convertMonth(mOd); // konverze na int

    return checkDate(dOd,mOd,rOd);
  } else {
    return true;
  }  
}

/**
 * Boolean checkPackets()
 *  - neco objednano? - pak musi byt zadane spravne datum
 * @return false jedine tehdy, kdyz si neco vybral a je spatne datum 
 */
function checkPackets() {
  var i = calculatePackets();
  if (i>0) {
    var dOd = document.getElementById("paketyOdDen").value;    //string nebo int
    var mOd = document.getElementById("paketyOdMesic").value;  //string
    var rOd = document.getElementById("paketyOdRok").value;    //string nebo int
  
    mOd = convertMonth(mOd); // konverze na int

    return checkDate(dOd,mOd,rOd);
  } else {
    return true;
  }
}  

/**
 * Boolean checkRental()
 *  - neco objednano? - pak musi byt zadane spravne datum
 * @return false jedine tehdy, kdyz si neco vybral a je spatne datum 
 */
function checkRental() {
  var i = calculateRental(); 
  if (i>0) {
    var dOd = document.getElementById("pujcovnaOdDen").value;    //string nebo int
    var mOd = document.getElementById("pujcovnaOdMesic").value;  //string
    var rOd = document.getElementById("pujcovnaOdRok").value;    //string nebo int
  
    mOd = convertMonth(mOd); // konverze na int

    return checkDate(dOd,mOd,rOd);
  } else {
    return true;
  }
}

/**
 * Boolean checkFunAway()
 *   - neco objednano? - pak musi byt zadane spravne datum
 * @return false jedine tehdy, kdyz si neco vybral a je spatne datum 
 */
function checkFunAway() {
  var i = calculateFunAway(); 
  if (i>0) {
    var dOd = document.getElementById("radovankyOdDen").value;    //string nebo int
    var mOd = document.getElementById("radovankyOdMesic").value;  //string
    var rOd = document.getElementById("radovankyOdRok").value;    //string nebo int
  
    mOd = convertMonth(mOd); // konverze na int

    return checkDate(dOd,mOd,rOd);
  } else {
    return true;
  }
}

/**
 * checkContact()
 *  - funkcnost zastupuje cast fce checkForm() 
/*





/**
 * Boolean checkDate() obecna funkce pro kontrolu data, kontroluje: 
 *  - max. mozny den v mesici
 * - predpoklada parametry typu Int, jinak vraci false  
 * @param denOd - integer
 * @param mesicOd - integer (leden = 1, prosinec = 12)
 * @param rokOd - integer
 * @return false - spatne zadane datum (chybne vyplne)
  *         true - jinak 
 */  
function checkDate(denOd, mesicOd, rokOd, denDo, mesicDo, rokDo) {
  // sebeobrana
  if (denOd<0 || mesicOd<0 || rokOd<0) {
    return false;
  }
  if (denOd=="" || mesicOd=="" || rokOd=="") {
    return false;
  }
  if (isNaN(denOd) || isNaN(mesicOd) || isNaN(rokOd)) {
    return false;
  }
  if ((mesicOd == 2 || mesicOd == 4 ||mesicOd == 6 || mesicOd == 9 || mesicOd == 11) && (denOd == 31)) {
    return false;
  }
  if (mesicOd == 2 && denOd == 30) {
    return false;
  }
  return true;
  
}

/**
 * Boolean checkEmail() - kontrola spravnosti formatu emailove adresy
 * @param str - retezec
 * @return true/false
 */
function checkEmail(str) {
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  var isOK = !r1.test(str) && r2.test(str);
  
  return isOK;
}   

/**
 * Boolean checkMobil() - kontrola spravnosti formatu tel cisla
 *  - predpoklada, ze tel cislo neobsahuje mezery, zacina znakem + a ma pocet cislic >= 6 
 * @param str - tel cislo
 * @return true/false
 */   
function checkMobil(str) {
  var regexp = /^(\d{6,})$/;
     
  var matches = regexp.exec(str); 
  if (matches) {
    return true;
  } else {
    return false;
  }
}

/**
 * Boolean checkName() - kontrola spravnosti jmena
 *  - retezec >= 4
 *  - neni cislo
 *  - neobsahuje cisla a jine neslovni znaky
 * @param str - retezec k vyhudnoceni
 * @return true/false
 */
function checkName(str) {
  var regexp = /\d/;  // existuje ve slove cislo?
  var matches = regexp.exec(str);
  
  return !(matches) && str.length >= 4;
}

//================ 3. =====================================
//================ "write" fce ============================



/**
 * void writeTotalPrice() 
 */ 
function writeTotalPrice() {
  writePriceSchool();
  writePricePackets();
  writePriceRental();
  writePriceFunAway();
  var cena = calculateAllWithoutDiscount();
  document.getElementById("totalPrice").innerHTML = msgs.plnaCena + ": " + cena + " CZK (" + Math.floor(cena / euro) + "EUR) <br />" + msgs.cenaPoSleve + ": " + Math.floor(cena * 0.95) + " CZK (" + Math.floor(cena * 0.95 / euro) + "EUR)" ;
}

/**
 * void writePriceSchool()
 */
function writePriceSchool() {
  var cena = calculateSchool();
  document.getElementById("shoolPrice").innerHTML = msgs.plnaCena + ": " + cena + " CZK (" + Math.floor(cena / euro) + "EUR) <br />" + msgs.cenaPoSleve + ": " + Math.floor(cena * 0.95) + " CZK (" + Math.floor(cena * 0.95 / euro) + "EUR)" ;
}  

/**
 * void writePricePackets()
 */
function writePricePackets() {
  var cena = calculatePackets();
  document.getElementById("packetsPrice").innerHTML = msgs.plnaCena + ": " + cena + " CZK (" + Math.floor(cena / euro) + "EUR) <br />" + msgs.cenaPoSleve + ": " + Math.floor(cena * 0.95) + " CZK (" + Math.floor(cena * 0.95 / euro) + "EUR)" ;
}

/**
 * void writePriceRental()
 */
function writePriceRental() {
  var cena = calculateRental();
  document.getElementById("rentalPrice").innerHTML = msgs.plnaCena + ": " + cena + " CZK (" + Math.floor(cena / euro) + "EUR) <br />" + msgs.cenaPoSleve + ": " + Math.floor(cena * 0.95) + " CZK (" + Math.floor(cena * 0.95 / euro) + "EUR)" ;
}

/**
 * void writePriceFunAway()
 */
function writePriceFunAway() {
  var cena = calculateFunAway();
  document.getElementById("funAwayPrice").innerHTML = msgs.plnaCena + ": " + cena + " CZK (" + Math.floor(cena / euro) + "EUR) <br />" + msgs.cenaPoSleve + ": " + Math.floor(cena * 0.95) + " CZK (" + Math.floor(cena * 0.95 / euro) + "EUR)" ;
}


//================ 4. =====================================
//================ "calculate" fce ========================

/**
 * int calculateAllWithoutDiscount()
 */
function calculateAllWithoutDiscount() {
  return calculateGiftCertif() + calculateSchool() + calculatePackets() + calculateRental() + calculateFunAway();
} 

/**
 * calculateSchool() - spocita cenu za VYUKA
 * @return cenu v Kc
 */
function calculateSchool() {
  return calculatePrivateSchool() + calculateGroupSchool() + calculateNurserySchool();
} 

/**
 * calculatePrivateSchool() - spocita cenu za VYUKA - PRIVATNI VYUKA
 * @return cenu v Kc
 */  
function calculatePrivateSchool() {
  return calculateSkiSchPrivVIP() + calculateSkiSchPrivFaF() + calculateSNBSchPrivVIP() + calculateSNBSchPrivFaF()
    +  calculateCrossCountSchPrivVIP() + calculateCrossCountSchPrivFaF() + calculateTelemarkSchPrivVIP()
    + calculateTelemarkSchPrivFaF() + calculateSkialpSchPrivVIP() + calculateSkialpSchPrivFaF();    
}

/**
 * calculateGroupSchool() - spocita cenu za VYUKA - SKUPINOVA VYUKA
 * @return cenu v Kc
 */  
function calculateGroupSchool() {
  return calculateSkiSchGroup() + calculateSNBSchGroup();
}

/**
 * calculateNurserySchool() - spocita cenu za VYUKA - DETSKA SKOLKA
 * @return cenu v Kc
 */
function calculateNurserySchool() {
  return calculateKidsSchPrivVIP() + calculateKidsSchNursery() + calculateKidsSchNurseryLunch();
}

/**
 * calculatePackets() - spocita cenu za PAKETY
 * @return cenu v Kc
 */
function calculatePackets() {
  return calculatePacketsSki() + calculatePacketsSNB() + calculatePacketsSkolka();
}

/**
 * calculateRental() - spocita cenu za PUJCOVNA
 * @return cenu v Kc
 */
function calculateRental() {
  return calculateRentalKidsSet() + calculateRentalCarvingSet() + calculateRentalSNBSet() + calculateRentalSledges();
}

/**
 * calculateFunAway() - spocita cenu za RADOVANKY
 * @return cenu v Kc
 */
function calculateFunAway() {
  return calculateFunAwaySledge() + calculateFunAwayQuads() + calculateFunAwayTandem();
}  

  
//==============================================================================
//================== SKOLA =====================================================
//== PRIVATNI VYUKA ============================================================

/**
 * calculateSkiSchPrivVIP() - spocita cenu za: PRIVATNI VYUKA - Lyzarska Skola - VIP privat
 * @return cenu v Kc - zohlednuje slevu 10% pri objednavce vice jak 4 hodin
 *
 */ 
function calculateSkiSchPrivVIP() {
    if (document.getElementById("lyzSkolaPrivVIPDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
  	} else {							 // zde index zustava stejny
  	 	var j = document.getElementById("lyzSkolaPrivVIPDny").value;
  	}
  
	return lyzePrivVIPCenik[j];
}

/**
 * calculateSkiSchPrivFaF() - spocita cenu za: PRIVATNI VYUKA - Lyzarska Skola - Rodina a kamaradi
 * @return cenu v Kc
 */ 
function calculateSkiSchPrivFaF() {
  
  if (document.getElementById("lyzSkolaPrivFaFDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
	} else {							 // zde index zustava stejny
	 	var j = document.getElementById("lyzSkolaPrivFaFDny").value;
	}
  
  var i = document.getElementById("lyzSkolaPrivFaFOsoby").value;
  /*
  window.alert(document.getElementById("lyzSkolaPrivFaFDny").value);
  window.alert(document.getElementById("lyzSkolaPrivFaFOsoby").value);
  */
	return lyzePrivFaFCenik[i][j];
}

/**
 * calculateSNBSchPrivVIP() - spocita cenu za: PRIVATNI VYUKA - Snowboardova Skola - VIP privat
 * ceny jsou stejne jako pro lyz vyuku
 * @return cenu v Kc - zohlednuje slevu 10% pri objednavce vice jak 4 hodin
 */
function calculateSNBSchPrivVIP() {
	if (document.getElementById("SNBSkolaPrivVIPDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
  	} else {							 // zde index zustava stejny
  	 	var j = document.getElementById("SNBSkolaPrivVIPDny").value;
  	}
  
	return snbPrivVIPCenik[j];
}

/**
 * calculateSNBSchPrivFaF() - spocita cenu za: PRIVATNI VYUKA - Snowboardova Skola - Rodina a kamaradi
 * @return cenu v Kc
 */
function calculateSNBSchPrivFaF() {
	if (document.getElementById("SNBSkolaPrivFaFDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
	} else {							 // zde index zustava stejny
	 	var j =  document.getElementById("SNBSkolaPrivFaFDny").value;
	}
	
	var i = document.getElementById("SNBSkolaPrivFaFOsoby").value;
	return snbPrivFaFCenik[i][j];
}

/**
 * calculateCrossCountSchPrivVIP() - spocita cenu za: PRIVATNI VYUKA - Bezky - VIP privat
 * ceny jsou stejne jako pro lyz vyuku
 * @return cenu v Kc - zohlednuje slevu 10% pri objednavce vice jak 4 hodin
 */
function calculateCrossCountSchPrivVIP() {
  if (document.getElementById("bezkySkolaPrivVIPDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
  	} else {							 // zde index zustava stejny
  	 	var j = document.getElementById("bezkySkolaPrivVIPDny").value;
  	}
  
	return lyzePrivVIPCenik[j];
}

/**
 * calculateCrossCountSchPrivFaF() - spocita cenu za: PRIVATNI VYUKA - Bezky - Rodina a kamaradi
 * @return cenu v Kc
 */
function calculateCrossCountSchPrivFaF() {
	if (document.getElementById("bezkySkolaPrivFaFDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
	} else {							                                            // zde index zustava stejny
	 	var j = document.getElementById("bezkySkolaPrivFaFDny").value;
	}
  
  var i = document.getElementById("bezkySkolaPrivFaFOsoby").value;
	return lyzePrivFaFCenik[i][j];
}

/**
 * calculateTelemarkSchPrivVIP() - spocita cenu za: PRIVATNI VYUKA - Telemark - VIP privat
 * ceny jsou stejne jako pro lyz vyuku
 * @return cenu v Kc - zohlednuje slevu 10% pri objednavce vice jak 4 hodin
 */
function calculateTelemarkSchPrivVIP() {
  if (document.getElementById("telemarkSkolaPrivVIPDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
  	} else {							 // zde index zustava stejny
  	 	var j = document.getElementById("telemarkSkolaPrivVIPDny").value;
  	}
  
	return lyzePrivVIPCenik[j];
}

/**
 * calculateTelemarkSchPrivFaF() - spocita cenu za: PRIVATNI VYUKA - Telemark - Rodina a kamaradi
 * @return cenu v Kc
 */
function calculateTelemarkSchPrivFaF() {
	if (document.getElementById("telemarkSkolaPrivFaFDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
	} else {							 // zde index zustava stejny
	 	var j = document.getElementById("telemarkSkolaPrivFaFDny").value;
	}
  
  var i = document.getElementById("telemarkSkolaPrivFaFOsoby").value;
	return lyzePrivFaFCenik[i][j];
}

/**
 * calculateSkialpSchPrivVIP() - spocita cenu za: PRIVATNI VYUKA - Skialpy - VIP privat
 * ceny jsou stejne jako pro lyz vyuku
 * @return cenu v Kc - zohlednuje slevu 10% pri objednavce vice jak 4 hodin
 */
function calculateSkialpSchPrivVIP() {
  if (document.getElementById("skialpyPrivVIPDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
  	} else {							 // zde index zustava stejny
  	 	var j = document.getElementById("skialpyPrivVIPDny").value;
  	}
  
	return lyzePrivVIPCenik[j];
}

/**
 * calculateSkialpSchPrivFaF() - spocita cenu za: PRIVATNI VYUKA - Skialp - Rodina a kamaradi
 * @return cenu v Kc
 */
function calculateSkialpSchPrivFaF() {
	if (document.getElementById("skialpySkolaPrivFaFDny").value == "1/2") {  // 1/2 dne ma index 7
		var j = 7;
	} else {							 // zde index zustava stejny
	 	var j = document.getElementById("skialpySkolaPrivFaFDny").value;
	}

  var i = document.getElementById("skialpySkolaPrivFaFOsoby").value;
	return lyzePrivFaFCenik[i][j];
}

//== SKUPINOVA VYUKA ===========================================================

/**
 * calculateSkiSchGroup() - spocita cenu za: SKUPINOVA VYUKA - lyzarska skola
 * @return cenu v Kc
 */
function calculateSkiSchGroup() {
	return lyzeSkupCenik[document.getElementById("lyzVyukaSkupDny").value] * document.getElementById("lyzVyukaSkupOsoby").value;
}

/**
 * calculateSNBSchGroup() - spocita cenu za: SKUPINOVA VYUKA - SNB skola
 * @return cenu v Kc
 */
function calculateSNBSchGroup() {
	return lyzeSkupCenik[document.getElementById("SNBVyukaSkupDny").value] * document.getElementById("SNBVyukaSkupOsoby").value;
}

//== DETSKA VYUKA ==============================================================

/**
 * calculateKidsSchPrivVIP() - spocita cenu za: DETSKA VYUKA - lyzarska skola - VIP privat
 * @return cenu v Kc
 */
function calculateKidsSchPrivVIP() {
  var hodiny = document.getElementById("DetVyukaVIPHodiny").value;
  return skolkaVIPHodinacenik[hodiny];
  //alert ("hodiny : " + hodiny + " cena: " + skolkaVIPHodinacenik[hodiny]);
}

/**
 * calculateKidsSchNursery() - spocita cenu za: DETSKA VYUKA - lyzarska skola - detska skolka
 * @return cenu v Kc
 */
function calculateKidsSchNursery() {
  if(document.getElementById("DetVyukaSkolkaCasovaJednotka").value == "day")
  {
    
    //alert ("pocet osob: " + document.getElementById("DetVyukaSkolkaOsoby").value + " pocet dni " + document.getElementById("DetVyukaSkolkaDny").value + " cena: " + skolkaSkupDnyCenik[document.getElementById("DetVyukaSkolkaDny").value] * document.getElementById("DetVyukaSkolkaOsoby").value);
    return skolkaSkupDnyCenik[document.getElementById("DetVyukaSkolkaDny").value] * document.getElementById("DetVyukaSkolkaOsoby").value;
    //return document.getElementById("DetVyukaSkolkaDny").value * document.getElementById("DetVyukaSkolkaOsoby").value * skolkaSkolickaDenOsoba;
  }
  else
  {
    return skolkaSkupHodCenik[document.getElementById("DetVyukaSkolkaDny").value] * document.getElementById("DetVyukaSkolkaOsoby").value;
    //return document.getElementById("DetVyukaSkolkaDny").value * document.getElementById("DetVyukaSkolkaOsoby").value * skolkaSkolickaHodinaOsoba;
  }
	
}

/**
 * calculateKidsSchNurseryLunch() - spocita cenu za: DETSKA VYUKA - lyzarska skola - detska skolka + obed
 * @return cenu v Kc
 */
function calculateKidsSchNurseryLunch() {
	return skolkaSkolickaObedcenik[document.getElementById("DetVyukaSkolkaObedDny").value] * document.getElementById("DetVyukaSkolkaObedOsoby").value;
}

//==============================================================================
//================== PAKETY ====================================================

/**
 * calculatePacketsSki() - spocita cenu za: PAKETY - SKI
 * @return cenu v Kc
 */
function calculatePacketsSki() {
 
	return paketyDospSkupHSCenik[document.getElementById("paketySkiDny").value] * document.getElementById("paketySkiPocet").value;
}


/**
 * calculatePacketsSNB() - spocita cenu za: PAKETY - SNB
 * @return cenu v Kc
 */
function calculatePacketsSNB() {
	return paketySnbSkupHSCenik[document.getElementById("paketySNBDny").value] * document.getElementById("paketySNBPocet").value;
}



/**
 * calculatePacketsSkolka() - spocita cenu za: PAKETY - SKOLKA
 * @return cenu v Kc
 */
function calculatePacketsSkolka() {
	return paketySkolkaSkupHSCenik[document.getElementById("paketySkolkaDny").value] * document.getElementById("paketySkolkaPocet").value;
}


//==============================================================================
//================== PUJCOVNA ==================================================

/**
 * calculateRentalKidsSet() - spocita cenu za: PUJCOVNA - KIDS SKI SET
 * @return cenu v Kc
 */
function calculateRentalKidsSet() {
  return pujcKidsSkiSetCenik[document.getElementById("pujcKidsSetDny").value] * document.getElementById("pujcKidsSetKusy").value;
}

/**
 * calculateRentalCarvingSet() - spocita cenu za: PUJCOVNA - CARVING SET
 * @return cenu v Kc
 */
function calculateRentalCarvingSet() {
	return pujcCarvSkiSetCenik[document.getElementById("pujcCarvingSetDny").value] * document.getElementById("pujcCarvingSetKusy").value;
}

/**
 * calculateRentalSNBSet() - spocita cenu za: PUJCOVNA - SNB SET
 * @return cenu v Kc
 */
function calculateRentalSNBSet() {
	return pujcSnbSetCenik[document.getElementById("pujcSNBSetDny").value] * document.getElementById("pujcSNBSetKusy").value;
}


/**
 * calculateRentalSledges() - spocita cenu za: PUJCOVNA - SANE
 * @return cenu v Kc
 */
function calculateRentalSledges() {
	return pujcSaneCenik[document.getElementById("pujcSaneDny").value] * document.getElementById("pujcSaneKusy").value;
}


//==============================================================================
//================== RADOVANKY MIMO SJEZDOVKU ==================================

/**
 * calculateFunAwaySledge() - spocita cenu za: RADOVANKY MIMO SJEZDOVKU - SANKY
 * @return cenu v Kc
 */
function calculateFunAwaySledge() {
	if (document.getElementById("radovankySaneDruh").value == "celodenni") {
		return document.getElementById("radovankySaneOsoby").value * saneCelodenvyletOsoba;
	} else {
		return document.getElementById("radovankySaneOsoby").value * saneNocvyletOsoba;
	}
}

/**
 * calculateFunAwayQuads() - spocita cenu za: RADOVANKY MIMO SJEZDOVKU - CTYRKOLKY
 * @return cenu v Kc
 */
function calculateFunAwayQuads() {
  var numberOfPersons =  document.getElementById("radovankyCtyrkolkyOsoby").value;
	
	return numberOfPersons * ctyrkolkyOsoba;
}

/**
 * calculateFunAwayTandem() - spocita cenu za: RADOVANKY MIMO SJEZDOVKU - TANDEM PARAGLIDING
 * @return cenu v Kc
 */
function calculateFunAwayTandem() {
	var persons = document.getElementById("radovankyTandemOsoby").value;
	var price = 0;
	if (persons > 0 && persons == 1) {
		price = persons * tandemOsoba;
	} else if(persons > 1 ) {
		price = persons * tandemOsoba2;
	}
	
	return price;
}


//==============================================================================
//================== DARKOVE CERTIFIKATY =======================================
////////////////////////////// DARKOVE CERTIFIKATY

function calculateGiftCertif() {
  return calculateGiftCertifLyzSkola()
           + calculateGiftCertifCertifCtyrkolky()
           + calculateGiftCertifTandempara()
           + calculateGiftCertifPujcovna()
           + calculateGiftCertifNocniSane()
           + calculateGiftCertifLanac();
}


function calculateGiftCertifLyzSkola() {
  if(document.getElementById("darkCertifLyzSkolaPocet") == null)
  {
    return 0;
  }
  else
  {
    var pocet = document.getElementById("darkCertifLyzSkolaPocet").value;
    return pocet * certifLyzSkola;
  }
   
}

function calculateGiftCertifCertifCtyrkolky() {
  if(document.getElementById("darkCertifCtyrkolkyPocet") == null)
  {
    return 0;
  }
  else
  {
    var pocet = document.getElementById("darkCertifCtyrkolkyPocet").value;
    return pocet * certifCtyrkolky;  
  }  
}

function calculateGiftCertifTandempara() {
  if(document.getElementById("darkCertifTandemparaPocet") == null)
  {
    return 0;
  }
  else
  {
    var pocet = document.getElementById("darkCertifTandemparaPocet").value;
    return pocet * certifTandempara; 
  }  
   
}

function calculateGiftCertifPujcovna() {
  if(document.getElementById("darkCertifPujcovnaPocet") == null)
  {
    return 0;
  }
  else
  {
   var pocet = document.getElementById("darkCertifPujcovnaPocet").value;
    return pocet * certifPujcovna;
  }    
}

function calculateGiftCertifNocniSane() {
  if(document.getElementById("darkCertifNocniSanePocet") == null)
  {
    return 0;
  }
  else
  {
   var pocet = document.getElementById("darkCertifNocniSanePocet").value;
   return pocet * certifNocniSane;
  }
  
}

function calculateGiftCertifLanac() {
  if(document.getElementById("darkCertifLanacPocet") == null)
  {
    return 0;
  }
  else
  {
   var pocet = document.getElementById("darkCertifLanacPocet").value;
  return pocet * certifLanac;
  }  
}










