function ajax(url,idElement){
	if (url != 0){
		if (window.ActiveXObject){
    		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
        else{
			httpRequest = new XMLHttpRequest();
		}
    	httpRequest.open("GET", url+'&popisek='+idElement, true);
        httpRequest.onreadystatechange= function () {processRequest(idElement); } ;
        httpRequest.send(null);
	}
	else{
		document.getElementById(idElement).innerHTML = "";
	}
	//setTimeout("alert('"+idElement+"')",10);
}

function processRequest(element){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var vystup = document.getElementById(element);
			vystup.innerHTML = httpRequest.responseText;
		}
		else{
			alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}

$(document).ready(function() {

/*$("#scroller").simplyScroll({
	className: 'vert',
	horizontal: false,
	frameRate: 20,
	speed: 1
});  */

// otevirani odkazu v novem okne
$('a[href^="http://"]').each(function() {
    $(this).attr("target", "_blank");
});
// otevirani odkazu v novem okne
$('a[rel^="newWindow"]').each(function() {
    $(this).attr("target", "_blank");
});
// otevirani pdf v novem okne
$("a[href$=.pdf]").each(function() {
    $(this).attr("target", "_blank");
});

$('.scroll-pane').jScrollPane({showArrows: true});

if ($(".input-search").length > 0) {
   var defaultInputSearch = $(".input-search").val();
   $(".input-search").focus(function(){
      if (defaultInputSearch == $(this).val()) $(this).val("");   
   });
   $(".input-search").blur(function(){
      if ($(this).val() == "") $(this).val(defaultInputSearch);   
   });   
}

/* nyroModal */
$('a[rel*=nyroModal]').nyroModal(); // Select all links that contains lightbox in the attribute rel
$('a[href$="jpg"]').nyroModal(); // Select all links with lightbox class
$('a[href$="swf"]').nyroModal();

/* zalozky na HP */
$("#block-aktuality").show();
$(".button.aktuality").show();
$("#block-uredni-deska").hide();
$(".button.uredni-deska").hide();
$("#block-kalendar-akci").hide();
$(".button.kalendar").hide();
$("#button-aktuality").click(function(){
	//$("#top-box .flag a.active").dropShadow({left: 2, top: 2, opacity: 0.4, blur: 5});
   //$("#top-box .flag a.active").removeShadow();
   $("#top-box .flag a").removeClass("active");
   $(this).addClass("active");
   
   $("#block-aktuality").show();
   $("#block-uredni-deska").hide();
   $("#block-kalendar-akci").hide();
   //$("#top-box .flag a.active").dropShadow({left: 2, top: 2, opacity: 0.4, blur: 5});
   
   $(".button.aktuality").show();
   $(".button.uredni-deska").hide();
   $(".button.kalendar").hide();
});
$("#button-uredni-deska").click(function(){
   //$("#top-box .flag a.active").removeShadow();
   $("#top-box .flag a").removeClass("active");
   $(this).addClass("active");
   //$("#top-box .flag a.active").dropShadow({left: 2, top: 2, opacity: 0.4, blur: 5});
   $("#block-aktuality").hide();
   $("#block-uredni-deska").show();
   $("#block-kalendar-akci").hide();  
   
   $(".button.aktuality").hide();
   $(".button.uredni-deska").show();
   $(".button.kalendar").hide();
});
$("#button-kalendar-akci").click(function(){
   $("#top-box .flag a").removeClass("active");
   $(this).addClass("active");
   $("#block-aktuality").hide();
   $("#block-uredni-deska").hide();
   $("#block-kalendar-akci").show();
   
   $(".button.aktuality").hide();
   $(".button.uredni-deska").hide();
   $(".button.kalendar").show();  
   
   // navaznost na pravy box s kalendarem
   $(".flag.n1").removeClass("active");
	$(".flag.n2").addClass("active");
	$("#block-weather").hide();
	$("#block-calendar").show(); 
});

/* zalozky na HP - levy box */
$("#block-weather").show();
$("#block-calendar").hide();
$("#button-weather").click(function(){
	$(".flag.n2").removeClass("active");
	$(".flag.n1").addClass("active");
	$("#block-weather").show();
	$("#block-calendar").hide();
});
$("#button-calendar").click(function(){
	$(".flag.n1").removeClass("active");
	$(".flag.n2").addClass("active");
	$("#block-weather").hide();
	$("#block-calendar").show();
	
	// navaznost na hlavni zalozky
	$("#top-box .flag a").removeClass("active");
	$("#button-kalendar-akci").addClass("active");
	$("#block-aktuality").hide();
	$("#block-uredni-deska").hide();
	$("#block-kalendar-akci").show();
	$(".button.aktuality").hide();
	$(".button.uredni-deska").hide();
	$(".button.kalendar").show();
});


/* stiny */
//$("#top-box .flag a.active").dropShadow({left: 2, top: 2, opacity: 0.4, blur: 5});
//$("#top-box .top").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
$("#top-box .body").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
$("#top-box .bottom").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
//$("#content.right .body").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
//$("#content.right .bottom").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
//$("#content.right .top").dropShadow({left: 0, top: 1, opacity: 0.4, blur: 5});
//$(".left-box .body").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
//$(".left-box .bottom").dropShadow({left: 0, top: 0, opacity: 0.4, blur: 5});
//$(".left-box .top").dropShadow({left: 0, top: 1, opacity: 0.4, blur: 5});

/* vysky boxu */
//$("#info-box .body").height($("#top-box .body").height()+34);

/* nastaveni stejnych bunek ve fotogalerii */
$(window).load(function() {
	var vyska = 0;
	$.each($("#photogalery img"), function(index, value) {
	  if (vyska < ($(this).height())) vyska = $(this).height();
	});
	$("#photogalery .items a").height(vyska);
});

// flash - pocasi
$('.wunderground').flash({
    src: 'http://www.wunderground.com/swf/pws_mini_rf_nc.swf?station=ISTU01596&amp;freq=2.5&amp;units=metric&amp;lang=CZ',
    width: 265,
    height: 119
});



jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}
$("a.anchorLink").anchorAnimate()

// rozbalovani a zabalovani textu
/*$(".more-content").click(function () {
   $('.rest').slideToggle();
   if ($('.rest').css("display") == 'none'){
		$('.more-content').css("display", "inline");
		$('.more-content-less').css("display", "none");
	}
	else{
		$('.more-content').css("display", "none");
		$('.more-content-less').css("display", "inline");
	}
   return false;
});
$(".more-content-less").click(function () {
   $('.rest').slideToggle();
   if ($('.rest').css("display") == 'block'){
		$('.more-content').css("display", "inline");
		$('.more-content-less').css("display", "none");
	}
	else{
		$('.more-content').css("display", "none");
		$('.more-content-less').css("display", "inline");
	}
   return false;
});
if ($('.rest').css("display") == 'none'){
	$('.more-content').css("display", "inline");
	$('.more-content-less').css("display", "none");
}
else{
	$('.more-content').css("display", "none");
	$('.more-content-less').css("display", "none");
}*/

$("a.more-text1").click(function () { $('.rest1').slideToggle(); return false; });
$("a.more-text2").click(function () { $('.rest2').slideToggle(); return false; });
$("a.more-text3").click(function () { $('.rest3').slideToggle(); return false; });
$("a.more-text4").click(function () { $('.rest4').slideToggle(); return false; });
$("a.more-text5").click(function () { $('.rest5').slideToggle(); return false; });
$("a.more-text6").click(function () { $('.rest6').slideToggle(); return false; });
$("a.more-text7").click(function () { $('.rest7').slideToggle(); return false; });
$("a.more-text8").click(function () { $('.rest8').slideToggle(); return false; });
$("a.more-text9").click(function () { $('.rest9').slideToggle(); return false; });
$("a.more-text10").click(function () { $('.rest10').slideToggle(); return false; });

// ajax kalendar
$('#ajaxCalendar .active').live('click', function() {
    $("#block-kalendar-akci .kalendar").hide();
	$("#ajaxCalendarHP").load($(this).attr("href")).fadeIn(500);
	//alert($(this).attr("href"));
	return false;
});


});

