function _getPageSize() 
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
};

function _getPageScroll() 
{
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	
	return arrayPageScroll;
}
		
		
function _finish() 
{
	$('#fenetre').hide();
	$('#overlay').fadeOut(function() { $('#overlay').hide(); });
	$('embed, object, select').css({ 'visibility' : 'visible' });
}
		
		
function _AjustementAutoFenetre(largeur, hauteur)
{
	$(window).resize(function() 
	{
		// Get page sizes
		var arrPageSizes = _getPageSize();
		var arrPageScroll = _getPageScroll();
		// Style overlay and show it
		$('#overlay').css({
			width:		arrPageSizes[0],
			height:		arrPageSizes[1]
		});
		
		var margeW = arrPageScroll[0] + Math.round((arrPageSizes[2]-largeur)/2);
		var margeH = arrPageScroll[1] + Math.round((arrPageSizes[3]-hauteur)/2);

		$('#fenetre').css({
			top:	margeH,
			left:	margeW
		});
	});
	
}
		
		
function ChargerFenetre(fenetre, background, opacity, largeur, hauteur, info)
{
	$("#overlay").hide();
	$("#fenetre").hide();	
	$('embed, object, select').css({ 'visibility' : 'hidden' });
	var arrPageSizes = _getPageSize();
	var arrPageScroll = _getPageScroll();
	$("#overlay").css({
			zIndex: 510,
			backgroundColor:	'#000',
			position:	'absolute',
			opacity:			0.8,
			width:				arrPageSizes[0],
			height:				arrPageSizes[1],
			top: 				0,
			left:				0
		}).fadeIn();
	
	var lien = this.rel;
	
	
	switch (fenetre)
	{
		case 'filemanagerJS':
			_filemanagerJS(info);
		break;
		case 'transition_magasin_boutique':
			_transition_magasin_boutique();
		break;
		case 'transition_panier':
			_transition_panier(info);
		break;
		case 'diaporama':
			_diaporama(info);
		break;
	}
	
	
	var margeW = arrPageScroll[0] + Math.round((arrPageSizes[2]-largeur)/2);
	var margeH = arrPageScroll[1] + Math.round((arrPageSizes[3]-hauteur)/2);
	$("#fenetre").css({
			zIndex: 			520,
			position : 			'absolute',
			opacity:			1,
			top:				margeH,
			left:				margeW,
			backgroundColor:	'#FFFFFF',
			width:				largeur,
			height:				hauteur
		}).fadeIn();
	
	
	_AjustementAutoFenetre(largeur, hauteur);	
	$('#overlay').click(function(){_finish();});
	
	return false;
}
			
		
		
/*function _AjustementAutoFenetre(largeur, hauteur)
{
	$(window).resize(function() 
	{
		// Get page sizes
		var arrPageSizes = _getPageSize();
		var arrPageScroll = _getPageScroll();
		var ccs_position = _infI7();
	
		if(ccs_position == "absolute")
		{
			var widthOverlay = arrPageSizes[0];
			var heightOverlay = arrPageSizes[1];
		}
		else	
		{
			var widthOverlay = '100%';
			var heightOverlay = '100%';
		}
		// Style overlay and show it
		
		var overlayW = arrPageSizes[0];
		var overlayH = arrPageSizes[1];
		
		
		$('#overlay').css({
			width:		arrPageSizes[0],
			height:		arrPageSizes[1]
		});
		
		var margeW = arrPageScroll[0] + Math.round((arrPageSizes[2]-largeur)/2);
		var margeH = arrPageScroll[1] + Math.round((arrPageSizes[3]-hauteur)/2);
		
		

		$('#fenetre').css({
			top:	margeH,
			left:	margeW
		});
	});
						  
	
}*/
		
		

