	
	var rootPath = 'http://' + window.location.hostname + '/';
	var ajaxPath = 'http://' + window.location.hostname + '/__project/ajax/';
	var jsPath = 'http://' + window.location.hostname + '/__project/js/';


	//fce kter overi jestli existuje element na strance podle ID
	jQuery.fn.exists = function(){return jQuery(this).length>0;}


	
	/////////////////////////
	// SCROLL TO ELEMENT
	/////////////////////////
	function scrollToElem(elem){
		
		var destination = $(elem).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 700);
		return false;
	}
	
	/////////////////////////
	// TOP POZICE ELEMENTU
	/////////////////////////	
	function getElemTopPos(elem){
		var p = $(elem);
		var pos = p.position();
		return pos.top;
	}



	/////////////////////////
	// AUTOVALUE
	/////////////////////////
	function autovalue(){
		
		$("input.autovalue, textarea.autovalue").livequery('focus', function(event) {
			$(this).addClass('focused');
			strNull = $(this).attr('rel');
			str = $(this).val();
			if(str === strNull){
				$(this).val('');
			}
		})
		$("input.autovalue, textarea.autovalue").livequery('blur', function(event) {
			strNull = $(this).attr('rel');
			str = $(this).val();
			if(str === ''){
				$(this).val(strNull);
				$(this).removeClass('focused');
			}
			
		})
	}
	
	// inicializace
	autovalue();
	
	
	//////////////////////////////////////////////////////
	//	Google Maps API
	//////////////////////////////////////////////////////
	
	function getLatLng(width, height, address, lat, lng){
	  	if($('div.loadAjaxPage').length == 0){
	  		loadAjaxPage('', width+'px', height+'px', ajaxPath + "mapGetLatLong.php", false, {address:address, lat:lat, lng:lng});
	  	}else{
	  		loadAjaxPageNext('', width+'px', height+'px', ajaxPath + "mapGetLatLong.php", false, {address:address, lat:lat, lng:lng});
	  	}
	}
	
	
	
	var pulkaW = getHalfPageHor();
	var pulkaH = getHalfPageVer();

	function createMenu(){ 
		/*	
		$(".uvod").animate({'left':pulkaH-110+'px', 'top':pulkaH-120+'px'},{duration:1200, easing:"easeOutBounce"}); 
		$(".pokyny").animate({'left':pulkaH-125+'px', 'top':pulkaH-65+'px'},{duration:1200, easing:"easeOutBounce"}); 
		$(".fotografie").animate({'left':pulkaH-120+'px', 'top':pulkaH-10+'px'},{duration:1200, easing:"easeOutBounce"}); 
		*/
		setTimeout(function() {
			//$(".uvod").animate({'left':pulkaW-(170+250)+'px', 'top':pulkaH-90+'px'},{duration:1000, easing:"easeOutBounce"}); 
			$(".uvod").animate({'left':pulkaW-(3*140)+'px', 'top':'5px'},{duration:1000, easing:"easeOutBack"}); 
		}, 400 );
		setTimeout(function() {
			//$(".pokyny").animate({'left':pulkaW-(180+250)+'px', 'top':pulkaH-40+'px'},{duration:1300, easing:"easeOutBounce"}); 
			$(".pokyny").animate({'left':pulkaW-(2*140)+'px', 'top':'5px'},{duration:1300, easing:"easeOutBack"}); 
		}, 600 );
		setTimeout(function() {
			//$(".fotky").animate({'left':pulkaW-(175+250)+'px', 'top':pulkaH+15+'px'},{duration:1600, easing:"easeOutBounce"}); 
			$(".fotky").animate({'left':pulkaW-(1*140)+'px', 'top':'5px'},{duration:1600, easing:"easeOutBack"}); 
		}, 800 );
		setTimeout(function() {	
			//$(".mapa").animate({'left':pulkaW-(168+250)+'px', 'top':pulkaH+40+'px'},{duration:2000, easing:"easeOutBounce"}); 
			$(".mapa").animate({'left':pulkaW-(0)+'px', 'top':'5px'},{duration:1600, easing:"easeOutBack"}); 
		}, 1000 );
		
		
		$('.btn.active').mouseover(function() {
			$(this).animate({'top':'+=8'},{duration:'200', easing:"easeOutBack"});
				}).mouseleave(function() {
			$(this).animate({'top':'-=8'},{duration:'200', easing:"easeOutBack"});
		});
		
	}


	function centerHor(elem){
		
		var scrollDim = 	getScrollXY();
		var widthPlus =		scrollDim[0];
		var windowWidth = 	document.documentElement.clientWidth;
		var popupWidth = 	$(elem).width();
		//centering
		$(elem).css({"left":(windowWidth/2-popupWidth/2) + widthPlus});	
	}

	//////////////////////////////////////////////////////
	function centerVer(elem){
		
		var scrollDim = getScrollXY();
		var heightPlus =scrollDim[1];
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $(elem).height();
		//centering
		$(elem).css({"top": (windowHeight/2-popupHeight/2) + heightPlus});
	}
	//////////////////////////////////////////////////////
	function getCenterVer(elem){
		
		var scrollDim = getScrollXY();
		var heightPlus =scrollDim[1];
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $(elem).height();
		//centering
		return  (windowHeight/2-popupHeight/2) + heightPlus;
	}
	//////////////////////////////////////////////////////
	function getHalfPageHor(){
		
		return (document.documentElement.clientWidth/2);
	}
	//////////////////////////////////////////////////////
	function getHalfPageVer(){
		
		return (document.documentElement.clientHeight/2);
	}

	//////////////////////////////////////////////////////
	function centerElem(elem){
		
		var scrollDim = getScrollXY();
		var widthPlus =scrollDim[0];
		var heightPlus =scrollDim[1];
		//alert (scrollDim);	
		
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $(elem).height();
		var popupWidth = $(elem).width();
		//centering
		$(elem).css({
			//"position": "absolute",
			//"opacity": "0.0",
			"top": (windowHeight/2-popupHeight/2) + heightPlus,
			"left": (windowWidth/2-popupWidth/2) + widthPlus
		},1000);
		
	}

	function animateCenterElem(elem){
		//alert('jirka')
		var scrollDim = getScrollXY();
		var widthPlus =scrollDim[0];
		var heightPlus =scrollDim[1];
		
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $(elem).height();
		var popupWidth = $(elem).width();
		//centering
		$(elem).animate({
			"top": (windowHeight/2-popupHeight/2) + heightPlus,
			"left": (windowWidth/2-popupWidth/2) + widthPlus
		},{duration:1000, easing:"easeOutBack"});
		
	}


	function centerElemWresize(elem){
		
		var scrollDim = getScrollXY();
		var widthPlus =scrollDim[0];
		var heightPlus =scrollDim[1];
		alert (scrollDim);	
		
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $(elem).height();
		var popupWidth = $(elem).width();
		//centering
		$(elem).css({
			"top": (windowHeight/2-popupHeight/2) + heightPlus,
			"left": (windowWidth/2-popupWidth/2) + widthPlus
		},{queue:false, duration:300, easing:"backEaseOut"});
		
	}


	function getScrollXY() {
		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
		    //Netscape compliant
		    scrOfY = window.pageYOffset;
		    scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		    //DOM compliant
		    scrOfY = document.body.scrollTop;
		    scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		    //IE6 standards compliant mode
		    scrOfY = document.documentElement.scrollTop;
		    scrOfX = document.documentElement.scrollLeft;
		  }
		  return [ scrOfX, scrOfY ];
	}

	function initPlayer(autoStart, videoPlace, stageW, stageH, videoFile, tmbFile){
		
		var flashvars = {};
		var params = {};
		
		params.bgcolor = "#4290B7";
		params.allowfullscreen = "true";
		params.wmode = "transparent";
		
		flashvars.stageW = stageW;
		flashvars.stageH = stageH;
		flashvars.videoPath = videoFile;
		flashvars.imagePath = tmbFile;
		flashvars.autoStart = autoStart;
		flashvars.autoHide = "true";
		flashvars.autoHideTime = "1";
		flashvars.hideLogo = "true";
		flashvars.volAudio = "60";
		flashvars.disableMiddleButton = "false";
		flashvars.playSounds = "true";
		flashvars.soundBarColor = "0x0066FF";
		flashvars.barColor = "0x0066FF";
		flashvars.barShadowColor = "0x91BBFB";
		flashvars.subbarColor = "0xffffff";
		flashvars.extendVideo = "true";

		if($('#' + videoPlace).length > 0){
			flashembed(videoPlace, 
		    		{ 
			    		src: 	rootPath + "__libs/_player/deploy/flvPlayer.swf", 
			    		wmode: 	"transparent", 
			    		width: 	stageW, 
			    		height: stageH,
						//version: [20, 0], 
						expressInstall: "http://static.flowplayer.org/swf/expressinstall.swf"
					},
					flashvars
			);
		};
		
	}
	
	this.tooltip = function(selector){	
		/* CONFIG */		
			xOffset = -5;
			yOffset = 15;		
			
			// these 2 variable determine popup's distance from the cursor
			// you might want to adjust to get the right result		
		/* END CONFIG */		
		$(selector).hover(function(e){	
			
			$("#tooltip").remove();
			
			var winWidht = document.documentElement.clientWidth;
			var winHeight = document.documentElement.clientHeight;
			var x_krat = -0.5;
			
			this.t = this.title;
			this.title = "";		
			if(this.t != ''){
				
			var toolText = this.t;
			toolText = toolText.replace(/b_s/g, "<b>");
			toolText = toolText.replace(/b_e/g, "</b>");
			toolText = toolText.replace(/b_r/g, "<br />");
				
			// vytvorim tooltip
			$("body").append("<div id='tooltip'>"+ toolText +"</div>");
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + ($("#tooltip").width()*x_krat)) + "px")
				//.html(toolText)
				.fadeIn("fast");
			}
			// nastavim pohyb tooltipu
			$(this).mousemove(function(e){
				var xOffset = -25;
				var yOffset = $("#tooltip").width()*x_krat;	
				
				
				var leftPos = e.pageY - xOffset;
				var topPos 	= e.pageY - yOffset;
				
				if((e.pageX + ($("#tooltip").width()*x_krat)+25) > winWidht){
					yOffset = ($("#tooltip").width()+10) * (-1);
				}else if(e.pageX < ($("#tooltip").width()*x_krat)+25){
					yOffset = 10;
				}
				if((e.pageY + ($("#tooltip").height()+30)) > winHeight){
					xOffset = $("#tooltip").height()+15;
				}				
				$("#tooltip")
					.css("top",(e.pageY - xOffset) + "px")
					.css("left",(e.pageX + yOffset) + "px");	
			});	
			
	    },
		function(){
			this.title = this.t;		
			$("#tooltip").remove();
	    });	
	};

	// video 
	$(document).ready(function(){
		$('.forPlay').each(function(e){

			var w = $(this).width();
			var h = $(this).height();
			var href = $(this).children('a').attr('href');
			$(this).append('<a class="playVideo" href="'+href+'"><div style="width:'+w+'px; height:'+h+'px;"></div></a>')
			
			$('.playVideo').css({'opacity':'0.5'});
			$('.playVideo').hover(function(){
				$(this).animate({'opacity':'1'})
			}, function(){
				$(this).animate({'opacity':'0.5'})
			})
		})
	});	
	
	// starting the script on page load
	$(document).ready(function(){
		tooltip("input, select, textarea, .tooltip");
	});
	
	
	// Zafixovani menu
	$(document).ready(function(){	
		$(window).scroll(function() {
			if($(this).scrollTop()>60){
				
				$('#mainMenuHolder').css({'opacity':'0.5', 'z-index':'100'})
				$('#mainMenuHolder').hover(function(){
						$(this).css({'opacity':'1'})
					}, function(){
						$(this).css({'opacity':'0.5'})
					})
			}else{
				$('#mainMenuHolder').css({'opacity':'1'})
			}
		});
		
	});
