if (!document.getElementById && document.all) document.getElementById = document.all;


function addBookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function okno(soubor, vyska, sirka) {
	window.open(soubor,'','toolbar=no,scrollbars=yes,location=no,status=no,width='+sirka+',height='+vyska+',resizable=1')
}

function formular_hledej(formular)  {
	if (formular.value == "hledaný film") {
		formular.value="";
	}
	return true;
}

function formular_prihlas1(formular)  {
	if (formular.value == "uživatelské číslo") {
		formular.value="";
	}
	return true;
}

function formular_prihlas2(formular)  {
	if (formular.value == "heslo") {
		formular.value="";
	}
	return true;
}

function validate_prihlas(formular)  {
	if ((formular.uz_cislo.value=="") || (formular.uz_cislo.value=="uživatelské číslo"))  {
		alert ("Chyba: vyplňte prosím pole 'už. jméno'.");
		formular.uz_cislo.focus();
		return false;
  	}

	if ((formular.uz_heslo.value=="") || ((formular.uz_cislo.value=="uživatelské číslo") && (formular.uz_heslo.value=="heslo"))) {
		alert ("Chyba: vyplňte prosím pole 'heslo'.");
		formular.uz_heslo.focus();
		return false;
   	}
}

function validate_uzivatel(formular)  {
  if ((formular.zmen_heslo.checked=="true") && (formular.heslo_form.value=="")) {
   alert ("Chyba: vyplňte prosím pole 'Heslo'.");
   formular.heslo_form.focus();
   return false;
  }

  if ((formular.zmen_heslo.checked=="true") && (formular.heslo_form2.value=="")) {
	 alert ("Chyba: vyplňte prosím pole 'Heslo pro kontrolu'.");
   formular.heslo_form2.focus();
   return false;
  }

  if ((formular.zmen_heslo.checked=="true") && (formular.heslo_form.value!=formular.heslo_form2.value)) {
	 alert ("Chyba: 'Heslo' a 'Heslo pro kontrolu' není totožné!");
   formular.heslo_form2.focus();
   return false;
  }

  if (formular.telefon.value=="") {
	 alert ("Chyba: vyplňte prosím pole 'Telefon'.");
	 formular.telefon.focus();
   return false;
  }
}


function validate_kontakt(formular)  {
  if((formular.email.value == "") || (formular.email.value!='') & (formular.email.value.indexOf("@") < 1 || formular.email.value.indexOf("@") != formular.email.value.lastIndexOf("@") || formular.email.value.lastIndexOf(".") < formular.email.value.lastIndexOf("@")+2  || formular.email.value.lastIndexOf(".") > (formular.email.value.length-3) || formular.email.value.lastIndexOf(".") < (formular.email.value.length-4))) {
   alert('Chyba: email nemá správný tvar!');
   formular.email.focus();
   return false;
  }

  if (formular.text.value=="") {
   alert ("Chyba: vyplňte prosím pole 'Dotaz'.");
   formular.text.focus();
   return false;
  }
}

function validate_rezervace(formular)  {
	if (formular.rezervace_od.value=="")  {
		alert ("Chyba: vyplňte prosím pole 'Datum vyzvednutí'.");
		formular.rezervace_od.focus();
		return false;
  	}
}

function validate_hledej(formular)  {
	if (formular.searchtext.value=="")  {
		alert ("Chyba: je třeba vyplnit řetězec pro vyhledání.");
		formular.searchtext.focus();
		return false;
  	}
}

var jeVidetHeslo = false;
if (!document.getElementById && document.all) document.getElementById = document.all;


function heslo(formular)  {
  document.getElementById('heslo_form').disabled = (jeVidetHeslo ? 'true;' : '');
  document.getElementById('heslo_form2').disabled = (jeVidetHeslo ? 'true;' : '');
  jeVidetHeslo = (jeVidetHeslo ? false : true);
}

function logout(sesid, timeout)  {
	countdown(((timeout*60)*1000), sesid);
}

function countdown(timeout, sesid)  {
	timeout = timeout - 1000;
	strTimeout = timeout / 1000;
	strTimeoutMin = strTimeout / 60;
	strTimeoutMin = Math.floor(strTimeoutMin);
	strTimeoutSec = strTimeout - (strTimeoutMin*60);
	strTimeoutSec = Math.floor(strTimeoutSec);
	if (strTimeoutSec<'10') {
		strTimeoutSec = "0"+strTimeoutSec;
	}
	if (strTimeoutMin<'0') {
		document.getElementById('logout').innerHTML = 'Vaše připojení vypršelo!';
 	} else {
		document.getElementById('logout').innerHTML = 'Vaše připojení vyprší za '+strTimeoutMin+':'+strTimeoutSec+'.';
		timerID = setTimeout("countdown('"+timeout+"', '"+sesid+"')",1000);
	}
}

function skoc(adresa) {
  window.open(adresa,"_self");
}

function rezervace(datum) {
  document.getElementById('rezervace_form').rezervace_od.value = datum;
}

function okno(soubor,sirka,vyska)  {
	window.open(soubor,'','toolbar=no,scrollbars=yes,location=no,status=no,width='+sirka+',height='+vyska+',resizable=1')
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}
