/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
}
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

dojo.require("dojo.fx");
dojo.require("dojo.fx.easing");

var obrazek =	[
							{
								prvniPristup: true,
								index: 0,
								prvni: false,
								prechod: 1500,
								vymena: 4000
							}
						];

function obrazkyAnimace(index)
{
	if (dojo.byId('fotografie-0').complete && dojo.byId('fotografie-1').complete)
	{
		if (obrazek[0].prvniPristup)
		{
			obrazek[0].prvniPristup = false;
			obrazek[0].prvni = !obrazek[0].prvni;
			dojo.fadeIn({
				node: dojo.byId('fotografie-0'),
				duration:  obrazek[0].prechod,
				onEnd: function(){
					if (slideshow.length > 1)
					{
						var obrIndex = (Math.ceil(Math.random()*(slideshow.length))) - 1;
						while (obrIndex == obrazek[0].index)
							obrIndex = (Math.ceil(Math.random()*(slideshow.length))) - 1;
						obrazek[0].index = obrIndex;
						dojo.byId('fotografie-1').src = slideshow[obrazek[0].index];
						setTimeout("obrazkyAnimace("+obrazek[0].index+")", obrazek[0].vymena);
					}
				}
			}).play();
		}
		else
		{
			var anim = dojo.fx.combine([
				dojo.fadeOut({
					node: obrazek[0].prvni ? dojo.byId('fotografie-0') : dojo.byId('fotografie-1'),
					duration:  obrazek[0].prechod
				}),
				dojo.fadeIn({
					node: obrazek[0].prvni ? dojo.byId('fotografie-1') : dojo.byId('fotografie-0'),
					duration: obrazek[0].prechod
				})
			]);

			dojo.connect(anim, 'onEnd', function(){
				var obrIndex = (Math.ceil(Math.random()*(slideshow.length))) - 1;
				while (obrIndex == obrazek[0].index)
					obrIndex = (Math.ceil(Math.random()*(slideshow.length))) - 1;
				obrazek[0].index = obrIndex;
				dojo.byId(obrazek[0].prvni ? 'fotografie-0' : 'fotografie-1').src = slideshow[obrazek[0].index];
				obrazek[0].prvni = !obrazek[0].prvni;
				setTimeout("obrazkyAnimace("+obrazek[0].index+")", obrazek[0].vymena);
			});
			anim.play();
		}
	}
	else
		setTimeout("obrazkyAnimace("+index+")", 10);
}

function obrazky()
{
	if ((typeof(slideshow) != 'undefined') && (slideshow.length > 0))
	{
		dojo.fadeOut({
			node: dojo.byId('fotografie-1'),
			duration: 5
		}).play();

		dojo.fadeOut({
			node: dojo.byId('fotografie-0'),
			duration: 5,
			onEnd: function(){
				var obrIndex = 0;
				if (slideshow.length > 1)
					var obrIndex = (Math.ceil(Math.random()*(slideshow.length))) - 1;
				obrazek[0].index = obrIndex;
				dojo.byId('fotografie-0').src = slideshow[obrIndex];
				obrazkyAnimace(obrIndex);
			}
		}).play();
	}
}

var poukazy = [	{
								action: 0,
								queue: 0,
								node: 'darkovy-poukaz-levy_a'
							},
							{
								action: 0,
								queue: 0,
								node: 'darkovy-poukaz-pravy_a'
							}];

function poukaz_in(index)
{
	if (poukazy[index].action == 0)
	{
		poukazy[index].action = 1;
		dojo.fadeOut({
			node: dojo.byId(poukazy[index].node),
			duration: 1,
			onEnd: function(){
				dojo.byId(poukazy[index].node).style.display = 'block';
				dojo.fadeIn({
					node: dojo.byId(poukazy[index].node),
					duration: 1000,
					onEnd: function(){
						poukazy[index].action = 0;
						if (poukazy[index].queue == -1)
							poukaz_out(index);
						else
							poukazy[index].queue = 0;
					}
				}).play();
			}
		}).play();
	}
	else
	{
		if (poukazy[index].queue <=0)
			poukazy[index].queue = 1;
		else
			poukazy[index].queue = 0;
	}
}

function poukaz_out(index)
{
	if (poukazy[index].action == 0)
	{
		poukazy[index].action = -1;
		dojo.fadeOut({
			node: dojo.byId(poukazy[index].node),
			duration: 1000,
			onEnd: function(){
				dojo.byId(poukazy[index].node).style.display = 'none';
				poukazy[index].action = 0;
				if (poukazy[index].queue == 1)
					poukaz_in(index);
				else
					poukazy[index].queue = 0;
			}
		}).play();
	}
	else
	{
		if (poukazy[index].queue >=0)
			poukazy[index].queue = -1;
		else
			poukazy[index].queue = 0;
	}
}

/* hýbe s námpisem "vyhledat" */
function pozicuj(objekt, hodnota, vyplnenyObjekt)
{
   if(vyplnenyObjekt.value == ""){
      //document.getElementById(objekt).style.left = hodnota+"px";
      document.getElementById(objekt).style.zIndex = hodnota;
   }
}
function pozicujPrvni(objekt, hodnota, top, left, color)
{
      document.getElementById(objekt).style.position="absolute";
      document.getElementById(objekt).style.top =  top+"px";
      document.getElementById(objekt).style.left =  left+"px";
      document.getElementById(objekt).style.zIndex = hodnota;
      document.getElementById(objekt).style.color= color; 
}
