function SLB_show(url, type)
{
	var a = document.getElementById('SLB_film');
	var b = document.getElementById('SLB_content');
	var c = document.getElementById('SLB_loading');
	if(url) {
		a.style.top = 0;
		a.style.left = 0;
		a.style.display = "";
		a.style.height = document.body.scrollHeight + 'px';
		if(document.getElementById('SLB_loading')) document.getElementById('SLB_loading').style.display = "block";
		SLB_setCenter(c,true);
		if(type == 'image') {
			b.innerHTML="<img src=" + url + " class='SLB_center' onload='SLB_setCenter(this);' />";
			if(arguments[2])	a.onclick = function () { SLB_show() };
			if(arguments[3]) b.innerHTML += "<div class='SLB_caption'>"+ arguments[3] +"</div>";;
		} else if (type == 'iframe') {
			b.innerHTML="<iframe src=" + url + " width="+ arguments[2] +" height="+ arguments[3] +" class='SLB_center' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' scrolling='no' onload='SLB_setCenter(this);' /></iframe>";	
			if(arguments[4]) {
				b.innerHTML += "<div align=right class='SLB_close' onclick='SLB_show();' title='Close window'><img src='virtualtour/images/closewindow.gif'></div>";
			}
			b.onclick = ''; b.firstChild.style.cursor = 'default'; 
		} else if (type='html'){
			b.innerHTML = url;
			SLB_setCenter(b.firstChild);
			if(arguments[2]) b.onclick = ''; 
		}
	} else {
		a.onclick = '';
		a.style.display = "none";
		b.innerHTML = "";
		b.onclick = function () { SLB_show() };
		c.style.display = "none";
	}
}

function SLB_setCenter(obj) {
	if (obj) {
		var h = window.innerHeight || self.innerHeight || document.body.clientHeight;
		var w = window.innerWidth || self.innerWidth || document.body.clientWidth;
		var l = (document.body.scrollLeft + ((w-(obj.width||parseInt(obj.style.width)||obj.offsetWidth))/2)) ;
		var t = (document.body.scrollTop + ((h-(obj.height||parseInt(obj.style.height)||obj.offsetHeight))/2)) ;
		if((obj.width||parseInt(obj.style.width)||obj.offsetWidth) >= w) l = 0;
		if((obj.height||parseInt(obj.style.height)||obj.offsetHeight) >= h) t = 0;
		if(document.getElementById('SLB_content')) document.getElementById('SLB_content').style.left = l + "px";
		if(document.getElementById('SLB_content')) document.getElementById('SLB_content').style.top = t + "px";
		obj.style.visibility = 'visible';
		if(obj.nextSibling && (obj.nextSibling.className == 'SLB_close' || obj.nextSibling.className == 'SLB_caption')) {
			obj.nextSibling.style.display = 'block';
		}
		if(!arguments[1]) {
			if(document.getElementById('SLB_loading')) document.getElementById('SLB_loading').style.display = "none";
		} else {
			obj.style.left = l + "px";
			obj.style.top = t + "px";
		}
	}
}
 var prevOnScroll = window.onscroll;
 window.onscroll = function () {
	if(prevOnScroll != undefined) prevOnScroll();
	if(document.getElementById('SLB_film')) document.getElementById('SLB_film').style.height = document.body.scrollHeight + 'px';
	if(document.getElementById('SLB_film')) document.getElementById('SLB_film').style.width = document.body.scrollWidth + 'px';
	if(document.getElementById('SLB_content')) SLB_setCenter(document.getElementById('SLB_content').firstChild);          
}
var prevOnResize = window.onresize;   
window.onresize = function () {
	if(prevOnResize != undefined) prevOnResize();
	if(document.getElementById('SLB_film')) document.getElementById('SLB_film').style.height = document.body.offsetHeight + 'px';
	if(document.getElementById('SLB_film')) document.getElementById('SLB_film').style.width = document.body.offsetWidth + 'px';
	if(document.getElementById('SLB_content')) SLB_setCenter(document.getElementById('SLB_content').firstChild);      
}
