function open_window ( url, w, h, b_resizable, b_scrollbars )
{
	if ( w > screen.width - 50 ) w = screen.width - 50;
        if ( h > screen.height - 50) h = screen.height - 50;

	var x = Math.floor ( ( screen.width - w - 10 ) / 2 );
	var y = Math.floor ( ( screen.height - h - 29 ) / 2 );

	if ( typeof ( gallery_window ) == "undefined" || gallery_window.closed )
	{
		gallery_window = window.open ( url, 'gallery_window', 'menubar=0,toolbar=0,location=0,scrollbars=' + ( b_scrollbars ? '1' : '0' ) + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',width=' + w + ',height= ' + h + ',resizable=' + ( b_resizable ? '1' : '0' ) );
	}else gallery_window.location.href = url;

        gallery_window.focus();
}

function galeria ( url )
{
	open_window ( url, 770, 700, false, false );
}

function ZobrazProgram ( s_which )
{
	if ( s_which == 'dnes' || s_which == 'dalsi' )
	{
		var o_div_dnes = document.getElementById ( 'program_dnes' );
		var o_div_dalsi = document.getElementById ( 'program_dalsi' );

		if ( s_which == 'dnes' )
		{
			o_div_dalsi.style.display = 'none';
			o_div_dnes.style.display = 'block';
		}else
		{
			o_div_dnes.style.display = 'none';
			o_div_dalsi.style.display = 'block';
		}
	}else if ( s_which == 'cinohra' || s_which == 'opera' || s_which == 'balet' )
	{
		var o_div_cinohra = document.getElementById ( 'program_cinohra' );
		var o_div_opera = document.getElementById ( 'program_opera' );
		var o_div_balet = document.getElementById ( 'program_balet' );

		if ( s_which == 'cinohra' )
		{
			o_div_opera.style.display = 'none';
			o_div_balet.style.display = 'none';
			o_div_cinohra.style.display = 'block';
		}else if ( s_which == 'opera' )
		{
			o_div_cinohra.style.display = 'none';
			o_div_balet.style.display = 'none';
			o_div_opera.style.display = 'block';
		}else
		{
			o_div_cinohra.style.display = 'none';
			o_div_opera.style.display = 'none';
			o_div_balet.style.display = 'block';
		}
	}
}

var s_opened = '';
var t = null;
var spot_hra = false;

function Ukaz ( s )
{
	clearTimeout ( t );

	if ( s_opened == s ) return;
	else if ( s_opened != '' ) _NaozajSkry ( s_opened );

	var o_obj = document.getElementById ( s );

	if ( o_obj == null ) return;

	o_obj.style.zIndex = 1000;
	o_obj.style.display = 'block';

	s_opened = s;
}

function Skry ( s )
{
	t = setTimeout ( "_NaozajSkry('" + s + "')", 500 );
}

function _NaozajSkry ( s )
{
	clearTimeout ( t );

	var o_obj = document.getElementById ( s );

	if ( o_obj == null ) return;

	o_obj.style.display = 'none';

	s_opened = '';
}

function UkazStranku ( i_stranka )
{
	var o = null;
	var i;

	clearInterval ( o_interval );
	
	for ( i=1; i<=i_pocet_stranok; i++ )
	{
		o = document.getElementById ( "partneri_predstavenia_stranka_" + i );

		if ( o == null )
		{
			continue;
		}

		o.style.display = i == i_stranka ? 'block' : 'none';
	}

	i_aktualna_stranka = i_stranka;

	SpustiStrankovanie ();
}

function DalsiaStranka ()
{
	i_aktualna_stranka++;

	if ( i_aktualna_stranka > i_pocet_stranok )
	{
		i_aktualna_stranka = 1;
	}

	UkazStranku ( i_aktualna_stranka ); 
}

function SpustiStrankovanie ()
{
	o_interval = setInterval ( "DalsiaStranka()", 3000 );
}

function HrajSpot ( o )
{
	var img = o.childNodes[0];

	if ( img == null ) return;

	if ( spot_hra )
	{
		niftyplayer('player1').pause ();
		img.src = "/swift_data/source/img/reprak_off.gif";
	}else
	{
		niftyplayer('player1').play ();
		img.src = "/swift_data/source/img/reprak_on.gif";
	}

	spot_hra = !spot_hra;
}

function fbs_click ( url, title )
{
	u=url;
	t=title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');

	return false;
}

function PripravLinky ()
{
	var anchors = document.getElementsByTagName ( "a" );

	for ( var i = 0; i < anchors.length; i++ )
	{
		var anchor = anchors[i];
		var relAttribute = String(anchor.getAttribute("rel"));
		if (anchor.getAttribute("href"))
		{
			if ( relAttribute.match ( /^galeria/ ) )
			{
				eval ( "anchor.onclick = function () { " + relAttribute + "; return false; }" );

				anchor.href = "javascript:void(0)";
			}
		}
	}
}

if (window.addEventListener) {
	window.addEventListener("load",PripravLinky,false);
} else if (window.attachEvent) {
	window.attachEvent("onload",PripravLinky);
} else {
	window.onload = function() {PripravLinky();}
}