var lang;

$(document).ready(function(){

	//$('.prim_nav, .a_s_nav, #rbq, #soumission p, #h_phone, .main_text_slide, .sec_slide, #caa, .detail_slide a, .title, .description, .sub_title, .col_right ul li, .li_critere, .title_gallerie, .description_gallerie, .cont_categorie').css('display', 'none');

	

	$.get('includes/get_session.php', function(lang) {

		

		/* pour la navigation primaire */

		$("#h_nav li ul").hide();

		$("#h_nav li").hover(function(){

			$(this).find('ul:first').css({visibility: "visible",display: "block"}).animate({height:"32px"},{queue: false, duration: 200});

			$(this).find('ul:first').find('p:first').find('a').css('display', 'inline');

			},function(){

				$(this).find('ul:first').css('display', 'none').animate({height:"0"},{queue: false, duration: 200});

				$(this).find('ul:first').find('p:first').find('a').css('display', 'none');

		});



		var id = 0;

		/* Pour la navigation des pages */

		$(".link_sub_categorie").click(function(){

			id = $(".link_sub_categorie").index($(this));

			$(".link_sub_categorie").css('color', 'white');

			$(".link_sub_categorie").css('border', 'none');

			$(this).css('color', 'white');

			$(this).css('border-bottom', '1px dotted white');

			Cufon.refresh();

			$('.cg').fadeOut(500);

			$('#'+$(this).attr('id').substr(3)).fadeIn(500);

		}).hover(function(){

			$(this).css('border-bottom', '1px dotted white');

		}).mouseleave(function(){

			$(this).css('border', 'none');

			$(".link_sub_categorie").eq(id).css('border-bottom', '1px dotted white');

		});

		

		/* Pour les gallerie */

		$(".link_categorie").click(function(){

			id = $(".link_categorie").index($(this));

			$(".link_categorie").css('color', '#0769A8');

			$(".link_categorie_p").css('border', 'none');

			$(this).css('color', '#013668');

			$(this).find('span:first').css('border-bottom', '1px dotted #0153A5');

			Cufon.refresh();

			var id_array = $(this).attr('id').split("_");

			id = id_array[1];

			$('.panel_gallerie').fadeOut(500);

			$("#p_"+id).fadeIn(500);

		}).hover(function(){

			$(this).find('span:first').css('border-bottom', '1px dotted #0153A5');

		}).mouseleave(function(){

			$(this).find('span:first').css('border', 'none');

			$(".link_categorie").eq(id).find('span:first').css('border-bottom', '1px dotted #0153A5');

		});

		

		/* Pour le footer */

		$('#third_nav').find('span:last').css('display', 'none');

		

		/* Pour les light_box */
		
		$(".thumbs_a").fancybox({

			'overlayColor'	:	"#000000",
			'titleShow'		:	true,
			'overlayShow'	:	true,
			'titlePosition' : 	'inside',
			
		});

		

		$("#soumission").fancybox({

			'overlayColor'	:	"#000000",
			'overlayShow'	:	true

		});

		

		$(".cat_thumbs").fancybox({

			'overlayColor'	:	"#000000",
			'titleShow'		:	true,
			'titlePosition' : 	'inside',
			'overlayShow'	:	true

		});



		$(".swf").click(function() {

                 $.fancybox({

                  'padding'             : 0,

                  'autoScale'			: false,

                  'transitionIn'        : 'none',

                  'transitionOut'       : 'none',

                  'title'               : this.title,

                  'width'               : 680,

                  'height'              : 495,

                  'href'                : this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',

                  'type'                : 'swf',    // <--add a comma here

                  'swf'                 : {'allowfullscreen':'true'} // <-- flashvars here

                  });

                 return false;

		}); 

		

		

		$(".thumbs_a").hover(function(){

			$(this).parent().parent().find('div:first').find('p:first').find("a:first").find('img:first').attr('src', $(this).find('img:first').attr('src'));

		});

		

		$("#soumission p, #soumission img").hover(function(){

			$("#white_arrow").attr("src", "images/white_down_arrow_hover.png");

		}).mouseleave(function(){

			$("#white_arrow").attr("src", "images/white_down_arrow.png");

		});



		/*******************************/

		/* Pour le slidder de l'index */

		/*****************************/

	

		var theInt = null;

		var $crosslink, $navthumb;

		var curclicked = 0;

		var cur;

		var item;

		

		

		$(".cross-link").eq(0).css("background", "url(images/sec_nav1_"+lang+".jpg)");

		$(".cross-link").eq(1).css("background", "url(images/sec_nav2_"+lang+".jpg)");

		$(".cross-link").eq(2).css("background", "url(images/sec_nav3_"+lang+".jpg)");



		$('.content_slide').click(function(){

			var href = $(this).find('.detail_slide').find('a:first').attr('href');

			document.location = href;

		}).hover(function(){

			$(".white_arrow2").attr("src", "images/white_down_arrow_hover.png");

		}).mouseleave(function(){

			$(".white_arrow2").attr("src", "images/white_down_arrow.png");

		});

		

		$(".cross-link").click(function(){

			curclicked = $(".cross-link").index($(this));

			item = curclicked+1;

			$(".cross-link").eq(0).css("background", "url(images/sec_nav1_"+lang+".jpg)");

			$(".cross-link").eq(1).css("background", "url(images/sec_nav2_"+lang+".jpg)");

			$(".cross-link").eq(2).css("background", "url(images/sec_nav3_"+lang+".jpg)");

			$(".cross-link").eq(curclicked).css("background", "url(images/sec_nav"+(item)+"_hover_"+lang+".jpg)");

			

		}).hover(function(){

			item = $(".cross-link").index($(this)) + 1;

			$(this).css("background", "url(images/sec_nav"+(item)+"_hover_"+lang+".jpg)");

		

		}).mouseleave(function(){

			item = $(".cross-link").index($(this)) + 1;

			$(this).css("background", "url(images/sec_nav"+(item)+"_"+lang+".jpg)");

			$(".cross-link").eq(curclicked).css("background", "url(images/sec_nav"+(curclicked+1)+"_hover_"+lang+".jpg)");

			

		});



		theInterval = function(cur){

			$(".cross-link").eq(0).css("background", "url(images/sec_nav1_hover_"+lang+".jpg)");

			

			clearInterval(theInt);

			

			if( typeof cur != 'undefined' )

				curclicked = cur;

				

			theInt = setInterval(function(){

				var next = curclicked+1;

				var last = curclicked-1;

				var src = last +1;

				

				if( 0 == curclicked ){

					last = 2;

				}

				

				if( 0 == src ){

					src = 3;

				}



				$(".cross-link").eq(last).css("background", "url(images/sec_nav"+src+"_"+lang+".jpg)");

				$(".cross-link").eq(curclicked).css("background", "url(images/sec_nav"+next+"_hover"+lang+".jpg)");

				$(".cross-link").eq(curclicked).trigger('click');

				

				curclicked++;



				

				if( 3 == curclicked ){

					curclicked = 0;

				}

			}, 6000);

		};



		$(function(){

			$("#main-photo-slider").codaSlider();

			theInterval();

		});

	/***************/

	/* Fin slider */

	/*************/

	});

});


