window.addEvent("domready", function(){

            /* xbox */

  var x_box = new XBox();

            /* form-validation */

  var form_validation = new FormValidation({
      default_border : "1px solid #CDC9C7",
      error_border : "1px solid #EC008C"
  });

            /* targetblanks */

  $$("a.targetblank").addEvent("click", function(event){
    if(typeof window.open(this.href)=="object"){
      event.stop();
    }
  });

            /* background player */

  /*if($("background_navi")){
    if(background.length < 1){
      $("background_navi").setStyle("display", "none");
    } else {
      var background_index = 0;

      var change_background = function(action){
        if(action.step > 0){
          if(background_index + 1 == background.length){
            background_index = 0;
          } else {
            background_index++;
          }
        } else {
          if(background_index - 1 < 0){
            background_index = background.length - 1;
          } else {
            background_index--;
          }
        }
        $$(".background_flash")[0].className = "background_flash";
        $$(".background_flash")[0].addClass(background[background_index].className);
        $$("#now strong").set("html", background[background_index].name);
        return false;
      };
      if($("next")){
        if(background.length < 2){
          $("next").setStyle("display", "none");
        } else {
          $$("#next a").addEvent("click", change_background.bind(this, {"step": 1}));
        }
      }
      if($("prev")){
        if(background.length < 2){
          $("prev").setStyle("display", "none");
        } else {
          $$("#prev a").addEvent("click", change_background.bind(this, {"step": -1}));
        }
      }
      if($("play")){
        $$("#play a").addEvent("click", function(){
          return false;
        });
      }

      if($("pause")){
        $$("#pause a").addEvent("click", function(){
          return false;
        });
      }

      if($("stop")){
        $$("#stop a").addEvent("click", function(){
          return false;
        });
      }

      if($("mute")){
        $$("#mute a").addEvent("click", function(){
          return false;
        });
      }

    }
  }//*/

            /* navi -> sub */

  if($$("#navi .sub").length > 0){
    $$("#navi .sub")
      .addEvent("mouseenter", function(){
        $(this.id).addClass("hover");
      })
      .addEvent("mouseleave", function(){
      $(this.id).removeClass("hover");
    });
  }

          /* news box close */

  if($$(".close").length > 0){
    $$(".close").each(function(item, index){
      item.addEvent("click", function(){
        item.getParent().getElements("*").setStyle("visibility", "hidden");
        item.getParent().setStyle("border-bottom", 0);
        (function(){
          new Fx.Morph(item.getParent(), {
          }).start({
          		"width": 0,
          		"height": 0,
          		"min-height": 0,
          		"padding": 0
          	}).chain(function(){
              item.getParent().setStyle("display","none");
            });
        }).delay(0);
        return false
      });
    });
  }

          /* magic */

  if($("magic")){
    var magic = $("magic");
    magic.addEvent("click", function(){
      if(magic.hasClass("act")){
        $("global").setStyle("height", "auto");
        $("global").setStyle("overflow", "visible");

        $("background_header").fade(1);
        $("content").fade(1);
        $("navi").fade(1);
        $("search").fade(1);
        $("search_box").fade(1);

        if($("page_listing")){
          $("page_listing").fade(1);
        }


      } else {
        $("background_header").fade(0);
        $("content").fade(0);
        $("navi").fade(0);
        $("search").fade(0);
        $("search_box").fade(0);

        if($("page_listing")){
          $("page_listing").fade(0);
        }

        (function(){
          $("global").setStyle("height", 107);
          $("global").setStyle("overflow", "hidden");
        }).delay(400);
      }
      magic.toggleClass("act");
    });
  }//*/

          /* search */

  if($$("#search a").length > 0){
    $$("#search a")
      .addEvent("mouseenter", function(){
        $("search_box").setStyle("display", "block");
        $$("#search a").addClass("hover");
      })
      .addEvent("mouseleave", function(){
        $("search_box").setStyle("display", "none");
        $$("#search a").removeClass("hover");
      })
      /*.addEvent("click", function(){
        alert("asdasd");
        return false;
      })*/;
    $("search_box")
      .addEvent("mouseleave", function(){
        $("search_box").setStyle("display", "none");
        $$("#search a").removeClass("hover");
      })
      .addEvent("mouseenter", function(){
        $("search_box").setStyle("display", "block");
        $$("#search a").addClass("hover");
      });
  }

          /* search text */

  if($$("html").get("lang") == "en"){
    var search_value = "Searched word...";
  } else {
    var search_value = "Hledaný výraz...";
  }

  if($("searched_text")){
    if($("searched_text").value == ""){
      $("searched_text").value = search_value;
    }
    $("searched_text")
      .addEvent("click", function(){
        if($("searched_text").value == search_value){
          $("searched_text").value = "";
        }
      })
      .addEvent("blur", function(){
      if($("searched_text").value == ""){
        $("searched_text").value = search_value;
      }
    });
  }

  			 /* youtube flash */

  $$(".flash-banner").each(function(flash){
    var alt = flash.getElement("a");
    flashsize = alt.get("data-flashsize");
    flashsize = flashsize.split("x");
    new Swiff(alt.href, {
      container: flash,
      width: flashsize[0],
      height: flashsize[1],
      params: {
        wmode: "opaque"
      }
    });
  });
  $$(".flash-background").each(function(flash){
  	var alt = flash.getElement("a");
  	new Swiff('/inc/flash/player.swf', {
  		container: flash,
  		id: 'player',
  		width: '100%',
  		height: '100%',
  		params: {
	        wMode: "opaque",
	        swLiveConnect: "true",
	        bgcolor: "#000000",
	        scale: "exactfit"
	    },
	    vars: { sourceURL: alt.href }
  	});
  });
  $$(".flash-flvplayer").each(function(flash){
  	var alt = flash.getElement("a");
  	flashsize = alt.get("data-flashsize");
    flashsize = flashsize.split("x");
  	new Swiff('/inc/flash/playermp3.swf', {
  		container: flash,
  		width: flashsize[0],
  		height: flashsize[1],
  		params: {
	        wMode: "opaque"
	    },
	    vars: { file: alt.href, searchbar: 'false' }
  	});
  });
  $$(".flash-player").each(function(flash){
  	var alt = flash.getElement("a");
  	new Swiff('/inc/flash/playermp3.swf', {
  		container: flash,
  		width: 250,
  		height: 20,
  		params: {
  			wMode: "opaque"
  		},
  		vars: {file: alt.href, searchbar: 'false', autostart: 'false', frontcolor: '0x666666'}
  	});
  });
  $$(".flash-mp3player").each(function(flash){
  	var alt = flash.getElement("a");
  	new Swiff('/inc/flash/playermp3.swf', {
  		container: flash,
  		width: 18,
  		height: 20,
  		params: {
  			wMode: "opaque"
  		},
  		vars: {file: alt.href, searchbar: 'false', autostart: 'false', frontcolor: '0x666666'}
  	});
  });//*/

            /* IE6 bug fixing */

  if(Browser.Engine.trident && Browser.Engine.version == 4){

    /* position:fixed bug */

    window.addEvent("scroll", function(){
      $$(".background_flash").setStyle("top", window.getScrollTop());
      $("footer").setStyle("top", window.getScrollTop() + window.getHeight() - 85);
    });

    /* .close hover */

    if($$("#hp_news li .close").length > 0){
      $$("#hp_news li .close")
        .addEvent("mouseenter", function(){
          this.addClass("hover");
        })
        .addEvent("mouseleave", function(){
          this.removeClass("hover");
        });
    }
  }

	/* AJAXY */
	myMute = function(){
		if($('mute').hasClass('mute')){
			//$('mute').removeClass('mute');
			$('mute').toggleClass('muteon');
		} else {
			//$('mute').removeClass('muteon');
			$('mute').toggleClass('mute');
		}
		new Request({method: 'get'}).send('ajax&action=mute');
	}

	negativeVote = function(hash, id){
		new Request({method: 'get'}).send('ajax&action=negative&hash=' + hash + '&id=' + id);
	}//*/
	
	;(function($){
		if($.fn.cycle)
		{
			$prev = $('<a href="#" class="btn-prev">&lt;</a>');
			$next = $('<a href="#" class="btn-next">&gt;</a>');
			$('.event-list .partners-box').append($prev).append($next);
			$('.event-list .partners-box .partners-imgs').cycle({
				speed: 1000,
				timeout: 1500,
				pause: true,
				prev: $prev,
				next: $next		 				
			});
		}	
		$('.btn-load-images').bind('click', function(){
  		var dlg = new wzh.dialogs.LoadImages();
  		dlg.open();
  		return false;
  	});
	})(jQuery);

});
