// Å¬¶óÀÌ¾ðÆ® ºê¶ó¿ìÀú Ã¼Å©
var mlEvent = null;
var hvEvent = null;
var IE,IE5,IE6,IE7,IE8,FF,OP,SF,NA = 0;
var tApp = navigator.userAgent.toLowerCase();
var CKEDITOR = null;
if (tApp.indexOf('msie') > -1) {
	IE = 1;
	if (tApp.indexOf('msie 5') > -1) IE5 = 1;
	else if (tApp.indexOf('msie 6') > -1) IE6 = 1;
	else if (tApp.indexOf('msie 7') > -1) IE7 = 1;
	else if (tApp.indexOf('msie 8') > -1) IE8 = 1;
	else IE = 1;
}
else if (tApp.indexOf('firefox') > -1) FF = 1;
else if (tApp.indexOf('opera') > -1) OP = 1;
else if (tApp.indexOf('safari') > -1) SF = 1;
else NA = 1;

var elmBy = function(id, num, obj) {
	id = id || 0;
	num = num || null;
	obj = obj || document;

	if (num == null) result = obj.getElementById(id);
	else result = obj.getElementsByName(id)[num];

	return result;
}

var elmNames = function(id, obj) {
	id = id || 0;
	obj = obj || document;

	return obj.getElementsByName(id);
}

var elmFormItem = function (formName, elmName, num, obj) {
	obj = obj || document;
	elmName = elmName || null;
	num = num || false;
	result = null;

	if (elmName == null) {
		result = obj.forms[formName];
	}
	else {
		if (num != false) {
			result = obj.forms[formName].elements[elmName][num];
		}
		else {
			result = obj.forms[formName].elements[elmName];
		}
	}

	return result;
}

var byTagName = function(name, num, flag, obj) {
	num = num || 0;
	flag = flag || null;
	obj = obj || document;

	if (flag == 'all') result = obj.getElementsByTagName(name);
	else if (flag == null || flag == 'undefined') result = obj.getElementsByTagName(name)[num];
	else result = null;

	return result;
}

var byTagAttr = function(name, attrName, attrValue, obj) {
	obj = obj || document;
	list = byTagName(name,0,'all',obj);
	if (!list) return;

	len = list.length;
	result = null;

	for (i=0; i<len; i++) {
		if (list[i].getAttribute(attrName) == attrValue) result = list[i];
	}

	return result;
}

// ÀÌº¥Æ® ¸®½º³Ê
function addEvent(obj, evt, callback, flag) {
	flag = flag || false;
	evt = evt.toLowerCase();

	if (obj.addEventListener) {
		obj.addEventListener(evt, eval(callback), flag);
	}
	else if (obj.attachEvent) {
		obj.attachEvent('on' + evt, eval(callback));
	}
	else {
		try {
			fn = 'obj.on'+evt+'=callback';
			eval(fn);
		}
		catch(error) {}
	}
}

// ÀÌº¥Æ® ¸®¹«¹ö
function removeEvent(obj, evt, callback, flag) {
	flag = flag || false;
	evt = evt.toLowerCase();

	if(obj.removeEventListener) {
		obj.removeEventListener(evt, eval(callback), flag);
	}
	else if (obj.detachEvent) {
		obj.detachEvent('on' + evt, eval(callback));
	}
	else {
		try {
			fn = 'obj.on'+evt+'=null';
			eval(fn);
		}
		catch(error) {}
	}
}

// ÀÌº¥Æ®
function Event(evt) {
	var e = evt || window.event;
	if(!e) return;

	if(e.type) this.type = e.type.toLowerCase();

	if(e.target) {
		this.target = e.target;
	}
	else if(e.srcElement) {
		this.target = e.srcElement;		// IE
	}
	else this.target = null;

	this.cX = e.clientX;
	this.cY = e.clientY;
}

// Å¬¸¯ À§Ä¡ ±¸ÇÏ±â
function getClickPos(cw, ch, ow, oh) {
	// Å¬¸¯ÇÑ °³Ã¼ÀÇ »çÀÌÁî
	objW = parseInt(ow);
	objH = parseInt(oh);
	body = document.body;
	marginX = body.clientWidth - (cw + objW);
	marginY = body.clientHeight - (ch + objH);

	if (marginX < 0) {
		posLeft = cw + body.scrollLeft + marginX;
	}
	else {
		posLeft = cw + body.scrollLeft;
	}

	if (marginY < 0) {
		posTop = ch + bocy.scrollTop + marginY + 20;
	}
	else {
		posTop = ch + body.scrollTop;
	}

	this.posLeft = posLeft - 10;
	this.posTop = posTop - 5;

	return this;
}

function searchParentNodes(obj, matchId) {
	var pNode = obj.parentNode || null;
	var result = null;

	if (pNode) {
		if (pNode.id == matchId) {
			result = true;
		}
		else {
			result = searchParentNodes(pNode, matchId);
		}
	}

	return result;
}

// ¿¤¸®¸ÕÆ® º¸ÀÌ±â/°¨Ãß±â (¿µ¿ª Â÷ÁöX)
function visibilityLayer(obj) {
	if (!obj.style.visibility || obj.style.visibility == 'hidden') {
		obj.style.visibility = 'visible';
	}
	else {
		obj.style.visibility = 'hidden';
	}
}

// ¿¤¸®¸ÕÆ® º¸ÀÌ±â/°¨Ãß±â (¿µ¿ª Â÷ÁöO)
function displayLayer(obj, option) {
	var option = option || 'block';

	if (!obj.style.display || obj.style.display == 'none') {
		obj.style.display = option;
	}
	else {
		obj.style.display = 'none';
	}
}

// ¿µ¿ª ±³Ã¼
function exchangeArea(thisObj, newObj) {
	if (!thisObj.style.display || thisObj.style.display != 'none') {
		thisObj.style.display = 'none';
		newObj.style.display = 'block';
	}
	else {
		thisObj.style.display = 'block';
		newObj.style.display = 'none';
	}
}

// ¿¤¸®¸ÕÆ® »ý¼º
function createElm(tagName, attrs) {
	var attrs = attrs || 0;
	var elm = null;

	if (document.createElement) {
		elm = document.createElement(tagName);
		if (attrs != 0) {
			var len = attrs.length;
			for (i=0; i<len; i++) {
				elm.setAttribute(attrs[i].attr, attrs[i].val);
			}
		}
	}
	return elm;
}


function addTag(tag, pObj, attrs, obj) {
	attrs = attrs || null;
	obj = obj || document;
	var createTag = null;

	if (obj.createElement) {
		try {
			createTag  = obj.createElement(tag);
			if (attrs != null) {
				var num = attrs.length;
				for (var i=0; i<num; i++) {
					createTag.setAttribute(attrs[i][0], attrs[i][1]);
				}
				pObj.appendChild(createTag);
			}
		}
		catch(error) {}
	}
	return createTag;
}

// ½ºÅ¸ÀÏ½ÃÆ® ·Îµå
function loadStylesheet(path, obj) {
	obj = obj || document;
	var attr = new Array();
		attr.push(['rel', 'stylesheet']);
		attr.push(['href', path]);

	return addTag('link', byTagName('head', 0, null, obj), attr, obj);
}

function loadJavascript(path, obj) {
	obj = obj || document;
	var attr = new Array();
		attr.push(['type', 'text/javascript']);
		attr.push(['src', path]);

	return addTag('javascript', byTagName('head', 0, null, obj), attr, obj);
}

// ¿¤¸®¸ÕÆ® ¹è°æ»ö»ó º¯°æ (mouseover/out)
function hoverOn(obj, option, tColor, oColor) {
	if(!obj) return;

	tColor = tColor || '#efefef';
	oColor = oColor || '#ffffff';

	if (option == 'on') {
		obj.style.backgroundColor = tColor;
	}
	else if (option == 'off') {
		obj.style.backgroundColor = oColor;
	}
}

// ¿¤¸®¸ÕÆ® º¸´õ º¯°æ (mouseover/out)
function hoverBorder(obj, option, tBorder, oBorder) {
	if(!obj) return;

	tBorder = tBorder || '1px solid #6f6f6f';
	oBorder = oBorder || 'none';

	if (option == 'on') {
		obj.style.border = tBorder;
	}
	else if (option == 'off') {
		obj.style.border = oBorder;
	}
}


function hoverImage(obj, oStr, tStr) {
	this.off = new Image();
	this.on = new Image();

	this.off.src = obj.src;
	this.on.src = obj.src.replace(oStr, tStr);
	return this;
}

// ÆË¾÷Ã¢ ¿­±â
function openPopup(url, title, w, h, option, left, top) {
	option = option || null;
	left = left || 0;
	top = top || 0;

	// ÇöÀç Ã¢ÀÇ À¯È¿ÇÑ ¿µ¿ª Å©±â ±¸ÇÏ±â
	if(screen.availWidth) sW = screen.availWidth;
	else sW = 0;
	if(screen.availHeight) sH = screen.availHeight;
	else sH = 0;

	// »õÃ¢ À§Ä¡
	if (sW > w) aL = (sW - w) / 2;
	else aL = 0;
	if (sH > h) aT = (sH - h) / 2;
	else aH = 0;

	opt = 'width='+w+',height='+h+',left='+aL+',top='+aT+','+option;
	return window.open(url,title,opt);
}

function printSwf(url, w, h) {
	html = '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="param" width="'+w+'" height="'+h+'">';
	html += '<param name="movie" value="'+url+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="bgcolor" value="#ffffff">';
	html += '<param name="menu" value="false">';
	html += '<param name=wmode value="transparent">';
	html += '<param name="swliveconnect" value="true">';
	html += '	<embed src="'+url+'" quality=high bgcolor="#ffffff" menu="false" width="'+w+'" height="'+h+'" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	html += '</object>';
	document.write(html);
}

function printoutMediaPlayer(url, w, h) {
	html = '<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="'+w+'" height="'+h+'">';
	html += '<param name="AllowChangeDisplaySize" value="true">';
	html += '<param name="AnimationAtStart" value="true">';
	html += '<param name="AutoSize" value="true">';
	html += '<param name="ClickToPlay" value="true">';
	html += '<param name="DisplaySize" value="2">';
	html += '<param name="EnableFullScreenControls" value="true">';
	html += '<param name="EnablePositionControls" value="true">';
	html += '<param name="ShowAudioControls" value="true">';
	html += '<param name="ShowControls" value="true">';
	html += '<param name="ShowPositionControls" value="true">';
	html += '<param name="ShowStatusBar" value="true">';
	html += '<param name="ShowTracker" value="true">';
	html += '<param name="Volume" value="2000">';
	html += '<param name="FileName" value="'+url+'">';
	html += '<embed src="'+url+'" width="'+w+'" height="'+h+'"></embed>';
	html += '</object>';
	document.write(html);
}

function printFlashMovie(url, w, h, comp) {
	comp = comp || null;
	var classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	var codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
	var beforeHtml = '';
	var lastHtml = '';
	var extraHtml = '';
	var etc = '';

	switch(comp) {
		case 'mgoon' :
			codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0';
			etc = 'id="' + url.substring(url.indexOf('V'), url.strlen) + '"';
			url = url + '/';
			break;
		case 'mncast' :
			beforeHtml = '<param name="wmode" value="transparent" />';
			lastHtml = '<embed src="'+url+'" width="'+w+'" height="'+h+'" wmode="transparent"></embed>';
			break;
		case 'utube' :
			beforeHtml = '<param name="wmode" value="transparent" />';
			lastHtml = '<embed src="'+url+'" type="application/x-shockwave-flash" wmode="transparent" width="'+w+'" height="'+h+'"></embed>';
			break;
		case 'pandora' :
			laseHtml = '<embed src="'+url+'" width="'+w+'" height="'+h+'" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="always" /></embed>';
			break;
		case 'tagstory' :
			codebase = '"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0';
			laseHtml = '<embed src="'+url+'" width="'+w+'" height="'+h+'" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="always" /></embed>';
			etc = 'id="' + url.substring(url.indexOf('V'), url.strlen) + '"';
			break;
		default :
			extraHtml = '<embed src="'+url+'" allowFullScreen="true" quality="high" bgcolor="#ffffff" width="'+w+'" height="'+h+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>';
			break;
	}
	html = '<object classid="'+classid+'" codebase="'+codebase+'" width="'+w+'" height="'+h+'" '+etc+'>';
	html += '<param name="allowScriptAccess" value="always" />';
	html += '<param name="allowFullScreen" value="true" />'
	html += '<param name="movie" value="'+url+'" />'
	html += '<param name="quality" value="high" />';
	html += '<param name="bgcolor" value="#ffffff" />';
	html += beforeHtml;
	html += lastHtml
	html += '</object>';

	if (extraHtml != '') {
		document.write(extraHtml);
	}
	else {
		document.write(html);
	}
}

function openImage(w, h, target) {
	var myWin = openPopup('','image',w,h,'resizable=yes');
	myWin.document.open();
	myWin.document.write("<html><head><title>¿øº» ÀÌ¹ÌÁö</title></head>");
	myWin.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
	myWin.document.write("<img src='"+target+"' style='cursor:pointer;' border='0' onclick='window.close()'>");
	myWin.document.write("</html></html>");
	myWin.document.close();
}

function mainContsMore(id) {
    o = elmBy(id);
    o.style.visibility = 'visible';
}

function mainContsClose(id) {
    o = elmBy(id);
    o.style.visibility = 'hidden';
}
