var SLB_cnt = 0;

function SLB(url, type)
{
	var a = document.getElementById('SLB_film');
	var b = document.getElementById('SLB_content');
	if(url) {
		a.style.top = 0;
		a.style.left = 0;
		//페이드 인으로 나타나기
		$('#SLB_film').fadeIn("slow");
		
		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			a.style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			a.style.height = document.body.scrollHeight + 'px';
		}
		if(type == 'image') {
			b.innerHTML="<div id='SLB_image' style='cursor:pointer; text-align:right; padding:10px; background-color:#fff; width:" + arguments[2] + "px;' ><img src='" + url + "' /><img src='/img2010/common/closelabel.gif' /></div>";
			SLB_setCenter(b, arguments[2], arguments[3]);
			
		} else if(type == 'youtube') {
			b.innerHTML="<div id='SLB_image' style='cursor:pointer; text-align:right; padding:0px; background-color:#000; width:" + arguments[2] + "px;' ><img src='/img2010/common/closeX.gif' /><iframe width='" + arguments[2] + "' height='" + arguments[3] + "' src='" + url+ "' frameborder='0' allowfullscreen></iframe></div>";
			SLB_setCenter(b, arguments[2], arguments[3]);
			
		}else if (type == 'iframe') {
			//alert(arguments[2]);
			b.innerHTML="<iframe id='SLB_iframe'  name='SLB_iframe' src=" + url + " width="+ arguments[2] +" height="+ arguments[3] +" class='SLB_center' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' scrolling='no'/></iframe>";
			SLB_setCenter(b, arguments[2], arguments[3]);
			
		} else if (type == 'html'){
			b.innerHTML = url;
			SLB_setCenter(b.firstChild, arguments[2], arguments[3]);
		
		} else if (type == 'cross_domain'){
			var i_width = arguments[2] - 10;
			var i_height = arguments[3] - 50;
			b.innerHTML="<table border='0' cellpadding='0' cellspacing='0' id='popup' width='100%'><tr id='popHead'><td ><img id='popLogo' src='/img2010/common/logo_popup.gif'/> <span id='popTitle'> <img src='/img2010/common/btn_popupClose2.gif' alt='닫기' id='popClose' style='cursor:pointer' onClick='SLB();'/> </span> </td></tr><tr id='popBody'><td width='100%'><iframe id='SLB_iframe'  name='SLB_iframe' src=" + url + " width="+ i_width +" height="+ i_height +" class='SLB_center' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' scrolling='no'/></iframe></td></tr></table>";
			SLB_setCenter(b, arguments[2], arguments[3]);
		}
		
	} else {
		a.onclick = '';
		a.style.display = "none";
		a.style.height = '100%';
		a.style.width = '100%';
		b.innerHTML = "";
		b.onclick = function () { SLB() };
		SLB_cnt = 0;
	}
}

   	  	
//현재창의 가로세로 중앙에 창뛰우기
function SLB_setCenter(obj, SLBwidth, SLBheight) {
	if (obj) {
		//alert(SLBwidth);
		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)) - SLBwidth/2;
		var t = ((window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop) + ((h-(obj.height||parseInt(obj.style.height)||obj.offsetHeight))/2)) - SLBheight/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')) {
				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";
				}
			}
		}
		//페이드 인으로 나타나기
		$('#SLB_content').fadeIn("slow");
	}
}
