//movie(플래시 시작을 movie로 시작)
function gotoMovie(){
	location.href ='list.html?movieNum=0';
//	alert("movie 페이지 이동");
}

//Slide Show Gallery(플래시 시작을 SlideShow Gallery로 시작)
function gotoGallery(){
	location.href ='list.html?movieNum=1';
//	alert("SlideShow Gallery 페이지 이동");
}

//About Event
function gotoAboutEvent(){
	location.href ='facebook.html';
}

//How To Join (플래시 시작을 How To Join 으로 시작)
function gotoHowToJoin(){
	location.href ='list.html?movieNum=3';
//	alert("How to Join 페이지 이동");
}

//Create your own
function creatYourOwn(){
	location.href ='step.html';
}

//슬라이드쇼 보기
function viewSlideShow(id){
	var type = "html";
	var subject = "My London Trip";
	var date = "Oct 02, 2009";
	var create = "Julie Lee";
	ssBOC(id, type, subject, date, create);
//	alert("선택한 슬라이드 쇼 보기 : " + id);
}

function img_change(obj, mode){
	var reg = /(.*)_(on|off)/;
	var find = obj.src.match(reg)[0];
	var name = obj.src.match(reg)[1];
	obj.src = obj.src.replace(find,name+'_'+mode);
}

function tabSwap(sw, tabcount) {
	for (i = 1; i < tabcount ; i++) {
		if (sw == i) {		
			document.getElementById('step'+i).style.display='';
		} else {
			document.getElementById('step'+i).style.display='none';
		}
	}
}

function closePop(obj){
	document.getElementById(obj).style.display = 'none';
}


// about flash


// change flash size
function setSize(flashID, stwidth, stheight) {
  var w = parseInt(stwidth);	
  var h = parseInt(stheight);	

	var el = thisMovie(flashID);
	el.setAttribute("height", h);
	el.style.height = h + "px";
	el.setAttribute("width", w);
	el.style.width = w + "px";
	
	var el = document.getElementById(flashID); 
	el.style.height = h + "px";
	el.style.width = w + "px";	
}
function thisMovie(movieName) { 
	if (navigator.appName.indexOf("Microsoft") != -1) {
		  return getElementByTagAndId("object", movieName);
	} else {
		  return getElementByTagAndName("embed", movieName);
	}
}
function getElementByTagAndId(tagName, id){
	var el = null;
	var els = document.getElementsByTagName(tagName);
	for(var i=0 ; i < els.length ; i++){
		if(els[i].id == id) {	el = els[i];	break;	}
	}
	return el;
}
function getElementByTagAndName(tagName, name){
	var el = null;
	var els = document.getElementsByTagName(tagName);
	for(var i=0 ; i < els.length ; i++){
		if(name == "" && i == 0){	el = els[i];	break;	}
		if(els[i].name == name) {	el = els[i];	break;	}
	}
	return el;
}



function resizeFrame(iframeObj){
  var innerBody = iframeObj.contentWindow.document.documentElement;
  var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
  var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
    if(innerHeight>0 && innerWidth>0){
        iframeObj.style.height = innerHeight + "px";
        iframeObj.style.width = innerWidth + "px";
		ssBOC_setCenter(iframeObj);
	}
}

var ssBOC_cnt = 0;

function ssBOC(url, type, subject, date, create)
{
	var a = document.getElementById('ssBOC_film');
	var b = document.getElementById('ssBOC_content');
	var c = document.getElementById('ssBOC_loading');
	var d = document.getElementById('ReStore');
	/* films */
	a.style.position = "absolute";
	a.style.top = "-4px";
	a.style.left = "-21px";
	a.style.height = win.getScrollHeight()+"px";
	a.style.width = win.getScrollWidth()+"px";
	/* //films */

	if(url) {
		a.style.top = 0;
		a.style.left = 0;
		a.style.display = "";

		if(type == 'html') {
			var openobject = document.getElementById(arguments[0]);
			var modal_html
			modal_html = '';
			modal_html += '<table id="ST50_frame" cellpadding="0" cellspacing="0" border="0" width="'+ arguments[2] +'" onload="tryReHeight(\''+arguments[5]+'\');">';
			modal_html += '<tr>';
			modal_html += '<td align="center">';
			modal_html += '<div style="width:560px; height:505px; background:url(img/bg_showmovie.gif) 0 0 no-repeat">';
				modal_html += '<div class="inside"><a href="#" onclick="ssBOC();"><img src="img/btn_close2.gif"></a></div>';
				modal_html += '<div class="cont">';
					modal_html += '<dl>';
					modal_html += '<dt>' + subject + '</dt>';
					modal_html += '<dd>Added : <span>' + date + '</span> | Created by : <span>' + create + '</span></dd>';
					modal_html += '</dl>';
					modal_html += '<div class="flashpos"><img src="img/tmp_flash.jpg" alt="" /></div>';
				modal_html += '</div>';
			modal_html += '</div>';
			modal_html += '</td>';
			modal_html += '</tr>';
			modal_html += '</table>';
			b.innerHTML = modal_html;
//			ssBOC_setCenter(b.firstChild);
//			if(arguments[3]) a.onclick = function() { ssBOC() };

		} else if (type == 'frame'){

		}


		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			a.style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			a.style.height = document.body.scrollHeight + 'px';
		}
		c.style.display = "block";
		a.style.zIndex = "9997";
		d.style.zIndex = "9996";
		ssBOC_setCenter(b,true);

//		hideSelect();
	} else {
		a.onclick = '';
		if(d.style.display != "")
		{
			a.style.display = "none";
			a.style.height = '100%';
			a.style.width = '100%';
		}
		b.innerHTML = "";
		b.onclick = function () { ssBOC() };
		c.style.display = "none";
		a.style.zIndex = "9995";
		d.style.zIndex = "9998";
		showSelect();
		ssBOC_cnt = 0;
	}
}

function ssBOC_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('ssBOC_content').style.left = l + "px";
		if(ssBOC_cnt == 0) {
			document.getElementById('ssBOC_content').style.top = t + "px";
			if(document.getElementById('ssBOC_content').offsetHeight >= h - 20) {
				ssBOC_cnt ++;
			}
			if(obj.nextSibling && (obj.nextSibling.className == 'ssBOC_close' || obj.nextSibling.className == 'ssBOC_caption')) {
				obj.nextSibling.style.display = 'block';
				if((t - (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop))>(obj.nextSibling.offsetHeight/2)) {
					document.getElementById('ssBOC_content').style.top = parseInt(document.getElementById('ssBOC_content').style.top) - (obj.nextSibling.offsetHeight/2) + "px";
				}
			}
		}
		obj.style.visibility = 'visible';
		if(!arguments[1]) {
			document.getElementById('ssBOC_loading').style.display = "none";
		} else {
			obj.style.left = l + "px";
			obj.style.top = t + "px";
		}
	}
}

function hideSelect() {
	var windows = window.frames.length;
	var selects = document.getElementsByTagName("SELECT");
	for (i=0;i < selects.length ;i++ )
	{
		selects[i].style.visibility = "hidden";
	}
	if (windows > 0) {
		for(i=0; i < windows; i++) {
			try {
				var selects = window.frames[i].document.getElementsByTagName("SELECT");
				for (j=0;j<selects.length ;j++ )
				{
					selects[j].style.visibility = "hidden";
				}
			} catch (e) {}
		}
	}
}

function showSelect() {
	var windows = window.frames.length;
	var selects = document.getElementsByTagName("SELECT");
	for (i=0;i < selects.length ;i++ )
	{
		selects[i].style.visibility = "visible";
	}
	if (windows > 0) {
		for(i=0; i < windows; i++) {
			try {
				var selects = window.frames[i].document.getElementsByTagName("SELECT");
				for (j=0;j<selects.length ;j++ )
				{
					selects[j].style.visibility = "visible";
				}
			} catch (e) {}
		}
	}
}

function tryReHeight(sign) {
	var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
	var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0;
	var currentfr=document.getElementById('ssBOC_iframe');
	var currentDiv=document.getElementById('ssBOC_content');
	if(sign) {
		alert('aa');
		try {
			if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) {
				setIframeSize(currentfr.contentDocument.body.offsetHeight+FFextraHeight);
			} else if (currentfr.Document && currentfr.Document.body.scrollHeight) {
				setIframeSize(currentfr.Document.body.scrollHeight);
			}
		}catch(e) { }
		ssBOC_setCenter(document.getElementById('ssBOC_content').firstChild);
	} else {
		alert('bbb');
		ssBOC_setCenter(document.getElementById('ssBOC_content').firstChild);
	}
}

function setIframeSize(h, w) {
	ssBOC_cnt = 0;
	var ifr = currentfr=document.getElementById('ssBOC_iframe');
	if (ifr) {
		if(w) {
			ifr.width = w;
		}
		if(h) {
			ifr.height = h;
		}
		ssBOC_setCenter(ifr);
	}
}

var prevOnScroll = window.onscroll;
window.onscroll = function () {
	try
	{
		if(prevOnScroll != undefined) prevOnScroll();
		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			document.getElementById('ssBOC_film').style.height = document.documentElement.scrollHeight + 'px';
			//document.getElementById('lp_film').style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			document.getElementById('ssBOC_film').style.height = document.body.scrollHeight + 'px';
			//document.getElementById('lp_film').style.height = document.body.scrollHeight + 'px';
		}
		document.getElementById('ssBOC_film').style.width = document.body.scrollWidth + 'px';
		//document.getElementById('lp_film').style.width = document.body.scrollWidth + 'px';
		ssBOC_setCenter(document.getElementById('ssBOC_content').firstChild);
	}
	catch (e)
	{
	}
}

var prevOnResize = window.onresize;
window.onresize = function () {
	try
	{
		if(prevOnResize != undefined) prevOnResize();
		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			document.getElementById('ssBOC_film').style.height = document.documentElement.scrollHeight + 'px';
		} else { 
			document.getElementById('ssBOC_film').style.height = document.body.scrollHeight + 'px';
		}
		document.getElementById('ssBOC_film').style.width = document.body.offsetWidth + 'px';
		ssBOC_setCenter(document.getElementById('ssBOC_content').firstChild);
	}
	catch (e)
	{
	}
}

//width and height value on window from mootools
var win ={
	getWidth: function(){
		if (document.childNodes && !document.all && !navigator.taintEnabled) return window.innerWidth;
		if (window.opera) return document.body.clientWidth;
		return document.documentElement.clientWidth;
	},

	getHeight: function(){
		if (document.childNodes && !document.all && !navigator.taintEnabled) return window.innerHeight;
		if (window.opera) return document.body.clientHeight;
		return document.documentElement.clientHeight;
	},

	getScrollWidth: function(){
		if (window.ActiveXObject) return Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth);
		if (document.childNodes && !document.all && !navigator.taintEnabled) return document.body.scrollWidth;
		return document.documentElement.scrollWidth;
	},

	getScrollHeight: function(){
		if (window.ActiveXObject) return Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight);
		if (document.childNodes && !document.all && !navigator.taintEnabled) return document.body.scrollHeight;
		return document.documentElement.scrollHeight;
	},

	getScrollLeft: function(){
		return window.pageXOffset || document.documentElement.scrollLeft;
	},

	getScrollTop: function(){
		return window.pageYOffset || document.documentElement.scrollTop;
	},
	getPosition: function(){return {'x': 0, 'y': 0}}

};



