/*site zIndex composition

80			= Alpha black layer
90			= tools (cjack, etc)
94, 95, 96	= clownie (goodie, card, goodie)
100			= the header
110			= popup windows
*/

var g_ar_viewer = new Array();
function openViewer(width, height, url, id, title, extra_html){

	//alert(window.innerHeight + '  ' + document.body.scrollTop);

	SetAlphaPanel(30);
	showSelect('hidden');

	if(extra_html == undefined)
		extra_html = '';

	var d =  gById(id);

	if(d == null){
		d = document.createElement("DIV");
		d.style.cssText = 'position:absolute;';
		d.id = id;
		d.style.zIndex = 110;
	}

	d.style.left = (WindowSize('width')-width)/2 + 'px'; //todo, half screen

	var top = (((WindowSize('height')-height)/2)+WindowScroll('top'));

	if(top < document.body.scrollTop)
		d.style.top = WindowScroll('top');
	else
		d.style.top  = top + 'px';

	d.style.border = '1px black solid';

	d.innerHTML =	'<table class="tableList" style="width:' + width + 'px;">' +
						'<tr class="head2">' +
							'<td style="text-align:left;width:100%;">' + title + '</td>' +
							'<td style="text-align:right;"><a href="javascript:closeViewer(\'' + id + '\');">X</a></td>' +
						'</tr>' +
					'</table>' +
					'<iframe frameborder="0" style="width:' + width + 'px;height:' + height + 'px;" src=' + url +'></iframe>' +
					extra_html;

	document.body.appendChild(d);

	if( !g_ar_viewer.find(id))
		g_ar_viewer[g_ar_viewer.length] = id;

}

function closeViewer(id){

	g_ar_viewer.remove(id);

	if(g_ar_viewer.length==0){
		SetAlphaPanel(0);
		showSelect('visible');
	}

	document.body.removeChild(gById(id));

}


