$(document).ready(function() {
		var index=0;
		var timeout;
		var images;
		var num_images;
		
		function showImage(id){
			if(id>=num_images){
				$(images[0]).animate({'opacity':'0.80','width':'350px'},2000);
				index=0;
			}
			else{
				$(images[id]).animate({'opacity':'0.80','width':'350px'},2000);
			}
		}
		
		function hideImage(id){
			if(id==0){
				$(images[num_images-1]).animate({'opacity':'0.10','width':'200px'},2000);
			}
			else{
				$(images[id-1]).animate({'opacity':'0.10','width':'200px'},2000);
			}
		
		
		}

		function animateTrainingInit(){
			index=0;
			images=null;
			num_images=0;
			images=$(".training_img:visible");
			num_images=$(".training_img:visible").length;
		}
		
		function animateTrainingPlay(){
			showImage(index);
			setTimeout(function(){hideImage(index);},10000);
			index++;
			timeout=setTimeout(function(){animateTrainingPlay();},10000);
		}
		
		
		function showTraining(){
			$(".training_box").css({'display':'none'});
			var page=$(this).attr('href');
			$(page).show(2000);
			animateTrainingInit();
			animateTrainingPlay();
		}
		
		function show(){
			var img=$(this).attr('rel');
			$("#container_all>"+img).animate({'opacity':'0.80','height':'170px'},500);
		}
		
		function hide(){
			var img=$(this).attr('rel');
			$("#container_all>"+img).animate({'opacity':'0.30','height':'130px'},500);
		}
		
		
		$(".sublink").hover(show,hide);	

		$(".sublink").click(showTraining);
								
});


