re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$/;

$(document).ready(function() {
/*
$("#banner-obsah").jCarouselLite({
		auto: 2000,
		speed: 350,
		visible: 6
	});
*/


/* top menu */	
	$("#top-menu a:first").css("border","none");
	
	$("#top-menu div").each(function() {
		var thisOneWidth = $(this).width();
		var thisOneMargin = (thisOneWidth / 2) * -1;
		$(this).css("marginLeft", thisOneMargin);
		var pridejZobacek = $(this).html() + "<span class='subArrow'>&nbsp;</span>";
		$(this).html(pridejZobacek);
		$(this).find(".sub-top").find("li").css("width",thisOneWidth - 30);
	});
	
	$(".btn-top-menu").hover(function() {
		$(this).find("div").fadeIn("fast", function() {
			$(this).css("opacity","0.90");
		});
	}, function() {
		$(this).find("div").fadeOut("fast");
	});
	
/* top menu - konec */

/* prepinani produkt menu */

	/* zapne menu a submenu, ktere obsahuje polozku item-aktivni, pokud takova neni, zapne se menu dle rad */
	if ($(".produkt-menu").find(".item-aktivni").length > 0) {
		$(".item-aktivni").parent("li").parent("ul").parent("li").parent("ul").css("display", "block");
		$(".item-aktivni").parent("li").parent("ul").css("display", "block");
		$(".item-aktivni-b").parent("li").parent(".sub-menu").css("display", "block");
	} else {
		$("#dle-rad").css("display", "block");
	}
	
	$(".produkt-menu h2").click(function() {
		var aktivniMenu = $(this).parent("div").find(".produkt-menu-ul");
		var aktivniMenuStav = aktivniMenu.css("display");
		if (aktivniMenuStav == "none") {
			$(".produkt-menu .produkt-menu-ul").slideUp("normal");
			$(".produkt-menu-ul .sub-menu").slideUp("fast");
			aktivniMenu.slideDown("normal");
			aktivniMenu.find(".item-aktivni, .item-aktivni-b").parent("li").parent(".sub-menu").slideDown("fast");
		}
	});
	
	/* prepina na klik submenu v menu dle pece */
	$(".produkt-menu-ul h3").click(function() {
		var aktivniSubMenu = $(this).parent("li").find(".sub-menu");
		var aktivniSubMenuStav = aktivniSubMenu.css("display");
		if (aktivniSubMenuStav == "none") {
			$(".produkt-menu-ul .sub-menu").slideUp("fast");
			aktivniSubMenu.slideDown("fast");
		}
	});

/* prepinani produkt menu - konec */

/* produkt menu onmouse */
	$(".produkt-menu-ul h3, .produkt-menu-ul .h3").each(function() {
		var aContent = "<span class='sp2'>&nbsp;</span><span class='sp1'>" + $(this).html() + "</span>";
		$(this).html(aContent);
	});
	
	$(".produkt-menu-ul h3, .produkt-menu-ul .h3").hover(function() {
		$(this).find(".sp2").css("left", "0px");
	}, function() {
		$(this).find(".sp2").css("left", "-220px");
		/*$(this).find(".sp2").animate({ 
			left: "-220px"
		}, "fast" );*/
	});
	
	$(".sub-menu a").hover(function() {
		$(this).animate({ 
			paddingLeft: "45px"
		}, 200 );
	}, function() {
		$(this).animate({ 
			paddingLeft: "25px"
		}, 100 );
	});
	
	$(".sub-menu-open a").hover(function() {
		$(this).animate({
			paddingLeft: "45px"
		}, 200 );
	}, function() {
		$(this).animate({
			paddingLeft: "25px"
		}, 100 );
	});
/* produkt menu onmouse - konec */

/* vycentrovani nahledu produktu + akce, novinka a bestseller */

	$(".produktImage a img, .produktImage span img").each(function () {
		vystredS = ($(this).width()/2)*-1;
		vystredV = ($(this).height()/2)*-1;
		$(this).css("margin-left", vystredS);
		$(this).css("margin-top", vystredV);
		$(this).css("display", "block");
	});
	
	$(".akce .produktImage a").each(function() {
		var addStickerA = $(this).html() + "<span class='stk-akce'>&nbsp;</span>";
		$(this).html(addStickerA);
	});
	$(".novinka .produktImage a").each(function() {
		var addStickerN = $(this).html() + "<span class='stk-novinka'>&nbsp;</span>";
		$(this).html(addStickerN);
	});
	$(".bestseller .produktImage a").each(function() {
		var addStickerB = $(this).html() + "<span class='stk-bestseller'>&nbsp;</span>";
		$(this).html(addStickerB);
	});
/* vycentrovani nahledu produktu + akce, novinka a bestseller - konec */

/* lightbox */
	$(function(){
	  $("a[rel^='lightbox']").lightbox();
	});
/* lightbox - konec */

});

function kontrolaodeslani() {

 if (!document.nahled.souhlas.checked){
			alert("Musíte souhlasit s obchodními podmínkami!");
			return false;
			}
	}

function kontrolalogin() {

 if (document.vstup.login.value == ""){
			alert("Prosím, vložte svůj login");
    document.vstup.login.focus();
    document.vstup.login.select();
			return false;
			}
 if (document.vstup.pass.value == ""){
			alert("Prosím, vložte svoje heslo");
    document.vstup.pass.focus();
    document.vstup.pass.select();
			return false;
			}
	}

function iRemove (amtField){
  amtField.value = 0;
  document.ProTab.submit();
}

function kontrolanews() {
 if (document.formnews.email.value== ""){
			alert("Prosím, vložte svůj email");
    document.formnews.email.focus();
    document.formnews.email.select();
			return false;
			}

//	Kontrola e-mailu
	if ( document.formnews.email.value != "" ) {
		if (re.test(document.formnews.email.value) == 0) {
			alert ("E-mailová adresa není správná");
			document.formnews.email.focus();
			document.formnews.email.select();
			return false;
		}
	}
	if(!document.formnews.novinky.checked && !document.formnews.akce.checked  && !document.formnews.vyprodej.checked ) {
		 alert("Prosím vyberte alespoň jednu oblast zájmu");
	   return false;
	}


}


function kontrola() {
	prijmeni=document.uprav.prijmeni.value;
	jmeno=document.uprav.jmeno.value;
	ulice=document.uprav.ulice.value;
	mesto=document.uprav.mesto.value;
	psc=document.uprav.psc.value;
	telefon=document.uprav.telefon.value;
	email=document.uprav.email.value;
	firma=document.uprav.firma.value;
	IC=document.uprav.IC.value;

    if (document.uprav.pass) {
     if (document.uprav.pass.value == "") {
			alert("Heslo nesmí být prázdné");
      document.uprav.pass.focus();
      document.uprav.pass.select();
			return false;
		}
	}

 if (document.uprav.firma.value == "") {
 if (prijmeni == ""){
			alert("Vložte svoje příjmení");
    document.uprav.prijmeni.focus();
    document.uprav.prijmeni.select();
			return false;
			}
 if (jmeno == ""){
			alert("Vložte svoje jméno");
    document.uprav.jmeno.focus();
    document.uprav.jmeno.select();
			return false;
			}
 }
 if (ulice == ""){
			alert("Vložte adresu");
    document.uprav.ulice.focus();
    document.uprav.ulice.select();
			return false;
			}
 if (mesto == ""){
			alert("Vložte město");
    document.uprav.mesto.focus();
    document.uprav.mesto.select();
			return false;
			}
 if (psc == ""){
			alert("Vložte PSČ");
    document.uprav.psc.focus();
    document.uprav.psc.select();
			return false;
			}
 if (telefon == ""){
			alert("Vložte prosím telefon.\nČasto kontaktujeme zákazníka ohledně stavu objednávky.");
    document.uprav.telefon.focus();
    document.uprav.telefon.select();
			return false;
			}
 if (email == "" ){
			alert("E-mail musí být zadán.\nNa tento e-mail zasíláme potvrzení objednávky a daňové doklady.");
    document.uprav.email.focus();
    document.uprav.email.select();
			return false;
			}
	if ( document.uprav.email.value != "" ) {
		if (re.test(document.uprav.email.value) == 0) {
			alert ("E-mailová adresa není platná");
			document.uprav.email.focus();
			document.uprav.email.select();
			return false;
		}
	}
 if (firma != "" && IC == ""){
			alert("Pokud je vložen název firmy musí být vložen i IČ");
    document.uprav.IC.focus();
    document.uprav.IC.select();
			return false;
			}
 } 

function kontrolaklub() {
	prijmeni=document.uprav.prijmeni.value;
	jmeno=document.uprav.jmeno.value;
	ulice=document.uprav.ulice.value;
	mesto=document.uprav.mesto.value;
	psc=document.uprav.psc.value;
	telefon=document.uprav.telefon.value;
	email=document.uprav.email.value;
	firma=document.uprav.firma.value;
	IC=document.uprav.IC.value;

    if (document.uprav.pass) {
     if (document.uprav.pass.value == "") {
			alert("Heslo nesmí být prázdné");
      document.uprav.pass.focus();
      document.uprav.pass.select();
			return false;
		}
	}

 if (document.uprav.firma.value == "") {
 if (prijmeni == ""){
			alert("Vložte svoje příjmení");
    document.uprav.prijmeni.focus();
    document.uprav.prijmeni.select();
			return false;
			}
 if (jmeno == ""){
			alert("Vložte svoje jméno");
    document.uprav.jmeno.focus();
    document.uprav.jmeno.select();
			return false;
			}
 }
 if (ulice == ""){
			alert("Vložte adresu");
    document.uprav.ulice.focus();
    document.uprav.ulice.select();
			return false;
			}
 if (mesto == ""){
			alert("Vložte město");
    document.uprav.mesto.focus();
    document.uprav.mesto.select();
			return false;
			}
 if (psc == ""){
			alert("Vložte PSČ");
    document.uprav.psc.focus();
    document.uprav.psc.select();
			return false;
			}
 if (telefon == ""){
			alert("Vložte prosím telefon.\nČasto kontaktujeme zákazníka ohledně stavu objednávky.");
    document.uprav.telefon.focus();
    document.uprav.telefon.select();
			return false;
			}
 if (email == "" ){
			alert("E-mail musí být zadán.\nNa tento e-mail zasíláme potvrzení objednávky a daňové doklady.");
    document.uprav.email.focus();
    document.uprav.email.select();
			return false;
			}
	if ( document.uprav.email.value != "" ) {
		if (re.test(document.uprav.email.value) == 0) {
			alert ("E-mailová adresa není platná");
			document.uprav.email.focus();
			document.uprav.email.select();
			return false;
		}
	}
 if (firma != "" && IC == ""){
			alert("Pokud je vložen název firmy musí být vložen i IČ");
    document.uprav.IC.focus();
    document.uprav.IC.select();
			return false;
			}

 if (!document.uprav.klub.checked){
			alert("Musíte souhlasit s podmínkami klubu!");
			return false;
			}


 } 


function kontrolakosik() {
	if (document.kosicek.velikost.selectedIndex == 0){
			alert("Vyberte velikost");
			return false;
	}
 } 



function kontrolapritel() {

 if (document.pritel.email.value == "" ){
			alert("Zadejte e-mail Vašeho přítele.");
    document.pritel.email.focus();
    document.pritel.email.select();
			return false;
			}
	if ( document.pritel.email.value != "" ) {
		if (re.test(document.pritel.email.value) == 0) {
			alert ("E-mailová adresa není platná");
			document.pritel.email.focus();
			document.pritel.email.select();
			return false;
		}
	}
 } 

