function ouvre(adresse,large,haut,nom,size) {
	var w;
	var outil="no";
	if (!nom) nom = adresse.replace(/\W/g,'');
	if (!size) size='no';
	var features =
		"width="+large
		+",height="+haut
		+",menubar="+outil
		+",location="+outil
		+",status="+outil
		+",toolbar="+outil
		+",resizable="+size
		+",scrollbars="+size
	if (!large && !haut)
		w = window.open(adresse);
	else
		w = window.open(adresse,nom,features);
	if (w) return false;
	return true;
}

jQuery(document).ready(function($){
	window.modal_position = ($.browser.msie && parseInt($.browser.version)<7) ? 'absolute' : 'fixed'; /*IE<7*/
	$(".modal").each(function(){
		$(this).bind('click',function(){
			var hauteur = ($('body').height()<$(window).height()) ? $(window).height() : $('body').height();
			$("<div id='modal_back' style='position:"+window.modal_position+";top:0px;left:0px;width:100%;height:"+hauteur+"px;background-color:black;opacity:0.8;'>&nbsp;</div>")
			.appendTo('body')
			.bind(
				"click",
				function(){
					$(this).remove();
					$('.modal_front').remove();
				}
			);
			if (window.modal_position=="absolute")	window.scrollTo(0,0); /*IE<7*/
			charge_modal(this.href);
			return false;
		})
	})
	function charge_modal(href) {
		var load = $("<img style='position:"+window.modal_position+";top:50%;left:50%;margin-top:-16px;margin-left:-16px' src='http://www.google.com/accounts/hosted/helpcenter/images/tooltips/spin_32.gif' />");
		$.ajax({
			type: "GET",
			url: href,
			beforeSend : function() {
				$('body').append(load);
			},
			success: function(data) {
				var old = $('#modal_front');
				var modal = $("<div class='modal_front' style='position:"+window.modal_position+";top:50%;left:50%;background-color:white;display:none;'></div>")
					.append(data)
					.appendTo('body')
					.find("a")
					.not('.non_modal')
					.each(function(){
						$(this).bind("click",function(){
							charge_modal(this.href);
							return false;
						})
					})
					.end()
					.end();
				var o = {width:modal.width(),height:modal.height()}
				modal.css({
					width: o.width+'px',
					height: o.height+'px',
					marginTop: '-'+parseInt(o.height/2)+'px',
					marginLeft: '-'+parseInt(o.width/2)+'px'
				})
// 				console.log(old);
				if (old.length>0) {
					old.attr('id','')
						.fadeOut(1000,function(){
							$(this).remove();
						});
				}
				modal.fadeIn(1000)
					.attr('id',"modal_front");
				load.remove();
			}
		});
	}
})

