// JavaScript Document

//global vars
	var on_slide = 1; //int that describes the actual shown slide (default is 1)!
	var timer_sec = 0; //describes the amount of seconds that passed since the slide is on
						// default should be zero! (has to be reset with every skip!
	var timer_run = 1; //defines if the slide timer runs: 1 or stops: -1 (default:1)
													
	function switch_slide(skip_direction){
		
		//holds int that describes the amount of slides
		var number_of_slides = document.getElementsByName('slide').length;
		//alert(number_of_slides);
		
		//currend slide int (onslide) plius a string form the id
		var current_slide_id = 'slide' + on_slide;
		
		//int for new slide is calculated
		var  new_slide;
		if((on_slide + skip_direction) < 1) new_slide = number_of_slides; //if it is the first slide, a left-skip
																		  //goes back to the last
		else if((on_slide + skip_direction) > number_of_slides) new_slide = 1; //if it is the last slide a right skip
																			  //goes to the first
		else new_slide = (on_slide + skip_direction); //otherwise it just moves one left or right
		
		 
		//id for new slide is built
		var slide_to_show_id = 'slide' + new_slide;
		on_slide = new_slide;
		
		//current slide is hidden and next slide shown
		document.getElementById(current_slide_id).className = 'slide_hidden';
		document.getElementById(slide_to_show_id).className = 'slide_visible';
		
		var on_guide_point;
		if(new_slide < 10) on_guide_point = "0" + new_slide;
		else on_guide_point = new_slide;
		
		guide_points(1, on_guide_point);
		
		timer_run = 1;
		timer_sec = 0;
	}
	
	function slide_timer_main(){
		timer_run = 1;
		
		if(timer_sec == 8){
			timer_run = -1;
			switch_slide(1);
			setTimeout('slide_timer_main()', 1000);
			
		}else if(timer_run == 1) {
			//alert('hi');
			timer_sec++;
			setTimeout('slide_timer_main()', 1000);
		} 
	}
	
	
	//var global_button_shown = -1;
	function show_buttons(global_button_shown){
		if(global_button_shown == -1){
			document.getElementById('dynamic_back_button').className='active';
			document.getElementById('dynamic_fwd_button').className='active';
		} else{
			document.getElementById('dynamic_back_button').className='hidden';
			document.getElementById('dynamic_fwd_button').className='hidden';
		}
		  
	}
	
	function guide_points(action, number){
		var guide_array;
		switch(action){
			case -1:
				guide_array = document.getElementsByName('slideshow_guide_points');
				for(var index in guide_array) guide_array[index].className="";
			break;
			
			case 1:
				if(number != null){
					guide_array = document.getElementsByName('slideshow_guide_points');
					for(var index in guide_array) guide_array[index].className="off";
					document.getElementById('guide_' + number).className = "active";
				}
			break;
		}
	}
