	
	var rootPath = 'http://' + window.location.hostname + '/';
	var ajaxPath = 'http://' + window.location.hostname + '/__project/ajax/';
	var jsPath = 'http://' + window.location.hostname + '/__project/js/';
	
    $(document).ready(function() {
        $(".TblHpBox tbody").each( function (){
            //$(" tr:even", this).css("background-color", "#1e1e1e");
        })
        $(".TblHpBox:not(.notEven) tbody tr:odd, .divAsTR:not(.notEven):odd").css("background-color", "#181818");
        
    });

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

	

	function checkReport(caller){
		
		$.post( ajaxPath + 'printReport.php',function(html){
				
			if(html == 0){}else{
				$('body').append('<div id="reportHolder" ></div>')
				$(caller).append('<div id="reportHolderInner" >'+html+'</div>');
				centerElemHorizontal(caller, '-45px');
				$(caller).css({'opacity':'1.0'});
				var winTop = $(window).scrollTop();
				var top = winTop-6;
				$(caller).animate({'top':top+'px'}, 500);
				//$(caller).animate( { backgroundColor: 'red'}, 300).animate({'top':top+'px'}).animate( { backgroundColor: '#16A9E2' }, 900);
			
				setTimeout( function(){ 
					closeReport(caller);
				}, 5000);
			
				$(caller).click(function(){
					closeReport(caller);
				});
				$(window).scroll(function(){
					closeReport(caller);
				})
			}
		});
	}	
	function closeReport(caller){
		$(caller).animate({'top':'-35px', 'opacity':'0'}, function(){
			$(this).remove();
		})
	}
	
	$(document).ready(function () {
		checkReport('#reportHolder');
	});
	
	/////////////////////////
	// SCROLL TO ELEMENT
	/////////////////////////
	function scrollToElem(elem){
		
		var destination = $(elem).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 700);
		return false;
	}

	/////////////////////////
	// 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();
	
	/////////////////////////
	// LOAD LOGIN
	/////////////////////////
	function loadLoginForm(elem){
		$(elem).html('<div class="divLoader16" style="padding:8px 0px;">&nbsp;</div>');
		
		setTimeout( function(){ 
			$.post( rootPath + '__templates/public/inc_member_login.php',
					function(html){
						$(elem).html(html);
					});
		}, 1000);
		
	}
	
	
	/////////////////////////
	// NASTAVENI DATUMU
	/////////////////////////
	$(document).ready(function() {		
			//$(":date").dateinput();
			// the czech localization
			$.tools.dateinput.localize("cs",  {
			   months:        'leden,únor,březen, duben,květen,červen,červenec,srpen,září,říjen,listopad,prosinec',
			   shortMonths:   'led,úno,bře,dub,kvě,čer,čec,srp,zář,říj,lis,pro',
			   days:          'neděle,pondělí,úterý,středa,čtvrtek,pátek,sobota',
			   shortDays:     'ne,po,út,st,čt,pá,so'
			});
			$(":date").dateinput({ 
				lang: 'cs',
				trigger: true, 
				format: 'dd.mm.yyyy', 
				firstDay: 1 
			})

			// use the same callback for two different events. possible with bind
			$(":date").bind("onShow onHide", function()  {
				$(this).parent().toggleClass("active"); 
			});

	});
	
	
	//////////////////////////////////////////////////////
	//	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});
	  	}
	}


	//////////////////////////////////////////////////////
	//	Report Animation
	//////////////////////////////////////////////////////
	
	function printReport(reportType, after, string){
	  	if(reportType == 1){
	  		if($('div.loadAjaxPage').length == 0){
	  			$(after).after('<div id="report" class="reportSuccess">'+string+'</div>');
	  		}
	  		$("#report").animate( { backgroundColor: 'lightgreen' }, 1000).animate( { backgroundColor: 'white' }, 1000);
	  	}else{
	  		if($('div.loadAjaxPage').length == 0){
	  			$(after).after('<div id="report" class="reportError">'+string+'</div>');
	  		}
	  		$("#report").animate( { backgroundColor: 'pink' }, 1000).animate( { backgroundColor: 'white' }, 1000);
	  	}
	}


	
	/////////////////////////
	// PRELOAD IMAGES
	///////////////////////// 
    $(document).ready(function(){
    	
   	
		/*$.preload( 'img', {
			placeholder:'http://' + window.location.hostname + '/placeholder.php?a=1&w='+$(this).attr('width')+'&h='+$(this).attr('height'),//this is the really important option
			notFound:'http://' + window.location.hostname + '/placeholder.php?a=2&w='+$(this).attr('width')+'&h='+$(this).attr('height'),//optional image if an image wasn't found
			threshold: 2 //'2' is the default, how many at a time, to load.
		});*/
    	
		$('img').livequery(function(event) {
			var w = $(this).width();
			var h = $(this).height();
			
			$.preload( $(this), {
				//placeholder:'http://' + window.location.hostname + '/placeholder.php?a=1&w='+w+'&h='+h,//this is the really important option
				notFound:'http://' + window.location.hostname + '/placeholder.php?a=2&w='+w+'&h='+h,//optional image if an image wasn't found
				threshold: 2 //'2' is the default, how many at a time, to load.
			});
		});		
		/*
    	$('img').livequery(function(event) {
			var w = $(this).width();
			var h = $(this).height();
    		$(this).lazyload({
    			placeholder:'http://' + window.location.hostname + '/placeholder.php?a=1&w='+w+'&h='+h,//this is the really important option
	    		//placeholder : "http://develop.nausus.com/__images/grey.gif"
	    		event:"scroll",
	    		efect:"fadeIn"
	
	    	 });
    	});
    	*/
    	

    });
	
	
	/////////////////////////
	// OVLADANI MUTACI NA FE
	/////////////////////////	
	$(document).ready(function () {
		$("div#langHolder,div#logoutHolder");
		$("div#langHolder").mouseover(function(){
				$(this).addClass('hoverLogLang');
				$("div#langItemsHolder").css({'display':'block'});
			});
		$("div#langHolder").mouseleave(function(){
				$("div#langItemsHolder").css({'display':'none'});
				$(this).removeClass('hoverLogLang');
		});
		$("div#logoutHolder").mouseover(function(){
			$(this).addClass('hoverLogLang');
		});
		$("div#logoutHolder").mouseover(function(){
			$(this).removeClass('hoverLogLang');
		});
	});
	//////////////////////////////////////////////////////
	

	
	$(document).ready(function(){
		//$(".hpPageItem :last").css({'color':'red','border-bottom':'dotted 1px #ccc'});
	});

	
	/////////////////////////
	// SHOW / HIDE ELEMET
	/////////////////////////
	function showHideElement(element, caller){
		$(element).toggleClass('hideElement');
		if(caller != ''){
			$(caller).toggleClass('hideElement');
		}
	}
	//////////////////////////////////////////////////////
	
	
	/////////////////////////
	// INFO O REKLAMNE
	/////////////////////////
	$(document).ready(function(){
		$("div.banner").each(function(){
			$(this).prepend('<div class="bannerInfo">Reklama</div>');
		})
	});
	//////////////////////////////////////////////////////
	
	
	/////////////////////////
	// SEARCH
	/////////////////////////
	$(document).ready(function(){

		$("form#searchForm").submit(function(){
			strNull = $("input#search").attr('rel');
			str = $("input#search").val();
			if($("input#search").val() === '' || str === strNull){
				$("input#search").css({'border-color':'red'});
				return false;
			}
		})
	
	});
	//////////////////////////////////////////////////////	
	
	////////////////////////////////////////////
	//// fce pro ovladani menu
	////////////////////////////////////////////
	
	$(document).ready(function(){
		//pole homepage
		$('.btnHome').animate({'opacity':'0.5'}).hover(
				function () {
					$(this).animate({'opacity':'1'},'fast');
				}, 
				function () {
					$(this).animate({'opacity':'0.5'},'slow');	  
			});
		// pole menu
		$('.subMenu').animate({'opacity':'0.95'}, 600);
		$('#topMenuHolder .item').hover(
			function () {
				var qIndex = $('#topMenuHolder .item').index(this);
				$('.subMenu:eq('+qIndex+')').css({'z-index':'15','top':'51px'}).animate({'opacity':'0.95'}, 200);
			}, 
			function () {
				var qIndex = $('#topMenuHolder .item').index(this);
				$('.subMenu:eq('+qIndex+')').css({'z-index':'14'}).animate({'opacity':'0'}, 400);
				setTimeout( function(){ 
					$('.subMenu:eq('+qIndex+')').css({'top':'-200px'});
				}, 600);	  
		});

	});
	
	$(document).ready(function(){
		$(".menuItem").hover(
		  function () {
		    $(this).css({'background-position':'0% 100%'});
		  }, 
		  function () {
		    $(this).css({'background-position':'0% 50%'});
		  }
		);
	});
	

    $(document).ready(function () {

        $('a.media').each(function (i) {
            var audioPlayer = '<object type="application/x-shockwave-flash" data="Editor/common/audioplayer/player.swf" height="24" width="290">';
            audioPlayer += '<param name="movie" value="Editor/common/audioplayer/player.swf">';
            audioPlayer += '<param name="FlashVars" value="playerID=' + i + '&soundFile=' + $(this).attr('href') + '&titles=' + $(this).html() + '">';
            audioPlayer += '<param name="quality" value="high">';
            audioPlayer += '<param name="menu" value="false">';
            audioPlayer += '<param name="wmode" value="transparent">';
            audioPlayer += '</object>';
            /*audioPlayer += '<br/><a href=\"' + $(this).attr('href') + '\" target=\"_blank\">download mp3</a>';*/
            $(this).after(audioPlayer).remove();
        });

    });

	
	

	///////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	// POPUP WIN
	///////////////////////////////////////////////////////////////////////////	
	
	
	/////////////////////////
	// DRAG POPUP WIN
	/////////////////////////
    function dragPopup() {
        $(".loadAjaxPage,.loadAjaxPageNext,.loadAjaxPageHelp" ).draggable( { handle: "div.top" } );
    }

	/////////////////////////
	// resize POPUP WIN
	/////////////////////////    
    function resizePopup() {
		$(".loadAjaxPage,.loadAjaxPageNext,.loadAjaxPageHelp, .resize").resizable({
			ghost: true
		});
	}


	// fce ktera prekryje zvoleny elemnt
	function getPageCover(){
		//$("div#pageTopOrange").text('Pracuji ... čekejte prosím');
		//$("div#pageTopOrange").removeClass('topReady').addClass('topInProgress');
		//$("div#pageTopOrange").animate({'top':'0px', 'opacity':'0.9'});
		var h = $(document).height();
		var w = $(document).width();
		var bgloader = '<div id="loaderBG" style=" width:'+w+'px; height:'+h+'px;"></div>';
		
		if ($("div#loaderBG").exists()) {
			$("div#loaderBG").css({'opacity':'0.8'});
		}else{
			$("body").prepend(bgloader);
			$("div#loaderBG").css({'opacity':'0.8'});
		}

	}
	// fce ktera vycentruje over pri zmene velikosti okna
	$(document).ready(function(){
		$(window).resize(function() {
			centerElemWresize("div.loadAjaxPage");
			centerElemWresize("#jqDialog_box");
			var h = $(document).height();
			var w = $(document).width();
			$("div#loaderBG").css({'width':w+'px', 'height':h+'px'});
		});
	});

	function removePageCover(){
		//$("div#pageTopOrange").removeClass('topInProgress').addClass('topReady');
		//$("div#pageTopOrange").text('Připraven ...');
		//$("div#pageTopOrange").animate({'top':'-42px'}, 300); // $(this).animate({ backgroundColor: "black" }, 1000);
		//$("div#pageFooterHolder").animate({'bottom':'0px'}, 300);
		$("div#loaderBG").fadeOut("slow", function(){
			$(this).remove();
		});
	}
	function readyPageCover(){
		/*
		$("div#pageTopOrange").removeClass('topInProgress').addClass('topReady');
		$("div#pageTopOrange").text('Připraven ...');
		
		setTimeout(function(){
			$("div#pageTopOrange").animate({'top':'-42px'}, 300);
			$("div#pageFooterHolder").animate({'bottom':'-50px'}, 300);
			}, 900);
			*/
	}



	////////////////////////////////////////////////

	function loadAjaxPage(target, w, h, loadPage, close, data)
	{
		var ajaxElem = 'div.loadAjaxPage';
		if(target == ''){target = 'body'};
		// zavolam pageCover
		getPageCover(target);
		// vlozim div 
		var ajaxElemCreate = '<div class="loadAjaxPage"></div>';
		$(target).append(ajaxElemCreate);
		// nastavim rozmer
		if(w != '' || w == 0){$(ajaxElem).css({'width' : w});}
		if(h != '' || h == 0){$(ajaxElem).css({'height' : h});}
		// vycentruji
		$(ajaxElem).load(loadPage, { 'data': data });
		centerElem(ajaxElem);
		$(ajaxElem).animate({
				'opacity':'1.0'}, function(){
					//readyPageCover();
				});
		if(close){
			$("div#loaderBG").click(function(){
				removeAjaxPageLoader();
			});
		};	
		$("div.loadAjaxPage input[class*='grey']").livequery('click', function(event) {
			removeAjaxPageLoader();
		});	
	}
	function removeAjaxPageLoader(){
		$("div.loadAjaxPage").fadeOut("250", function(){
			$("div.loadAjaxPage").remove();
			removePageCover();
		});
	}

	function loadAjaxPageNext(target, w, h, loadPage, close, data)
	{
		var ajaxElem = 'div.loadAjaxPageNext';
		if(target == ''){target = 'body'};
		// zavolam pageCover
		//getPageCover(target);
		// vlozim div 
		var ajaxElemCreate = '<div class="loadAjaxPageNext"></div>';
		$("div.loadAjaxPage").css({'z-index':'499'});
		$(target).append(ajaxElemCreate);
		// nastavim rozmer
		if(w != '' || w == 0){$(ajaxElem).css({'width' : w});}
		if(h != '' || h == 0){$(ajaxElem).css({'height' : h});}
		// vycentruji
		$(ajaxElem).load(loadPage, { 'data': data });
		centerElem(ajaxElem);
		$(ajaxElem).animate({
				'opacity':'1.0'}, function(){
					readyPageCover();
				});
		if(close){
			$("div#loaderBG").click(function(){
				removeAjaxPageLoaderNext();
				
			});
		};	
		$("div.loadAjaxPageNext input[class*='grey']").livequery('click', function(event) {
			removeAjaxPageLoaderNext();
		});	
	}
	function removeAjaxPageLoaderNext(){
		$("div.loadAjaxPageNext").fadeOut("250", function(){
			$("div.loadAjaxPageNext").remove();
			$("div.loadAjaxPage").css({'z-index':'501'});
			//removePageCover();
		});
	}


	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 centerElemHorizontal(elem, top){
		
		var scrollDim = getScrollXY();
		var widthPlus =scrollDim[0];
		var heightPlus =scrollDim[1];
		//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": (top),
			"left": (windowWidth/2-popupWidth/2) + widthPlus
		},1000);
		
	}
	function centerElemVertical(elem, left){
		
		var scrollDim = getScrollXY();
		var widthPlus =scrollDim[0];
		var heightPlus =scrollDim[1];
		//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": (left)
		},1000);
		
	}
	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
		},1000);
		
	}


	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 ];
	}
