// pomocna funkce pro inicializaci promennych z URL - pro citaty
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


// vlastni funkce pro zpozdovani
$.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
    return this.animate({delay:1}, time, callback);
}


// jquery settings
$(document).ready(function(){ 

 	var histslech = $.cookie('histslech');
	
	// pokud v cookie historici, zobraz menu historici
	if (histslech == 'historici') {	
	 $(".m-verejnost").hide(); 
	 $("#menu-main").addClass('historici'); 	
	}
	else {
        $(".m-historici").hide(); 
    };
   
	// menu verejnost   
    $("a.odkazv").click(function () {
	$(".m-verejnost").show();
	$(".m-historici").hide();  
	$("#menu-main").addClass('verejnost');  
	$("#menu-main").removeClass('historici'); 
	$.cookie('histslech', 'verejnost', { expires: 150 }); 
	return false;
    });
	
	// menu historici
    $("a.odkazh").click(function () {
	$(".m-verejnost").hide();
	$(".m-historici").show();  
	$("#menu-main").removeClass('verejnost');  
	$("#menu-main").addClass('historici'); 
	$.cookie('histslech', 'historici', { expires: 150 }); 
	return false;
    });
	
	
	
	// stiny obrazku
	$(".box img")
	.wrap("<div class='wrap0'><div class='wrap1'><div class='wrap2'>" +	"<div class='wrap3b'></div></div></div></div>");
	$(".clanek img")
	.wrap("<div class='wrap0'><div class='wrap1'><div class='wrap2'>" +	"<div class='wrap3'></div></div></div></div>");
		
	// fotky v ramu na HP
	$(".fotkavramu a").hover(function() {
		$(this).next("em").animate({opacity: "show", top: "-65"}, "slow");
	}, function() {
		$(this).next("em").animate({opacity: "hide", top: "-70"}, "fast");
	});
	
	// zakulaceni rohu	
	$('.ramecek').corner("15px cc:#f8f2dc");	
	$('.ramecek2').corner("15px cc:#f8f2dc");
	$('.ramecek3').corner("15px cc:#f8f2dc");
	
	//udela vicesloupcovy seznam
	//$('.dvasloupce').makeacolumnlists({cols: 2, colWidth: 0, equalHeight: 'ul', startN: 1});
	$('.trisloupce').makeacolumnlists({cols: 3, colWidth: 0, equalHeight: 'ul', startN: 1});
	
	//$(".svobs,p").append("&nbsp;");

	
	// zobrazeni a skryti citatu	
	if (citatyset=='hp') {	
	
		// citaty na HP - zobrazi se a hned se skryji
     	$('#svitek2').delay(1500).animate( {width:"36px", right: "26"}, 1000);
		$(".svobs").delay(1500).animate({opacity: "hide"}, 1000);	
		$(".svlink").delay(1500).toggleClass("svlink2");

		// funkce pro skryti a zobrazeni citatu
		$(".svlink a").toggle(
			function () {
			   $('#svitek2').animate( {width:"344", right: "26"}, "slow" );
			   $(".svobs").animate({opacity: "show"}, "slow");
			   $(".svlink").toggleClass("svlink2");	
			},				
			function () {
			   $('#svitek2').animate( {width:"36px", right: "26"}, "slow" );
			   $(".svobs").animate({opacity: "hide"}, "slow");
			   $(".svlink").toggleClass("svlink2");
			}			
		); 		

	}
	else {
		
		$('#svitek2').animate( {width:"36px", right: "26"}, 1);
		$(".svobs").animate({opacity: "hide"}, 1);
		$(".svlink").toggleClass("svlink2");
		
		// funkce pro skryti a zobrazeni citatu
		$(".svlink a").toggle(
			function () {
			   $('#svitek2').animate( {width:"344", right: "26"}, "slow" );
			   $(".svobs").animate({opacity: "show"}, "slow");
			   $(".svlink").toggleClass("svlink2");	
			},				
			function () {
			   $('#svitek2').animate( {width:"36px", right: "26"}, "slow" );
			   $(".svobs").animate({opacity: "hide"}, "slow");
			   $(".svlink").toggleClass("svlink2");
			}			
		); 		
		
			
    };		
			
  


});
