currentQwPopup = null;

function QW_POPUP(logo) {
	var background = '/images/popup.background.png';
	var contours = new Array(	'/images/popup.contour0.png',
								'/images/popup.contour1.png',
								'/images/popup.contour2.png',
								'/images/popup.contour3.png',
								'/images/popup.contour4.png',
								'/images/popup.contour5.png',
								'/images/popup.contour6.png',
								'/images/popup.contour7.png',
								'/images/popup.contour8.png',
								'/images/popup.contour9.png',
								'/images/popup.contour10.png' );
	var bodyOverflow = null;
	var theLogo = logo;

	var html = '';
	html += '<div id="qw_popup" style="display: none; position: absolute; z-index: 99999; width: 100%; height: 100%; background-image: url(\''+background+'\'); left: 0; top: 0;">';

	
	html += '<table border="0" cellpadding="0" cellspacing="0" align="center" height="100%"><tr><td>';
	html += '<div style="position: relative">';
	html += '<a href="#" onclick="QW_POPUP_current().close(); return false" class="qw_popup_close_button" id="qw_popup_close_button" style="position: absolute; left: 500px; top: 8px"><img src="/images/popup.fermer.png"></a>';
	html += '<div style="position: absolute; left: 45px; top: 16px"><img id="qw_popup_logo" src="'+logo+'"></div>';
	html += '<table border="0" cellpadding="0" cellspacing="0">';
	html += '<tr><td width="10"><img src="'+contours[0]+'"></td><td width="45"><img src="'+contours[1]+'"></td><td width="410" style="background-image:url(\''+contours[2]+'\')">&nbsp;</td><td width="45"><img src="'+contours[3]+'"></td><td width="10"><img src="'+contours[4]+'"></td></tr>';
	html += '<tr><td width="10" style="background-image:url(\''+contours[5]+'\')">&nbsp;</td><td width="500" colspan="3"><div id="qw_popup_content"';
	if ( contours[6] != null )
		html += ' style="background-image:url(\''+contours[6]+'\')"';
	html += '></div></td><td width="10" style="background-image:url(\''+contours[7]+'\')">&nbsp;</td></tr>';
	html += '<tr><td width="55" colspan="2"><img src="'+contours[8]+'"></td><td width="410" style="background-image:url(\''+contours[9]+'\')">&nbsp;</td><td width="55" colspan="2"><img src="'+contours[10]+'"></td></tr>';
	html += '</table>';
	html += '</div>';
	html += '</td></tr></table>';
	html += '</div>';
	document.write(html);

	this.open = function(file, hasCloseButton) {
		currentQwPopup = this;
		
		// Masque les barres de défilement
		this.bodyOverflow = document.body.style.overflow;
		document.body.style.overflow = 'hidden';
		
		document.getElementById('qw_popup_logo').src = theLogo;
		
		var popup = document.getElementById('qw_popup');
		var left = typeof(window.pageXOffset) == 'undefined' ? document.body.scrollLeft : window.pageXOffset;
		var top  = typeof(window.pageYOffset) == 'undefined' ? document.body.scrollTop  : window.pageYOffset;
		popup.style.left = left;
		popup.style.top  = top;
		var ajax = new QW_AJAX;
		var html = ajax.get(file, null, false);
		document.getElementById('qw_popup_content').innerHTML = html;
		var closeButton = document.getElementById('qw_popup_close_button');
		if ( hasCloseButton )
			closeButton.style.visibility = 'visible';
		else
			closeButton.style.visibility = 'hidden';
		popup.style.display = 'block';
	}

	this.close = function() {
		document.body.style.overflow = this.bodyOverflow;
		document.getElementById('qw_popup').style.display = 'none';
	}
}

function QW_POPUP_current() {
	return currentQwPopup;
}
