	// JavaScript Document
	// by frizbee.be
	// functionality for slideshow

	$(document).ready(function() {
		
		/// vars
			
			var i_current_banner = 0;
			var i_total_banners = $('.slideshow-images li').length;
			var id_interval;
			var i_pause = 8000;
						
		/// is there more than 1 banner?
		
			if(i_total_banners > 1)
			{
				/// hide all banners
					
					$('.slideshow-images li').hide();
					
				/// make the nav buttons ready for mouseover
				
					$('.slideshow-nav li').hover(
						function()
						{
							/// mousehover
								
								if(!$(this).hasClass('active')) $(this).addClass('mousehover');
						},
						function()
						{
							/// mouseout
							
								if(!$(this).hasClass('active')) $(this).removeClass('mousehover');
						}
					);
				
				/// make the nav buttons clickable
				
					$('.slideshow-nav li').click(function()
					{							
						/// only show the selected banner when he is not allready active
							
							if(!$(this).hasClass('active'))
							{
								/// stop the slideshow
									
									stop_slideshow();
									
								/// update the current banner
								
									i_current_banner = $(this).attr('title') - 1;
								
								/// play the slideshow
								
									play_slideshow();
							}
					});
									
				/// start the slideshow
				
					play_slideshow();
			}
			else
			{
				
				/// hide the nav buttons
				
					$('.slideshow-nav').hide();
				
			}
			
		/// make the slideshow visible
					
			$('.slideshow').show();
			
		/// play the slideshow
			
			function play_slideshow()
			{				
				/// stop the animation
				
					clearTimeout(id_interval);
				
				/// hides all banners
				
					$('.slideshow-images li').fadeOut();
				
				/// show the new banner
				
					$('.slideshow-images li').eq(i_current_banner).fadeIn();
					
				/// make all nav buttons standard css
				
					$('.slideshow-nav li').removeClass('active');
					
				/// set the current nav button active
				
					$('.slideshow-nav li').eq(i_current_banner).removeClass('mousehover');
					$('.slideshow-nav li').eq(i_current_banner).addClass('active');
					
				/// update the current banner number
					
					if(i_current_banner + 1 == i_total_banners) i_current_banner = 0;
					else i_current_banner ++;
					
				/// lets move on with the slideshow
				
					id_interval = setTimeout(play_slideshow, i_pause);
			}
			
		/// stop the slideshow
		
			function stop_slideshow()
			{
				clearTimeout(id_interval);
			}		
		
	});

