// MOUSE on/ff
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// 레이어에 사용
function Layers_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
	  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=Layers_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function Layers_showHideLayers() { //v3.0
	var i,p,v,obj,args=Layers_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=Layers_findObj(args[i]))!=null) { v=args[i+2];
	  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	  obj.visibility=v; }
}

//영문자와 숫자만 입력가능
function validate(field) {
var valid = "abcdefghijklmnopqrstuvwxyz0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("영문자와 숫자만 입력할 수 있습니다");
field.focus();
field.select();
   }
}

/********************************************************************************************************
	팝업
********************************************************************************************************/

function popup_form_print()
{
    window.open ("/common/popup_form_print.asp","","width=716,height=500,scrollbars=yes");
}

function popup_find_id()
{
    window.open ("/membership/popup_find_id.asp","","width=540,height=300,scrollbars=no");
}

function popup_find_pw()
{
    window.open ("/membership/popup_find_pw.asp","","width=540,height=300,scrollbars=no");
}

function popup_id_check()
{
    window.open ("/membership/popup_id_check.asp","","width=540,height=300,scrollbars=no");
}

function windowOpen(url, name, width, height, scr)
{
	window.open(url, name, "width="+width+"px,height="+height+"px,scrollbars="+ scr +",toolbar=0");
}


// JavaScript Document

<!-- png파일 배경 빼기 -->
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 ''; 
}

// flash(파일주소, 가로, 세로, 배경색, 윈도우모드, 변수, 경로)
function flash(url,w,h,bg,win,vars,base){
	var s=
	"<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='"+w+"' height='"+h+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='wmode' value='"+win+"' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<param name='base' value='"+base+"' />"+
	"<embed src='"+url+"' base='"+base+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	document.write(s);
}

<!-- onfocus -->
function bluring(){
 	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
	if(event.srcElement.tagName=="LI") document.body.focus();
 }
 document.onfocusin=bluring;
 
 // MOUSE on/ff
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// 레이어에 사용
function Layers_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
	  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=Layers_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function Layers_showHideLayers() { //v3.0
	var i,p,v,obj,args=Layers_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=Layers_findObj(args[i]))!=null) { v=args[i+2];
	  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	  obj.visibility=v; }
}

//주민등록번호 체크
function bsshChek(str_jumin1,str_jumin2)
{
	var resno = str_jumin1 + str_jumin2;
	var fmt = /^\d{6}[1234]\d{6}$/;
	if (!fmt.test(resno))
		return false;

	birthYear = parseInt(resno.charAt(6)) <= 2 ? "19" : "20";	//1900년대 : 1,2	2000년대 : 3,4
	birthYear += resno.substr(0, 2);
	birthMonth = resno.substr(2, 2) - 1;
	birthDate = resno.substr(4, 2);
	birth = new Date(birthYear, birthMonth, birthDate);
	if (birth.getFullYear() % 100 != resno.substr(0, 2) || birth.getMonth() != birthMonth || birth.getDate() != birthDate)
		return false;

	var sum = 0;
	for (i = 0; i < 12; i++) sum += parseInt(resno.charAt(i)) * (i%8 + 2);
	if ((11 - (sum % 11)) % 10 != resno.charAt(12))
		return false;

	return true;
}

//이메일선택
function selectMail(f) {
	var selMail = f.selectEmail.options[f.selectEmail.selectedIndex].value;
	if(selMail == "etc" || selMail == "") {
		document.getElementById("maildomain").value = "";
		document.getElementById("maildomain").focus();
	} else {
		document.getElementById("maildomain").value = selMail;
	}
}

//이메일체크
function isEmail(str)
{
	var supported = 0;
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

//숫자체크
function numCheck(Str)
{
	var Re=true;
	for(i=0;i<Str.length;i++)
	{
		var a=Str.charCodeAt(i);
		if(a<46 || a>57) Re=false;
	}
	return Re;
}

//영숫자체크
function txtCheck(Str)
{
	var Re=true;
	for(i=0;i<Str.length;i++)
	{
		var a=Str.charCodeAt(i);
		if ((a > 47 && a < 58) || (a > 64 && a < 91) || (a > 96 && a < 123))
		{
			Re=true;
		}else{
			Re=false;
		}
	}
	return Re;
}


//한글체크
function hanCheck(Str)
{
	var Re=false;
	for(i=0;i<Str.length;i++)
	{
		var a=Str.charCodeAt(i);
		if (a > 128)
		{
			Re=true;
		}else{
			Re=false;
		}
	}
	return Re;
}

//영어체크
function engCheck(Str)
{
	var Re=false;
	for(i=0;i<Str.length;i++)
	{
		var a=Str.charCodeAt(i);
		if ((a > 64 && a < 91) || (a > 96 && a < 123))
		{
			Re=true;
		}else{
			Re=false;
		}
	}
	return Re;
}

//연락처체크
function telCheck(Tel1, Tel2, Tel3){
	var Re=true;
	if(!numCheck(Tel1) ||!numCheck(Tel2) ||!numCheck(Tel3) )
		Re = false;
	else if(Tel1.length <2 || Tel1.length >3)
		Re = false;
	else if(Tel2.length <3 || Tel2.length >4)
		Re = false;
	else if(Tel3.length <4 || Tel3.length >4)
		Re = false;
	return Re;
}

//사업자 등록번호 체크
function saupChek(str_saup1,str_saup2,str_saup3)
{
	var Num = (str_saup1 + str_saup2 + str_saup3);

	if (Num.length < 1){
		//alert("사업자 등록번호를 입력하세요.");
		//theForm.num1.focus();
		return false;
	}
	if (isNaN(Num)){
		//alert("사업자 등록번호는 숫자만 입력하세요.");
		//theForm.num1.focus();
		return false;
	}

	var w_c, w_e, w_f, w_tot;

	w_c = Num.charAt(8) * 5;
    w_e = parseInt((w_c / 10), 10);
    w_f = w_c % 10;

    w_tot  = Num.charAt(0) * 1 + Num.charAt(1) * 3 + Num.charAt(2) * 7;
    w_tot += Num.charAt(3) * 1 + Num.charAt(4) * 3 + Num.charAt(5) * 7;
    w_tot += Num.charAt(6) * 1 + Num.charAt(7) * 3 + Num.charAt(9) * 1;
    w_tot += (w_e + w_f);

    if (!(w_tot % 10)){
		return true;
    }else{
		//alert("규칙에 맞지 않는 사업자 등록번호 입니다.");
		//theForm.num1.focus();
		return false;
    }
}

//기일입력
function cdateformchk(cdate){
	today=new Date();

	var ndate=new Date(cdate);
	var nday2=ndate.getDay();

	if( ndate <= today ){
		if(!confirm("날짜가 지났거나 오늘입니다. 그래도 입력하시겠습니까?")){
			return false;
		}
	}

	if(nday2==0){
		if(!confirm("처리기한이 일요일입니다. 그래도 입력하시겠습니까?")){
			return false;
		}
	}
	return true;
}

//파일 확장자 검사
extArray = new Array(".html",".htm",".php",".exe",".phtml",".inc",".cgi",".com",".asp",".jsp",".pl",".php3",".eff",".prc",".sh",".js",".css");
function LimitAttach(form, file, name)
{
	allowSubmit = true;
	if (!file) return;

	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);

	ext = file.slice(file.indexOf(".")).toLowerCase();

	for (var i = 0; i < extArray.length; i++)
	{
		if (extArray[i] == ext)
		{
			allowSubmit = false;
			break;
		}
	}

	if (allowSubmit)
	{
		return true;
	}
	else
	{
		alert("죄송합니다.\n\n업로드가 지원되지않는 파일형식 입니다. \n\n파일형식을 확인해보시고 새로 작성하여 주시기 바랍니다.");
		name.select();
		document.selection.clear();
		//document.getElementsByName("listfile").value = "";
		//faddFile();
		return false;
	}
}

//새창띄우기
function newwin(a,b,c){
	var objPopup =window.open(a,b,c);
	if (objPopup == null) {
		return alert("차단된 팝업창을 허용해 주십시오.");
	}
	objPopup.focus();
}

function _ID(obj){return document.getElementById(obj)}

/*** 레이어 팝업창 띄우기 ***/
function popupLayer(s,w,h)
{
	if (!w) w = 600;
	if (!h) h = 400;

	var pixelBorder = 3;
	var titleHeight = 12;
	w += pixelBorder * 2;
	h += pixelBorder * 2 + titleHeight;

	var bodyW = window.screen.availWidth; //document.body.clientWidth;
	var bodyH = window.screen.availHeight; //document.body.clientHeight;

	var posX = (bodyW - w) / 2;
	var posY = (bodyH - h) / 2;

	hiddenSelectBox('hidden');

	/*** 백그라운드 레이어 ***/
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = 0;
		top = 0;
		width = "100%";
		height = "100%";
		if (bodyH < document.body.scrollHeight) height = document.body.scrollHeight;
		backgroundColor = "#000000";
		filter = "Alpha(Opacity=50)";
		opacity = "0.5";
	}
	obj.id = "objPopupLayerBg";
	document.body.appendChild(obj);

	/*** 내용프레임 레이어 ***/
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = posX + document.body.scrollLeft;
		top = posY + document.body.scrollTop;
		width = w;
		height = h - 5;
		backgroundColor = "#ffffff";
		border = "5px solid #78b300";
	}
	obj.id = "objPopupLayer";
	document.body.appendChild(obj);

	/*** 타이틀바 레이어 ***/
	var bottom = document.createElement("div");
	with (bottom.style){
		position = "absolute";
		width = w;
		height = titleHeight;
		left = 0;
		top = h - titleHeight - pixelBorder * 3;
		padding = "4px 0 0 0";
		textAlign = "center";
		backgroundColor = "#78b300";
		color = "#ffffff";
		font = "bold 8pt tahoma; letter-spacing:0px";
		
	}
	bottom.innerHTML = "<a href='javascript:closeLayer()' class='white'>X close</a>";
	obj.appendChild(bottom);

	/*** 아이프레임 ***/
	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = w;
		height = h - pixelBorder * 2 - titleHeight - 3;
		//border = "3 solid #000000";
	}
	ifrm.frameBorder = 0;
	ifrm.src = s;
	//ifrm.className = "scroll";
	obj.appendChild(ifrm);
}

function closeLayer()
{
	hiddenSelectBox('visible');
	_ID('objPopupLayer').parentNode.removeChild( _ID('objPopupLayer') );
	_ID('objPopupLayerBg').parentNode.removeChild( _ID('objPopupLayerBg') );
}

function hiddenSelectBox(mode)
{
	var obj = document.getElementsByTagName('select');
	for (i=0;i<obj.length;i++){
		obj[i].style.visibility = mode;
	}
}

/**
 * Calendar Script
 * @usage	<input type=text onclick="calendar(event)">
 */

var now			= new Date();
var static_now	= new Date();
var week		= new Array("SUN","MON","TUE","WED","THU","FRI","SAT");
var weekNum		= new Array(1,2,3,4,5,6,7);

var tagNm		= "";
var thisObj		= "";
var eventElement= "";
var dy_calOpen	= "n";

function calendar(e)
{
	var event = e || window.event;
	if( !appname ){
		var appname = navigator.appName.charAt(0);
	}

	if( appname == "M" ){
		eventElement = event.srcElement;
		tagNm = eventElement.tagName;
	}else{
		eventElement = event.target;
		tagNm = eventElement.tagName;
	}

	var dy_x = event.clientX + document.body.scrollLeft;
	var dy_y = event.clientY + document.body.scrollTop;

	if( dy_calOpen == 'n' ){
		var NewElement = document.createElement("div");
		with (NewElement.style){
			position	= "absolute";
			left		= dy_x;
			top			= dy_y;
			width		= "205px";
			Height		= "170px";
			background	= "#ffffff";
			border		= "0px";
		}
		NewElement.id = "Dynamic_CalendarID";
		document.body.appendChild(NewElement);
		thisObj = NewElement;
		dy_calOpen = 'y';
	}else{
		thisObj.style.left	= dy_x;
		thisObj.style.top	= dy_y;
	}

	//달력 출력하기!!
	var calCont = calendarSet();
}

function calendarSet(val){

	var now_date	= new Date();

	var p;
	var z=0;

	switch(val){
		case 1:now.setFullYear(now.getFullYear()-1);break;
		case 2:now.setMonth(now.getMonth()-1);break;
		case 3:now.setMonth(now.getMonth()+1);break;
		case 4:now.setFullYear(now.getFullYear()+1);break;
		case 5:now=now_date;break;
	}

	var NowYear = now.getFullYear();
	var NowMonth = now.getMonth();
	var m_infoDate = NowYear+'/'+NowMonth;

	last_date = new Date(now.getFullYear(),now.getMonth()+1,1-1);	//해당월 마지막 일자
	first_date= new Date(now.getFullYear(),now.getMonth(),1);		//해당월 처음일자 요일

	var now_scY = now.getFullYear()+"";
	var calendar_area = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:4px #ffffff solid;\"><tr><td><table width=\"245\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"ffffff\" style=\"border:6px #78b300 solid;\"><tr height=\"26\" bgcolor=\"ffffff\" align=\"center\"><td style=\"padding-top:3px; padding-left:10px; \"> \n";
	calendar_area += "<div class=\"calendarTitleY\">";
	calendar_area += "<span onclick=\"calendarSet(1)\" class=\"pointer\">◀ </span>";
	calendar_area += now_scY;
	calendar_area += "<span onclick=\"calendarSet(4)\" class=\"pointer\"> ▶</span>";
	calendar_area += "</div> \n";
	calendar_area += "<div class=\"calendarTitleM\">";
	calendar_area += "<span onclick=\"calendarSet(2)\" class=\"pointer\">◀ </span>";
	calendar_area += (now.getMonth()+1) +"";
	calendar_area += "<span onclick=\"calendarSet(3)\" class=\"pointer\"> ▶</span>";
	calendar_area += "</div> \n";
	for(i=0;i<week.length;i++){
		if( weekNum[i] == 1 ) {
			calendar_area += "<div class=\"calendarWeekS\">"+week[i]+"</div> \n";
		} else if( weekNum[i] == 7 ) {
			calendar_area += "<div class=\"calendarWeekT\">"+week[i]+"</div> \n";
		} else {
			calendar_area += "<div class=\"calendarWeek\">"+week[i]+"</div> \n";
		}
	}

	calendar_area +="<div class=\"clearboth\"></div> \n";

	for(i=1;i<=first_date.getDay();i++){
		calendar_area+="<div class=\"calendarNoDay\">&nbsp;</div> \n";
	}

	z=(i-1);
	var clickDay;
	var weekCnt = 1;
	for (i=1;i<=last_date.getDate();i++){
		z++;
		p=z%7;
		var pmonth=now.getMonth()+1;
		if(i<10){var ii="0"+i;}else{var ii=i;}
		if(pmonth<10){pmonth="0"+pmonth;}

		clickDay = now.getFullYear() +''+ pmonth +''+ ii;

		// 날짜 출력
		if(i == now.getDate() && now.getFullYear()==static_now.getFullYear() && now.getMonth()==static_now.getMonth()){
			calendar_area += "<div class=\"calendarToDay\" onclick=\"calendarPrint('"+clickDay+"');\">"+ii+"</div> \n";
		}else if( p == 0 ){	//토요일
			calendar_area += "<div class=\"calendarDayT\" onclick=\"calendarPrint('"+clickDay+"');\">"+ii+"</div> \n";
		}else if( p == 1 ){	//일요일
			calendar_area += "<div class=\"calendarDayS\" onclick=\"calendarPrint('"+clickDay+"');\">"+ii+"</div> \n";
		}else{				//평일
			calendar_area += "<div class=\"calendarDay\" onclick=\"calendarPrint('"+clickDay+"');\">"+ii+"</div> \n";
		}
		if(p==0 && last_date.getDate() != i){
			calendar_area +="<div class=\"clearboth\"></div> \n";
			weekCnt++;
		}
	}

	if(p !=0){
		for(i=p;i<7;i++){
			calendar_area+="<div class=\"calendarNoDay\">&nbsp;</div> \n";
		}
	}

	var addtable1;
	var addtable2;
	if( weekCnt != 6){
		for(addtable1=weekCnt; addtable1 < 6; addtable1++){
			calendar_area +="<div class=\"clearboth\"></div> \n";
			for(addtable2=0; addtable2 < 7; addtable2++){
				calendar_area+="<div class=\"calendarNoDay\">&nbsp;</div> \n";
			}
		}
	}

	var nowDate	= now_date.getFullYear() + "-" + (100+( now_date.getMonth() + 1)).toString(10).substr(1) + "-" + (100+now_date.getDate()).toString(10).substr(1);

	calendar_area += "<div class=\"clearboth\"></div> \n";
	calendar_area += "<div class=\"calendarNow\" onclick=\"calendarSet(5)\" align=\"left\">Today : "+nowDate+" </div> \n";
	calendar_area += "<div class=\"calendarClose\" onclick=\"calendarClose();\" align=\"right\"><font class=ver8><b>X</b></font></div> \n";
	calendar_area += "</td></tr></table></td></tr></table> \n";

	thisObj.innerHTML = calendar_area;

}

function calendarClose()
{
	dy_calOpen = 'n';
	thisObj.parentNode.removeChild(thisObj);
}

function calendarPrint(date)
{
	if( tagNm == "INPUT" ) eventElement.value = date;
	else eventElement.innerHTML = date;
	calendarClose();
}

function calendar_get_objectTop(obj){
	if (obj.offsetParent == document.body) return obj.offsetTop;
	else return obj.offsetTop + get_objectTop(obj.offsetParent);
}

function calendar_get_objectLeft(obj){
	if (obj.offsetParent == document.body) return obj.offsetLeft;
	else return obj.offsetLeft + get_objectLeft(obj.offsetParent);
}

/*** onLoad 이벤트에 함수 할당 ***/
function addOnloadEvent(fnc)
{
	if ( typeof window.addEventListener != "undefined" )
		window.addEventListener( "load", fnc, false );
	else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", fnc );
	}
	else {
		if ( window.onload != null ) {
			var oldOnload = window.onload;
			window.onload = function ( e ) {
				oldOnload( e );
				window[fnc]();
			};
		}
		else window.onload = fnc;
	}
}

/**
 * extComma(x), extUncomma(x)
 *
 * 숫자 표시 (3자리마다 콤마찍기, 마이너스 및 소수점 유지)
 *
 * @Usage	var money = -1000.12;
 *			money = extComma(money);
 *			alert(money);	// -1,000.12
 *			alert(extUncomma(money));	// -1000.12
 */
function extComma(x){
	var head = '', tail = '', minus = '';
	if (x < 0){
		minus = '-';
		x = x * (-1) + "";
	}
    if ( x.indexOf(".") >= 0 ) {
        head = comma(x.substring ( 0 , x.indexOf(".") ));
        tail = uncomma(x.substring ( x.indexOf(".") + 1, x.length ));
    }
    else head = comma(x);
	x = minus + head;
    if ( tail.toString().length > 0 ) x += "." + tail;
	return x;
}

function extUncomma(x){
	var head = '', tail = '', minus = '';
	if (x < 0){
		minus = '-';
		x = x * (-1) + "";
	}
    if ( x.indexOf(".") >= 0 ) {
        head = uncomma(x.substring ( 0 , x.indexOf(".") ));
        tail = uncomma(x.substring ( x.indexOf(".") + 1, x.length ));
    }
    else head = uncomma(x);
	x = minus + head;
    if ( tail.toString().length > 0 ) x += "." + tail;
	return x;
}

function inArray( needle, haystack )
{
	for ( i = 0; i < haystack.length; i++ )
		if ( haystack[i] == needle ) return true;
	return false;
}

function inFocus1(i) {
	(i).style.border='2px solid #627dce';
}

function outFocus1(i) {
	(i).style.border='1px solid #cccccc';
}

/*** 포커스 테두리 넣기 ***/
function linecss(){
	var obj = document.getElementsByTagName('input');
	var obj_txa = document.getElementsByTagName('textarea');
	for( e =0; e < obj.length; e++ ){
		var type = obj[e].getAttribute('type');
		if( type == 'text' || type == 'password' || type == 'file'){
			var isClsnm = false;
			var clsnm = obj[e].className.toString().split(' ');
			for (c = 0; c < clsnm.length; c++){
				if (inArray(clsnm[c], Array('lline', 'line', 'rline', 'cline', 'loginline'))) isClsnm = true;
			}
			if (isClsnm === true){
				addEvent(obj[e], 'focus', function(e) { inFocus1(getTargetElement(e)); });
				addEvent(obj[e], 'blur', function(e) { outFocus1(getTargetElement(e)); });
			}
		}
	}

	for( t =0; t < obj_txa.length; t++ ){
		var clsnm = obj_txa[t].className.toString().split(' ');
		if (inArray("tline", clsnm)){
			addEvent(obj_txa[t], 'focus', function(e) { inFocus1(getTargetElement(e)); });
			addEvent(obj_txa[t], 'blur', function(e) { outFocus1(getTargetElement(e)); });
		}
	}
}

/* 브라우저별 이벤트 처리*/
function addEvent(obj, evType, fn){
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function delEvent(obj, evType, fn){
	if (obj.removeEventListener) {
		obj.removeEventListener(evType, fn, false);
		return true;
	} else if (obj.detachEvent) {
		var r = obj.detachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function getTargetElement(evt)
{
	if ( evt.srcElement ) return target_Element = evt.srcElement; // 익스
	else return target_Element = evt.target; // 익스외
}


//팝업메뉴설정
function getElementAbsPosX(el)
{
    var dx = 0;
    if (el.offsetParent) {
        dx = el.offsetLeft + 8;
        while (el = el.offsetParent) {
            dx += el.offsetLeft;
        }
    }
    return dx;
}

function getElementAbsPosY(el)
{
    var dy = 0;
    if (el.offsetParent) {

        dy = el.offsetTop + el.offsetHeight / 2;
        while (el = el.offsetParent) {
            dy += el.offsetTop;
        }
    }
    return dy;
}

function GetAbsWindowBottom()
{
    // 팝업 윈도와 브라우저 윈도의 하단을 계산한다.
    // 모든 브라우저에서 다를 절대좌표지만 아래의 것은 보통 정확해야 한다!
 
    var abswindowbottom = 0;
    if (typeof(window.innerHeight) == 'number')
        abswindowbottom = window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight)
        abswindowbottom = document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight)
        abswindowbottom = document.body.clientHeight;
 
    if (typeof(window.pageYOffset) == 'number')
        abswindowbottom = abswindowbottom + window.pageYOffset;
    else if (document.body && document.body.scrollTop)
        abswindowbottom = abswindowbottom + document.body.scrollTop;
    else if (document.documentElement && document.documentElement.scrollTop)
        abswindowbottom = abswindowbottom + document.documentElement.scrollTop;
    return abswindowbottom;
}

function PopupMenu(name, vis)
{
    var el = 'menu' + name;
    var tag = 'menuroot' + name;
    if (!document.getElementById(el))  // 메뉴 오브젝트를 발견하지 못할때
        return;
    if (vis == 0) {  // 메뉴를 숨김
        document.getElementById(el).style.visibility = 'hidden';
        return;
    }

    // 메뉴시작 위치를 얻어옴
    var pos = document.getElementById(tag);
    var dx = getElementAbsPosX(pos);
    var dy = getElementAbsPosY(pos);

    // 메뉴 하단과 윈도 하단을 비교
    var abspopupbottom = dy + document.getElementById(el).clientHeight + 10;
    var abswindowbottom = GetAbsWindowBottom();

    // 메뉴가 윈도 하단 아래로 벗어나면 위로 올린다!
    if (abspopupbottom > abswindowbottom)
        dy = dy - (abspopupbottom - abswindowbottom);

    // 마지막으로 메뉴 위치를 설정하고 보이게 한다.
    document.getElementById(el).style.left = dx + 'px';
    document.getElementById(el).style.top = dy + 'px';
    if (vis > 0)
        document.getElementById(el).style.visibility = 'visible';
}

function cancel(url)
{
		var choose = confirm("지금까지 입력한 내용이 사라집니다.\n그래도 작업을 취소하시겠습니까?");
		if(choose){
			location.href = url;
		}else{
			return;
		}
}

function table_design_load()
{
	var tb = document.getElementsByTagName('table');
	for (i=0;i<tb.length;i++){
		if (tb[i].className=="tb"){
			with (tb[i]){
				setAttribute('border', 1);
				setAttribute('borderColor', "#e6e6e6");
				//setAttribute('rules', 'none');
				setAttribute('cellPadding',5);
				//frame = "hsides";
				//rules = "rows";
				//cellPadding = "4";
			}
			with (tb[i].style){

				width = "100%";
				borderCollapse = "collapse";
			}
		}
	}
}

function cssRound(id,color,bg)
{
	if (!bg) bg = '#ffffff';
	color = '#93a0a6';
	var obj = _ID(id);
	obj.style.backgroundColor = color;
	with (obj.style){
		margin = "5px 0 0 0";
		color = "#4c4c4c";
		font = "8pt dotum";
	}
	obj.innerHTML = "<div style='padding:8px 13px;'><img src='../images/admin/icn_chkpoint.gif'><br>" + obj.innerHTML + "</div>";

	cssRound_top(obj,bg,color);
	cssRound_bottom(obj,bg,color);
}

function cssRound_top(el,bg,color)
{
	var d=document.createElement("b");
	d.className="rOut";
	d.style.fontSize = 0;
	d.style.backgroundColor=bg;
	for(i=1;i<=4;i++){
		var x=document.createElement("b");
		x.className="r" + i;
		x.style.backgroundColor=color;
		d.appendChild(x);
	}
	el.style.paddingTop=0;
	el.insertBefore(d,el.firstChild);
}

function cssRound_bottom(el,bg,color){
	var d=document.createElement("b");
	d.className="rOut";
	d.style.fontSize = 0;
	d.style.backgroundColor=bg;
	for(i=4;i>0;i--){
		var x=document.createElement("b");
		x.className="r" + i;
		x.style.backgroundColor=color;
		d.appendChild(x);
	}
	el.style.paddingBottom=0;
	el.appendChild(d);
}

check = true;
function ShowDisplay()
{
	if (check)
	{$("#mid").append("<div style='width:100%;height:100%;background-color:#fff;text-align:center;padding-top:100px;'><img src='/images/loading.gif' alt='로딩중'/></div>");
		
		textMenu(); 
		$("select").hide();
		getSitemap();
		check = false;
	}
	else
	{	$("select").show();
		CloseMenu();
		check = true;
	}
}
function textMenu() {
//alert(document.getElementById(showAll));
	sitemap_top = parseInt(document.getElementById("showAll").style.top);
 
	if(sitemap_top < -1){
		sitemap_top = sitemap_top + 20 +"px" ;
		
		//$(showAll).style.top = sitemap_top;
		document.getElementById("showAll").style.top=sitemap_top;
		window.setTimeout("textMenu()", 10)
 
	}
 
}
 
function CloseMenu() {
	sitemap_top = parseInt(document.getElementById("showAll").style.top);
 	if(sitemap_top > -400){
		sitemap_top = sitemap_top - 20 +"px" ;
		
	//	$(showAll).style.top = sitemap_top;
	document.getElementById("showAll").style.top=sitemap_top;
		window.setTimeout("CloseMenu()", 10)
 
	}
 
}
function getSitemap(){
var strUrl='/inc/sitemap.asp';
		$.ajax({
			url: strUrl,
			type: "get",
			dataType: "html",
			error: function(textStatus,errorThrown){
				
			alert('Error:errorThrown='+errorThrown+"textStatus="+textStatus);
			},
			success :function (data, textStatus){
				//alert(unescape(data));
				$("#mid").html(unescape(data));		
						//ShowDisplay();
					}
			} );
}

