if (document.getElementById && document.getElementsByTagName) {
if (window.addEventListener) window.addEventListener('load', initScrollBars, false);
else if (window.attachEvent) window.attachEvent('onload', initScrollBars);
}

function initScrollBars() {
CSBfleXcroll('aktualne_scroll');
CSBfleXcroll('aktualne_scroll2');
CSBfleXcroll('akcni_scroll');
CSBfleXcroll('odchozi_scroll');
CSBfleXcroll('odchozi_scroll_fotogalerie');
}

function kontrolasoutez() {
	jmeno=document.soutez.jmeno.value;
	prijmeni=document.soutez.prijmeni.value;
	adresa=document.soutez.adresa.value;
	email=document.soutez.email.value;
	odpoved=document.soutez.odpoved.value;

 if (jmeno == ""){
			alert("Jméno musí být vyplněno");
	    document.soutez.jmeno.focus();
	    document.soutez.jmeno.select();
			return false;
			}
 if (prijmeni == ""){
			alert("Příjmení musí být vyplněno");
	    document.soutez.prijmeni.focus();
	    document.soutez.prijmeni.select();
			return false;
			}
 if (adresa == ""){
			alert("Adresa musí být vyplněna");
	    document.soutez.adresa.focus();
	    document.soutez.adresa.select();
			return false;
			}
 if ((email == "") || (email.indexOf("@")<1)){
			alert("Vložte prosím e-mail");
	    document.soutez.email.focus();
	    document.soutez.email.select();
			return false;
			}                      
 if (odpoved == ""){
			alert("Odpověď musí být vyplněna");
	    document.soutez.odpoved.focus();
	    document.soutez.odpoved.select();
			return false;
			}
 } 

function nahled(aaa, wi, he) {
  prewiev = window.open('',aaa,'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width='+ wi +',height='+ he +',left=10,top=10');
  prewiev.document.open();
  prewiev.document.write("<html><head>");
  prewiev.document.write("<title>OC FUTURUM HRADEC KRÁLOVÉ</title></head>");
  prewiev.document.write("<BODY bgcolor=#FFFFFF marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 bottommargin=0 framespacing=0 frameborder=0>");
  prewiev.document.write("<a href=javascript:onClick=window.close()><img src=obchody/"+aaa+".jpg border=0 alt='Kliknutím obrázek zavřete'></a>");
  prewiev.document.write("</body></html>");
  prewiev.document.close();
}

function nahled2(aaa, wi, he) {
  prewiev = window.open('',aaa,'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width='+ wi +',height='+ he +',left=10,top=10');
  prewiev.document.open();
  prewiev.document.write("<html><head>");
  prewiev.document.write("<title>OC FUTURUM HRADEC KRÁLOVÉ</title></head>");
  prewiev.document.write("<BODY bgcolor=#FFFFFF marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 bottommargin=0 framespacing=0 frameborder=0>");
  prewiev.document.write("<a href=javascript:onClick=window.close()><img src=pic/"+aaa+".gif border=0 alt='Kliknutím obrázek zavřete'></a>");
  prewiev.document.write("</body></html>");
  prewiev.document.close();
}

function nahled3(aaa) {
	prewiev2 = window.open('obchody/obrazek.html?'+aaa,'nahledy','toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=200,height=100,left=10,top=10');
	prewiev2.window.focus();
}
function nahled4(aaa, wi, he) {
  prewiev = window.open('',aaa,'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width='+ wi +',height='+ he +',left=10,top=10');
  prewiev.document.open();
  prewiev.document.write("<html><head>");
  prewiev.document.write("<title>OC FUTURUM HRADEC KRÁLOVÉ</title></head>");
  prewiev.document.write("<BODY bgcolor=#FFFFFF marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 bottommargin=0 framespacing=0 frameborder=0>");
  prewiev.document.write("<a href=javascript:onClick=window.close()><img src=aktualne/"+aaa+".jpg border=0 alt='Kliknutím obrázek zavřete'></a>");
  prewiev.document.write("</body></html>");
  prewiev.document.close();
}
function nahled5(aaa) {
	prewiev2 = window.open('aktualne/obrazek.html?'+aaa,'nahledy','toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=200,height=100,left=10,top=10');
	prewiev2.window.focus();
}

function miss(aaa) {
	prewiev2 = window.open('miss/obrazek.html?'+aaa,aaa,'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=200,height=100,left=10,top=10');
	prewiev2.window.focus();
}

function nahledgal(idg,idf) {
	prewiev2 = window.open('fotogalerie/obrazek.asp?idg='+idg+'&idf='+idf,'fotogalerie','toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=200,height=100,left=10,top=10');
	prewiev2.window.focus();
}

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
DOM = (document.getElementById) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

function popUp(menuName,on) {
		if (on) {
			if (NS4) {
				document.layers[menuName].visibility = "show";
			} else if (DOM) {
				document.getElementById(menuName).style.visibility = "visible";
                        } else {
				document.all[menuName].style.visibility = "visible";
			}
		} else {
			if (NS4) {
				document.layers[menuName].visibility = "hide";
			} else if (DOM) {
				document.getElementById(menuName).style.visibility = "hidden";
			} else {
				document.all[menuName].style.visibility = "hidden";
			}
		}
}

function kontrola() {
	Login=document.uprav.Login.value;
	Pass=document.uprav.Pass.value;
	Jmeno=document.uprav.Jmeno.value;
	Prijmeni=document.uprav.Prijmeni.value;
	Email=document.uprav.Email.value;
	Adresa=document.uprav.Adresa.value;
	Mesto=document.uprav.Mesto.value;
	PSC=document.uprav.PSC.value;

 if (Login == ""){
			alert("Login musí být vyplněn");
    document.uprav.Login.focus();
    document.uprav.Login.select();
			return false;
			}
 if (Pass == ""){
			alert("Heslo musí být vyplněno");
    document.uprav.Pass.focus();
    document.uprav.Pass.select();
			return false;
			}
 if (Jmeno == ""){
			alert("Jméno musí být vyplněno");
    document.uprav.Jmeno.focus();
    document.uprav.Jmeno.select();
			return false;
			}
 if (Prijmeni == ""){
			alert("Příjmení musí být vyplněno");
    document.uprav.Prijmeni.focus();
    document.uprav.Prijmeni.select();
			return false;
			}
 if ((Email == "") || (Email.indexOf("@")<1)){
			alert("Vložte prosím e-mail");
    document.uprav.Email.focus();
    document.uprav.Email.select();
			return false;
			}                      
 if (Adresa == ""){
			alert("Adresa musí být vyplněna");
    document.uprav.Adresa.focus();
    document.uprav.Adresa.select();
			return false;
			}
 if (Mesto == ""){
			alert("Město musí být vyplněno");
    document.uprav.Mesto.focus();
    document.uprav.Mesto.select();
			return false;
			}
 if (PSC == ""){
			alert("PSČ musí být vyplněno");
    document.uprav.PSC.focus();
    document.uprav.PSC.select();
			return false;
			}
	if(!document.uprav.souhlas.checked) {
		 alert("Musíte souhlasit s důležitými informacemi a závaznými podmínkami");
	   document.uprav.souhlas.focus();
	   return false;
	}

 } 

function kontrola2() {
	Login=document.vstup.Login.value;
	Pass=document.vstup.Pass.value;

 if (Login == ""){
			alert("Login musí být vyplněn");
    document.vstup.Login.focus();
    document.vstup.Login.select();
			return false;
			}
 if (Pass == ""){
			alert("Heslo musí být vyplněno");
    document.vstup.Pass.focus();
    document.vstup.Pass.select();
			return false;
			}
 } 
function kontrola3() {
	Login=document.zapom.Login.value;

 if (Login == ""){
			alert("Login musí být vyplněn");
    document.zapom.Login.focus();
    document.zapom.Login.select();
			return false;
			}
 } 



function kontrolaletni() {
	tip=document.letni.tip.value;
	jmeno=document.letni.jmeno.value;
	prijmeni=document.letni.prijmeni.value;
	adresa=document.letni.adresa.value;
	email=document.letni.email.value;
	telefon=document.letni.telefon.value;
	nakup=document.letni.nakup.value;

 if (tip == ""){
			alert("Prosíme, vyplňte Váš tip");
    document.letni.tip.focus();
    document.letni.tip.select();
			return false;
			}
 if (jmeno == ""){
			alert("Jméno musí být vyplněno");
    document.letni.jmeno.focus();
    document.letni.jmeno.select();
			return false;
			}
 if (prijmeni == ""){
			alert("Příjmení musí být vyplněno");
    document.letni.prijmeni.focus();
    document.letni.prijmeni.select();
			return false;
			}
 if (adresa == ""){
			alert("Adresa musí být vyplněna");
    document.letni.adresa.focus();
    document.letni.adresa.select();
			return false;
			}
 if ((email == "") || (email.indexOf("@")<1)){
			alert("Vložte prosím e-mail");
    document.letni.email.focus();
    document.letni.email.select();
			return false;
			}                      
 if (telefon == ""){
			alert("Prosíme, vyplňte Váš telefon ");
    document.letni.nakup.focus();
    document.letni.nakup.select();
			return false;
			}
 if (nakup == ""){
			alert("Datum a čas Vašeho nákupu musí být vyplněn.");
    document.letni.nakup.focus();
    document.letni.nakup.select();
			return false;
			}
 if (!document.letni.souhlas.checked){
			alert("Musíte souhlasit s pravidly a zpracováním osobních údajů.");
			return false;
			}
 } 

function kontrolasearch() {

	co=document.hledat.co.value;

if (co == "" || co.length < 3){
			alert("Prosím, vložte minimálně 3 znaky");
		  document.hledat.co.focus();
  		document.hledat.co.select();
			return false;
}
}

function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',10000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
});
