/*
* Put any code in page_set() that needs to be run on window load
*/
function page_set(){
  if(typeof(photos_total) != 'undefined' && photos_total > 1){
    setTimeout('photo_display(1)', 3000);
  } 
}


/*
* Slideshow for a group of photos
*/

var current_slide_id=0;
var current_slide=false;

function show_slides(id){
}

var idPhotoCurr='img-0';
var iCountCurr=0;

var thumb_slide;
var next_photo;
function photo_display(count){
	
	var id='img-' + count;
	if(idPhotoCurr!=id){
		new Effect.Appear(id, {duration: 1.5});
	}

	if(idPhotoCurr!='' && idPhotoCurr!=id){
		photoClose(idPhotoCurr);
	}
	
	idPhotoCurr=id;
	iCountCurr=count;
	
	if(count+1 == photos_total){
		next_photo=0;
	}else{
		next_photo=count+1;
	}
	setTimeout('photo_display(next_photo)', 5000);
}

function photoClose(id){
	new Effect.Fade(id, {duration: 1.5});
}


/*
* Combine closing any currently element layer in a group and opening the next one
*/
var current_id = false;
var holding = false;
function display_layer(id){
  
	if(current_id != false && current_id != id){
		close_layer(current_id);
	}
	holding = id;
	setTimeout("show_layer('" + id + "')", 500)
}

/*
* Show any element with fading
*/
function show_layer(id){
  if(holding == id){
    new Effect.Appear(id, {duration: 0.5});
  	current_id = id;
  }
}

/*
* Hide any element with fading
*/
function close_layer(id){
	new Effect.Fade(id);
}

window.onload = function () { page_set(); };