var SLB_cnt = 0;

function SLB(typet, type)
{
	var a = document.getElementById('SLB_film');
	var b = document.getElementById('SLB_content');
	var c = document.getElementById('SLB_loading');
	a.style.cssText = 'z-index: 99997; position:absolute; display:none; width:100%; height:100%; background-color:#000000; -ms-filter: "Alpha(Opacity=50)"; filter:Alpha(opacity=50); opacity:0.5';
	
	a.style.height = document.documentElement.clientHeight +'px';
	if (document.documentElement.clientWidth < document.getElementById('wd_flash').scrollWidth){
		a.style.width = document.getElementById('wd_flash').scrollWidth+'px';
	}
	
	if (typet == 'show_pop') {
		a.style.top = 0;
		a.style.left = 0;
		a.style.display = "";
		if (document.documentElement.scrollHeight > document.getElementsByTagName('body')[0].scrollHeight) {
			a.style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			a.style.height = document.getElementsByTagName('body')[0].scrollHeight + 'px';
		}
		
		c.style.display = "block";
		SLB_setCenter(c,true);
		SLB_setCenter(b);
		b.style.display = "block";
		a.onclick = function () { SLB() };
	} else {
		a.onclick = '';
		a.style.display = "none";
		a.style.height = '100%';
		a.style.width = '100%';
		c.style.display = "none";
		b.style.display = "none";
		SLB_cnt = 0;
	}
}

function SLB_setCenter(obj) {
	if (obj) {
		var h = (window.innerHeight || self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
		var w = (window.innerWidth || self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
		var l = ((window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft) + ((w-(obj.width||parseInt(obj.style.width)||obj.offsetWidth))/2));
		var t = ((window.pageYOffset || document.documentElement.scrollTop || 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 = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
		document.getElementById('SLB_content').style.left = l + "px";
		if(SLB_cnt == 0) {
			document.getElementById('SLB_content').style.top = t + "px";
			if(document.getElementById('SLB_content').offsetHeight >= h - 20) {
				SLB_cnt ++;
			}
			if(obj.nextSibling && (obj.nextSibling.className == 'SLB_close' || obj.nextSibling.className == 'SLB_caption')) {
				obj.nextSibling.style.display = 'block';
				if((t - (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop))>(obj.nextSibling.offsetHeight/2)) {
					document.getElementById('SLB_content').style.top = parseInt(document.getElementById('SLB_content').style.top) - (obj.nextSibling.offsetHeight/2) + "px";
				}
			}
		}
		obj.style.visibility = 'visible';
		if(!arguments[1]) {
			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 (document.getElementById('SLB_content').style.display=='block'){
		if(prevOnScroll != undefined) prevOnScroll();
		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			document.getElementById('SLB_film').style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			document.getElementById('SLB_film').style.height = document.body.scrollHeight + 'px';
		}
		if (document.documentElement.scrollWidth > document.body.scrollWidth) {
			document.getElementById('SLB_film').style.width = document.documentElement.scrollWidth + 'px';
		} else { 
			document.getElementById('SLB_film').style.width = document.body.scrollWidth + 'px';
		}
		SLB_setCenter(document.getElementById('SLB_content'));
	}
}

var prevOnResize = window.onresize;
window.onresize = function () {
	if (document.getElementById('SLB_content').style.display=='block'){
		if(prevOnResize != undefined) prevOnResize();
		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			document.getElementById('SLB_film').style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			document.getElementById('SLB_film').style.height = document.body.scrollHeight + 'px';
		}
		if (document.documentElement.scrollWidth > document.body.scrollWidth) {
			document.getElementById('SLB_film').style.width = document.documentElement.scrollWidth + 'px';
		} else { 
			document.getElementById('SLB_film').style.width = document.body.scrollWidth + 'px';
		}
		SLB_setCenter(document.getElementById('SLB_content'));
	}
}