try {
  
  /*$(function() {
  	$.fn.nyroModal.settings.processHandler = function(settings) {
  		var from = settings.from;
  		if (!settings.type && from && from.href) {
  			var arr = from.href.split('?');
  			//if carrying extra stuff
  			if(arr.length>1){
  				var newArr=arr[0].split('.');
  				var newType=settings.type;
  				//alert('extension is: ' + newArr[newArr.length-1]);
  				switch(newArr[newArr.length-1].toUpperCase()){
  					case 'IMG':
  					case 'JPG':
  					case 'JPEG':
  					case 'PNG':
  					case 'GIF':
  					case 'ASPX':
  						newType='image';
  						break;
  					default:
  						newType=settings.type;
  				}
  				//alert("new type is " + newType);
  				$.nyroModalSettings({
  					type: newType
  				});
  			}
  		}
  	};
  	
  });*/
  
  $(document).ready(function(){										
    
    // vypnuti popisového pole v nyromodal okne
    $(".nyroModal").fancybox({type: 'image'}); 
	  
    // definice tridy pro tooltip
    $(".toolTip").ndTooltips({appendToElement:"true"});
    
    // definice horniho menu
	  //$("#topMenu").ndMenu({showActiveClass:"False", slideEffect:"true", slideEffectTime: 300, delayEffect: "true", delayTime: 300});
	  $(".rollMenu, .centreMenu, #topMenu").ndMenu({showActiveClass:"False", slideEffect:"true", slideEffectTime: 0, delayEffect: "true", delayTime: 200});
	  
	  
	  // definice horniho menu
	  //$(".rollMenu, .centreMenu, #topMenu").ndMenu({showActiveClass:"False"});
    
    // Nastaveni Javascriptove validace prislusnym formularum dle ID
    $(".allForms").ndFormValidator();
    
    // zobrazeni a skryti cenikovych tabulek v detailu aktivity
    $(".rollPriceList").click(function(){
      $(this).parents(".itemCentre").children(".tblPrices").slideToggle(1000);
      $(this).parents(".itemCentre").children(".openingHours").slideToggle(1000);
      $(this).toggleClass("click");
    });
    
    // ovladani menu s ikonkama center nahore 
    $("#iconMenu a").hover(
      function() {
       $("#iconMenu a").addClass("animate");
       
       $(this).find(".smallItem").hide();
       $(this).find(".bigItem").show();
       $(this).removeClass("animate");
       
       $("#iconMenu .smallItem .text").hide();
       
       $("#iconMenu a.animate .smallItem .noOpacity").hide();
       $("#iconMenu a.animate .smallItem .opacity").show();
      },
      function() {
        $(this).find(".smallItem").show();
        $(this).find(".bigItem").hide();
        
        $("#iconMenu .smallItem .text").show();
        
        $("#iconMenu a.animate .smallItem .noOpacity").show();
       $("#iconMenu a.animate .smallItem .opacity").hide();
      }
    );
    
    // funkce pro vlozeni nyroModal pro obrazky z kamery START
    $(".webCams img").each(function(index) {
			var thisSrc = $(this).attr("src");
				thisSrc = thisSrc.toLowerCase();			
			
			if( thisSrc.search("/files/camera/") != -1 ){
				
				// sestaveni elementu
				var anchor = $("<a class='webCam'></a>").attr("href", "/webkamery/reload?source=" + thisSrc);
				// zkopirovani puvodniho elementu
				var image = $(this).clone();
										
				// pripojeni noveho el do DOMu
				anchor.append(image);
				$(this).after( anchor ).remove();
				
			}			
		});
		
		$(".webCam").fancybox({
      width: 620,
      height: 470,
      type: 'iframe'
    });
		
		// funkce pro zobrazeni podmenu aktivit na HP START
		$(".actItem").hover(
      function() {
        var linkWidth = $(this).find("a:first").attr("offsetWidth");
        $(this).css("position","relative");
        $(this).find(".centreMenu").show();
        $(this).find(".centreMenu").css("left",linkWidth+20+"px");
        $(this).find("a:first").addClass("active");
      },
      function() {
        $(this).css("position","static");
        $(this).find(".centreMenu").hide();
        $(this).find("a:first").removeClass("active");
      }
    );
    
    $(".actItem .centreMenu li").hover(
      function() {
        $(this).css("position","relative");
        $(this).find("img").fadeIn();
      },
      function() {
        $(this).css("position","static");
        $(this).find("img").hide();
      }
    );
    
    $("#categoriesMenu").hover(
      function() {
        $(this).find(".activityListHp").show();
      },
      function() {
        $(this).find(".activityListHp").hide();
      }
    );
    
    // 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>');
    					
	});
	
	// script pro nahrazeni select boxu service_id zduvodu stylovani START //  
	$(document).ready(function(){
		
	
		// --------------------------------------------------------
	    // nastaveni pluginu
	    // --------------------------------------------------------
	    
		sB_Identificator	= "mySb";
		sB_OptionsCount		= 0;
		sb_Direction		= "bottom" // top | bottom			
	
		// --------------------------------------------------------
	
		// pomocna funkce pro vytvoreni noveho elementu	
		function setupElement(pType, pClass, pId){
			var element = document.createElement(pType);
				$element = $(element);
				$element.attr("class", pClass);
				$element.attr("id", pId);
				
			return $element 
		}
		
		// pomocna funkce pro zjisteni velikosti skryteho elementu (menu)
		function getHiddenHeight( element ){
		
			if( $( element ).is(":visible") ){ clientHeight = -1; }
			else{
				$( element ).show();
				clientHeight = $( element ).attr("clientHeight");
				$( element ).hide();
			}
			
			return clientHeight;								
		}		
			
		// --------------------------------------------------------	
	
		// vytvoreni vsech potrebnych elementu	
		$sB_Container 	=	setupElement("div",		"sbContainer",		sB_Identificator);
		$sB_InputEnv 	=	setupElement("div",		"sbInput-env",		sB_Identificator + "Input-env_1");
		$sB_Input 		= 	setupElement("input",	"sbInput",			sB_Identificator + "Input_1");
		$sB_Control		=	setupElement("div",		"sbControl",		sB_Identificator + "Control_1");
		$sB_Options		=	setupElement("div",		"sbOptions-env",	sB_Identificator + "Options-env_1");
		$sB_OptionsUl	=	setupElement("ul",		"sbOptions",		sB_Identificator + "Options_1");
				
		// naplneni necislovaneho seznamu - vlastni rozbalovaci oblast						
		$("#service_id").find("option").each( function(i){
		
			$sB_OptionsLi = setupElement("li", "", $(this).attr("value"));
			$sB_OptionsLi.text( $(this).text() );									
			$sB_OptionsUl.append( $sB_OptionsLi ); 
			
		});
		
		// ma se seznam voleb scrollovat?
		if( sB_OptionsCount > 0 ){
			$sB_Options.css("overflow", "auto" );
			$sB_Options.css("height", sB_OptionsCount * 25 );
		}		
		
		// do inputu vloz vybranou polozku selectu		
		$sB_Input.attr("value", $("select").find("option:selected").text() );
		$sB_Input.attr("readonly", "readonly" );
		
		// --------------------------------------------------------
		
		// sestaveni obalky pro necislovany seznam a skryjem ji  		 					 		
		$sB_Options.append( $sB_OptionsUl ).hide();													   
		$sB_InputEnv.append( $sB_Input );
		
		// sestaveni celeho noveho selectboxu									   	
		$sB_Container.append( $sB_InputEnv );
		$sB_Container.append( $sB_Control );						
		$sB_Container.append( $sB_Options );
						
		// skryti realneho selectboxu a pripojeni noveho selectboxu		
		$("#service_id").hide().after( $sB_Container );

		// --------------------------------------------------------					
		
		// rozbaleni a sbaleni vsech polozek
		$(".sbControl, .sbInput")
		.click(function(e){	
			$(".sbControl").toggleClass("downStatus");
			
			// rolovani dolu
			if( sb_Direction == "bottom" ){ $(".sbOptions-env").toggle(); }
			
			// rolovani nahoru
			if( sb_Direction == "top" ){				
				
				// nastaveni pozadovane vysky
				height = getHiddenHeight(".sbOptions-env");								
				if( height != -1 ){					
					height = (height + 1) * (-1);
					$(".sbOptions-env").css("top", height + "px");					
				}
																
				$(".sbOptions-env").toggle();
				
			}			
		});
						
		$(".sbContainer")
		.click(function(){
			$(".sbInput").focus();
		});
				
				
		// --------------------------------------------------------
		
		// vlastni chovani menu
		$(".sbOptions").find("li")
		.mouseover( function(e){
			$(".sbOptions").find("li").removeClass("hover");
			$(this).addClass("hover");
		})
		.click( function(e){			
			
			$("#mySbInput_1").attr("value", $(this).text());
			index = $(this).attr("id");
			
			$("#service_id").find("option").each( function(i){
				if( $(this).attr("value") == index ){
					$(this).attr("selected", "selected");
				}
			});
			
			// skryti polozek a nastaveni statusu pro kontrolni prvek
			$(".sbOptions-env").hide();
			$(".sbControl").removeClass("downStatus");			
			
		});
				
	});
  
  // script pro nahrazeni select boxu service_id zduvodu stylovani END //
  
} 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

