// JavaScript Document

//popup Pub -------------------------------------------------------------------------------------
function pub(el){
	var photo = Event.element(el).getAttribute('src').toString().sub(/logo/, 'agrandi');
	var oldPhoto = $('bigUp').down('img').getAttribute('src').toString();
	if( photo != oldPhoto && $('bigUp').getStyle('display') != "none" ){
		$('bigUp').down('img').setAttribute('src', photo);
	}else{
		$('bigUp').down('img').setAttribute('src', photo);
		new Effect.toggle('bigUp','slide', {scaleX:false,scaleY:true});
	}
}

//preload des pub -------------------------------------------------------------------------------
function preload(photo){
	imgPreloader = new Image;
	imgPreloader.src = photo;
}

//popup Event -----------------------------------------------------------------------------------
function AffichEvent(){
	win=window.open("pop_event.php", "popup_event", "width=450px,height=500px,top=5,left=5,screenX=5,screenY=5,scrollbars=no,resizable=no");
	win.focus();
}


function initialise(){
	//init popup Pub
	new Insertion.Top('corps', "<div id=\"bigUp\" style=\"display:none;position:absolute;top:29px;left:230px;z-index:100\"  ><div><a href=\""+window.document.location+"#\" class=\"agrandi\" ><img src=\"\" /></a></div></div>");
	Element.getElementsByClassName( 'body', 'agrandi').each( function(e){
																   	Event.observe( e, 'click', pub, false);
																 	preload( e.down('img').getAttribute('src').toString().sub(/logo/, 'agrandi'));
																   });
	//init popup Event
	Try.these(
			  function(){	Event.observe($('popup'),'click',AffichEvent, false)}
			  );
	
}





Event.observe( window, 'load', initialise, false);