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

document.observe('dom:loaded', function()
{
	var dim = wsize();
	var h = dim[1];
	if($("text").offsetHeight < h) {
		$("text").style.height = h+"px";
	}
	// 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;
	var go = new PeriodicalExecuter(start_slideshow,4);
});

function slide(direction)
{
	// hide current image
	Effect.Fade(lame_slider[current_frame],{duration: 3});
	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: 3});
}


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

function wsize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  var p = new Array(myWidth, myHeight);
  return p;
}

