try {
  $(function() {
  	$.fn.nyroModal.settings.processHandler = function(settings) {
  		var from = settings.from;
  		if (!settings.type && from && from.href) {
  			/*alert(
  				'type should be image: '+settings.type + '\n'
  				+ "need to determine if image manually");*/
  			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() {
    
	$('.nw').click( function() { window.open( $(this).attr('href') ); return false; });

    $("a.maps").nyroModal({
       minWidth: 750,
       minHeight: 550
    });
    
    $("a.DictionaryWordAnchorClass").tipTip();

    
    // Nastaveni Javascriptove validace prislusnym formularum dle ID
    $(".allForms").ndFormValidator();
    
    // vypnuti popisového pole v nyromodal okne
    $(".nyroModal").nyroModal({galleryCounts: false});
    
    $("#procedures .procedureInfo").hide();
    $("#procedures a").click(
      function() {
        $("#procedures .procedureInfo").slideUp();
        
        var parent = $(this).parents("li");
        parent.find(".procedureInfo").slideDown("slow");
        return false;
      }
    );
    
  });
  
  function callMessageBox(message) {
      jAlert(message, 'Info');
  }
  
  $(function() {
    $.datepicker.setDefaults($.datepicker.regional['cs']);
    $(".date-pick").datepicker({
      showOn: 'both',
			buttonImage: '/img/calendar.gif',
			buttonImageOnly: true,
      buttonText: 'Vložit datum',
			showButtonPanel: true
    });
	});
	
	// script pro nahrazeni select boxu 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						
		$("#selguide").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", $("#selguide").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		
		$("#selguide").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");
			
			$("#selguide").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 START
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

