try {

  $(document).ready(function(){
  
    // stylovani tabulky tempTable1
    $(".tempTable1 tr:even,.tempTable2 tr:even").addClass("colored");						
	
    // aktivace FancyBoxu / nahrazeni nyroModalu
    $(".nyroModal").fancybox({
      type:'image',
      centerOnScroll:true,
      onStart: function() {
        $("iframe[title='YouTube video player']").css("visibility","hidden"); 
      },
      onClosed: function() { 
        $("iframe[title='YouTube video player']").css("visibility","visible");
      }
    });
    
    // definice horniho menu
	  $(".topMenu").ndMenu({showActiveClass:"True"});
	  
    var hoverBg = "";
    var hoverTextCol = "";
	  var firstLink = "";
    $(".topMenu a").hover(function() {
      var ul = $(this).closest("ul");
      var parent = $(this).closest("li");
      if(parent.hasClass("active")==false) {
        $(this).addClass("hover");
        if(ul.hasClass("level-1")==true) {
          firstLink = $(this);
          hoverBg = $(this).css("background-image");
          hoverTextCol = $(this).find("span").css("color");
        }
      }
    }, function() {
      var ul = $(this).closest("ul");
      var parent = $(this).closest("li");
      if(parent.hasClass("active")==false) {
        $(this).removeClass("hover");
      }
    });
    
    $(".topMenu .level-2 a").hover(function() {
      firstLink.css("background-image",hoverBg);
      firstLink.find("span").css("color",hoverTextCol);    
    }, function(){
      firstLink.css("background-image","");
      firstLink.find("span").css("color","");
    });
    
    $(".leftMenu a").hover(
      function(){
        if($(this).hasClass("active") == false) {
          currentClass = $(this).attr("class");
          $(this).addClass("active");
        } else {
          currentClass = $(this).attr("class");
        }
      },
      function(){
        if( currentClass == "" ){
          $(this).removeClass("active");
        }        
      }
	  );
	  
	  
    // Nastaveni Javascriptove validace prislusnym formularum dle ID
    $(".allForms.cz").ndFormValidator();
    $(".allForms.en").ndFormValidator({lang:'en'});
    $(".leftContactForm.cz").ndFormValidator();
    $(".leftContactForm.en").ndFormValidator({lang:'en'});
    
    /* ANKETA  */
  	$('.inquiry a').click(function(){
  		
  		var idAnketa = $(this).attr('class').substring($(this).attr('class').indexOf('|')+1);
  		//console.log(idAnketa);
  		
  		var COOKIE_NAME = window.location.hostname+"_anketa_"+idAnketa;
  		var options = { path: '/', expires: 10 };
  		
  		if($.cookie(COOKIE_NAME))
  		{
  			callMessageBox("Váš hlas již byl započítán!");
  		} else {
  			$.cookie(COOKIE_NAME, 'mcInquiry', options); 
        alert("Děkujeme za Váš názor!");
        $.post(".", {InternalEventState:"PollClick",InternalEventValue:$(this).attr('class')});
  			location.reload(true);
  		}
  		
  		return false;
  	});
  	
  	$("#faq a").click(function(){
      var artEl = $(this).parents(".articles");
      $(artEl).find(".bodyFaq").slideToggle("slow");  
    })
    
    // --------------------------
		// FACEBOOK pluginy
		var cultureInfo = $("meta[http-equiv='Content-languague']").attr("content");
		$("#fbLike").html('<iframe src="http://www.facebook.com/plugins/like.php?locale='+cultureInfo+'&amp;href='+document.location+'&amp;layout=standard&amp;show_faces=false&amp;width=400&amp;action=like&amp;colorscheme=light&amp;height=40" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:400px; height:40px;" allowTransparency="true">Facebook</iframe>');
  	
  });
  
  function callSendFormMessageBox() {
    var url = location.href;
    $("#message").dialog({
      modal: true,
      draggable: false,
      resizable: false,
      close: function(event, ui) {
        location.href = url
      }
  	});
  }
  
} catch(err) {

}

// funkce pro SiteMapu START //

this.sitemapstyler = function(){
	var sitemap = document.getElementById("sitemap")
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				//ul.style.display = "none";
				var span = document.createElement("span");
				span.className = "expanded";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};

window.onload = sitemapstyler;

// funkce pro SiteMapu END //

// funkce pro zrušení defaultního textu input pole END

function KillDefaultText(elementValue,elementId) {
  if(document.getElementById(elementId).value == elementValue) {
    document.getElementById(elementId).value = "";
  }
}

// funkce pro zrušení defaultního textu input pole END

// funkce pro zpětné vložení def. textu START

function PasteDefaultText(elementValue,elementId) {
  if(document.getElementById(elementId).value == "") {
    document.getElementById(elementId).value = elementValue;
  }  
}

// funkce pro zpětné vložení def. textu END

// funkce pro vlozeni fotek z fotogalerie ke clanku START
function GenerateCustomFckGallery(files_array)
{
		var result="";
		for (var a=0;a<files_array.length;a++)
			result+="<a class=\"nyroModal\" href=\""+files_array[a].path+"\" rel=\"gal\"><img class=\"body-gallery\" alt=\"\" src=\""+files_array[a].thumb+"\" /></a>";
		return result;
}
// funkce pro vlozeni fotek z fotogalerie ke clanku END

