/* ěščřžýáíé utf-8 */
var tmpC, GMAPS = false, map, mapInfoWindow = false;









/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only things you may need to change in this file are the following
variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26)

The numbers you set for checkboxHeight and radioHeight should be one quarter
of the total height of the image want to use for checkboxes and radio
buttons. Both images should contain the four stages of both inputs stacked
on top of each other in this order: unchecked, unchecked-clicked,
checked, checked-clicked.

You may need to adjust your images a bit if there is a slight vertical
movement during the different stages of the button activation.

The value of selectWidth should be the width of your select list image.

Visit http://ryanfait.com/ for more information.

*/

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "180";


/* No need to change anything after this */


document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } </style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				if(!inputs[a].getAttribute("disabled")) {
					span[a].onmousedown = Custom.pushed;
					span[a].onmouseup = Custom.check;
				} else {
					span[a].className = span[a].className += " disabled";
				}
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				if(!inputs[a].getAttribute("disabled")) {
					inputs[a].onchange = Custom.choose;
				} else {
					inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";
				}
			}
		}
		document.onmouseup = Custom.clear;
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}

window.addEvent("domready", function(){

Custom.init();});








(function(){var l=document.createElement('link');l.href='/common/css/blazek-js.css';l.rel='stylesheet';l.type='text/css';l.media='screen';document.getElementsByTagName('head')[0].appendChild(l);})();

/* domready */

window.addEvent("domready", function() {

          /* xbox */

var x_box = new XBox();

	
	var tmpSwf, tmpF, tmpX, tmpN, tmpI, tmpM, locations, tmp = false, objX, obj = false, menuToggleFunction, str, menuMouseEnter, menuMouseLeave, t;

	window.bdy = $(document.body);




	
	if($("detail")){
	  $("main").setStyle("height",Math.max($("menu").getHeight(),$("detail").getHeight()))
	}else if($("catalog")){
	  $("main").setStyle("height",Math.max($("menu").getHeight(),$("catalog").getHeight())+40)
	}else if($("main")){
	  //$("main").setStyle("height",Math.max($("content").getHeight(),$("menu").getHeight())-380)
	  		  //alert(Math.max($("content").getHeight(),$("menu").getHeight()))
	}
	
	
	
if($$(".inlinegal").length){

	  Mediabox.scanPage();
}


/* infobox start */

if ($("infobox")){
  
	if(Browser.Engine.trident){

		$$("body")[0].addEvent("keydown", function(event){
			if(event.key == "esc"){
				$("infobox").setStyle("display", "none");
				$("infobox_box").setStyle("display", "none");
			}
		});

	} else {

		window.addEvent("keydown", function(event){
			if(event.key == "esc"){
				$("infobox").setStyle("display", "none");
				$("infobox_box").setStyle("display", "none");				
			}
		});

	}

	
	/*
	$("page_enter").addEvent("click", function(event){
		$("infobox").setStyle("display","block");
    $("infobox_box").setStyle("display","block");
		return false;
	});
	*/
	
	$("infobox").setStyle("width", window.getScrollWidth());
  $("infobox").setStyle("height", window.getScrollHeight());
  $$("#infobox,#close_link").addEvent("click", function(event){
    $("infobox").setStyle("display","none");
    $("infobox_box").setStyle("display","none");
    return false;
  });
}
/* infobox end */

if($("eueu")){
		
		var myEffect = new Fx.Morph('eueu', {
    duration: 'short',
    transition: Fx.Transitions.Sine.easeOut
});
 
		
  $("eueu").addEvent("mouseover",function(){
myEffect.start({
    'width': [45, 210]  // Morphs the 'width' style from 900px to 300px.
});

  });
  
  $("eueu").addEvent("mouseout",function(){
myEffect.start({
    'width': [ 210,45]  // Morphs the 'width' style from 900px to 300px.
});
    
  });
  
}

	
	
	if (window.Cufon && Cufon.replace) {
		 Cufon.replace('#promo h2, #promo p, #hp-carousel strong, #hp-carousel em',  { fontFamily: 'GloriolaThin' });
Cufon.replace('#osa h4,.instone h5');
    // Cufon.replace('#promo h2,.wysiwyg h1, .wysiwyg h2', { fontFamily: 'MyriadLight' });
	}
	

	
	
	var rako_bg = new RakoBackground({
  bg_id : "rako_backgrounds",
  wheeler_id : "wheeler",
  
  ratio : 0.7,
  delay: 4000,
  stop_wheeling : false
}); 
	


	
if($("osa")){
  var years=$("osa").getElements(".stone");
  years.each(function(el,i){
  if(i%2!=0){
    $("osar").adopt(el,"bottom");

}
});
}



	


	var kotvos=$("page").getElements("a[href*=#]");
kotvos.addEvent("click",function(event){
  
  var matches=this.href.toString().match(/#(.+)/);

  	  
  var myFx = new Fx.Scroll("content").toElement($(matches[1]));
  
  
  
event.stop();
	  event.stopPropagation();
	  return false;
  	  
});







	
	
	
	var setContentHeight=function(){
	  $("content").setStyle("min-height",$(window).getHeight()-$("footer").getHeight()+"px");
	  if($("hp-carousel")){

	    $("hp-carousel").setStyle("min-height",$(window).getHeight()-$("footer").getHeight()+"px");
	  }
if($("mainin")){

	  if($("mainin").getFirst().getHeight()<($(window).getHeight()-$("footer").getHeight()-170)){

	  $("mainin").setStyle("height",$(window).getHeight()-$("footer").getHeight()-210+"px");
	 }
	  }
	 
	  
	};
	
	setContentHeight();
	window.addEvent("resize",setContentHeight);
	
	
	
	
	
	
	
	
	if($("voushop")){
	  $("step2").setStyle("display","none");
	  $("step3").setStyle("display","none");
	  $("step4").setStyle("display","none");
	  $("step5").setStyle("display","none");

	  Mediabox.scanPage();

	  
	 function number_format(number, decimals, point, separator) 
{ 
if(!isNaN(number)) 
{ 
point = point ? point : '.'; 
number = number.toString().split('.'); 
if(separator) 
{ 
var tmp_number = new Array(); 
for(var i = number[0].length, j = 0; i > 0; i -= 3) 
{ 
var pos = i > 0 ? i - 3 : i; 
tmp_number[j++] = number[0].substring(i, pos); 
} 
number[0] = tmp_number.reverse().join(separator); 
} 
if(decimals ) 
if(number[1])number[1] = Math.round(parseFloat(number[1].substr(0, decimals) + '.' + number[1].substr(decimals, number[1].length), 10)); 
else number[1]="00";
return(number.join(point));
 
} 

else return(null); 
} 
	
	
	
	
	
	
	
     var rooms=$("srooms").getElementsByTagName("h3");
     $$("#voushop select.salesroom").each(function(el){
	   for(var i=0;i<rooms.length;i++){
	     var txt=$(rooms[i]).get("text");
		 var str=rooms[i].getNext().getFirst().get("text");
		 var matches=str.match(/(\d{3}\s?\d{2})(.+)$/);
		 txt+=", "+matches[2];
	     el.options[el.options.length]=new Option(txt,txt);
	   }
	 });


	$("autofill").addEvent("click",function(event){
	  
	  
	  
	  
	  
	  req = new Request({noCache: 1, url: '/ajax.php?card='+$("f_card_no").get("value")+"&pin="+$("f_pin").get("value"), method: 'get', onSuccess: function(responseText, responseXML){
        var r=responseXML.getElementsByTagName("result");
		if(r[0].getAttribute("error")==1){
		  alert("Chybné klubové údaje.")
		}else{
		  var getHim=function(tn,ds){
		    var els=responseXML.getElementsByTagName(tn);
			if(els[0].firstChild){
			  $(ds).set("value",els[0].firstChild.data);
			}
		  };
		  getHim("name","f_first_name");
		getHim("surname","f_last_name");
		getHim("street","f_street");
		getHim("streetnum","f_streetnum");
		getHim("city","f_city");
		getHim("zip","f_zip");
		getHim("phone","f_phone");
		getHim("mail","f_mail");
		}
		
		event.stop();
	  event.stopPropagation();
	  return false;
		
	  }}).send();
	  event.stop();
	  event.stopPropagation();
	  return false;
	});
	 
	 
	$("voushop").set("step",1);
	   $("voushop").addEvent("submit",function(event){
	  //  alert(this.get("step"));
	    if(this.get("step")<5){
	      window.setStep(parseInt(this.get("step"),10)+1);
	    }else{
	      this.submit();
	    }
	    event.stopPropagation();
	    return false;
	  });
	  
	  $$("#vouchers input").each(function(el){el.oldvalue=el.value;}).addEvent("change",function(){
		  		  if(!/^\d+$/.test(this.value)){
				  alert("Zadejte korektní hodnotu");
		    this.value=this.oldvalue;
		  }else{
		    this.oldvalue=this.value;
			var prTd=this.getParent().getParent().getParent().getNext();
			var opr=this.getParent().getParent().getParent().getPrevious().get("text").replace(/\s+/g,"").replace(/[^0-9]+/g,"");
			
			prTd.set("text",prTd.get("text").replace(/^([^ča-z]+)(\s[ča-z]+)$/i,number_format((parseInt(opr,10)*this.value),0,""," ")+"\$2"));
			
			var sum1=sum2=0;
			$$("#vouchers .pr").each(function(el){
			  
			  if(el.get("text").indexOf("EUR")>0){
			    sum2+=parseInt(el.get("text").replace(/[a-zč]+/gi,"").replace(/\s+/g,""),10);
			  }else{
			    sum1+=parseInt(el.get("text").replace(/[a-zč]+/gi,"").replace(/\s+/g,""),10);
			  }
			});
			
			
			
		    $("prc1").set("text",number_format(sum1,0,""," ")+" Kč");
			$("prc2").set("text",number_format(sum2,0,""," ")+" EUR");
			
		  }
		});
		
	  
	  var setPreview=function(){
	    
		
		var shtml="";
		
		if($("v1count").value)shtml+=($("v1count").value+" &times; Dárková poukázka v hodnotě 500 Kč<br />");
		if($("v2count").value)shtml+=($("v2count").value+" &times; Dárková poukázka v hodnotě 1 000 Kč<br />");
		if($("v3count").value)shtml+=($("v3count").value+" &times; Dárková poukázka v hodnotě 20 EUR<br />");
		if($("v4count").value)shtml+=($("v4count").value+" &times; Dárková poukázka v hodnotě 50 EUR<br /><br />");
		shtml+=("Celkem: "+parseInt(parseInt($("v1count").value*500,10)+parseInt($("v2count").value*100,10),10)+" Kč a "+parseInt(parseInt($("v3count").value*20,10)+parseInt($("v4count").value*50,10),10)+" EUR");
		
		$("r_basket").set("html",shtml);
		
		
	    $("r_name").set("html",$("f_first_name").value+" "+$("f_last_name").value+"<br />");
	    
		if($("f_company").get("value").trim()!==""){
		  $("r_company").set("html",$("f_company").value+"<br />");
		  $("r_company").setStyle("display","block");
		}else{
		  $("r_company").setStyle("display","none");
		}
	    
		if($("f_ic").get("value").trim()!==""){
		  $("r_ic").set("html","IČ: "+$("f_dic").value+"<br />");
		  $("r_ic").setStyle("display","block");
		}else{
		  $("r_ic").setStyle("display","none");
		}
	    
		if($("f_dic").get("value").trim()!==""){
		  $("r_dic").set("html","DIČ: "+$("f_dic").value+"<br />");
		  $("r_dic").setStyle("display","block");
		}else{
		  $("r_dic").setStyle("display","none");
		}
	    
		$("r_addr").set("html",$("f_street").value+" "+$("f_streetnum").value+"<br />");
	    $("r_addr2").set("html",$("f_city").value+"&nbsp;&nbsp;"+$("f_zip").value+"<br />");
	    $("r_phone").set("html",$("f_phone").value+"<br />");
	    $("r_mail").set("html",$("f_mail").value+"<br />");
	    
		if($("f_note").get("value").trim()!==""){
		  $("r_note").set("html","Poznámka: "+$("f_note").value);
		  $("r_note").setStyle("display","block");
		}else{
		  $("r_note").setStyle("display","none");
		}
	    
		
		var setField=function(s,d,b){
		b=b||"";
		  if($(s).get("value").trim()!==""){
		    $(d).set("html",b+$(s).get("value")+"<br />");
			$(d).setStyle("display","block");
		  }else{
		    $(d).setStyle("display","none");
		  }
		}
		
		
		setField($("f_d_company"),$("r_d_company"));
	    
        
		if($("f_d_first_name").get("value").trim()!=="" || $("f_d_last_name").get("value").trim()!==""){
		  $("r_d_name").set("html",$("f_d_first_name").get("value")+" "+$("f_d_last_name").get("value")+"<br />");
		  $("r_d_name").setStyle("display","block");
		}else{
		  $("r_d_name").setStyle("display","none");
		}
	    
		if($("f_d_street").get("value").trim()!==""){
		  $("r_d_addr").set("html",$("f_d_street").value+" "+$("f_d_streetnum").value+"<br />");
		  $("r_d_addr").setStyle("display","block");
		}else{
		  $("r_d_addr").setStyle("display","none");
		}
	    
		if($("f_d_city").get("value").trim()!==""){
		  $("r_d_addr2").set("html",$("f_d_city").get("value")+"&nbsp;&nbsp;"+$("f_d_streetnum").value+"<br />");
		  $("r_d_addr2").setStyle("display","block");
		}else{
		  $("r_d_addr2").setStyle("display","none");
		}
		
	    		
		setField($("f_d_note"),$("r_d_note"),"Poznámka: ");
	    
		
		
		var phtml="";
		
		if($("payment_1").checked){
          phtml="Platba dobírkou a odeslání poukázek na adresu uvedenou v objednávce";
		}
		
		if($("payment_2").checked){
          phtml="Platba v hotovosti a osobní převzetí poukazů na adrese BLAŽEK PRAHA a.s., Ortenovo náměstí 16, Praha 7 – Holešovice";
		}
		
		if($("payment_3").checked){
          phtml="Platba v hotovosti a osobní převzetí poukazů ve vybrané prodejně Blažek: "+$("srs3").value;
		}
		
		if($("payment_4").checked){
		  phtml="Platba převodem a osobní převzetí poukazů na adrese BLAŽEK PRAHA a.s., Ortenovo náměstí 16, Praha 7 – Holešovice (převzetí poukazů je možné až po uhrazení faktury)";
		}

		if($("payment_5").checked){
		  phtml="Platba převodem a osobní převzetí poukazů ve vybrané prodejně Blažek: "+$("srs2").value+" (převzetí poukazů je možné až po uhrazení faktury)";
		}

		if($("payment_6").checked){
          phtml="Platba převodem a odeslání poukazů na adresu uvedenou v objednávce (odeslání poukazů probíhá až po úhradě faktury)";
		}
		
		
		$("r_payment").set("html",phtml);
		
		
		
	  };
	  
	  
	  window.setStep=function(step){
	   
	   setPreview();
	   
	   // alert(step)
		var requireField=function(elid){
		  if($(elid).get("value").trim()===""){
		    alert("Položka "+$(elid).getPrevious().get("text")+" musí být vyplněna");
			return false;
		  }
		
		  return true;
		};
		
		
		var validateMail=function(elid){
		  
		  
		  if(!/[a-z0-9.+_-]{1,64}@[a-z0-9.+_-]{1,252}\.[a-z]{2,6}/.test($(elid).get("value"))){
		    alert("Položka "+$(elid).getPrevious().get("text")+" má chybný formát");
			return false;
		  }
		  
		  
		  
		  return true;
		};
		
		
		var updateSteps=function(s){
		  $$("#steps span").each(function(el,i){
		    el.className="";
			el.onclick=null;
			if(i<(s-1)){
			  el.addClass("clickable");
			  el.onclick=function(){
			    window.setStep(i+1);
				
			  };
			}else if(i==(s-1)){
			  el.addClass("active");
			}else{
			
			}
		  });
		};
		
		switch(step){
		
		  case 1:
		     $("voushop").set("step",1);
			 updateSteps(1);
		      $("step1").setStyle("display","block");
			  $("step2").setStyle("display","none");
	          $("step3").setStyle("display","none");
	          $("step4").setStyle("display","none");
	          $("step5").setStyle("display","none");
		  break;
		  
		  case 2:
		    var checkInp=function(el){
			el=$(el);
			  if(/^\d+$/.test(el.value)){
			    
				  return true;
				
			  }
			  return false;
			};
			
			if(!checkInp("v1count") || !checkInp("v2count") || !checkInp("v3count") || !checkInp("v4count")){
			  alert("Zadejte korektní počet kusů");
			}else if($("v1count").value==0 && $("v2count").value==0 && $("v3count").value==0 && $("v4count").value==0){
			  alert("Zadejte alespoň nějaký počet kusů");
			}else{
			  $("voushop").set("step",2);
			  updateSteps(2);
		      $("step1").setStyle("display","none");
			  $("step2").setStyle("display","block");
	          $("step3").setStyle("display","none");
	          $("step4").setStyle("display","none");
	          $("step5").setStyle("display","none");
	  	  
			}
			
		  break;
		  
		  case 3:
		      
			  if(
			  requireField("f_first_name")
			&&  requireField("f_last_name")
			&&  requireField("f_street")
			&&  requireField("f_streetnum")
			&&  requireField("f_city")
			&&  requireField("f_zip")
			&&  requireField("f_phone")
			&&  requireField("f_mail")
			&&  validateMail("f_mail")
			  ){
			  
			  
			  $("step1").setStyle("display","none");
			  $("step2").setStyle("display","none");
	          $("step3").setStyle("display","block");
	          $("step4").setStyle("display","none");
	          $("step5").setStyle("display","none");
	  	  $("voushop").set("step",3);
		  updateSteps(3);
		  }
		  break;
		  
		  case 4:
		  
		  
		  
		      
		  
		  
		  
    		  $("step1").setStyle("display","none");
			  $("step2").setStyle("display","none");
	          $("step3").setStyle("display","none");
	          $("step4").setStyle("display","block");
	          $("step5").setStyle("display","none");
	  	  
		  $("voushop").set("step",4);
		  updateSteps(4);
		  
		  break;
		  
		  case 5:
		  
		  var checked=false;
		  $$("#step4 input[type=radio]").each(function(el){
		    if(el.checked)checked=true;
		  });
		  
		  if(!checked){
		     alert("Vyberte způsob platby a dodání"); 
		  }else{
		  
		  
		  //vybrana prodejna
		  
		    if($("payment_3").checked && $("srs3").get("value")==0 || $("payment_5").checked && $("srs2").get("value")==0){
			  	  alert("Vyberte prodejnu");
			}else{
		  
		  
		    $("step1").setStyle("display","none");
			  $("step2").setStyle("display","none");
	          $("step3").setStyle("display","none");
	          $("step4").setStyle("display","none");
	          $("step5").setStyle("display","block");
	  	  
		  $("voushop").set("step",5);
		  updateSteps(5);
		  
		  }
		  
		  }
		  break;
		
		
		}
	  }
	  
	  
	}
	
	
	
	
	
	
	
	
	if($("mainphoto")){
	  
	  $$(".linker").addEvent("mousedown",function(){
	    
		$("mainphoto").src=this.firstChild.src.replace("85x85","260x370");
		
	  });

	  $$(".linker").addEvent("mouseover",function(){
	    
		$("mainphoto").src=this.firstChild.src.replace("85x85","260x370");
		
	  });

	     
	  
	  
	}
	
	
	if($("trends")){
	  $$("#trends img").addEvent("click",function(){
	    $("bigBg").style.backgroundImage="url('"+this.src.replace("small/","")+"')";
	  });
	  
	  $$("#trends img").addEvent("mouseover",function(){
	    $("bigBg").style.backgroundImage="url('"+this.src.replace("small/","")+"')";
	  });
	  
	}
	
	
	menuToggleFunction = function(event) {
		var a;
		a = this.getParent();
		if (a.hasClass('open')) {
			a.removeClass('open');
			a = 0;
		}
		else {
			a.addClass('open');
			a = 1;
		}
		a = this.retrieve('localization:text').split('/')[a].clean();
		this.getFirst().set('text', a).set('title', a);
		return false;
	};

	tmpM = $('navimenu');
	if (tmpM) {

		// toggler / opener+closer for topmenu navigation vs. catalogue link
		if (false && window.bdy.hasClass('shop')) {
			str = tmpM.get('rel') || tmpM.getAttribute('rel') || tmpM.rel;
			tmpM.grab(new Element('h3').adopt(new Element('span', {title: str.split('/')[0], text: str.split('/')[0]})).store('localization:text', str).addEvent('click', menuToggleFunction), 'top');
		}

		// wrapper for top and bottom light-shadow under the menu LI-s
		objX = new Element('span', {'class': 'light'}).adopt(new Element('span', {'class': 'bgTop'}), new Element('span', {'class': 'bgBottom'}));

		// compute position and store it in elementStore
		menuMouseEnter = function (o, p) {
			var tp = this.retrieve('tp');
			if (tp !== 0 || !tp) {
				tp = this.store('tp', {'top': this.getPosition(p).y, 'height': this.getHeight()}).retrieve('tp');
			}
			o.setStyles(tp);
		};

		// absolute hide for light-shadow wrapper
		menuMouseLeave = function(o) {
			o.setStyles({'top': -900, 'height': 26});
		};

		tmpM.grab(objX, 'top');
		tmpM.getElement('ul').getChildren().each(function(li) {
			li.addEvents({
				'mouseenter': menuMouseEnter.bind(li, [objX, tmpM]),
				'mouseleave': menuMouseLeave.bind(li, objX)
			});
		});
	}

	var tmpI = new InputLabels2('#search-form-input');
	var tmpII = new InputLabels('input.labeled');
	var tmpN = new Footer('subnav');

	tmpC = $('catalog');
	if (tmpC) {
		tmpC = new Catalog(tmpC);
	}

	tmpD = $('detail');
	if (tmpD) {
		tmpD = new ProductDetail(tmpD, tmpN);
	}

	tmpF = $('filtering');
	if (tmpF) {
		tmpF = new CatalogFilter(tmpF);
	}

	tmpX = new HpVisuals('hp-carousel');

	if (GMAPS) {
		map = $('mainin');
		if (map) {
		
		
			locations = map.getElements('div.storeBox');
			map = map.getElement('h2');
			if (map) {
				locations = locations.map(function(loc){
					return [loc.getElement('h3').get('text'),loc.getElement('span.latitude').get('text').toFloat(),loc.getElement('span.longitude').get('text').toFloat(),'<div class="bubbleStore">' + loc.get('html') + '</div>'];
				});

				
				if(window.location.href.indexOf("slovensko")>-1){
				  //oc: 48°40'26.083"N, 19°17'26.589"E
				  var myLatlng = new google.maps.LatLng(48.6738, 19.291);
				  var zoo=7;
				}else if(window.location.href.indexOf("ceska")>-1){
				  // 49°51'37.012"N, 15°54'13.691"E
				  var myLatlng = new google.maps.LatLng(49.8, 15.6);
				  var zoo=7;
				}else{
				  var myLatlng = new google.maps.LatLng(49.9019, 16.9);
				  var zoo=6;
				}
				
				
				
				var myOptions = {
					zoom: zoo,
					center: myLatlng,
					scrollwheel: false,
					mapTypeId: google.maps.MapTypeId.ROADMAP
				}

				map = new Element('div', {id:'googlemap'}).injectBefore(map);
		    map = new google.maps.Map(document.getElementById("googlemap"), myOptions);
// google.maps.MapPanes.floatShadow.style.visibility="hidden"; 



				var image = new google.maps.MarkerImage('/common/images/maps/image.png', new google.maps.Size(45,45), new google.maps.Point(0,0), new google.maps.Point(13,31));
				
				var shadow = new google.maps.MarkerImage('/common/images/maps/transparent.png', new google.maps.Size(45,45), new google.maps.Point(0,0), new google.maps.Point(13,31));
				
				var shape = {coord: [15,0,18,1,20,2,21,3,22,4,23,5,23,6,23,7,24,8,24,9,24,10,24,11,24,12,23,13,23,14,22,15,22,16,22,17,21,18,21,19,20,20,19,21,18,22,17,23,17,24,16,25,15,26,15,27,14,28,13,29,13,30,11,30,11,29,10,28,9,27,8,26,7,25,7,24,6,23,5,22,5,21,3,20,3,19,2,18,1,17,1,16,1,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,1,4,2,3,4,2,6,1,8,0,15,0], type: 'poly'};

				function attachOpenInfoWindow(mark, mapa, locs, number) {
					if (!mapInfoWindow) {
						mapInfoWindow = new google.maps.InfoWindow({maxWidth:400, maxHeight:200, size: new google.maps.Size(400,200), pixelOffset: new google.maps.Size(10,10)});
						google.maps.event.addListener(mapInfoWindow, 'domready', function(){
							var t;
							t = $$('#googlemap div.bubbleStore:not(.q)');
							if (t && t.length > 0) {
								t = t.pop();
								t = $(t.addClass('q').getParent().setStyle('overflow','hidden').parentNode.parentNode);
								if (t) {
									return;
									t = t.getAllPrevious();
									t.each(function(q){
										if (q.getStyle('backgroundImage').length > 10) {
											// q.setStyle('backgroundImage', 'url("/common/images/maps/iw3.png")');
										}
										else {
											q.setStyles({'backgroundColor': '#000000', 'borderColor': '#545454'});
										}
									});
								}
							}
						});
					}
				  google.maps.event.addListener(mark, 'click', function() {
				    mapInfoWindow.open(mapa, mark);
				    mapInfoWindow.setContent(locs[number][3]);
					$$("#googlemap .gmnoprint").each(function(el){
					  var zi=(el.getParent().getStyle("z-index"));
					  if(zi==104){
					    el.getParent().setStyle("display","none");
					  }
					});
					//.setStyle("display","none").setStyle("visibility","hidden");
				  });
				}

        var markers = [];

				locations.each(function(store, i) {
					var myLatLng = new google.maps.LatLng(store[1], store[2]);
					var marker = new google.maps.Marker({
						position: myLatLng,
						shadow: shadow, icon: image, shape: shape,
						title: store[0]
					});
				  attachOpenInfoWindow(marker, map, locations, i);
          markers.push(marker);
				});

        markerClusterer = new MarkerClusterer(map, markers, {
          maxZoom: 11,
          gridSize: 40,
          styles: [
						{
							url: '/common/images/maps/m1.png',
							height: 45,
							width: 45,
							anchor: [8, 12],
							textColor: '#ffffff',
							textSize: 12
						}, {
							url: '/common/images/maps/m2.png',
							height: 45,
							width: 45,
							anchor: [8, 12],
							textColor: '#ffffff',
							textSize: 12
						}, {
							url: '/common/images/maps/m3.png',
							height: 45,
							width: 45,
							anchor: [8, 12],
							textColor: '#ffffff',
							textSize: 12
						}
					]
        });
		
		
		

			}
		}
	}

	
	
	
/*	t = $$('form.form-validation');


	if (t && t.length > 0) {


	MooTools.lang.setLanguage('cs-CZ');

		t.each(function(f,i){
			i = new Form.Validator.Inline(f);

		});
	}


*/



var form_validation = new FormValidation({
    default_border : "1px solid #CCCCCC",
    error_border : "1px solid #E80000",
    error_background : "#E80000"
});





	$$('a.targetblank').set('target', '_blank');

	t = new CacheLoader({
		backgrounds: [
			{'/common/images/layout/background/': ['corners.png', 'detail-prevnext.png', 'filter-checkbox-sprite.png', 'filter-sprite.png', 'slider-sprite.png']},
			{'/common/images/maps/': ['m1.png', 'm2.png', 'm3.png', 'image.png', 'shadow.png']},
			{'/cs/images/content/trendy/': ['trendy01.jpg', 'trendy02.jpg', 'trendy03.jpg', 'trendy04.jpg', 'trendy05.jpg', 'trendy06.jpg','trendy07.jpg','trendy08.jpg','trendy09.jpg','trendy10.jpg','trendy11.jpg','trendy12.jpg','trendy13.jpg','trendy14.jpg']},
		]
	});

	t = $$('p.printLinkIn');
	if (t && t.length > 0) {
		t.adopt(new Element('a', {
			'href': '#',
			'class': 'print',
			'id': 'printPreview',
			'title': 'Tisk',
			'html': ' <span />',
			events: {
				'click': function () {
					window.print();
					return false;
					var screenPreviewEl, tm;
					$$('link[media="print"]').setProperty('media', 'print, screen');
					$$('link[media="screen"]').setProperty('media', 'disable');
					screenPreviewEl = $('screenPreview');
					if (!screenPreviewEl) {
						tm = new Element('a', {
							events: {
								'click': function () {
									screenPreview();
									return false;
								}
							},
							'id': 'screenPreview',
							'href': '#',
							'text': 'Zavřít tisk'
						}).inject(document.id(document.body), 'top');
					}
					else {
						screenPreviewEl.removeClass('hide');
					}
					return false;
				}
			}
		}));
	}
/*
	tmpSwf = $('flash-carousel');
	if (tmpSwf) {
		tmpSwf = new Swiff('/cs/swf/carousel.swf', {
			container: tmpSwf,
			id: 'FlashIDEVer',
			width: 730,
			height: 430,
			params: {
				quality: 'high',
				wMode: 'transparent'
			},
			vars: {
				dataPath: 'http://blazek.praguebest.cz/cs/swf/carousel_asset/data.xml'
			}
		});
	}

*/

        /* flash is allready instaled */

	if($("hp")){
	
		if(!FlashDetect.installed){
	    //alert("Flash is required to enjoy this site.");     	
			//$$('body').addClass('noflashinstalled');
	    $("rako_backgrounds").setStyle("display", "none");
	    $("page").addClass("noflashinstalled");
		}else{
	    //alert("Flash is insalled on your Web browser.");
			//$$('body').addClass('flashallreadyinstalled');
		}
	}

});

function screenPreview() {
	var a;
	a = $$('link[media="disable"]');
	if (a && a.length > 0) {
		a.setProperty('media', 'screen');
	}
	a = $$('link[href="/common/css/print.css"]');
	if (a && a.length > 0) {
		a.setProperty('media', 'print');
	}
	a = $('screenPreview');
	if (a) {
		a.addClass('hide');
	}
	window.focus();
	return false;
}



function picWin(){var url=(typeof(arguments[0])=="string")?arguments[0]:"URL_MISSING";var width=arguments[1] || 100;var height=arguments[2] || 100;var title=arguments[3] || "";var winParams=arguments[4] || "";var closeTitle=(document.lang=="cs")?"Kliknutím zavřete okno":"Click to close the window";var encoding="iso-8859-2";if(typeof(arguments[0])=="object"){var assign=function(data){var vars=["url","width","height","title","winParams","closeTitle","encoding"];var vl=vars.length;for(var i=0;i<vl;i++)if(!isUndefined(data[vars[i]]))eval(vars[i]+"=data."+vars[i]);};assign(arguments[0]);}var win=window.open("about:blank","","width="+width+",height="+height+((winParams=="")?"":(","+winParams)));if(typeof(win)!="object")return true;var html='<html><head><title>'+title+'</title><meta http-equiv="content-type" content="text/html; charset='+encoding+'"></head><body style="margin:0"><img src="'+url+'" style="cursor:pointer;display:block;" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+closeTitle+'"></body></html>';win.document.open();win.document.write(html);win.document.onclick=function(){win.close();};win.document.close();win.focus();return false;}


