$(document).ready(function(){

	/* schovani */

	$("#odkryj-blok").click(function(event) {  
	   event.preventDefault();  
	   $("#schovany-blok").slideToggle();  
	});  
	$("a#zavrit").click(function(event) {  
	   event.preventDefault();  
	   $("#schovany-blok").slideUp();  
	});  
	/* konec schovani */
	
	/* light box */
	
	$(function(){
		$("a[rel^='lightbox']").lightbox();
	});

	/* seznam obchodu */
	$(".seznam-obchodu li:first div.hide").slideDown("fast");
	$(".seznam-obchodu li").click(
		function () {
			$(".seznam-obchodu").find("div.hide").slideUp("fast");
			$(this).find("div.hide").slideDown("fast");
		}
	);
	/* konec seznam obchodu */
	
	/*rozdeleni v seznamu obchodu */
	//http://upsidestudio.com/web/splitcol/
	$('.splitcol').each(function() {
				if($(this).is("ol")) { var ordered = true; }
				var colsize = Math.round($(this).find("li").size() / 2);
				$(this).find("li").each(function(i) {
						 if (i>=colsize) {
									$(this).addClass('right_col');
						 }
				});
				if(ordered) {
						 $(this).find('.right_col').insertAfter(this).wrapAll("<ol class='splitcol' start='" + (colsize+1) + "'></ol>").removeClass("right_col");
				} else {
						 $(this).find('.right_col').insertAfter(this).wrapAll("<ul class='splitcol'></ul>").removeClass("right_col");
				}
		});	
	/*konec rozdeleni*/
	
	
	$("#show").click(
		function () {
		$("div.hide").toggle("fast");
			//$(this).find("div.hide").toggle("fast");
			//$(this).find("div.hide").slideDown("fast");
		}
	);
	
	/*tabs mapa-centra*/
	
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	/* konec tabs - mapa centra*/

	/*slideshow - loga*/
	$(function() {
	    setInterval( "slideSwitch()", 5000 );
	});

	/* konec slideshow - loga */
	
	/*akce obchodu - tabs*/
	$(function(){

	// Tabs
	 $('#rotate > ul').tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000);

	});


		/* marque */
	$(function(){	
		
	  // Add Scroller Object
	  $jScroller.add("#scroller_container","#scroller","left",2,true);
	
	  // Start Autoscroller
	  $jScroller.start();
		
	});
	
	
	
	/*stridani barev radku*/

	$('table.sortable tbody tr:odd').addClass('odd');
  $('table.sortable tbody tr:even').addClass('even');

	
	
});

if (document.getElementById && document.getElementsByTagName) {
if (window.addEventListener) window.addEventListener('load', initScrollBars, false);
else if (window.attachEvent) window.attachEvent('onload', initScrollBars);
}

function initScrollBars() {
	CSBfleXcroll('akcni_scroll');
}



function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // 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}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$/;

function kontrola() {
 if (document.uprav.email.value==""){
			alert("Prosím, vložte svůj e-mail.");
		document.uprav.email.focus();
		document.uprav.email.select();
			return false;
			}
//	Kontrola e-mailu
	if ( document.uprav.email.value !="" ) {
		if (re.test(document.uprav.email.value) == 0) {
			alert ("E-mailová adresa není správná.");
			document.uprav.email.focus();
			document.uprav.email.select();
			return false;
		}
	 }
	 if (document.uprav.oborzajmu.value==""){
		alert("Prosím, vložte obor, o který máte zájem.");
		document.uprav.oborzajmu.focus();
		document.uprav.oborzajmu.select();
		return false;
		}
	 if (document.uprav.poznamka.value== ""){
		alert("Prosím, vložte poznámku.");
		document.uprav.poznamka.focus();
		document.uprav.poznamka.select();
		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 kontrola_registrace() {
	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;
			}

 } 

function kontrolanapiste() {
	
	if (document.napiste.napiste_jmeno.value== ""){
			alert("Prosím, vložte své jméno a příjmení");
			document.napiste.napiste_jmeno.focus();
			document.napiste.napiste_jmeno.select();
			return false;
			}		

 if (document.napiste.napiste_email.value== ""){
			alert("Prosím, vložte svůj email");
			document.napiste.napiste_email.focus();
			document.napiste.napiste_email.select();
			return false;
			}

//	Kontrola e-mailu
	if ( document.napiste.napiste_email.value != "" ) {
		if (re.test(document.napiste.napiste_email.value) == 0) {
			alert ("E-mailová adresa není správná");
			document.napiste.napiste_email.focus();
			document.napiste.napiste_email.select();
			return false;
		}
	}
	
	if (document.napiste.napiste_zprava.value== ""){
			alert("Prosím, vložte zprávu");
			document.napiste.napiste_zprava.focus();
			document.napiste.napiste_zprava.select();
			return false;
			}	
}

// STARY WEB

var path = "img/";

if (document.images) {
  aktualne1= new Image ();
  aktualne1.src= "img/aktualne1.gif";

  obchodysluzby1= new Image ();
  obchodysluzby1.src= "img/obchodysluzby1.gif";

  spravacentra1= new Image ();
  spravacentra1.src= "img/spravacentra1.gif";

  mapacentra1= new Image ();
  mapacentra1.src= "img/mapacentra1.gif";

  nabidkaprostor1= new Image ();
  nabidkaprostor1.src= "img/nabidkaprostor1.gif";

  kestazeni1= new Image ();
  kestazeni1.src= "img/kestazeni1.gif";

  registrace1= new Image ();
  registrace1.src= "img/registrace1.gif";


}

function PushOn(image_name) {
  if (document.images) {
  document.images[image_name].src = path+image_name+"1.gif";
 }
}
function PushOff(image_name) {
  if (document.images) {
  document.images[image_name].src = path+image_name+".gif";
 }
}

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 OSTRAVA</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 OSTRAVA</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=img/"+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 OSTRAVA</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 nahled_miss(aaa) {
	prewiev2 = window.open('aktualne/minimiss2009/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 Otevri(item) {
	if (document.getElementById(item)) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none");
   if (visible) {
     obj.style.display="none";
   } else {
      obj.style.display="block";
   }
  }
}

if (document.getElementById && document.getElementsByTagName) {
if (window.addEventListener) window.addEventListener('load', initScrollBars, false);
else if (window.attachEvent) window.attachEvent('onload', initScrollBars);
}

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";
			}
		}
}
