function launchModal(id,width,height,opacity)
{
var scroll = $(window).scrollTop();
	//var id = jQuery(this).attr('href');	
	$.ajax({
		url: './edito/ajax.popin/'+id.substring(1,id.length)+'.html',
		type: 'POST',
		dataType: 'html',
		success: function(result) {

			$('#boxes').prepend(result);
			$(id).ready(function(){
				var box = jQuery(id).parent('#boxes');
				jQuery(id).parent('#boxes').remove();
				jQuery('body').append(box);	

				//console.log($(id).html());		
				//Get the screen height and width
				var maskHeight = jQuery(document).height();
				var maskWidth = jQuery(window).width();

				//Set height and width to mask to fill up the whole screen
				jQuery('#mask').css({'width':maskWidth,'height':maskHeight,'top':'0px','left':'0px','position':'absolute'});

				//transition effect		
				//jQuery('#mask').fadeIn(1000);	
				jQuery('#mask').css('display','block');
				if(opacity==false||opacity==undefined)
					jQuery('#mask').fadeTo(0,0);
				else
					jQuery('#mask').fadeTo(0,opacity);
				

				//Get the window height and width
				var winH = jQuery(window).height();
				var winW = jQuery(window).width();

				//On habille la modal
				var content = jQuery(id).html();
				jQuery(id).empty();
				jQuery(id).append( '<div class="window-header">'+
									'<div class="window-header-left"></div>'+
									'<div class="window-header-corps"></div>'+
									'<div class="window-header-right"></div>'+
									'<div class="clearer"></div>'+
									'</div>'+
									'<div class="window-content">'+
									'<div class="window-content-left"></div>'+
									'<div class="window-content-corps">'+
									content+
									'</div>'+
									'<div class="window-content-right"></div>'+
									'</div>'+
									'<div class="window-footer">'+
									'<div class="window-footer-left"></div>'+
									'<div class="window-footer-corps"></div>'+
									'<div class="window-footer-right"></div>'+
									'<div class="clearer"></div>'+
									'</div>'+
									'<div class="window-origine" style="display:none;">'+
									content+
									'</div>'
								);

				//Set the popup window to center  $(document).height(); scrollTop()
				jQuery(id).css('top', (scroll+100)+'px');
				jQuery(id).css('left', winW/2-width/2);
				jQuery(id).css('width',  width+'px');
				jQuery(id).css('height', height+'px');
				jQuery(id+' .window-header .window-header-corps').css('width',  (width-60)+'px');
				jQuery(id+' .window-footer .window-footer-corps').css('width',  (width-60)+'px');
				//jQuery(id+' .window-content').css('width',  (width)+'px');
				jQuery(id+' .window-content .window-content-corps').css('width',  (width-60)+'px');
				//jQuery(id+' .window-content').css('height',  (height-60)+'px');
				jQuery(id+' .window-content .window-content-corps').css('height', (height-60)+'px');
				jQuery(id+' .window-content .window-content-left').css('height', (height-60)+'px');
				jQuery(id+' .window-content .window-content-right').css('height', (height-60)+'px');

				//transition effect
				//jQuery(id).fadeIn(0);
				jQuery(id).css('display','block');
				return false;
			});
		}
	});

}

function resetBox(id)	
{
	var content = jQuery(id+' .window-origine').html();
	jQuery(id).empty();
	jQuery(id).append(content);
}

function closeModal(id)
{
	jQuery(id).parent().children().hide();
	resetBox(id);
	return false;
}

function closeAll()
{
	jQuery('#mask').parent().children('div').hide();
	jQuery('#mask').parent().children('div.window').each(function(){
		resetBox('#'+$(this).attr('id'));
	});
	return false;
}
