// "global" variables
var current_frame = images_count = 0;
var lame_slider;

document.observe('dom:loaded', function()
{
	// loop thru all images and hide them
	lame_slider = $('slider').getElementsByTagName('li');
	for(i=0;i<lame_slider.length;i++)
		if(i!=0) lame_slider[i].style.display = 'none';
	images_count = lame_slider.length -1;
	pageSize=getPageSize();
	swidth = (pageSize[0] - 950)/2;
	$('hidediv').style.width = swidth + "px";
	$('hidediv').style.height = "142px";
	$('hidediv').style.left = "-"+swidth+"px";
	new Effect.Move('imgover', { x: -632, y: 0, duration: 2});
	var go = new PeriodicalExecuter(start_slideshow,4);
});




function slide(direction)
{
	// hide current image
	Effect.Fade(lame_slider[current_frame],{duration: 1.8});
	if(direction == 'fw')
		if (current_frame == images_count) { current_frame = 0; } else { current_frame++; }
	else
		if (current_frame == 0) { current_frame = images_count; } else { current_frame--; }
	// and show next or previous
	Effect.Appear(lame_slider[current_frame],{duration: 1.8});
}


function start_slideshow() {	var pe = new PeriodicalExecuter(slide('fw'),4); }

function getPageSize()
{     
      var xScroll, yScroll;
  
  if (window.innerHeight && window.scrollMaxY) { 
   xScroll = window.innerWidth + window.scrollMaxX;
   yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
   xScroll = document.body.scrollWidth;
   yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
   xScroll = document.body.offsetWidth;
   yScroll = document.body.offsetHeight;
  }
  
  var windowWidth, windowHeight;
  
  if (self.innerHeight) { // all except Explorer
   if(document.documentElement.clientWidth){
    windowWidth = document.documentElement.clientWidth; 
   } else {
    windowWidth = self.innerWidth;
   }
   windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
   windowWidth = document.documentElement.clientWidth;
   windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
   windowWidth = document.body.clientWidth;
   windowHeight = document.body.clientHeight;
  } 
  
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
   pageHeight = windowHeight;
  } else { 
   pageHeight = yScroll;
  }
 
  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){ 
   pageWidth = xScroll;  
  } else {
   pageWidth = windowWidth;
  }

 return [pageWidth,pageHeight];
}                                	


/*
var i = 0;
var odhrnuto = false;
var stav = 0;
var counter = 0;

function turnImage() {
	counter = counter + 1;
	if(counter == 3 & stav == 0)
		{
			if($('imgover').style.display != 'none') {
				new Effect.Move('imgover', { x: -632, y: 0, duration: 3});
				$('imgunder').style.background = 'url('+application_root+'uploads/gallery/'+pole[i]+')';
			}
			counter = 0;
			stav = 1;
			i++;
		}
 	if(counter == 6 & stav == 1)
		{
			new Effect.Move('imgover', { x: 632, y: 0, duration: 3});
			counter = 0;
			stav = 0;
		}

	if(i == (pole.length)) i=0;
	setdiv();
}

var pe = new PeriodicalExecuter(turnImage, 1);

function setdiv() {
	sirka_obr = window.innerWidth;
	sirka = (sirka_obr - 950)/2;
	$('hidediv').style.width = sirka + "px";
	$('hidediv').style.height = "142px";
	$('hidediv').style.left = "-"+sirka+"px";
}


document.observe("dom:loaded",setdiv);
*/
