
	function ns_newsticker($items_to_fade, $ticker_time)
	{

		tickerchange = setInterval(ns_start_ticker, $ticker_time);
		var $tickeritem = jQuery($items_to_fade);
		var i = 1;

		function ns_start_ticker()
		{

			$tickeritem.filter(":eq("+i+")").trigger('fade');
			i+1 < $tickeritem.length ? i++ : i = 0;	

		}

		$tickeritem.each(function(i)
		{

			jQuery(this).bind("fade",function()
			{

				$new_ticker_item = $tickeritem.filter(":eq("+i+")");

				if( $new_ticker_item.css("display") == "none" )
				{

					$tickeritem.filter(":visible").fadeOut(400, function()
					{

						$new_ticker_item.fadeIn(400);

					});

				}

			});
		});

	}

	function aktualizujOdkazy()
	{

		if(!document.getElementsByTagName)
		return false;

		var links = document.getElementsByTagName("a");

		for (var i=0; i < links.length; i++)
		{

			if(links[i].className.match("popup"))
			{

				links[i].onclick = function ()
				{

					return !window.open(this.href);

				}

			}

		}

	}


	$(function(){

		$('.overs').hover(function() {

			$(this).addClass('over');

		}, function() {

			$(this).removeClass('over');

		});

		$(".maphp").colorbox({width:"842px", height:"629px", inline:true, href:"#maps"});

		$('.flex').elastic();

		ns_newsticker(".ticker li",4000);

		$("a[rel='gal']").colorbox();

		aktualizujOdkazy();

		$('.bimg').each(function(index) {

			widthpan = $(this).width();
			widthimg = $(this).find('img').width();

			widthf = widthpan-widthimg;
			widthf = widthf/2;

			$(this).find('img').css("margin-left",widthf);

			heightpan = $(this).height();
			heightimg = $(this).find('img').height();

			heightf = heightpan-heightimg;
			heightf = heightf/2;

			$(this).find('img').css("margin-top",heightf);

		});

	});
