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

          /* cufon START */
if (Cufon && Cufon.replace) {
	Cufon.replace('div.wysiwyg h1, div.wysiwyg h2, div.wysiwyg h3, div.wysiwyg h4, div.wysiwyg h5, div.wysiwyg h6');
	/* -- all the changes? -- */
}
          /* cufon END */


          /* gmap with markerclusterer */

if($("gmap")){
  if(typeof(tower_detail_position_x) == "undefined" && typeof(tower_detail_position_y) == "undefined"){ // default page
    var gmap_towers = new Towers({
      id : "gmap",
      json : data,
      map_x : 49.854277,
      map_y : 14.534668,
      map_zoom : 7
    }); 
  } else {
    var gmap_towers = new Towers({ // detail tower page
      id : "gmap",
      json : data,
      map_x : tower_detail_position_x,
      map_y : tower_detail_position_y,
      map_zoom : 11
    }); 
  }
}          


          /* tower detail */
          
if($("tower_map_thumb")){
  if($$(".tower_map").length > 0){
    $$(".tower_map")
    .addEvent("mouseenter", function(){
      $("tower_map_thumb").setStyle("display", "block");
    })
    .addEvent("mouseleave", function(){
      $("tower_map_thumb").setStyle("display", "none");
    })
  }
}

          /* scroll and cookie */
          
if($("select_tower")){        
  $("select_tower_content").setStyle("display", "block");
  var scroll_height = $("tower_list_wheeler").getHeight()-232;
  if(scroll_height > 0){
    var towerScroll = new Slider($("scroll_bar"), $("bar"), {
            steps: scroll_height,
            mode: "vertical",
            wheel: "true",
            onChange: function(step){
               $("tower_list_wheeler").setStyle("top",-step);
            }
    }).set(0);
  
  } else {
    $("scroll_bar").addClass("disabled");
  }
  $("select_tower_content").setStyle("display", "none");
  
  $("select_tower_heading").addEvent("click", function(){
   if($("select_tower_heading").hasClass("act")){
      $("select_tower_content").setStyle("display", "none");
      Cookie.write("tower_select", "false", {path: "/"});
   } else {
      $("select_tower_content").setStyle("display", "block");
      Cookie.write("tower_select", "true", {path: "/"});
   }
   $("select_tower_heading").toggleClass("act")
  });
 
  // cookie
  
  if(Cookie.read("tower_select") == "true"){
    $("select_tower_heading").addClass("act");
    $("select_tower_content").setStyle("display", "block"); 
  }
  
}


if($("party_form")){
	
	$("f_accommodation_b").addEvent("change", function(){
		if($("f_accommodation_b").checked == true && $("f_transport_b").checked == true){
			$("check-asterix").addClass("nocss");
			$("f_city").removeClass("check-is-blank");
		} else {
			$("check-asterix").removeClass("nocss");
			$("f_city").addClass("check-is-blank");
		}
	});
	
	$("f_transport_b").addEvent("change", function(){
		if($("f_accommodation_b").checked == true && $("f_transport_b").checked == true){
			$("check-asterix").addClass("nocss");
			$("f_city").removeClass("check-is-blank");
		} else {
			$("check-asterix").removeClass("nocss");
			$("f_city").addClass("check-is-blank");
		}
	});
	
	$("f_accommodation_a").addEvent("change", function(){
		if($("f_accommodation_a").checked == true){
			$("check-asterix").removeClass("nocss");
			$("f_city").addClass("check-is-blank");
		}
	});
	
	$("f_transport_a").addEvent("change", function(){
		if($("f_transport_a").checked == true){
			$("check-asterix").removeClass("nocss");
			$("f_city").addClass("check-is-blank");
		}
	});
	
}




        /* search text */

if($$("html").get("lang") == "en"){
  var search_value_map = "ex. Jested";
} else {
  var search_value_map = "např. Ještěd";
}

if($("search_map")){
  if($("search_map").value == ""){
    $("search_map").value = search_value_map;
  }
  
	$("search_map")
	.addEvent("click", function(){
    if($("search_map").value == search_value_map){
			$("search_map").value = "";
    }    
  })
	.addEvent("blur", function(){
    if($("search_map").value == ""){
      $("search_map").value = search_value_map;
    }    
  });  
}










          /* xbox */
          
var x_box = new XBox(); 

if($$(".xbox_download").length > 0){
	x_box.download_link = true;
}

          /* form-validation */
          
var form_validation = new FormValidation({
    default_border : "1px solid #C4C3BE",
    error_border : "1px solid #F19214"
});

          /* targetblanks */

$$("a.targetblank").addEvent("click", function(event){
  if(typeof window.open(this.href)=="object"){
    event.stop();
  }
});

if($("photogallery_vote")){
  var photogallery_votes = $$("#photogallery_vote .vote");

  $("photogallery_vote").addEvent("submit", function(){
    var votes = 0;
    for(var x = 0; x < photogallery_votes.length; x++){
      if(photogallery_votes[x].checked == true){
        votes++;
      }
    }
    if(votes > 0 && votes < 4){
      return true;
    } else {
      alert("Musíte hlasovat pro 1 až 3 fotky.");
      return false;
    }
  });
  
  photogallery_votes.addEvent("click", function(){
    var votes = 0;
    for(var x = 0; x < photogallery_votes.length; x++){
      if(photogallery_votes[x].checked == true){
        votes++;
      }
    }
    if(votes < 3){
      for(var x = 0; x < photogallery_votes.length; x++){
        if(photogallery_votes[x].checked != true){
          photogallery_votes[x].disabled = "";
        }
      }
    } else {
      for(var x = 0; x < photogallery_votes.length; x++){
        if(photogallery_votes[x].checked != true){
          photogallery_votes[x].disabled = "disabled";
        }
      }
    }
  });
  
  /*
  photogallery_votes.addEvent("click", function(){
    if(this.disabled == "disabled"){
      alert("Hlasování je omezeno na 4 fotografie. Nemůžete hlasovat pro více fotek!");
    }
  });
  */
}

/* infobox start */

if ($("infobox")){
  $("ecall_link").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,#infobox_box").addEvent("click", function(event){
    $("infobox").setStyle("display","none");
    $("infobox_box").setStyle("display","none");
    return false;
  });
}

/* infobox start */

if ($("all_popup")){
  $("all_popup").setStyle("width", window.getScrollWidth());
  $("all_popup").setStyle("height", window.getScrollHeight());
  $$("#all_popup,#all_popup_box").addEvent("click", function(event){
    $("all_popup").setStyle("display","none");
    $("all_popup_box").setStyle("display","none");
    return false;
  });
}


          /* tc tabz */

if($("tctabz")){
  tab_links = $$("#tctabz a");
  tab_links.addEvent("click", function() {
    for(var z = 0; z < tab_links.length; z++){
      $('tc' + tab_links[z].id.substring(5)).setStyle("display", "none");
      $(tab_links[z].id).removeClass("act");          
    }
    $('tc' + this.id.substring(5)).setStyle("display", "block");
    $(this.id).addClass("act");
    this.blur();
  });  
}

if($("tctabz1")){
  tab_links1 = $$("#tctabz1 a");
  tab_links1.addEvent("click", function() {
    for(var z = 0; z < tab_links1.length; z++){
      $('tc' + tab_links1[z].id.substring(5)).setStyle("display", "none");
      $(tab_links1[z].id).removeClass("act");          
    }
    $('tc' + this.id.substring(5)).setStyle("display", "block");
    $(this.id).addClass("act");
    this.blur();
  });  
}

if($("tctabz2")){
  tab_links2 = $$("#tctabz2 a");
  tab_links2.addEvent("click", function() {
    for(var z = 0; z < tab_links2.length; z++){
      $('tc' + tab_links2[z].id.substring(5)).setStyle("display", "none");
      $(tab_links2[z].id).removeClass("act");          
    }
    $('tc' + this.id.substring(5)).setStyle("display", "block");
    $(this.id).addClass("act");
    this.blur();
  });  
}

if($("tctabz3")){
  tab_links3 = $$("#tctabz3 a");
  tab_links3.addEvent("click", function() {
    for(var z = 0; z < tab_links3.length; z++){
      $('tc' + tab_links3[z].id.substring(5)).setStyle("display", "none");
      $(tab_links3[z].id).removeClass("act");          
    }
    $('tc' + this.id.substring(5)).setStyle("display", "block");
    $(this.id).addClass("act");
    this.blur();
  });  
}



        /* search text */

if($$("html").get("lang") == "en"){
  var search_value = "Insert search term...";
} else {
  var search_value = "Zadejte hledaný text...";
}

if($("search")){
  if($("search").value == ""){
    $("search").value = search_value;
  }
  $("search")
    .addEvent("click", function(){
      if($("search").value == search_value){
        $("search").value = "";
      }    
    })
    .addEvent("blur", function(){
      if($("search").value == ""){
        $("search").value = search_value;
      }    
  });  
}

          /* select store */

if($("select_store")){
  $("select_store").addEvent("click", function(){
    if(this.hasClass("act")){
      $("select_store_list").setStyle("display", "none");
    } else {
      $("select_store_list").setStyle("display", "block");
    }
    this.toggleClass("act");
  });
}

          /* print */
          
$$(".print").addEvent("click", function(){
  window.print();
  return false;
});   

          /* roll up */

if($("toptop")){
  var toptop = new Fx.Scroll(window);
  $("toptop").addEvent("click", function(){
    toptop.toTop();
    return false;
  });
}


          /* rezonance form */
if($("rezonance_form")){

	$$("#rezonance_form #f_information_actual_box input, #rezonance_form #f_information_interest_box input, #rezonance_form #f_information_usefull_box input, #rezonance_form #f_all_information_box input, #rezonance_form #f_popular_themes_box input, #rezonance_form #f_missing_information_box input,	#rezonance_form #f_atractive_colors_box input, #rezonance_form #f_count_pages_box input,	#rezonance_form #f_form_magazine_box input, #rezonance_form #f_periodical_box input,#rezonance_form #f_connect_box input").addClass("check-is-checked");
	
	$$("#f_popular_themes_other,#f_missing_information_other").setStyle("display","none");
	
	
	$("f_information_actual_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_information_actual_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_information_actual_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_information_interest_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_information_interest_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_information_interest_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_information_usefull_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_information_usefull_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_information_usefull_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_all_information_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_all_information_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_all_information_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	if($("f_popular_themes_box")){
		$("f_popular_themes_box").getElements("input").each(function(input){
			
			input.addEvent("click", function(){
				
				var counter = 0;
				
				$("f_popular_themes_box").getElements("input").each(function(input_test){
					if(input_test.checked==true){
						counter++;
					}
				});
				
				if(counter>0){
					$("f_popular_themes_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
					$("f_popular_themes_other").removeClass("check-is-blank").setStyle("border","none");
				} else {
					$("f_popular_themes_box").getElements("input").addClass("check-is-checked");
					$("f_popular_themes_other").removeClass("check-is-blank").setStyle("border","none");
				}
				
			});
			
		});
		
		$("f_popular_themes_12").addEvent("click", function(){
			
			if(this.checked==true){
				$("f_popular_themes_other").addClass("check-is-blank").setStyle("display","block");
			} else {
				$("f_popular_themes_other").removeClass("check-is-blank").setStyle("display","none").setStyle("border","none");
			}
			
		});
	}
	
	if($("f_missing_information_box")){
		$("f_missing_information_box").getElements("input").each(function(input){
			
			input.addEvent("click", function(){
				
				var counter = 0;
				
				$("f_missing_information_box").getElements("input").each(function(input_test){
					if(input_test.checked==true){
						counter++;
					}
				});
				
				if(counter>0){
					$("f_missing_information_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
					$("f_missing_information_other").removeClass("check-is-blank").setStyle("border","none");
				} else {
					$("f_missing_information_box").getElements("input").addClass("check-is-checked").setStyle("border","none");
					$("f_missing_information_other").removeClass("check-is-blank").setStyle("border","none");
				}
				
			});
			
		});
		
		$("f_missing_information_8").addEvent("click", function(){
			
			if(this.checked==true){
				$("f_missing_information_other").addClass("check-is-blank").setStyle("display","block");
			} else {
				$("f_missing_information_other").removeClass("check-is-blank").setStyle("display","none").setStyle("border","none");
			}
			
		});
	}
	
	
	
	
	$("f_atractive_colors_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_atractive_colors_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_atractive_colors_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_count_pages_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_count_pages_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_count_pages_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_form_magazine_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_form_magazine_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_form_magazine_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_periodical_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_periodical_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_periodical_box").getElements("input").addClass("check-is-checked");
			}
			
		});
		
	});
	
	$("f_connect_box").getElements("input").each(function(input){
		
		input.addEvent("click", function(){
			
			if(input.checked=true){
				$("f_connect_box").getElements("input").removeClass("check-is-checked").setStyle("border","none");
			} else {
				$("f_connect_box").getElements("input").addClass("check-is-checked");
			}
			                  
		});
		
	});
	
}





if($("customer_satisfaction")){
	
	var slider = $('slider');
	
	new Slider(slider, slider.getElement('.knob'), {
		steps: 100,
		range: [100, 0],
		initialStep: 100,
		mode: 'vertical',
		onChange: function(value){
			$('percent_value').set("html",value);
			$('scale_tip').set("value",value);
			var top = ($$('#slider .knob')[0].getCoordinates().top).toInt();
			var height = (732 - top) + "px"
			$('slider_scale').setStyle("height",height);
		},
		onComplete: function(value){
			var top = ($$('#slider .knob')[0].getCoordinates().top).toInt();
			var height = (732 - top) + "px"
			$('slider_scale').setStyle("height",height);
		}
	});
  
}


});
