// Simple slideshow function 
// created by chris third 20/04/06
// 
// provides a basic javascript based standards compliant slideshow
// supports slide indexs and next / previous buttons
// 
// Requires 
// A DIV which has the same ID value as the variable carosel [see below] containing 
// the slides, each slide must be contained within a DIV with a unique ID
// A DIV which has the same ID value as the variable slideMenu containing the links
// to each slide as an anchor i.e. (<a href="#slide_id">slide name</a>).
// There can also optionally by a DIV with the same ID value as the variable navButtons
// any links within this DIV will increment the slideshow forward or back dependant on
// the value of the anchor, for example <a href="#+2">+2</a> will increment the slideshow
// forward two slide while <a href="#-1">prev</a> will move it back one slide

window.onload = KRS3setUp;

slideMenu = 'menu';

carosel = 'slideshow';

navButtons = '';

indx =0;

function KRS3setUp(){

	//create the behaviours for each link
	var KRS3menu = document.getElementById(slideMenu);
	
	KRS3links = KRS3menu.getElementsByTagName('a');
	
	for(var i=0; i<KRS3links.length; i++){
	
		link = KRS3links[i].href.split('#');
		
		ref= link.pop()
		
		KRS3links[i].ref=ref;
		KRS3links[i].indx = i;
		KRS3links[i].onclick = function(){return KRS3showSlide(this);}
	
	}
	if (navButtons!=''){
	var navBut = document.getElementById(navButtons);
	
	
	var navs = navBut.getElementsByTagName('a');
	
	for(var i=0; i<navs.length; i++){
			
		ref = navs[i].href.split('#').pop();
				
		navs[i].ref=parseFloat(ref);
		navs[i].onclick = function(){ 
		
			indx=indx+this.ref; 
				
			if(indx<0)
				indx=0;
				
			if(indx>KRS3links.length-1)
				indx = KRS3links.length-1;
				
				KRS3showSlide(KRS3links[indx])
			};
		}
	
	}
	KRS3showSlide(KRS3links[0])

}

function KRS3showSlide(obj){

	//show a slide
	var KRS3carosel = document.getElementById(carosel);
	var KRS3slides = KRS3carosel.getElementsByTagName('div');
	
	for(var i=0; i<KRS3slides.length; i++){
	
		if('slide_'+obj.ref==KRS3slides[i].id){
			KRS3slides[i].style.display='';
			}
		else
			KRS3slides[i].style.display='none';
			
		
	}



return false;

}









