	function IsValidEmail (email) {
		var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		return filter.test(email);
	}
	
	function mt(n,d,s,b) {
	  location.href = "mailto:" + n + "@" + d + "?subject=" + encodeURI(s) + "&body=" + encodeURI(b);
	}
	
	$.fn.pageLoad = function(loadpage){		
		$(".page .page-content").append('<img src="/img/ajax-loader.gif" />');
		function load_content_page(div, div_id){
				$(div).load(loadpage,{ 'page': div_id});
		}		
		$('.page .page-content').eachAsync({
			delay: 500, bulk: 0, loop: function(){	
				div = this;
				div_id = $(this).data("name");
				load_content_page(div, div_id);
			}
		})
	}
	
	var subpage = '';
	var subpage_holder = '';
	
	$.fn.subpageLoad = function(loadpage){
		function load_content_subpage(div, div_id){
			subpage = 1;
			subpage_holder = $(div).parent().attr('class');
			$(div).load(loadpage,{ 'page': div_id}, function(){
				$(div).addClass('sub');
			});
		}
		$('.submenu a').click(function(){
			subpageid = $(this).attr("rel").replace(/[^0-9]/g, '');
			sub_container = $(this).parent().parent().parent().parent().find("div.page-content");
			load_content_subpage(sub_container, subpageid);
			$('.submenu a').removeClass('active');
			$(this).addClass('active');
			return false;
		});
	}
	var currentpage = 1;
	$.fn.pageSlide = function(options){
		var defaults = {
			triggertype: 'menu',
			pagename: 'page' + currentpage,
			first_page: 'page',
			last_page : 'page'
		};
		
		if (subpage == 1){
			$('.submenu li a').removeClass('active');
			subpage_holder = subpage_holder.replace(/[^0-9]/g, '');
			$('.page' + subpage_holder + ' .page-content').removeClass('sub');
			$('.page' + subpage_holder + ' .page-content').load('../load_page.php',{ 'page': subpage_holder});
			subpage = 0;
		}
		
		var options = $.extend(defaults, options);
		
		currentpage = (options.pagename).replace(/[^0-9]/g, '');
			
			$('.menu a').attr('href', 'javascript:void(0)');
			
			function checkButtons(){
				last_page = (options.last_page).replace(/[^0-9]/g, '');
				first_page = (options.first_page).replace(/[^0-9]/g, '');
				if (currentpage == first_page){
						$('.nav.next').slideDown('fast');
						$('.nav.previous').slideUp('fast');
					}else if(currentpage == last_page){
						$('.nav.next').slideUp('fast');
						$('.nav.previous').slideDown('fast');
						$('.shield').hide();
					}else{
						$('.nav.next').slideDown();
						$('.nav.previous').slideDown();
						$('.shield').show();
					};
			}
				
			if (options.triggertype == "menu"){
				
				currentpage = (options.pagename).replace(/[^0-9]/g, '');
				
				$("div#content-container").scrollTo('.page' + currentpage, 800, {axis:'x', easing:'easeOutExpo'}) 				// Scroll to page
					$(this).delay(600,function(){																				// Focus on current page, using opacity
						$('.page' + currentpage ).fadeTo(250, 1.00);
						$('.page:not(.page' + currentpage  + ')').fadeTo(250, 0.33);												// Slide Pages Function
						$(".menu a").removeClass('active'); 
						$('a[rel=page' + currentpage  + ']').addClass('active');			
				});
				
				checkButtons();
			
			} else if (options.triggertype == "next"){
					currentpage++;
					$("div#content-container").scrollTo('.page' + currentpage , 800, {axis:'x', easing:'easeOutExpo'}) 			// Scroll to page
					$(this).delay(600,function(){	
						$('.page' + currentpage).fadeTo(250, 1.00)
						$('.page:not(.page' + currentpage + ')').fadeTo(250, 0.33);												// Slide Pages Function
						$(".menu a").removeClass('active'); 
						$('a[rel=page' + currentpage + ']').addClass('active');
				});
				checkButtons();
					
				} else if (options.triggertype == "previous"){
					currentpage--;
					$("div#content-container").scrollTo('.page' + currentpage , 800, {axis:'x', easing:'easeOutExpo'}) 		// Scroll to page		
					$(this).delay(600,function(){																			// Focus on current page, using opacity			
					
						$('.page' + currentpage).fadeTo(250, 1.00)
						$('.page:not(.page' + currentpage + ')').fadeTo(250, 0.33);											// Slide Pages Function				
						$(".menu a").removeClass('active'); $('a[rel=page' + currentpage + ']').addClass('active');		
					});
					checkButtons();
			};
			$('.page .shield').show();
			$('.page:not(.page' + currentpage  + ')').fadeTo(250, 0.33);	
			$('.page' + currentpage + ' .shield').hide();
	};																															// END fn.pageSlide function
	
	$.fn.pageWidth = function(container){																						//Setting width for IE6
			
		function resizeContainer(){
				var windowSize = $(window).width();	
				var menuSize = $('#menu-container').outerWidth();
				$('.ie6 ' + container).css({width: (windowSize - menuSize), left: menuSize});
				$('.ie6 body').css({width: windowSize})
			};
				
			resizeContainer();
				
			var resizeTimer = null;
			$(window).bind('resize', function() {
				if (resizeTimer) clearTimeout(resizeTimer);
				resizeTimer = setTimeout(resizeContainer, 100);
			});
	};
	
	$.fn.pageHeight = function(container){
		if($(window).height() <= 730){
			$('html').addClass('low')
		}else{}
																								//Setting width for IE6
			
	function resizeContainer(){
		if($(window).height() <= 730){
			$('html').addClass('low')
		}else{$('html').removeClass('low')}
			
		};
			
		resizeContainer();
			
		var resizeTimer = null;
		$(window).bind('resize', function() {
			if (resizeTimer) clearTimeout(resizeTimer);
			resizeTimer = setTimeout(resizeContainer, 100);
		});
	};

	/*  ------------------------------------------------------  */
	
	// zamena nadpisu za jiny font
	Cufon.replace('#menu ul li a'); 
	// fullscreen pozadi
	var FullscreenrOptions = {  width: 590, height: 402, bgID: '#bgimg' };
	jQuery.fn.fullscreenr(FullscreenrOptions);

	function fadeEfect () { $("#container").fadeIn(800); }	
	
	// po nacteni stranky
	$(document).ready(function () {
		// skryj celý obsah
		var $container = $("#container");
		$container.css('display', 'none');
		// animuj fade efektem s casovou prodlevou
		$container.delay(1000, function () {
			 
			$container.fadeIn(600); 
			
			// nacteni dat do kontejneru dalsich sekci
			$(".page1 .page-content").data("name", "1");
            $(".page2 .page-content").data("name", "2");
            $(".page3 .page-content").data("name", "3");
            $(".page4 .page-content").data("name", "4");
            $(".page5 .page-content").data("name", "5");
            $(".page6 .page-content").data("name", "6");

            $("#menu").fadeTo(1500, 0.7)
            		  .hover(function (){ $(this).stop().fadeTo(500, 1); }, function () { $(this).stop().fadeTo(1500, 0.7); });
            
            $('.page-content').each(function(){
            	$(this).before('<div class="shield" title="Přejít na tuto stránku."></div>');
            });
            
            $.fn.pageSlide({pagename:"page1", last_page:"page6", first_page : "page1"});
            
            $.fn.pageHeight();	
            	
            $.fn.pageWidth('#content-container');
            
            $.fn.pageLoad("load_page.php");
            
            $.fn.subpageLoad("load_sub_page.php");
            
            $('#menu a').click(function(){
            	$(this).pageSlide({pagename:$(this).attr('rel'), last_page:"page6", first_page : "page1"});
            });
            
            $('.next a').click(function(){
            	$(this).pageSlide({triggertype:"next", last_page:"page6", first_page : "page1"})			
            });		
            
            $('.shield').click(function(){
            	$(this).pageSlide({pagename:$(this).parent().attr('class'), last_page:"page6", first_page : "page1"})			
            });	
            		
            $('.previous a').click(function(){
            	$(this).pageSlide({triggertype:"previous", last_page:"page6", first_page : "page1"})			
            });	 
		});	
		

	});	
