﻿// for onload event
function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
    }
    else {
        elm['on' + evType] = fn;
    }
}

// Flash publishing with Cross Browsing
function swfprint(furl,fwidth,fheight,transoption, Id) {
	if (Id) {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle" id="'+Id+'">');
	} else {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
	}
	document.write('<param name="movie" value="'+ furl +'"/>');
	document.write('<param name="allowScriptAccess" value="always"/>');	//sameDomain
//	document.write('<param name="allowFullScreen" value="false"/>');
//	document.write('<param name="quality" value="high"/>');
	if (transoption == "t") {
		document.write('<param name="wmode" value="transparent"/>');
	} else if (transoption == "o") {
		document.write('<param name="wmode" value="opaque"/>');
	}
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<object type="application/x-shockwave-flash" allowScriptAccess="always" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
	if (transoption == "t") {
		document.write(' wmode="transparent"');
	} else if (transoption == "o") {
		document.write(' wmode="opaque"');
	}
	if (Id) {
		document.write(' id="'+Id+'"');
	}
	document.write('></object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}


// Embeded function image Over
function menuOver() {
	if (!!this.original && navigator.userAgent.indexOf("MSIE 6.")>=0  && document.all) {
		this.original = this.original.replace("_off.gif", "_on.gif");
		this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ this.original +"',sizingMethod='image');"
	} else {
		this.src = this.src.replace("_off.gif", "_on.gif");
	}
}

function menuOut() {
	if (!!this.original && navigator.userAgent.indexOf("MSIE 6.")>=0  && document.all) {
		this.original = this.original.replace("_on.gif", "_off.gif");
		this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ this.original +"',sizingMethod='image');"
	} else {
		this.src = this.src.replace("_on.gif", "_off.gif");
	}
}

// Tabbed menu
function initTabMenu(menuElId) {
	var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");
	if(tabMenu.length > 0){
		for(i=0; i<tabMenu.length; i++) {
			thismenu = tabMenu.item(i);
			thismenu.menuContainer = document.getElementById(menuElId);
			thismenu.targetEl = document.getElementById(tabMenu.item(i).href.split("#")[1]);
			thismenu.targetEl.style.display = "none";
			if(thismenu.getElementsByTagName("img").length>0)	{
				thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
				thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
			}
			thismenu.onclick = tabMenuClick;
		}
		initmenu = tabMenu.item(0);
		initmenu.menuContainer = document.getElementById(menuElId);
		initmenu.targetEl = document.getElementById(initmenu.href.split("#")[1]);
		initmenu.targetEl.style.display = "block";
		initmenu.className = "activate";
		if(initmenu.getElementsByTagName("img").length>0)	{
			initmenu.getElementsByTagName("img").item(0).onmouseover();
			initmenu.getElementsByTagName("img").item(0).onmouseover = null;
			initmenu.getElementsByTagName("img").item(0).onmouseout = null;
		}
		initmenu.menuContainer.current = initmenu;
	}
}
function tabMenuClick() {
	currentmenu = this.menuContainer.current;
	if (currentmenu != this) {
		currentmenu.targetEl.style.display = "none";
		currentmenu.className = null;
		if(currentmenu.getElementsByTagName("img").length>0)	{
			currentmenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
			currentmenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
			currentmenu.getElementsByTagName("img").item(0).onmouseout();
		}
		this.targetEl.style.display = "block";
		this.className = "activate";
		if(this.getElementsByTagName("img").length>0)	{
			this.getElementsByTagName("img").item(0).onmouseover = null;
			this.getElementsByTagName("img").item(0).onmouseout = null;
		}
		this.menuContainer.current = this;
	}
	return false;
}

//
function initTabMenuClick(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", "_off.gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "off");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace("_off.gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}


function setPNG24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/bPNG24b/i,'');
    obj.original = obj.src;
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}


function PngImgSet(containerID) {
	imageAll = document.getElementsByTagName("img");
	for (i=0; i<imageAll.length; i++ ) {
		var imgType = imageAll[i].src;
		if (imgType.indexOf(".png") != -1) {
			imageAll[i].className += " png24";
		}
	}
}

function correctPNG () {
	if (navigator.userAgent.indexOf("MSIE 6.")>=0  && document.all) {
		var objImages = document.images;

		for (var i=0; i<objImages.length; i++) {
			if (objImages[i].src.indexOf('.png') != -1) {
				setPNG24(objImages[i]);
			}
		}
	}
}

// onload event
addEvent(window,'load',function () {PngImgSet();},false);

// 동영상 버튼
function StartMediaUp ()
{
  //document.getElementById('player').url = "preludesteel.wma";
  document.getElementById('player').controls.play();
}

function ShutMediaDown ()
{
  document.getElementById('player').controls.stop();
}

function ShutMediaPause ()
{
  document.getElementById('player').controls.pause();
}

function ShutMediaChange(url) 
{
	ShutMediaDown ();
	document.getElementById('player').url = url;
	StartMediaUp ();
}

// 이미지뷰어에 사진을 클릭을 햇을때 동영상 플레이어를 숨김
function objmediahidden(){
	//alert("aaa");
	if (document.getElementById("player")) {
		ShutMediaDown();
		document.getElementById("player").style.display = "none";
		if (document.getElementById("hiddenplayer")) {
			document.getElementById("hiddenplayer").style.display = "block";
		}
	}
}

// 이미지 뷰어에 닫기 버튼을 클릭을 했을때 동영상 플레이어를 보임
function objmediashow(){
	//alert("bbb");
	if (document.getElementById("player")) {
		if (document.getElementById("hiddenplayer")) {
			document.getElementById("hiddenplayer").style.display = "none";
		}
		document.getElementById("player").style.display = "block";
		StartMediaUp();
	}
}
