function scroll(from, to )
{
	var direction = from > to ? 'Left' : 'Right';

	var hideImgId = 'type_'+parseInt(direction == 'Left' ? img_first_visible : img_first_visible + viewed_img - 1 );
	var viewImgId = 'type_'+parseInt(direction == 'Left' ? img_first_visible + viewed_img : img_first_visible - 1 );

	var hideImg = new Fx.Styles(hideImgId, {duration: slide_duration, transition: Fx.Transitions.linear});
	var viewImg = new Fx.Styles(viewImgId, {duration: slide_duration, transition: Fx.Transitions.linear});

	if ( direction == 'Left' && img_first_visible <= img_max_scroll || direction == 'Right' && img_first_visible > 1 )
	{
		( direction == 'Left' ? hideImg : viewImg ).start({'margin-left': [from, to] });
		direction == 'Left' ? img_first_visible++ : img_first_visible--;
	}
}

function AddFavorite(linkObj,addUrl,addTitle)
{
	if (document.all && !window.opera)
	{
		window.external.AddFavorite(addUrl,addTitle);
		return false;
	}
	else if (window.opera && window.print)
	{
		linkObj.title = addTitle;
		return true;
	}
	else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
	{
			window.sidebar.addPanel(addTitle,addUrl,'');
			return false;
	}
	window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
	return false;
}

function mapItem(img_name, width, height )
{
	img_prefix = '/images/world-'+img_name;
	this.slide_img = new Image (width, height );
	this.slide_img.src = img_prefix + ".png";
}

function addMapItem(img_name, width, height )
{
	mapItem [img_name] = new mapItem (img_name, width, height );
}

function mapOver(itemID )
{
	current_overID = itemID;
	if ( current_overID != last_overID )
	{
		document.worldmap.src = mapItem [current_overID].slide_img.src;
	}
}

var elParent;

function thumb(el )
{
	if ( !elParent || el.tagName == 'P' )
	{
		elParent = el.parentNode;
		elView = getChild(elParent, 'P' );
		if ( elView )
		{
			elParent.style.position = 'relative';
			elView.style.display = 'block';
		}
	}
	else
	{
		elHide = getChild(elParent, 'P' );
		if ( elHide )
		{
			elHide.style.display = 'none';
			elParent.style.position = 'static';
		}
		elParent = null;
	}
}

function getChild(node, tag )
{
	for ( i = 0; i <= node.childNodes.length; i++ )
	{
		if ( node.childNodes[i].tagName == tag )
		{
			return node.childNodes[i];
		}
	}
	return false;
}




var customLightbox = {
  config:
  {
    overlayBgColor:'#000',
    overlayOpacity:0.8,
    fixedNavigation:false,
    imageLoading:'/images/lightbox-ico-loading.gif',
    imageBtnPrev:'/images/lightbox-btn-prev.png',
    imageBtnNext:'/images/lightbox-btn-next.png',
    imageBtnClose:'/images/lightbox-btn-close.png',
    imageBlank:'/images/transparent.png',
    containerResizeSpeed:200,
    txtImage:'Obrázek:<br />',
    txtOf:'z',
    keyToClose:'c',
    keyToPrev:'p',
    keyToNext:'n',
    imageArray:[],
    activeImage:0
  },
  init: function()
  {
    $('a[rel=lightbox],a.lightbox').lightBox(customLightbox.config); //only rel="lightbox"

    var lbRels = new Array();  var thisRel = ''; var trIsIn = false;
    $('a[rel*="lightbox["]').each(function(){ //each rel="lightbox[..."
        thisRel = $(this).attr('rel').replace('lightbox[','').replace(']',''); //curren rel
        for(i=0; i<lbRels.length; i++) { //find if is not yet in array of rels
          if(thisRel == lbRels[i]) trIsIn = true;
          else trIsIn = false;
        }
        if(!trIsIn) lbRels[lbRels.length] = $(this).attr('rel').replace('lightbox[','').replace(']',''); //not i array of rels => store rel
    });
    for(i=0; i<lbRels.length; i++) { $('a[rel="lightbox['+lbRels[i]+']"]').lightBox(customLightbox.config); } //each unique rel => apply lightbox
  }
};



/*******************************************
 *
 *  on DOM ready
 *
 ********************************************/
$(document).ready(function() {

  customLightbox.init();
  //trackLinks.init();
  
  // scroll
  $('.scrollable').prepend('<a id="scrollToLeft" class="prevPage browse"></a>').append('<a id="scrollToRight" class="nextPage browse"></a>')
  .scrollable({
      size: 4,
      speed: 1000
  })
  .circular()
  .autoscroll({
      interval: 10000,
      steps: 4,
      autoplay: true,
      autopause: true
  });

});

