/*************************************************************************
	@ ÇÁ·ÎÁ§Æ®¸í : Çä½½¸® OBT À¥»çÀÌÆ®

	@ ÆäÀÌÁö  ¸í : /Script/jsEmbedObject.js

	@ ±â      ´É : »óÈ£ÀÛ¿ë ÄÁÆ®·Ñ ´ëÃ¼ ÇÔ¼ö

	@ ÀÌ      ·Â : 2008.03.27 °û±â¼·
*************************************************************************/

function fnWrite(strTarget){
	document.write(strTarget);
}

function fnEmbedMenu(strParamPath,intWidth,intHight){
	var strObject;
	strObject =	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + intWidth + "' height='" + intHight + "'  id='sub_navi' align='middle' />" +
					"<param name='allowScriptAccess' value='sameDomain' />" +
					"<param name='movie' value='" + strParamPath + "'/>" +
					"<param name='quality' value='high'/>" +
					"<param name='bgcolor' value='#000000'/>" +
					"<param name='menu' value='false'>" +
					"<embed src='" + strParamPath + "' quality='high' bgcolor='#000000' width='" + intWidth + "' height='" + intHight + "' name='sub_navi' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
				"</object>"
	fnWrite(strObject);
}

function fnMovie(strMov,intWidth,intHight) {
	var strObject;

	strObject =	"<object id='mbox' width='" + intWidth + "' height='" + intHight + "' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'  codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.%20cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject' VIEWASTEXT>" +
					"<param name='FileName' value='" + strMov + "'>" +
					"<param name='ShowControls' value='0'>" +
					"<param name='ShowStatusBar' value='0'>" +
					"<param name='ShowGoToBar' value='0'>" +
					"<param name='AutoStart' value='1'>" +
					"<param name='ClickToPlay1' value='1'>" +
					"<PARAM NAME='Volume' value='-600'>" +
					"<embed TYPE='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/mediaplayer/en/download/Win32I E4x86.asp' src='video/04_gfather_I.wmv'>" +
				"</object>"

	document.getElementById("divMovie").innerHTML = strObject;
}

function fnFanMoviePrev(strMov, width, height, divName) {
	var strObject;

	strObject =	"<object id='mbox' width='" + width + "' height='" + height + "' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'  codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.%20cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject' VIEWASTEXT>" +
					"<param name='FileName' value='" + strMov + "'>" +
					"<param name='ShowControls' value='0'>" +
					"<param name='ShowStatusBar' value='0'>" +
					"<param name='ShowGoToBar' value='0'>" +
					"<param name='AutoStart' value='1'>" +
					"<param name='ClickToPlay1' value='1'>" +
					"<PARAM NAME='Volume' value='-600'>" +
					"<embed TYPE='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/mediaplayer/en/download/Win32I E4x86.asp' src='video/04_gfather_I.wmv'>" +
				"</object>"

	document.getElementById(divName).innerHTML = strObject;
}

function fnFanMovieAdd(strMov, width, height, strAlign, innersource) {

	var strObject;

	strObject =		"<embed src='" +strMov + "' width=" + width + " height=" + height + " wmode=window>"

	if(strAlign == "top")
		opener.iFrmContent.document.body.innerHTML = strObject + "<br><br>" + innersource;
	else
		opener.iFrmContent.document.body.innerHTML = innersource + strObject + "<br><br>";
}

function GnxFlashActivate ( strFlashUrl , n4Witdh , n4Height , strWmode , strId , strClassName , strFlashvar ) {

	if (n4Witdh != 0) {
		objSize_attribute = " width='"+ n4Witdh +"' height='"+ n4Height +"'";
	} else {
		objSize_attribute = "";
	}

	if (strId != 0) {
		objId_attribute = " id='" + strId + "'";
		objId_IE_attribute = " id='" + strId + "'";
	} else {
		objId_attribute = "";
		objId_IE_attribute = "";
	}

	if (strClassName != 0) {
		className_attribute = " class='" + strClassName + "'";
	} else {
		className_attribute = "";
	}

	if (strWmode != 0) {
		wmode_param = "<param name='wmode' value='" + strWmode + "' />";
		wmode_attribute = " wmode='" + strWmode + "'";
	} else {
		wmode_param = "";
		wmode_attribute = "";
	}

	if (strFlashvar != 0) {
		Flashvar_param = "<param name='flashvars' value='" + strFlashvar + "' />";
		Flashvar_attribute = " Flashvars='" + strFlashvar + "'";
	} else {
		Flashvar_param = "";
		Flashvar_attribute = "";
	}

	document.writeln( "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' " + objSize_attribute + objId_IE_attribute + className_attribute + ">" );
	document.writeln( "<param name='movie' value='"+ strFlashUrl +"' />" );
	document.writeln( "<param name='quality' value='high' />" );
	document.writeln( "<param name='menu' value='0' />" );
	document.writeln( "<param name='allowScriptAccess' value='always' />" );
	document.writeln( "<param name='allowFullScreen' value='true' />" );
	document.writeln( wmode_param );
	document.writeln( Flashvar_param );
	document.writeln( "<!-- Hixie method -->" );
	document.writeln( "<!--[if !IE]> <-->" );
	document.writeln( "<object type='application/x-shockwave-flash' allowScriptAccess='always' data='"+ strFlashUrl +"'" + Flashvar_attribute + objSize_attribute + objId_attribute + wmode_attribute + className_attribute + "></object>" );
	document.writeln( "<!--> <![endif]-->" );
	document.writeln( "</object>" );
}

//Çä½½¸® : ´õ µð½ºÅäÇÇ¾Æ Æ¼Àú
function fnEmbedDystopia(strParamPath,intWidth,intHight,strFlashvar){
	var strObject;
	strObject =	"<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" + intWidth + "\" height=\"" + intHight + "\"  id=\"Dystopia\" />" +
					"<param name=\"allowScriptAccess\" value=\"always\" />" +
					"<param name=\"movie\" value=\"" + strParamPath + "\" />" +
					"<param name=\"quality\" value=\"high\"/>" +
					"<param name=\"bgcolor\" value=\"#000000\" />" +
					"<param name=\"menu\" value=\"false\" />" +
					"<param name=\"wmode\" value=\"transparent\" />" +
					"<param name=\"flashvars\" value=\"" + strFlashvar + "\" />" +
					"<param name=\"base\" value=\"" + strImageDir + "Dystopia/Swf/\" />" +
					"<embed src=\"" + strParamPath + "\" quality=\"high\" wmode=\"transparent\" flashvars=\"" + strFlashvar + "\" base=\"" + strImageDir + "Dystopia/Swf/\" bgcolor=\"#000000\" width=\"" + intWidth + "\" height=\"" + intHight + "\" name=\"Dystopia\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />" +
				"</object>"
	fnWrite(strObject);
}

//¼¼°è°ü ÇÃ·¡½Ã¿¡¼­ ½ºÅ©·ÑÀÌ ¾ÈµÇ´Â Çö»ó ÆÐÄ¡_2008.04.25
function scrollPage(delta){
	if(delta > 0){
		window.scrollBy(0,-50);
	}	
	else{
		window.scrollBy(0,50);
	}
}

//Åõ¸í PNG ÀÌ¹ÌÁö IEÆÐÄ¡
function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}

//°Ô½Ã¹° view ´ñ±Û
var lastLayer ="";
function showMenu(name,img){
	
	if(document.getElementById(name).style.display != "none"){
		img.src = "/IMG/board/btn_re_open.gif";
		document.getElementById(name).style.display = "none"
	}
	else{
		img.src = "/IMG/board/btn_re_close.gif";
		document.getElementById(name).style.display = ""
		if(lastLayer != "" && name != lastLayer){
			document.getElementById(lastLayer).style.display = "none";
		}
		lastLayer = name;
	}
}

//¿î¿µÁ¤Ã¥
var lastLayer ="";
function showprivacy(name){
	
	if(document.getElementById(name).style.display != "none"){
		document.getElementById(name).style.display = "none"
	}
	else{
		document.getElementById(name).style.display = ""
		if(lastLayer != "" && name != lastLayer){
			document.getElementById(lastLayer).style.display = "none";
		}
		lastLayer = name;
	}
}

// ÀÏ¹ÝÀûÀÎ ÆË¾÷ ÁÂ¿ì °¡¿îµ¥
function PgPopUp(IntWidth, IntHeight, StrUrl)
{
    var IntW = (screen.width-IntWidth)/2;
    var IntH = (screen.height-IntHeight)/2;

    var oWin = window.open(StrUrl,"PopUp","toolbar=no,menubar=no,resizable=no,width="+IntWidth+",height="+IntHeight+",left="+IntW+",top="+IntH+",scrollbars=0");
    oWin.focus(true);
}

var fm_all = null;
var div = null;
var imgdiv = null;
var fm = null;

function coverScreen(strDivSrc){
	var h = parseInt(document.documentElement.scrollHeight )+ "px" ;
	var w = parseInt(document.body.offsetWidth) +"px" ;

	div = document.createElement("iframe");
	div.className = "dvclass";
	div.style.top = "0px";
	div.style.left = "0px";
	div.style.width = w;
	div.style.height = h;
	div.style.position = "absolute";
	div.style.zIndex = 100;
	div.style.display = "none";
	div.frameBorder = "0";
	div.style.margin = "0";
	div.src = strDivSrc;

	document.body.appendChild( div );

	document.body.onresize = document.body.onresizestart = document.body.onresizeend = document.body.onscroll = function(){
		div.style.top = "0px";
		div.style.left = "0px";
		div.style.width = parseInt(document.body.offsetWidth) + 'px';
		div.style.height = parseInt(document.documentElement.scrollHeight)+"px" ;
		imgdiv.style.left = ( parseInt( document.documentElement.clientWidth ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	}

	imgdiv =  document.createElement("div");
	imgdiv.style.width = 400;
	imgdiv.style.height = 400;
	imgdiv.style.left = ( parseInt( div.style.width ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	//imgdiv.style.top = ( parseInt( document.body.scrollHeight ) / 2 ) - ( parseInt( imgdiv.style.height ) / 2 ) + 'px';
	imgdiv.style.top = ( parseInt( document.documentElement.clientHeight ) / 2 ) - ( parseInt( imgdiv.style.height ) / 2 ) + 'px';
	imgdiv.style.position = "absolute";
	imgdiv.style.zIndex = 101;
	imgdiv.style.display = "none";
	imgdiv.style.backgroundColor = "transparent";
	imgdiv.style.color = "#FFFFFF";
	document.body.appendChild( imgdiv );

	fm = document.createElement("iframe");
	fm.id = "iframe_pop";
	fm.style.width = "100%";
	fm.style.height = "100%";
	fm.allowTransparency = "true";
	fm.style.backgroundColor = "transparent";
	fm.frameBorder = "0";
	fm.style.margin = "0";
	imgdiv.appendChild( fm );
}

function showImg(_w , _h , _src){
	if(div == null){
		 coverScreen("/Common/back.htm");
	 }
	imgdiv.style.width = _w + 'px';
	imgdiv.style.height = _h + 'px';
	imgdiv.style.left = ( parseInt( document.documentElement.clientWidth ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	imgdiv.style.top = ((parseInt( document.documentElement.clientHeight ) / 2 ) + ( parseInt( document.documentElement.scrollTop ))) - (parseInt(_h)/2) + 'px';

	fm.src = _src;
	div.style.display = "block";
	imgdiv.style.display = "block";
}

function showImg2(_w, _h, _src){
	if(div == null){
		 coverScreen("/Common/back2.htm");
	 }
	imgdiv.style.width = _w + 'px';
	imgdiv.style.height = _h + 'px';
	imgdiv.style.left = ( parseInt( document.documentElement.clientWidth ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	imgdiv.style.top = ((parseInt( document.documentElement.clientHeight ) / 2 ) + ( parseInt( document.documentElement.scrollTop ))) - (parseInt(_h)/2) + 'px';

	fm.src = _src;
	div.style.display = "block";
	imgdiv.style.display = "block";
}

function hideImg(){
	div.style.display = "none";
	imgdiv.style.display = "none";
	fm.src = "";
}

function fnShowImg( _src ){
	if( div == null ){
		 coverScreen("/Common/back.htm");
	 }

	fm.src = "/Common/imageView.asp?src=" + _src;
	//fm.src = "/Common/popimageView.asp?src=" + _src;

	div.style.display = "block";
	imgdiv.style.display = "block";

	div.onclick = function(){
		hideImg();
	}
}
	
function fnMoveImg(_w , _h)
{
	fm.style.width = ( parseInt( _w, 10) + parseInt( parseInt( _w, 10) * 0.01, 10) );
	fm.style.height = parseInt( _h, 10);
	imgdiv.style.width = ( parseInt( _w, 10) + parseInt( parseInt( _w, 10) * 0.01, 10) );
	imgdiv.style.height = ( parseInt( _h, 10) + parseInt( parseInt( _h, 10) * 0.01, 10) );
	imgdiv.style.left = ( parseInt( document.body.scrollWidth, 10 ) - parseInt( imgdiv.style.width, 10 ) ) / 2 +"px";

	if( (( parseInt( document.body.clientHeight, 10 ) / 2 ) - ( parseInt( _h , 10 ) / 2 )) < 0 ) 
		imgdiv.style.top = 50+"px";
	else
		imgdiv.style.top = ( parseInt( document.body.clientHeight, 10 ) / 2 ) - ( parseInt( _h , 10 ) / 2 ) +"px";

}

//¸ÞÀÎ ÅÇ ¸®½ºÆ®
function show_layer(obj, n, v) //show_layer(id, °¹¼ö, º¸¿©ÁÙ·¹ÀÌ¾î)
{
	for (var i=1; i<=n; i++)
	{
		if (i == v) {
			document.getElementById(obj+i).style.display = '';
		}
		else {
			document.getElementById(obj+i).style.display = 'none';
		}
	}
}

// scrolling layer
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + 'px';
	}, 30)
}
