// JavaScript Document

num=1;
function showPict (idimg)
	{
	$("#loading").show();
	$("#big_pict").attr({ src: $("#"+idimg).attr("href")});
	$("#big_pict").load(function () {
		$("#loading").hide();
		$("#legende").html($("#"+idimg).attr("alt"));
	var limiteh = $("#max").val()-6;
	if (idimg < 4)
		{
		var i = 1;
		$('#seemore').show();
		}
	else if (idimg > limiteh)
		{
		var i = limiteh;
		}
	else
		{
		i = idimg-2; 
		$('#seemore').show();
		}
	
	
		});
	}


function PopupImage(img) {
	titre="Zoom";
	w=open("",'image','width=500,height=426,toolbar=no,scrollbars=no,resizable=no');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+80); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><a href='javascript:window.close();'><IMG src='"+img+"' border=0></a>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();

}

$(document).ready(function() {
						   
	$('a[href^="http://"]').attr({target: "_blank", title: "S\'ouvre dans une nouvelle fenêtre"});

	showPict (1);
	$("a.shownum").click(function() {
		num = $(this).attr("id");
		num = num*1;
		showPict (num);
		scrollTo(0,0);
		return false;
		
	});

	$("a.zoom").click(function() {
		lalargeur = $(this).children('img').width();
		if (lalargeur > 90)
			{
			href=$(this).attr('href');
			PopupImage(href);
			return false;
			}
	});

	
	$("a.showvideo").click(function() {
		num = $(this).attr("id");
		$(".videos").hide();
		$("#video_"+num).show();
		$("#legende").html($(this).attr("alt"));
		scrollTo(0,0);
		return false;
	});
	$('#next_image').click( function() { 
		if (num+1 < $('#max').val())
			num = num+1;
		else
			num = 1;
		showPict(num);
		scrollTo(0,0);
		return false;
		});
	
	$('#previous_image').click( function() { 
		if (num > 1)
			num = num-1;
		else
			num = $('#max').val()-1;
		showPict(num);
		scrollTo(0,0);
		return false;
		});
	
	
	
	$('a.menu').click( function() { 
		if ($(this).attr('href')== null || $(this).attr('href')== '')
			{
			$('a.menu').removeClass('bg_color');
			$(this).addClass('bg_color');
			$('.hide:visible').slideUp();
			$('#smenu'+$(this).attr('id')).slideDown();
			return false;
			}
		});



	$('.stripe').not('#fake').mouseover( function() { $('.stripe').height(45);$(this).height(66);$(this).prev().height(24);$(this).children('.sticker').show(); } );
	$('.stripe').not('#fake').mouseout( function() { $(this).height(45);$(this).prev().height(45);$(this).children('.sticker').hide();$('#stripe_'+$('#section').val()).height(66);$('#stripe_'+$('#section').val()).prev().height(24); } );
	
	
	$('#stripe_'+$('#section').val()).height(66);
	$('#stripe_'+$('#section').val()).prev().height(24);
	
	$('.focus').click( function() { 
	if ($(this).height()==145)
		{
		$(this).height('auto');
		$(this).children('.see_more').hide();
		}
	else if ($(this).height()>145)
		{
		$(this).height(145);
		$(this).children('.see_more').show();
		}
	
	} );
	

	$('div.article').click( function() { 
	if ($(this).height()==82)
		{
		$('div.article').height(82);
		$('div.article').children('.see_more').show();
		$(this).height('auto');
		$(this).children('.see_more').hide();
		}
	else if ($(this).height()>82)
		{
		$(this).height(82);
		$(this).children('.see_more').show();
		}
	} );


	$('.centre_box').click( function() { 
	if ($(this).height()==110)
		{
		$(this).height('auto');
		$(this).children('.see_more').hide();
		}
	else if ($(this).height()>110)
		{
		$(this).height(110);
		$(this).children('.see_more').show();
		}
	
	} );

	
	$('.masque').before("<a href='#' class='color a_lire_plus'>... Lire la suite</a>");
	
	$('.a_lire_plus').click( function() { 
		$('.a_lire_plus').show();
		$('.masque:visible').slideUp('slow');
		$(this).next('.masque').slideDown('slow');
		$(this).hide();
		return false;
		});

	$('.lbox').children('.box_cache').remove();


$('.lbox').click( function() { 
	topp1 = $(this).children('a').children('img').offset().top;
	lalargeur = $(this).children('div').children('a').children('img').width();
	$('.ctrl').addClass('lbox');
	$(this).removeClass('lbox');

	sIFR.replace(helvetica_light, {
	  selector: 'h1',
	  wmode : 'transparent',
	  css: ['.sIFR-root { color: #' + $('#ccolor').val() + '; text-transform: uppercase; font-size:27px;line-height:27px;}']
	});
	sIFR.replace(helvetica_bold, {
	  selector: 'h2',
	  wmode : 'transparent',
	  css: ['.sIFR-root { color:#000000; font-size:36px;line-height:32px;font-weight:bold;letter-spacing:-2;}','a { text-decoration: none;color:#000000; }','a:hover { color: #000000;text-decoration: underline; }']
	});

	sIFR.replace(helvetica_light, {
	  selector: 'h3',
	  wmode : 'transparent',
	  css: ['.sIFR-root {color: #' + $('#ccolor').val() + '; text-transform: uppercase; font-size:27px;line-height:27px;}']
	});
	
	topp2 = $(this).children('a').children('img').offset().top;
	if (topp1 > topp2)
		scrollTo(0,topp2-125);
	
	if (lalargeur == 82)
		{
		return false;
		}
	} );





	$('.colonne_droite_bas').mouseover(function() {
		$(this).removeClass('voile');
	});
	$('.colonne_droite_bas').mouseout(function() {
		$(this).addClass('voile');
	});

	$('a.sections_list').mouseover(function() {
		href = $(this).attr('href').substr(3,250).replace("/", "");
		//alert(href);
		$('.stripe').height(45);
		$('#stripe_'+href).height(66);
		$('#stripe_'+href).prev().height(24);
		$('#stripe_'+href).children('.sticker').show();
	});

	$('a.sections_list').mouseout(function() {
		href = $(this).attr('href').substr(3,250).replace("/", "");
		//alert(href);
		$('#stripe_'+href).height(45);
		$('#stripe_'+href).prev().height(45);
		$('#stripe_'+href).children('.sticker').hide();
		$('#stripe_'+$('#section').val()).height(66);
		$('#stripe_'+$('#section').val()).prev().height(24);
	});


	$('.box_cache').mouseover( function() { $(this).hide(); } );


	});
