var SlideShow = true;
	var slider_speed = 5000;
		
	var slider_items_lenght;
	var slider_photos_lenght;
	var slider_videos_lenght;
	var current_tab = 'photos';	
	
	$(document).ready(
		function () {			
	   		slider_photos_lenght = $('#photos > ul li').length;	   			   			
	   		slider_videos_lenght = $('#videos > ul li').length;	   		
	   		initSlider(current_tab);
	   		$('.latest_news ul li:last').css('padding-bottom','47px').css('background-image','none');
		}	
	);
	
	function openTab(tab_name){
		initSlider(tab_name);
		if (tab_name == 'photos') {
			$('#tab_photos').attr('class', 'active');
			$('#tab_videos').attr('class', '');
			$('#videos').hide();
			$('#photos').show();
			current_tab = 'photos'; 
			
		} else {
			$('#tab_photos').attr('class', '');
			$('#tab_videos').attr('class', 'active');
			$('#photos').hide();
			$('#videos').show();
			current_tab = 'videos';
		}		
	}
		
	function initSlider(tab){	
		if (tab == 'photos') {		
			slider_items_lenght = slider_photos_lenght;			
		} else { 
			slider_items_lenght = slider_videos_lenght;
		}
		for (var i=1; i<=10; i++) {			
			if (i > slider_items_lenght) {				
				$('#btn_slide-'+i).hide();
			} else {				
				$('#btn_slide-'+i).show();
			}
		}
		$('#slider_navigation').slideDown();		 
	}
	
	function showSlide(num){
			
		$('#slider_navigation ul li a').attr('class', '');
		$('#btn_slide-'+num).attr('class', 'active');		
		
		$('#'+current_tab+' > ul li').hide();
		$('#'+current_tab+'-item-'+num).fadeIn("slow");		
		
		if (SlideShow) {
		  	myTimer = setTimeout ( "showNextSlide()", slider_speed );
		}
	}
	
	function showNextSlide(){
		var activeId = $('#slider_navigation ul li a.active').attr('id');		
		var re = new RegExp('[\\d]+$');
					
		var m = re.exec(activeId);		
		  if (m == null) {
		    return false;
		  } else {		    
		      var num = m[0];    
		  }
		  if (num < slider_items_lenght){		  	
		  	showSlide(parseInt(num)+1);		  			  	
		  } else {
		  	if (SlideShow) {
		  		showSlide(1);
		  	}
		  }		  		
	}
	
	function showPrevSlide(){
		var activeId = $('#slider_navigation ul li a.active').attr('id');		
		var re = new RegExp('[\\d]+$');
					
		var m = re.exec(activeId);		
		  if (m == null) {
		    return false;
		  } else {		    
		      var num = m[0];    
		  }
		  if (num > 1){		  	
		  	showSlide(parseInt(num)-1);
		  }
	}
	
	function showFirstSlide() {
		showSlide(1);
	}
	
	function showLastSlide() {
		showSlide(slider_items_lenght);
	}
	
	
	function slideshowPause(stop){
		if (stop) { 
			clearTimeout(myTimer);
			SlideShow = false;				
			$('#bnt_pause').attr('class', 'play');
			return true;
		}
		var pauseBtnClass = $('#bnt_pause').attr('class');
		if (pauseBtnClass == 'pause') {			
			clearTimeout(myTimer);
			SlideShow = false;				
			$('#bnt_pause').attr('class', 'play');		
		} else {
			$('#bnt_pause').attr('class', 'pause');
			SlideShow = true;
			myTimer = setTimeout ( "showNextSlide()", slider_speed );
		}
	}	
	
	myTimer = setTimeout ( "showNextSlide()", slider_speed );
	 