function VersionCheck(){
	if(navigator.userAgent.indexOf('MSIE 5.') != -1) return 1;
	if(navigator.userAgent.indexOf('MSIE 6.') != -1) return 2;
	if(navigator.userAgent.indexOf('MSIE 7.') != -1) return 3;
	return 0;
}

function flash(c,d,e,rtn) {
	var rtnVal = undefined;
	 var flash_tag = "";
	 flash_tag = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+c+'" HEIGHT="'+d+'" id="flashMovie">';
	 flash_tag +='<param name="movie" id="movie" value="'+e+'">';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<param name="wmode" value="transparent">';  //플래시 배경 투명 설정
	 flash_tag +='<embed src="'+e+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+c+'" HEIGHT="'+d+'"></embed></object>'

	 if (rtnVal == rtn){
		document.write (flash_tag);
	 }else{
		return flash_tag;
	 }
}

function setFlash(src,rtn){
	var innerObj = document.all.MovieBox;
	var obj = flash("630","353",src,rtn);
	if (obj != undefined){
		innerObj.innerHTML = obj;
	}
	return;	
}

function setImage(obj, src){
	var innerObj = document.all.MovieBox;
		innerObj.innerHTML = "<img src='"+src+"' border='0' alt='사진'>";
		var obj_ = eval("document.all."+obj);
}
function menuChg(obj,val,id){
	var str = obj.src;
	var wSrc = "../images/menu/";
	var cssObj = eval("document.all."+id);

	if (obj.className != "selected"){
		if (val == "over"){
			var start = str.lastIndexOf("/")+1;
			var end   = str.lastIndexOf("." )  ;
			if (end==-1) end = str.length;
			var filename = str.substring(start,end);		
			var filename = filename.replace("_r","");

			obj.src=wSrc+filename+"_r"+".gif";
			cssObj.style.background="url('../images/menu/left_menu_simbol_01.gif') no-repeat right";
		}else{
			var filename = str.replace("_r.",".");
			obj.src=filename;
			cssObj.style.background="";
		}
	}

}

// 팝업윈도우	함수(원하는	크기로 툴바없이	화면 가운데	띄우기)
function openWindow(vWidth,	vHeight, vUrl, vOpt) {
	var	mdWindow = null;
	var	x	=	(screen.width	-	vWidth)/2;
	var	y	=	(screen.height - vHeight)/2;
	var	opt;
	if (vOpt ==	"" ||	vOpt ==	null)	vOpt = 0;
	opt	=			"width=" + vWidth	+	",height=" + vHeight;
	opt	=	opt	+	",scrollbars=" + vOpt	+	",toolbar=0,menubars=0,locationbar=0,historybar=0,statusbar=0";
	opt	=	opt	+	",outerWidth=" + vWidth	+	",outerHeight="	+	vHeight	+	",resizable=0";
	opt	=	opt	+	",left=" + x + ",top=" + y;
	opt	=	opt	+	",channelmode=no,	titlebar=no";
	var	mdWindow = window.open(vUrl, "", opt,	false);
}
// 팝업창닫기
function ClosePop()
{
//	opener.ClearFrmIDVal();
//	window.close();
	self.close();
}

function initSubmenu(chkobj){
	var obj;
	var chkobj_  = eval("document.all."+chkobj);
	for (var i = 1; i <=3;  i ++){
		obj= eval("document.all.menu_0"+i+"_sub");
		if (VersionCheck() != 3 ){
			obj_= eval("document.all.menu_0"+i);
			obj_.style.marginBottom = "11px";
		}
		if ("menu_0"+i+"_sub" == chkobj){
			obj.style.display="block";
				obj= eval("document.all.menu_0"+i+"_line");
				obj.style.marginBottom = "0";
		}else{
			obj.style.display="none";
				obj= eval("document.all.menu_0"+i+"_line");
				obj.style.marginBottom = "11px";
		}

	}
}

function showSubmenu(obj){
	var after = obj;
	
	initSubmenu(); //초기화
	obj_ =	eval("document.all."+obj+"_sub");

	obj_.style.display="block";
	obj= eval("document.all."+obj+"_line");
	obj.style.marginBottom = "0";
}

function showSubmenuOut(obj,status){

}

//topLink
function goLink( code1, code2 ) {
	var sUrl = "";
	if ( code1 == "01" ) {
		sUrl = "intro.jsp?sScndCode="+ code2;
	} else if ( code1 == "02" ) {
		sUrl = "world.jsp?sScndCode="+ code2;
	} else if ( code1 == "03" ) {
		sUrl = "experience.jsp?sScndCode="+ code2;
	} else if ( code1 == "04" ) {
		sUrl = "mokpan.jsp?sScndCode="+ code2;
	} else if ( code1 == "05" ) {
		sUrl = "trib.jsp?sScndCode="+ code2;
	} else if ( code1 == "06" ) {
		sUrl = "news.jsp?sScndCode="+ code2;
	}
	location.href= "/jsp/"+ sUrl;
}

var sDomain = "http://multi.koreastudy.or.kr";
//목판인쇄체험
function mokpan() {
	var height = screen.height;
	var width = screen.width;
	var leftpos = 255;
	var toppos = height / 2 - 240;
	sUrl = sDomain +"/Data/swf/mokpan/mokpan.htm";

	var tmpstr = "width=720,height=480,scrollbars=no,left="+ leftpos +",top="+ toppos;
	var mmData_mokpan = window.open(sUrl,"",tmpstr);
	mmData_mokpan.focus();
}
//10만 목판
function ten_man() {
	var height = screen.height;
	var width = screen.width;
	var leftpos = 255;
	var toppos = height / 2 - 240;
	sUrl = sDomain +"/Data/swf/mokpan/10man.htm";

	var tmpstr = "width=720,height=480,scrollbars=no,left="+ leftpos +",top="+ toppos;
	var mmData_man = window.open(sUrl,"",tmpstr);
	mmData_man.focus();
}
//유물뷰어 보기
function relcView(RelcCode, DataType) {
	var height = screen.height;
	var width = screen.width;
	var leftpos = width / 2 - 320;
	var toppos = height / 2 - 380;

	if (parseInt(DataType) == 10) {
		sUrl = sDomain +"/viewer/relcDtlView2.jsp?sRelcCode="+ RelcCode;
		window.open(sUrl, '', 'width=640, height=720, scrollbars=no, status=yes');
	} else if (parseInt(DataType) > 11) {
		sUrl = sDomain +"/viewer/viewerSelect.jsp?sRelcCode="+ RelcCode;
		window.open(sUrl, '', 'width=640, height=630, scrollbars=no, status=yes');
	} else if (parseInt(DataType) > 6) {
		sUrl = sDomain +"/viewer/relcDtlView2.jsp?sRelcCode="+ RelcCode;
		window.open(sUrl, '', 'width=640, height=660, scrollbars=no, status=yes');
	} else {
		sUrl = sDomain +"/viewer/relcDtlView.jsp?sRelcCode="+ RelcCode;
		window.open(sUrl, '', 'width=700, height=720, scrollbars=yes');
	}
}

getObject = function( objectId ) {
	if (typeof objectId == 'string') {
		if(document.getElementById && document.getElementById(objectId))
			return document.getElementById(objectId);
		else if (document.all && document.all(objectId))
			return document.all(objectId);
		else if (document.layers && document.layers[objectId])
			return document.layers[objectId];
		else
			return false;
	} else return objectId;
}

getClientWidth = function() {
	if ( navigator.appName.indexOf("Microsoft") != -1 )
		return ( (document.documentElement.offsetWidth || document.body.offsetWidth) - 20 );
	if ( parseInt(navigator.appVersion) > 3 )
		return ( window.innerWidth );
}

getClientHeight = function() {
	if ( navigator.appName.indexOf("Microsoft") != -1 )
		return ( (document.documentElement.offsetHeight || document.body.offsetHeight) - 20 );
	if ( parseInt(navigator.appVersion) > 3 )
		return ( window.innerHeight-10 );
}

getStyle = function(el, property) {
	var value = null;
	var dv = document.defaultView;

	el = getObject(el);

	if (property == 'opacity' && el.filters) {// IE opacity
		value = 1;
		try {
			value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
		} catch(e) {
			try {
				value = el.filters.item('alpha').opacity / 100;
			} catch(e) {}
		}
	} else if (el.style[property]) {
		value = el.style[property];
	} else if (el.currentStyle && el.currentStyle[property]) {
		value = el.currentStyle[property];
	} else if ( dv && dv.getComputedStyle ) {  // convert camelCase to hyphen-case
		var converted = '';
		for(i = 0, len = property.length;i < len; ++i) {
			if (property.charAt(i) == property.charAt(i).toUpperCase()) {
				converted = converted + '-' + property.charAt(i).toLowerCase();
			} else {
				converted = converted + property.charAt(i);
			}
		}

		if (dv.getComputedStyle(el, '').getPropertyValue(converted)) {
			value = dv.getComputedStyle(el, '').getPropertyValue(converted);
		}
	}
	return value;
};

setStyle = function(el, property, val) {
	var el = getObject(el);
	switch(property) {
		case 'opacity' :
			if (el.filters) {
				el.style.filter = 'alpha(opacity=' + val * 100 + ')';
				if (!el.currentStyle.hasLayout)
					el.style.zoom = 1;
			} else {
				el.style.opacity = val;
				el.style['-moz-opacity'] = val;
				el.style['-khtml-opacity'] = val;
			}
			break;
		default :
			el.style[property] = val;
	}
}

