// JavaScript Document
$(document).ready( function()
{
	$('#menu ul li#menuPIEA a').addClass('selected');

	$('#ici_et_ailleurs .over').css('display', 'none');

	$('#ici_et_ailleurs').children('.blog').hover(
		function()
		{
			$(this).children('.over').css('display', 'block');
		},
		function()
		{
			$(this).children('.over').css('display', 'none');
		}
	);

	$('#ici_et_ailleurs>.blog').click(showCadre);

	$('#ici_et_ailleurs h2').hover(
		function()
		{
			$('#ici_et_ailleurs').children('.blog').unbind('click',showCadre);
		},
		function()
		{
			$('#ici_et_ailleurs').children('.blog').bind('click',showCadre);
		}
	);
	
	$('#pdieda_cadre').click(function(){
		$(this).hide();
	}).mousemove(function(e){
		var offset = $(this).offset();
		if ($(this).children('img').width() > $(this).width())
		{
			$(this).children('img').css('left',	0-( (e.pageX-offset.left) * ($(this).children('img').width()-$(this).width())   / ($(this).width()) ) );
		}
		else
		{
			$(this).children('img').css('left',	($(this).width()-$(this).children('img').width()) /2 );
		}

		if ($(this).children('img').height() > $(this).height())
		{
			$(this).children('img').css('top',	0-( (e.pageY-offset.top ) * ($(this).children('img').height()-$(this).height()) / ($(this).height()) ) );
		}
		else
		{
			$(this).children('img').css('top',	($(this).height()-$(this).children('img').height()) /2 );
		}
			
	});//*/
	

	function showCadre(e)
	{
		var url = $(this).find('h1 a').attr('href');
		$('#pdieda_cadre').html('<img src="'+url+'" /><span class="close"></span>');

		$('#pdieda_cadre').css('width',$('#site').width());
		$('#pdieda_cadre').show();

		return false;
	}

});