// JavaScript Document
<!-- Build 1 -->
$(document).ready(function(){
       $("a#_1").click(function(){
		   $("div#des").show();
		   $("div#mission").hide();
		   $("div#contact").hide();
		   $("div#spacer").hide();
		   });
       $("a#_2").click(function(){
		   $("div#des").hide();
		   $("div#mission").show();
		   $("div#contact").hide();
		   $("div#spacer").hide();
		   });
       $("a#_3").click(function(){
		   $("div#des").hide();
		   $("div#mission").hide();
		   $("div#contact").show();
		   $("div#spacer").hide();
		   });
   	   $('div#des, div#spacer, div#contact, div#mission').show();
	   $('div#spacer, div#contact, div#mission').hide();

	  /* Setup images for slider */
	var w = $(window).width();
	if ( w < 321 ) 	{	
	$('img.pres').each(function(i) {
			//assign a flexible value based on file name
			var _x = $(this).width(); //var _x = $(this).width();
			var _y = $(this).height(); //var _y = $(this).height();
			var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');
				$(this).attr({
							src: 'tun_res/res_gfx/present/cs-255_00'+i+'.jpg',
							width: _x,
							height: _y,
							alt: _alt							
				});
			});
	} else if ( w < 400 ) {
		$('img.pres').each(function(i) {
			//assign a flexible value based on file name
			var _x = $(this).width(); //var _x = $(this).width();
			var _y = $(this).height(); //var _y = $(this).height();
			var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');
				$(this).attr({
							src: 'tun_res/res_gfx/present/cs-400_00'+i+'.jpg',
							width: _x,
							height: _y,
							alt: _alt							
				});
			});
   		$('nivo-slice').attr({'width':'377px', 'height':'245px'});;
		} else if ( w < 800 ) { 
			$('img.pres').each(function(i) {
				//assign a flexible value based on file name
				var _x = $(this).width(); //var _x = $(this).width();
				var _y = $(this).height(); //var _y = $(this).height();
				var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');		
					$(this).attr({
								src: 'tun_res/res_gfx/present/cs-500_00'+i+'.jpg',
								width: _x,
								height: _y,
								alt: _alt							
					});
				});
			} else {
				$('img.pres').each(function(i) {
				//assign a flexible value based on file name
				var _x = $(this).width(); //var _x = $(this).width();
				var _y = $(this).height(); //var _y = $(this).height();
				var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');		
					$(this).attr({
								src: 'tun_res/res_gfx/present/cs-1000_00'+i+'.jpg',
								width: _x,
								height: _y,
								alt: _alt							
					});
				});
			}


/* resizing routine */		
		$(window).resize(function() {
			var w = $(window).width();
			if ( w < 321 ) 	{	
				$('img.pres').each(function(i) {
						//assign a flexible value based on file name
						var _x = $(this).width(); //var _x = $(this).width();
						var _y = $(this).height(); //var _y = $(this).height();
						var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');
							$(this).attr({
										src: 'tun_res/res_gfx/present/cs-255_00'+i+'.jpg',
										width: _x,
										height: _y,
										alt: _alt							
							});
						});

			} else if ( w < 400 ) {
				$('img.pres').each(function(i) {
					//assign a flexible value based on file name
					var _x = $(this).width(); //var _x = $(this).width();
					var _y = $(this).height(); //var _y = $(this).height();
					var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');
						$(this).attr({
									src: 'tun_res/res_gfx/present/cs-400_00'+i+'.jpg',
									width: _x,
									height: _y,
									alt: _alt							
						});
					});
			} else if ( w < 800 ) { 
				$('img.pres').each(function(i) {
					//assign a flexible value based on file name
					var _x = $(this).width(); //var _x = $(this).width();
					var _y = $(this).height(); //var _y = $(this).height();
					var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');		
						$(this).attr({
									src: 'tun_res/res_gfx/present/cs-500_00'+i+'.jpg',
									width: _x,
									height: _y,
									alt: _alt							
						});
					});
			} else {
				$('img.pres').each(function(i) {
				//assign a flexible value based on file name
				var _x = $(this).width(); //var _x = $(this).width();
				var _y = $(this).height(); //var _y = $(this).height();
				var _alt = $(this).attr('alt');		//var _alt = $(this).attr('alt');		
					$(this).attr({
								src: 'tun_res/res_gfx/present/cs-1000_00'+i+'.jpg',
								width: _x,
								height: _y,
								alt: _alt							
					});
				});
			}
			
			
			
			
/*			if ( w < 320 ) {
				$('img.pres').each(function(i) {
					$(this).attr('src','tun_res/res_gfx/present/cs-255_00'+i+'.jpg');
					});					
					$('#slider').css({'height' : '251px', 'width': '164px'});
				} else if ( w < 399 )  {
					$('img.pres').each(function(i) {
						$(this).attr('src','tun_res/res_gfx/present/cs-400_00'+i+'.jpg');
					});
					$('#slider').css({'height' : '377px', 'width': '245px'});
				} else if ( w < 799 )  {
					$('img.pres').each(function(i) {
						$(this).attr('src','tun_res/res_gfx/present/cs-500_00'+i+'.jpg');
					});
					$('#slider').css({'height' : '500px', 'width': '325px'});
				} else {
				$('img.pres').each(function(i) {
					$(this).attr('src','tun_res/res_gfx/present/cs-1000_00'+i+'.jpg');
					});
					$('#slider').css({'height' : '1000px', 'width': '650px'});
				}*/


			});
			
		/* Here we are detecting user agents again because machenes are (bd) not humans */
			
		var agent = navigator.userAgent.toLowerCase();
		var is_iphone = (agent.indexOf('iphone') != -1);
		var is_ipad = (agent.indexOf('ipad') != -1);
		
		if (is_iphone || is_ipad ) {
			var device_help ="<meta name=\"viewport\" content=\"width=device-width\">";
		  }
		  
	/* FancyBox use */

			$("#carte").fancybox({
				'width'				: '90%',
				'height'			: '90%',
				'autoScale'			: true,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
		
			});		


});	
