//==============================================================
// Common JavaScript
//==============================================================
// FileName : common.js
// Last update : 2011-10-11
//==============================================================

//==============================================================
// Check Empty Filed & Process That...
//==============================================================

function empty_proc(obj, msg)
{
	if(obj.value.trim() == "")
	{
		alert(msg);
		obj.value = "";
		obj.focus();

		return true;
	}

	return false;
}

//==============================================================
// 공백을 없애는 함수
//==============================================================
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

function openWindow(theURL,winName,features) 
{ //v2.0
  window.open(theURL,winName,features);
}

//=======================================================================================================
/// 한글 입력 체크
//=======================================================================================================

function checkKorean(str)
{
	 var j = 0;
	 var CodeNum;

	for(i = 0; i < str.length; i++)
	{
		CodeNum = str.charCodeAt(i);

		if(CodeNum < 128)
		{
			j = j + 1;				
		}	
	}

	if(j > 0)
		return false;
	else
		return true;
}

//=======================================================================================================
/// 해당 필드를 비운다.
//=======================================================================================================

function setEmpty(obj)
{
	obj.value = "";
	obj.focus();
}

//=======================================================================================================
/// 주민등록번호 체크
//=======================================================================================================

function checkResident(resident1, resident2)
{
	var chk =0;

	for (var i = 0; i <=5 ; i++)
	{
		chk = chk + ((i % 8 + 2) * parseInt(resident1.substring(i, i + 1)));
	}

	for (var i = 6; i <= 11 ; i++)
	{
		chk = chk + ((i % 8 + 2) * parseInt(resident2.substring(i-6, i-5)));
	}

	chk = 11 - (chk % 11);
	chk = chk % 10;

	if (chk != resident2.substring(6, 7))
		return false;
	else
		return true;
}

//=======================================================================================================
/// Check_Email
//=======================================================================================================

function check_email(email)
{
	var atsym = email.indexOf("@");
	var period = email.indexOf(".");
	var space = email.indexOf(" ");
	var length = email.length -1;

    if((atsym < 1)||(period <=atsym+1)|| (period==length)|| (space != -1))
	{
		return false;
	}

	return true;
}

//=======================================================================================================
/// GetCookie
//=======================================================================================================

function getCookie(name)
{
	var nameOfCookie = name + "=";
	var x = 0;

	while (x <= document.cookie.length)
	{
		var y = (x + nameOfCookie.length);

		if (document.cookie.substring(x, y) == nameOfCookie) 
		{
			if((endOfCookie = document.cookie.indexOf(";", y)) == -1)
				endOfCookie = document.cookie.length;
				
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}

		x = document.cookie.indexOf(" ", x) + 1;

		if(x == 0)
			break;
	}

	return "";
}

//=======================================================================================================
/// SetCookie
//=======================================================================================================

function setCookie(name, value, expiredays)
{
	var todayDate = new Date();
	
	todayDate.setTime(todayDate.getTime() + (1000*30*24*60*60));

	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}



//=================================================================================================
/// checkRadio
//=================================================================================================

function checkRadio(oRadio, strMessage)
{
	for(var i = 0; i < oRadio.length; i++)
		if(oRadio[i].checked)
			return true;

	alert(strMessage);

	return false;
}

//=================================================================================================
// 체크박스 전체체크 및 BOOLEAN 리턴    20110721 kdy 
//=================================================================================================

function allChkandSetValue(field) 
{

	var chkfield = document.getElementsByName(field);
	var chk = 0;

	for(var i=0; i < chkfield.length; i++)
	{
		
		if(chkfield[i].checked) 		{
			AllChknCancel(field, mode = "cancel");
			chkfield[i].checked = false; 
			document.getElementById('id_tag').style.display='none';
			return false;
		}
		else 								{	
			AllChknCancel(field, mode = "check");
			chkfield[i].checked = true; 
		//	document.getElementById('id_tag').style.dispaly='block';
			document.getElementById('id_tag').style.display='block';
			return true;
		}
	}
}
//=================================================================================================
// 체크박스 BOOLEAN 리턴    20110721 kdy 
//=================================================================================================
function allChk(field) 
{

	var chkfield = document.getElementsByName(field);
	var chk = 0;

	for(var i=0; i < chkfield.length; i++)
	{
			if(chkfield[i].checked)   return true;
			else					    	      return false;
	}
}

//=================================================================================================
// 체크박스 전체체크, 해제, 반전 , 절대체크   20110721 kdy 추가수정
//=================================================================================================
function AllChknCancel(field, mode)
{
	var cbox = document.getElementsByName(field);
	var chk = 0;

	if(mode == 'check')
	{
		for(var i=0; i < cbox.length; i++)
			cbox[i].checked = true;
	}

	else if(mode == "cancel")
	{
		for(var i=0; i < cbox.length; i++)
			cbox[i].checked = false;
	}

	else if(mode == "reverse")
	{
		for(var i=0; i < cbox.length; i++)
		{
			if(cbox[i].checked) cbox[i].checked = false;
			else cbox[i].checked = true;
		}
	}
	else 
	{
		for(var i=0; i < cbox.length; i++)
		{
			if(cbox[i].checked) {
				AllChknCancel(field, mode = "cancel");
				cbox[i].checked = false; 
				}
			else {
				AllChknCancel(field, mode = "check");
				cbox[i].checked = true;
			}
		}
	}
}

//===========================================================================
// bluring
//===========================================================================

function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;

function TxtCheck(key, CtlName, TextMask)
{
	if((key > 47&&key < 58)||(key > 95 && key <106)) 
	{
		if(CtlName.value.length < TextMask.length) 
		{ 
			var aa = CtlName.value + String.fromCharCode(key);

			if(key > 47 && key < 58) 
			{
				var zz = aa.charAt(aa.length-1);
			}
			else if(key > 95 && key < 106)
			{	
				switch(key)
				{
					case 96: zz = '0'; break; case 97: zz = '1'; break;
					case 98: zz = '2'; break; case 99: zz = '3'; break;
					case 100: zz = '4'; break; case 101: zz = '5'; break;
					case 102: zz = '6'; break; case 103: zz = '7'; break;
					case 104: zz = '8'; break; case 105: zz = '9'; break;
				}
			}

			if(TextMask.charAt(aa.length-1) == '#') 
				CtlName.value = CtlName.value + zz;
			else 
				CtlName.value = CtlName.value + TextMask.charAt(aa.length-1) +zz;
			
			return false;
		}
	}
	else if(key == 8 || key == 9 || key == 13) 
		return ; 
	
	return false;
}

function onlyNumber1()
{
	if(((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 45))
		event.returnValue=false;
}

function onlyNumber()
{
	if((event.keyCode < 48) || (event.keyCode > 57))
		event.returnValue=false;
}


//===========================================================================
// 활성, 비활성 설정
//===========================================================================

function showObject(Obj,Boolen)
{
	if(Boolen){					//활성화
		Obj.disabled = false;
		Obj.style.background = "#ffffff";
	}
	else{						//비활성화
		Obj.disabled = true;
		Obj.style.background = "#dddddd";
	}
}

//===========================================================================
// 플래쉬 패치
//===========================================================================


function setEmbed() 
{ 
  var obj = new String; 
  var parameter = new String; 
  var embed = new String; 
  var html = new String; 
  var allParameter = new String; 
  var clsid = new String; 
  var codebase = new String; 
  var pluginspace = new String; 
  var embedType = new String; 
  var src = new String; 
  var width = new String; 
  var height = new String; 

    
  this.init = function( getType , s ,w , h ) { 
      
      if ( getType == "flash") 
      { 

        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";        
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"; 
        pluginspage = "http://www.macromedia.com/go/getflashplayer"; 
        embedType = "application/x-shockwave-flash"; 
      } 
      /* type 추가 
      else if ( ) 
      { 
      } 
      */ 
            
      parameter += "<param name='movie' value='"+ s + "'>\n";  
      parameter += "<param name='quality' value='high'>\n";    
      
      src = s; 
      width = w; 
      height = h; 
  } 
  
  this.parameter = function( parm , value ) {      
      parameter += "<param name='"+parm +"' value='"+ value + "'>\n";        
      allParameter += " "+parm + "='"+ value+"'"; 
  }  
  
  this.show = function() { 
      if ( clsid ) 
      { 
        obj = "<object classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"'>\n"; 
      } 
      
      embed = "<embed src='" + src + "' pluginspage='"+ pluginspage + "' type='"+ embedType + "' width='"+ width + "' height='"+ height +"'"+ allParameter +" ></embed>\n"; 
      
      if ( obj ) 
      { 
        embed += "</object>\n"; 
      } 
      
      html = obj + parameter + embed; 
      
      document.write( html );  
  } 
}

//=================================================================================================
// 레이어 display  block or none 설정	 -kdy-	
//=================================================================================================

function DisplayCheck(Obj,Object,type)
{
	var Object=document.getElementById(Object);
	
	//체크되는 것들 checkbox,radio
	if(type==undefined){		
		if(Obj.checked)    showDisplay(Object, true);	
		else			        showDisplay(Object, false);		
	}
	//마우스오버 및 아웃처리
	else{
		if(type=='mouseover')	  showDisplay(Object, true);	
		else							  showDisplay(Object, false);				
	}	
}

function showDisplay(Obj,Boolean)
{
	if(Boolean){					// block
		Obj.style.display= "block";
	}
	else{						// none
		Obj.style.display= "none";
	}
}

//===========================================================================
// 업로드파일 다운로드
//===========================================================================

function DownFile(filename,mode)
{
	if(!filename) 		alert("다운로드 파일을 선택해 주세요.");
	if(mode) location.href('/board/download.asp?file='+filename+'&mode='+mode);
	else       location.href('/board/download.asp?file='+filename);
}

//===========================================================================
// 입력된 값이 영어 알파벳과 숫자인 경우에 true를 리턴한다.
//===========================================================================

function isAlphaNum(obj)
{ 
	var str = obj.value;

	if(str.length == 0) return false;
	str = str.toUpperCase();

	for(var i=0; i < str.length; i++)
	{
		if(!(('A' <= str.charAt(i) && str.charAt(i) <= 'Z') || ('0' <= str.charAt(i) && str.charAt(i) <= '9')))
			return false;
	}
	
	return true;
}


function isNum(obj)
{ 
	var str = obj.value;

	if(str.length == 0) return false;
	str = str.toUpperCase();

	for(var i=0; i < str.length; i++)
	{
		if(!(('0' <= str.charAt(i) && str.charAt(i) <= '9')))
			return false;
	}
	
	return true;
}


function check_num(obj)
{
	if(!checkNumber(obj.value)){
	alert('숫자로만 입력해 주세요.');
	obj.value = '';
	obj.focus();
	return false;
	}
}

/***** img chk (kkang)****************************************************************************/
function ImgFileChk(obj, info)
{
	if(obj.value != "")
	{
		var maxi = obj.value.length;
		var ext = obj.value.substring(maxi-3, maxi);
		ext = ext.toLowerCase();

		if(ext != "gif" && ext != "jpg")
		{
			alert(info + "은(는) gif 또는 jpg 파일만 업로드가능합니다.");
			obj.focus();
			return false;
		}
	}

	return true;
}

/***** Member Password Check --- kkang ***********************************************************/
function check_pass(obj)
{
	var str = obj.value;
	var patten = /^[a-zA-Z0-9_]{4,12}$/;

	if(!patten.test(str))
		return false;
	else
		return true;
}

/***** checkNumber *******************************************************************************/
function checkNumber(nNumber)
{ 
    var anum=/(^\d+$)|(^\d+\.\d+$)/ ;

	
  if(event.keyCode==9 || event.keyCode==8 || event.keyCode==13) { }
  else{
	if (anum.test(nNumber))
        return true; 
    else 
        return false; 
  }
   return true; 
}

/***** check_num--- (kdy)***************************************************************/
function check_num(obj,target,number)
{
	
	if(!checkNumber(obj.value)){
			alert('숫자로만 입력해 주세요.');
			obj.value = '';
			obj.focus();
			return false;
    }
	else {
			sendFocus(obj, target, number);
	}
}


/******** (자동 Focus 이동) *****************************************************************/
function sendFocus(source, target, number)
{
	if(source.value.length >= number) {target.focus(); return;}
}



//[5] 메일주소 검사
function check_mail(cg) {
	 emailEx1 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z]+/;
	 emailEx2 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;
	 emailEx3 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;

	 if(emailEx1.test(cg.value)) return true;
	 if(emailEx2.test(cg.value)) return true;
	 if(emailEx3.test(cg.value)) return true;

	 return false;
}

// 메일주소 검사     각각 검사할때 
function check_mail2(cg,mode) {
  
  if(mode=='1')  emailEx =  /[^_0-9a-zA-Z-]/;
  else				 emailEx =  /[^_0-9a-zA-Z.-]/;
 
 if(emailEx.test(cg.value)) return true;
 
 return false;
}

function check_mail2_ok(obj,mode)
{
 if(event.keyCode==9 || event.keyCode==8 || event.keyCode==13) { }
 else {
		
		 if(check_mail2(obj,mode)){
		 alert('e-mail  형식에 맞지 않습니다.');
		 obj.value = '';
		 obj.focus();
		 return false;
		 }
	
 }
}

/***** check_Patten   각종 정규식에 의한 유효성 검사를 한다.   이벤트 핸들러를 사용한다면 onchange를 쓴다..  (kdy)    ***************/
function check_Patten(obj,mode,mode2)
{
    var str = obj.value;

	if (mode=='id')					{var patten = /^[_0-9a-zA-Z-]/;						var alert_str= '영문,숫자,특수기호만 사용가능합니다.';}//(영문소문자,숫자,_ 허용)
	else if (mode=='pass')		{var patten = /^[a-zA-Z0-9_]{4,12}$/;			var alert_str= '영문,숫자 혼합 4~12자리만 사용가능합니다.';}//패스워드 검사 
	else if (mode=='mobile')	{var patten = /^\d{3}-\d{3,4}-\d{4}$/;	    var alert_str= '010-3411-1234 형식만 사용가능합니다.';}//전화번호 자리 검사 010-3411-1234
	else if (mode=='mobile1')	{var patten = /^\d{3,4}/;									var alert_str= '전화번호 형식만 사용가능합니다.';}//전화번호1 자리 검사 010
	else if (mode=='mobile2')	{var patten = /^\d{3,4}/;									var alert_str= '전화번호 형식만 사용가능합니다.';}//전화번호2 자리 검사 3411
	else if (mode=='mobile3')	{var patten = /^\d{4}/;									var alert_str= '전화번호 형식만 사용가능합니다.';}//전화번호3 자리 검사 1234
	else if (mode=='social')		{var patten = /^\d{6}-\d{7}$/;					var alert_str= '800401-1111111 이렇게만 사용가능합니다.';}//' 주민번호 (숫자 6-7 자리검사) 800401-1212111
	else if (mode=='social13')	{var patten = /^\d{13}/;								var alert_str= '8004011111111 이렇게만 사용가능합니다.';}//' 주민번호 (숫자 13자리검사)	 8004011212111
	else if (mode=='business')	{var patten = /^\d{3}-\d{2}-\d{5}$/;		var alert_str= '사업자번호 형식에 맞지 않습니다.';}//주민번호나 사업자번호 검사
	else if (mode=='email')		{var patten = /[_a-zA-Z\d\-\.]+@([_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+)/;					var alert_str= 'abd@dsf.com 이렇게만 사용가능합니다.';}//' 이메일
	else if (mode=='date')		{var patten = /^\d{4}-\d{2}-\d{2}$/;					var alert_str= '1980-04-01 이렇게만 사용가능합니다.';}//' 날짜형식 검사 (숫자 4-2-2 자리검사) 1980-04-01
	
	else if (mode=='name')		{var patten = /[^가-힣]/;									var alert_str= '순수한글만 사용가능합니다.';}//true면 한글말고 다른게 섞여있고 false명순수 한글..
	else if (mode=='number')	{var patten = /[^0-9]/;										var alert_str= '순수숫자만 사용가능합니다.';}//true면 숫자말고 다른게 섞여있고 false명순수 숫자..
	
	
	if(event.keyCode==9 || event.keyCode==8 || event.keyCode==13) { }
	else{
		//alert(str+'<br>'+mode)
		if(mode=='name' || mode=='number' ){
			if(!patten.test(str))			 return true;
			else {
				alert(alert_str);
				obj.value = '';
				setTimeout(function()   {
					obj.focus();
				});
				return false;
			}
		}
		else {
			if(patten.test(str))	return true;  
			else {
				if(mode2){  check_Patten(obj,mode2) }
				else{
					alert(alert_str);
					obj.value = '';
					setTimeout(function(){
						obj.focus();
					});
					return false;
				}
			}
		}
	}
	return true; 
}



//===========================================================================
// 기본 스크립트 함수
//===========================================================================

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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.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=MM_findObj(n,d.layers[i].document); return x;
}

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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

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 email_ch(obj)
{
	//alert(obj.value);
	var patten = /[_a-zA-Z\d\-\.]+@([_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+)/; 
	if(patten.test(obj.value))    return true;
	else alert("유효한 이메일이 아닙니다.");
	//alert (patten.test(obj.value));
}


/******************************************************************************************/
/******** poplayer 관련 함수들 *****************************************************************/
/******************************************************************************************/
/******************************************************************************************/

function PasswordForm(type,mode,code, idx, data,action)
{
	var bwidth = document.body.clientWidth;
	var bheigh = document.body.clientHeight;
	var layerX = (bwidth-300) / 2;
	var layerY = (bheigh-200) / 2;
	var action = (action) ? action : "/inc/pass_check.asp" ;
	var html = '';
	
	html = "<form name=\"pwdfm\" action=\""+action+"\" method=\"post\"  target=\"hifr\" >";
	html += "<input type=\"hidden\" name=\"type\" value=\""+type+"\" />";
	html += "<input type=\"hidden\" name=\"mode\" value=\""+mode+"\" />";
	html += "<input type=\"hidden\" name=\"code\" value=\""+code+"\" />";
	html += "<input type=\"hidden\" name=\"idx\" value=\""+idx+"\"/>";
	html += "<input type=\"hidden\" name=\"encData\" value=\""+data+"\"/>";
	html += "<table cellpadding=\"0\" cellspacing=\"0\" class=\"PassLayer\">";
	html += "<colgroup><col width=\"30\" /><col /><col width=\"30\" /></colgroup>";
	html += "<tr>";
	html += "<td><img src=\"/img/layer/ly_top1.gif\" alt=\"\" /></td>";
	html += "<td class=\"bg_top\"></td>";
	html += "<td><img src=\"/img/layer/ly_top2.gif\" alt=\"\" /></td>";
	html += "</tr><tr>";
	html += "<td class=\"bg_left\"></td>";
	html += "<td align=\"center\" valign=\"top\">";
	html += "<h2><img src=\"/img/layer/pass_lay_tit.gif\" alt=\"비밀번호 입력\" /></h2>";
	html += "<dl><dt><img src=\"/img/layer/ly_pwd.gif\" alt=\"비밀번호\"  /></dt>";
	html += "<dd><input type=\"password\" name=\"pwd\" size=\"20\" class=\"lbox\" exp=\"비밀번호를 \" /></dd>";
	html += "</dl><input type=\"image\" src=\"/img/layer/btn_layer_ok.gif\" alt=\"입력완료\" />";
	html += "<div class=\"line\"></div></td>";
	html += "<td class=\"bg_right\"></td></tr>";
	html += "<tr><td><img src=\"/img/layer/ly_btm1.gif\" alt=\"\" /></td><td class=\"bg_btm\"></td>";
	html += "<td><img src=\"/img/layer/ly_btm2.gif\" alt=\"레이어닫기\" class=\"hand\" onClick=\"LayerClose();\" /></td></tr></table>";
	html += "</form>";	



	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		zIndex = "1000";
		left = 0;
		top = 0;
		width = "100%";
		height = "100%";
		height = document.body.scrollHeight+"px";
		//height = document.body.clientHeight;
		backgroundColor = "#000000";
		filter = "Alpha(Opacity=30)";
		opacity = "0.5";
	}
	obj.id = "LayerBg";
	document.body.appendChild(obj);

	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		zIndex = "1001";
		left = layerX + document.body.scrollLeft+"px";
		top = layerY + document.body.scrollTop+"px";
		width = 313;
		height = 167;
		backgroundColor = "#ffffff";
		//obj.style.backgroundImage = "url('/img/qna_bg.gif')";
		//obj.style.backgroundRepeat = "no-repeat";
		border = "3px solid #000000";
	}
	obj.id = "LayerContent";
	
	document.body.appendChild(obj);


	obj.innerHTML = html;
	document.pwdfm.pwd.focus();
}


function CmtPassForm(pobj, code, num)
{
	var obj = document.getElementById('CmtPwdLayer');
	if(obj != null) obj.parentNode.removeChild(obj);
	var html = "";
	html = "<form name=\"cmtform\" action=\"/board/board.act.php\" method=\"post\" onSubmit=\"return chkForm(this);\" target=\"hifr\">";
	html += "<input type=\"hidden\" name=\"num\" value=\""+num+"\" />";
	html += "<input type=\"hidden\" name=\"mode\" value=\"chkpwd\" />";
	html += "<input type=\"hidden\" name=\"code\" value=\""+code+"\"/>";
	html += "<input type=\"hidden\" name=\"act\" value=\"cmtd\" />";
	html += "<input type=\"password\" id=\"pwd\" name=\"pwd\" class=\"lbox\" align=\"absmiddle\" exp=\"비밀번호를 \"/> ";
	html += "<input type=\"image\" src=\"/img/btn/btn_boa_ok.gif\" title=\"확인\" align=\"absmiddle\" /> ";
	html += "<img src=\"/img/btn/btn_boa_cancel.gif\" alt=\"취소\" align=\"absmiddle\" class=\"hand\" onClick=\"javascript:document.getElementById('CmtPwdLayer').parentNode.removeChild(document.getElementById('CmtPwdLayer'));\" />";
	html += "</form>";


	obj = document.createElement("span");
	obj.id = "CmtPwdLayer";
	obj.style.width = "250px";
	obj.style.border = "#dddddd 1px solid";
	obj.style.padding = "3px";
	obj.style.backgroundColor = "#ffffff";
	obj.style.position = "absolute";

	if(pobj.innerHTML.toLowerCase().indexOf('img') != -1)
	{
		obj.style.marginTop = "0px";
		obj.style.marginLeft = "-250px";
	}

	obj.innerHTML = html;
	pobj.parentNode.insertBefore(obj, pobj.previousSibling);
	document.getElementById('pwd').focus();
}

/******** (review password form --- kkang(2011-04-14)) *****************************************************************/
function reviewPassForm(pobj, gcode, num, mode)
{
	var obj = document.getElementById('reviewPwdLayer');
	if(obj != null) obj.parentNode.removeChild(obj);
	var html = "";
	html = "<form name=\"cmtform\" action=\"./chk.reviewpwd.php\" method=\"post\" onSubmit=\"return chkForm(this);\" target=\"hifr\">";
	html += "<input type=\"hidden\" name=\"num\" value=\""+num+"\" />";
	html += "<input type=\"hidden\" name=\"mode\" value=\""+mode+"\" />";
	html += "<input type=\"hidden\" name=\"gcode\" value=\""+gcode+"\"/>";
	html += "<input type=\"password\" id=\"pwd\" name=\"pwd\" class=\"lbox\" align=\"absmiddle\" exp=\"비밀번호를 \"/> ";
	html += "<input type=\"image\" src=\"/img/btn/btn_boa_ok.gif\" title=\"확인\" align=\"absmiddle\" /> ";
	html += "<img src=\"/img/btn/btn_boa_cancel.gif\" alt=\"취소\" align=\"absmiddle\" class=\"hand\" onClick=\"javascript:document.getElementById('reviewPwdLayer').parentNode.removeChild(document.getElementById('reviewPwdLayer'));\" />";
	html += "</form>";


	obj = document.createElement("span");
	obj.id = "reviewPwdLayer";
	obj.style.width = "250px";
	obj.style.border = "#dddddd 1px solid";
	obj.style.padding = "3px";
	obj.style.backgroundColor = "#ffffff";
	obj.style.position = "absolute";

	if(pobj.innerHTML.toLowerCase().indexOf('img') != -1)
	{
		obj.style.marginTop = "0px";
		obj.style.marginLeft = "-250px";
	}

	obj.innerHTML = html;
	pobj.parentNode.insertBefore(obj, pobj.previousSibling);
	document.getElementById('pwd').focus();
}

/******** (Popup Layer alert --- kdy) *****************************************************************/
function Alert(str , action, w, h, bg, linebg,  scroll){
	if(document.getElementById("ContentLayer")) PopupLayerClose();

	w = (w) ? w : 650;
	h = (h) ? h : 500;
	bg = (bg) ? bg : "#000000";
	linebg = (linebg) ? linebg : "#000000";
	scroll = (scroll) ? scroll : "yes";

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	var layerX = (bodyW-w) / 2;
	var layerY = (bodyH-h) / 2;

	var obj = document.createElement("div");
	with(obj.style)
	{
		position = "absolute";
		left = 0;
		top = 0;
		zIndex = "1000";
		width = "100%";
		height=(document.body.scrollHeight > document.documentElement.scrollHeight) ? document.body.scrollHeight+"px" : document.documentElement.scrollHeight+"px";
		backgroundColor = bg;
		filter = "Alpha(Opacity=50)";
		opacity = "0.5";
	}
	obj.id = "layerback";
	document.body.appendChild(obj);
	
	var obj = document.createElement("div");
	with(obj.style)
	{
		position = "absolute";
		zIndex = "1001";
		left = layerX + document.body.scrollLeft + "px";
		top = layerY + document.body.scrollTop + "px";
		
		width = w + "px";
		height = h + "px";
		backgroundColor = "#ffffff";
		border = "3px solid " + linebg;
	}
	obj.id = "ContentLayer";
	document.body.appendChild(obj);

	var html = "";
	html += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
	html += "<tr>";
	html += "<td valign=\"top\" style=\"padding:20px 10px 0 10px;\">";
	html += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" bgcolor=\"#FFFFFF\">";
	html += "<colgroup>";
	html += "<col width=\"120\" class=\"cel1\"/>";
	html += "<col class=\"cel2\" />";
	html += "</colgroup>";
	html += "<tbody style=\"height:20px;\">";
	html += "<tr><td align='center' height='5%'></td></tr>";
	html += "<tr><td align='center'>";
	html += str;
	html += "</tbody>";
	html += "</table>";
	html += "</td>";
	html += "</tr>";
	if(action) html += "<tr><td style=\"padding:20px 10px 0 10px;\" align='center'><button class=\"rounded\" onclick=\"javascript:PopupLayerClose('"+action+"','home.php?go=mypage');\" onfocus=\"blur();\"><span>확인</span></button></td></tr>";
	else		 html += "<tr><td style=\"padding:20px 10px 0 10px;\" align='center'><button class=\"rounded\" onclick=\"javascript:PopupLayerClose('aa','');\" onfocus=\"blur();\"><span>확인</span></button></td></tr>";	
	html += "</table>";

	var btm = document.createElement("div");
	with(btm.style)
	{
		position = "absolute";
		width = "100%";
		height = 30+"px";
		zIndex = "1001";
		left = 0;
		top = (h - 33) + "px";
		padding = "4px 0 0 0";
		textAlign = "center";
		backgroundColor = linebg;
		color = "#ffffff";
		font = "bold 13px tahoma; letter-spacing:0px";
	}

	obj.innerHTML = html;
}


/******** (Popup Layer --- kkang) *****************************************************************/
function LayerPopUp(url, w, h, bg, linebg,  scroll)
{
	if(document.getElementById("ContentLayer")) PopupLayerClose();

	w = (w) ? w : 650;
	h = (h) ? h : 500;
	bg = (bg) ? bg : "#000000";
	linebg = (linebg) ? linebg : "#000000";
	scroll = (scroll) ? scroll : "yes";

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	var layerX = (bodyW-w) / 2;
	var layerY = (bodyH-h) / 2;

	

	var obj = document.createElement("div");
	with(obj.style)
	{
		position = "absolute";
		left = 0;
		top = 0;
		zIndex = "1000";
		width = "100%";
		height=(document.body.scrollHeight > document.documentElement.scrollHeight) ? document.body.scrollHeight+"px" : document.documentElement.scrollHeight+"px";
		backgroundColor = bg;
		filter = "Alpha(Opacity=50)";
		opacity = "0.5";
	}
	obj.id = "layerback";
	document.body.appendChild(obj);
	
	var obj = document.createElement("div");
	with(obj.style)
	{
		position = "absolute";
		zIndex = "1001";
		left = layerX + document.body.scrollLeft + "px";
		top = layerY + document.body.scrollTop + "px";
		
		width = w + "px";
		height = h + "px";
		backgroundColor = "#ffffff";
		border = "3px solid " + linebg;
	}
	obj.id = "ContentLayer";
	document.body.appendChild(obj);

	var btm = document.createElement("div");
	with(btm.style)
	{
		position = "absolute";
		width = "100%";
		height = 30+"px";
		zIndex = "1001";
		left = 0;
		top = (h - 33) + "px";
		padding = "4px 0 0 0";
		textAlign = "center";
		backgroundColor = linebg;
		color = "#ffffff";
		font = "bold 13px tahoma; letter-spacing:0px";
	}
	btm.innerHTML = "<a href=\"javascript:PopupLayerClose();\" style=\"color:#ffffff;\"> 창닫기 </a>";
	obj.appendChild(btm);

	var ifm = document.createElement("iframe");
		 ifm.id='iframe_id';
		 ifm.name='iframe_name';
	with(ifm.style)
	{
		width = (w - 6) + "px";
		height = (h - 20) + "px";
	}
	ifm.frameBorder = 0;
	ifm.src = url;
	ifm.scrolling = scroll;

	obj.appendChild(ifm);
}

 /******** (PopupLayerClose --- kdy) *****************************************************************/
function PopupLayerClose(action,target)
{
	var action;
	if(action){
		if(action=='goUrl') {
		    var taget= (target) ? target :  "/" ;
			window.parent.document.location.href=target ; 
		}
		else window.parent.document.location.reload() ;
	}
	document.getElementById('layerback').parentNode.removeChild(document.getElementById('layerback'));
	document.getElementById('ContentLayer').parentNode.removeChild(document.getElementById('ContentLayer'));

}

function LayerClose()
{
	document.getElementById('LayerBg').parentNode.removeChild(document.getElementById('LayerBg'));
	document.getElementById('LayerContent').parentNode.removeChild(document.getElementById('LayerContent'));
}




