﻿//window.status=Date();

//window.onerror = ScriptEventHandler;

function TimeNow(date)
{	
	//2009-07-29 오후 5:57:30 					
	var Month = (date.getMonth() + 1);
	var flag = 'AM ';
	var Hour = date.getHours();
	var Minute = date.getMinutes();
	var Second = date.getSeconds()
	
	if(Hour > 12)
	{
		flag = 'PM ';
		Hour = Hour - 12;
	}
	
	if(Month < 10)
	{
		Month =  '0' + Month ;
	}
	
	if(Hour < 10)
	{
		Hour =  '0' + Hour ;
	}
	
	if(Minute < 10)
	{
		Minute =  '0' + Minute ;
	}
	
	if(Second < 10)
	{
		Second = '0' + Second;
	}
	
	var dateString = date.getYear() + "-" + Month + "-" + date.getDate() + " " + flag + Hour + ":" + Minute + ":" + Second + "." + date.getMilliseconds();
	
	return dateString;
}


function TimeDiff(sdate,edate)
{
	
}

function OpenUserInfo(id)
{
	if(id.indexOf('#')==0) return;
	var hwnd=OpenWindow('/_CMON/CMONUserInfo.aspx?userid='+id,'UserInfo',362,360, "1", "no");
	hwnd.focus();
}

var _sPopUpDepthStr = "";

function GetPopUpDepth()
{
	_sPopUpDepthStr = "self";
	GetPopUpDepthLoop(self);
	return _sPopUpDepthStr;
}


function GetPopUpDepthLoop(objPopUp)
{
	if(typeof(objPopUp.opener) == "object")
	{
		_sPopUpDepthStr += ".opener";
		GetPopUpDepthLoop(objPopUp.opener);
	}
	
}

// 자신의 팝업창과 부모팝업창 모두 닫기
function SetPopUpAllClose(pObj)
{
	//alert(typeof(pObj));
	//if(typeof(objPopUp.opener) == "object")
	//{	
	//	objPopUp.close();
	//	SetPopUpAllClose(objPopUp.opener);
	//}	
}

// 스크립트 오류시 잡아내는 이벤트 핸들러			
function ScriptEventHandler(sMsg, sUrl, sLine)
{
	
	
	try
	{
		
		
		if(GetCookieValue("UserID") == "" || GetCookieValue("Lang") == "")
		{
			var sPopDepth = GetPopUpDepth();			
			alert("Session is timeout. Move to login page !!");
			eval(sPopDepth).top.location.href = "/";
			
			// 팝업창 모두 닫기
			//SetPopUpAllClose(self);
		}
		else
		{
			
			try
			{
				ShowProgress(false);
			}
			catch(ex)
			{
			
			}
			
			var sErrMsg = "";
			sErrMsg +="<table width=100% bgcolor='#FF941E' border=0 style='border-style:outset;border-color:#FF8300;border-width:2px;font-size:9pt' align=center><tr><td>";
			sErrMsg +="<table style='font-family:Dotum;font-size:9pt'>";
			sErrMsg +="<tr><td colspan=2 align=center style='font-weight:bold;color:white;font-size:12pt'><img src='/_CMON/Images/image/error_script.gif' align=absmiddle>&nbsp;WorkCrew Script Error</td></tr>";			
			sErrMsg +="<tr><td bgcolor=#efefef align=center width=80 >Error</td><td bgcolor=#FFB059>"+sMsg+"</td></tr>";
			sErrMsg +="<tr><td bgcolor=#efefef align=center>Line</td><td bgcolor=#FFB059>"+sLine+"</td></tr>";
			sErrMsg +="<tr><td bgcolor=#efefef align=center>URL</td><td bgcolor=#FFB059>"+sUrl+"</td></tr>";			
			sErrMsg +="</td></tr>";
			sErrMsg +="<tr><td colspan=2 height=30 align=center>";
			sErrMsg +="<span onclick='parent.divScriptError.style.display=\"none\"' style='font-weight:bold;color:blue;cursor:hand'><u>close</u></span>";
			sErrMsg +="</td></tr></table>";
			sErrMsg +="</td><tr></table>";
			
			ShowScriptError(sErrMsg);
			
		}	

		
	}
	catch(ex)
	{
		alert(ex.message);
	}	
	
	
}


// script error display function

function ShowScriptError(pErrMsg)
{
	
	var divTag = "";
	
	if(typeof(divScriptError) == "object")
	{
		divScriptError.style.display = "";
		
	}
	else
	{
		divTag += "<div id='divScriptError' name='divScriptError' style='width:100%;height:100%;Z-INDEX:1000;POSITION:absolute;left:0;top:0'>"; 
		divTag += "<table width=100% height=100%><tr><td align=center valign=center>";
		divTag += "<IFRAME name='iframeScriptError' src='about:blank' marginwidth=0 marginheight=0 margintop=0 frameBorder=0 width='400' height='200' scrolling=no></IFRAME>";
		divTag += "</td></tr></table>";
		divTag += "</div>";
			
		document.body.insertAdjacentHTML("beforeEnd",divTag);
	}
		
	iframeScriptError.location.reload();
	iframeScriptError.document.write(pErrMsg);
	
	
	
}						



function GetCookieValue(pKey)
{
	
	var sCookie = document.cookie	
	var sRtnValue = "";
	
	if (sCookie.indexOf(pKey+"=") != -1)
	{
		sCookie = sCookie.split(";")

		for (var i=0;i<sCookie.length;i++)
		{
			if (sCookie[i].indexOf(pKey+"=") != -1)
			{
				sRtnValue = unescape(sCookie[i].split("=")[1])
				break;
			}
		}
	}
	
	return sRtnValue;
}

// 특수문자인지 아닌지 구분
// true 리턴이면 특수문자
function IsExcChar(strValue)
{
 	//var regEx	 = /[~!@#$%^&*\[\]~|"'+=_:;,.<>]/;	
 	var regEx	 = /["'+=<>]/;	
	//var regExBlank  = /[" "]/;	
	//var regExKor = /[ㄱ-힝]/;
	return regEx.test(strValue);
}




function IsDomain(strValue)
{
	
 	var regEx	 = /([a-zA-Z0-9_\-]+\.[a-zA-Z0-9_.\-]+)/;
	return regEx.test(strValue);
}


function IsEmailAddr(pValue)
{
	var regEx = /[A-Za-z0-9]{2,}@[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9]{2,})?$/;
	return regEx.test(pValue);
}


// 숫자인지 아닌지 구분
// true 리턴이면 숫자임
function IsNumeric(strValue)
{
	
 	//var regEx	 = /[0-9]/;	
	//var regExBlank  = /[" "]/;	
	//var regExKor = /[ㄱ-힝]/;
	//return regEx.test(strValue);
	
	return !isNaN(strValue);
}


function YearAndMonthFormatDate(strValue)
{
    YearAndMonthFormatDate(strValue,".");

}


function YearAndMonthFormatDate(strValue,gubun)
{
   if (strValue == "") 
     return "&nbsp;";    
   if (strValue.length !=6)
     return strValue;
   if (!IsNumeric(strValue))
     return strValue;
   return strValue.substring(0,4)+gubun+strValue.substring(4,2);
}


function FormatDate(strValue)
{
    FormatDate(strValue,".");

}


function FormatDate(strValue,gubun)
{
   if (strValue == "") 
     return "&nbsp;";    
   if (strValue.length !=8)
     return strValue;
   if (!IsNumeric(strValue))
     return strValue;
   return strValue.substring(0,4)+gubun+strValue.substring(4,2)+gubun+strValue.substring(6,2); 
}



// 프로그레시브 설정
function SetProgressDiv(width, height, pIsReturn)
{
	var divTag = "";
	
	if(typeof(divProg) != "object")
	{
		divTag += "<div id='divProg' name='divProg' style='display:none;width:" + width + ";height:" + height + ";Z-INDEX:1000;POSITION:absolute;left:0;top:0'>"; 
		divTag += "<table width=100% height=100%><tr><td align=center valign=center>";
		//divTag += "<IFRAME  name='iframeProg' marginwidth=0 marginheight=0 margintop=0 frameBorder=1 width='200' height='93' scrolling=no></IFRAME>";		
		
		divTag += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='200' height='93'>";
		divTag += "<param name='movie' value='/_CMON/Images/ing.swf' />";
		divTag += "<param name='quality' value='high' />";
		divTag += "<embed src='/_CMON/images/ing.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='200' height='93'></embed>";
		divTag += "</object>";
	
	
		divTag += "</td></tr></table>";
	
		divTag += "</div>";
	
		document.body.insertAdjacentHTML("beforeEnd",divTag);
		
	}	
	
	
	return divTag;
}						


// 프로그레시브바 보여주기 / 숨기기
function ShowProgress(bView)
{	
	
	if(typeof(divProg) != "object")
	{
		divProg.style.left = (document.body.clientWidth - parseInt(divProg.style.width)-50) / 2;
		divProg.style.top  = (document.body.clientHeight - parseInt(divProg.style.height)-200) / 2 ;
	}
	
	/*
	var sFlash = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='200' height='93'>";
	sFlash += "<param name='movie' value='/_CMON/Images/ing.swf' />";
	sFlash += "<param name='quality' value='high' />";
	sFlash += "<embed src='/_CMON/images/ing.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='200' height='93'></embed>";
	sFlash += "</object>";
	*/
	
	//iframeProg.location.reload();
	//iframeProg.document.write(sFlash);			
	bView == true ? divProg.style.display = "" : divProg.style.display = "none";
}


// 문자열을 분리하고 첫번쨰 문자열을 가져온다.
function SplitAndGetFirstStr(str,split)
{
   var arr = new Array();
   arr = str.split(split);
   
   return arr[0];    
}

function OpenWindow(pPage, pName, pWidth, pHeight, scroll, resizable)
{
	var nLeft = 0;
	var nTop = 0;

	try
	{
		nLeft  = (top.document.body.clientWidth / 2)   - (pWidth / 2);
		nTop = (top.document.body.clientHeight / 2 ) - (pHeight / 2);
	}
	catch(e)
	{
		nLeft = 50;
		nTop = 50;
	}
	
	if(scroll == undefined || scroll == null)
		scroll = "yes";
	if(resizable == undefined || resizable == null)
		resizable = "yes";
	return window.open(pPage,pName,"left=" + nLeft + ",top=" + nTop + ",width=" + pWidth + ",height=" + pHeight + ",status=yes,resizable=" + resizable + ",scrollbars=" + scroll);
}	

function OpenWindow2(pPage, pName, pWidth, pHeight, scroll, resizable)
{
    var nLeft = 0;
    try
	{
		nLeft  = (top.document.body.clientWidth / 2)   - (pWidth / 2);
	}
	catch(e)
	{
		nLeft = 50;
	}
	var nTop = 0;
	
	if(scroll == undefined || scroll == null)
		scroll = "yes";
	if(resizable == undefined || resizable == null)
		resizable = "yes";
	return window.open(pPage,pName,"left=" + nLeft + ",top=" + nTop + ",width=" + pWidth + ",height=" + pHeight + ",status=yes,resizable=" + resizable + ",scrollbars=" + scroll);
}	


// 현재 프레임 위치 찾기
var sNowFrameName = "";

function GetFrameSet()
{
	sNowFrameName = "";
	GetFrameSetLoop(self);
	sNowFrameName = "top" + sNowFrameName;
	
	return sNowFrameName;
}
	
function GetFrameSetLoop(objFrame)
{
	var frmParent = objFrame.parent.frames;
	
	for(var i=0;i<frmParent.length;i++)
	{			
		if(objFrame.name == frmParent.frames[i].name)
		{
			//document.write(objFrame.name + "__"+ frmParent.frames[i].name+"<br>");						
			
			sNowFrameName = "." + objFrame.name + sNowFrameName;
									
			GetFrameSetLoop(frmParent[i].parent);
			
		}	
	}
	
}	



function DateFormat(pDate, pForamtString)
{       
    return pForamtString.replace(/(yyyy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,
        function($1)
        {
            switch ($1.toLowerCase())
            {
			    case 'yyyy': return pDate.getFullYear();
		        case 'mm':   return (pDate.getMonth() + 1).toString().length == 1 ? "0" + (pDate.getMonth() + 1).toString() : (pDate.getMonth() + 1).toString();
	            case 'dd':   return pDate.getDate().toString().length == 1 ? "0" + pDate.getDate().toString() : pDate.getDate().toString();
            }
        }
    );
} 



function GetByteString(value, length, tail)
{	
	var strVal 	= value;	
	var nStrLen = strVal.length;		
	var nByte 	= 0;
	var i 		= 0;
	var objRegKor = /[ㄱ-힝]/;
	
	var strRtnValue = "";
	
	for(i=0;i<nStrLen;i++)
	{
		objRegKor.test(strVal.charAt(i)) ? nByte += 2 : nByte += 1;
		strRtnValue += strVal.charAt(i);
		
		if(nByte > length)
		{
			strRtnValue += tail;				
			break;
		}	
	}	
	
	
	return strRtnValue;
	
}


// ajax 에러리턴
function GetAjaxError(response)
{
	return examAjaxProResponse(response);
}

//AjaxPro로부터의 Pesponse를 검사합니다.
function examAjaxProResponse(response)
{
	var hasError;
	try
	{
		hasError = (response.error != undefined && response.error != null);
	}
	catch(ex)
	{
		alert(ex.message);
		return true;
	}
	
	try
	{
		if (hasError == true)
		{
			var error = response.error;
			if (error.Message == "<<The session is timeout.>>")
			{
				alert("세션이 만료되었습니다.\n\n로그인 페이지로 이동합니다.");
				document.location.href = "/login.aspx";
				return true;
			}
			var summary = "";
			if(error.Message != undefined && error.Message != null)
			{
				summary += "Message: " + error.Message;
			}
			if(error.Source != undefined && error.Source != null)
			{
				if(summary.length > 0)
				{
					summary += "\n";
				}
				summary += "Source: " + error.Source;
			}
			if(error.Stack != undefined && error.Stack != null)
			{
				if(summary.length > 0)
				{
					summary += "\n";
				}
				summary += "Stack: " + error.Stack;
			}
			if(error.TargetSite != undefined && error.TargetSite != null)
			{
				if(summary.length > 0)
				{
					summary += "\n";
				}
				summary += "TargetSite: " + error.TargetSite;
			}
			if(error.Type != undefined && error.Type != null)
			{
				if(summary.length > 0)
				{
					summary += "\n";
				}
				summary += "Type: " + error.Type;
			}
			alert(summary); 
		}
	}
	catch(ex)
	{
		hasError = true;
		alert(ex.message);
	}
    return hasError;
}


function GetFileExtension(filePath)
{
  var lastIndex = -1;
  lastIndex = filePath.lastIndexOf('.');
  var extension = "";

  if ( lastIndex != -1 ) {
    extension = filePath.substring( lastIndex+1, filePath.len );
  }
  else {
    extension = "";
  }

  return extension;
}


function SetImageInfo(obj,  maxsize, callback)
{
	var imgInfo = new Image();
	
	imgInfo.onload		= ImageLoad;
	imgInfo.callBack	= callback;
	imgInfo.maxsize		= maxsize;
	imgInfo.obj			= obj;
	imgInfo.src			= obj.value;
					
}


function ImageLoad()
{
	var imgSrc, imgWidth, imgHeight, imgFileSize;					
	var maxFileSize;
	
	imgObj		= this.obj
	imgSrc		= this.src;
	imgFileSize = this.fileSize;
	imgMaxSize	= this.maxsize;
					
	if (imgMaxSize == "300K") 
	{
		maxFileSize = 307200; // 최대 300KB까지
	}
	else if (imgMaxSize == "1M") 
	{
		maxFileSize = 1024000; // 최대 1MB까지
	}

	if (imgSrc == "" || imgWidth <= 0 || imgHeight <= 0) 
	{
		alert('그림파일을 가져올 수 없습니다.');
		this.onload = LoadImageBlank;
		return false;
	}

	/*
	if (imgFileSize > maxFileSize) 
	{
		//alert('선택하신 그림 파일은 허용 최대크기인 ' + maxFileSize/1024 + ' KB 를 초과하였습니다.');					
		alert("1MB over");
		this.onload = LoadImageBlank;
		return false;
	}
	*/

	// 콜백함수가 있다면
	if(this.callBack)
		eval(this.callBack(this));
		
}

// imageLoad / imageLoad1 작동중 오류발생시 사용되는 함수
function LoadImageBlank() 
{ 

}


// 모달 대화상자를 띄운다.
function ShowModalDialog (pUrl, pWidth, pHeight)
{
	var left = (screen.width - pWidth) / 2 ;
	var top	= (screen.height - pHeight) / 2 ;
	var sFeatures = 'dialogLeft:' + left + ';dialogTop:' + top + ';dialogWidth:' + pWidth + 'px;dialogHeight:' + pHeight + 'px' ;
    var sReturnValue = window.showModalDialog(pUrl, self, sFeatures) ; 
    
    return sReturnValue ;
}


// 체크상자 모두 체크/해제
function SetAllCheck(pChk, pChecked)
{
	
	try
	{	
		if(pChk)
		{		
			var cnt = pChk.length;
			
			if(pChk.length)
			{
				for(var i=0;i<cnt;i++)
				{
					pChk[i].checked = pChecked;
				}
			}
			else
			{
				pChk.checked = pChecked;
			}
		}	
	}
	catch(ex)
	{
		alert(ex.message);			
	}	
	
}


// 콤보박스 텍스트로 선택하는 스크립트
// 김재경 20061108
function SetComboSelectText(pCombo, pSelText)
{
	
	try
	{	
		var count	= pCombo.length;
		var bExist	= false;		
		var iSelIndex = 0;
				
		for(i=0;i<count;i++)
		{
			
			if(pSelText == pCombo.options[i].text)
			{
				iSelIndex = i;
				break;
			}			
		}
		
		pCombo.selectedIndex = i;
		
	}
	catch(ex)
	{
		alert(ex.message);			
	}	
	
}


// 콤보박스 value로 선택하는 스크립트
// 김재경 20070108
function SetComboSelectValue(pCombo, pSelValue)
{
	
	try
	{	
		var count	= pCombo.length;
		var bExist	= false;		
		var iSelIndex = 0;
				
		for(i=0;i<count;i++)
		{			
			if(pSelValue == pCombo.options[i].value)
			{
				iSelIndex = i;
				break;
			}			
		}
		
		pCombo.selectedIndex = i;
		
	}
	catch(ex)
	{
		alert(ex.message);			
	}	
	
}


// 라디오 버튼 선택값 가져오는 함수
// 김재경 20061220
function GetRadioButtonCheckValue(pRadioButtonListName)
{
	var objChk = document.getElementsByName(pRadioButtonListName);
	var rtnValue = "";
	
	for(var i=0;i<objChk.length;i++)
	{
		if(objChk[i].name == pRadioButtonListName)
		{
			if(objChk[i].checked)
			{
				rtnValue = objChk[i].value;
				break;
			}
		}
	}
	
	return rtnValue;
	
}


// 라디오 버튼 선택값 가져오는 함수
// 김재경 20061220
function SetRadioButtonCheckValue(pRadioButtonListName, pValue)
{
	var objChk = document.getElementsByName(pRadioButtonListName);
	
	for(var i=0;i<objChk.length;i++)
	{
				
		if(objChk[i].name == pRadioButtonListName && objChk[i].value == pValue)
		{
			
			objChk[i].checked = true;
			break;
		}
	}
	
}



//javascript로 구현한 Request
// 김재경 20070106
function Request(pName)    
{
    var rtnval = "";
    var nowAddress = unescape(location.href);
    var parameters = (nowAddress.slice(nowAddress.indexOf("?")+1,nowAddress.length)).split("&");
    
    for(var i = 0 ; i < parameters.length ; i++){
        var varName = parameters[i].split("=")[0];
        if(varName.toUpperCase() == pName.toUpperCase())
        {
            rtnval = parameters[i].split("=")[1];
            break;
        }
    }
    
    return rtnval;
}

// 파일패스에서 이름만 따오기..
function GetFilePathToFileName(pFilePath)
{
	var sRtnVal = "";
	var arrFileNm = pFilePath.split('\\');
				
	if(arrFileNm.length > 0)
	{
		sRtnVal = arrFileNm[arrFileNm.length-1];
	}
	
	return sRtnVal;

}

// 파일패스에서 이름만 따오기..
function GetFileUrlToFileName(pFilePath)
{
	var sRtnVal = "";
	var arrFileNm = pFilePath.split('/');
				
	if(arrFileNm.length > 0)
	{
		sRtnVal = arrFileNm[arrFileNm.length-1];
	}
	
	return sRtnVal;

}


function ViewImage(pImg)
{
	var pop = OpenWindow("","viewimage","500","500");
	var sPath = pImg.src.replace(/Thumb_/g, '');
	
	pop.location.reload();
	pop.document.write("<img id='photo' style='cursor:hand;' onload='window.resizeTo(this.width + 100, this.height + 100);' onclick='self.window.close();' src='" + sPath + "'>");
	pop.window.focus();
	
}


function IsNull(pValue, pRepStr)
{
	
	return pValue == null ? pRepStr : pValue;
			
}


function PrintPreview(pDiv, pFunc) 
{ 

	var sUrl = "";
	
	if(pFunc == null)
		sUrl = "/_CMON/CMONPrint.aspx?div=" + pDiv;
	else
		sUrl = "/_CMON/CMONPrint.aspx?div=" + pDiv + "&func=" + pFunc;	
		
	return OpenWindow(sUrl, "", 900, 700, 1);			
			
} 


// 모서리가 둥근 테이블 만들때 사용 - 아래 예처럼 테이블 html 생성할것
/* 예제) radius 가 높을수록 둥글게됨, rborder = 테두리 색상 , rbgcolor = 안쪽색상
<table id="ta" width="300" height="100" border="0" radius="3" rborder="#999999" rbgcolor="red">
<tr>
<td valign="top">테스트입니다</td>
</tr>
</table>
<script>SetRoundTable("ta");</script>
*/
function SetRoundTable(objID) 
{	
	var obj = document.getElementById(objID);
	
	//obj 가 디스플레이 중인지 아닌지로 이하 로직을 태우고 안태우고를 정한다 20080710 김상민
	if(obj == null || obj.style.display == 'none')
	{		
		return false;
	}
	///////////////////////////////////////////////////////////////////////////////////////////
	var Parent, objTmp, Table, TBody, TR, TD;
	var bdcolor, bgcolor, Space;
	var trIDX, tdIDX, MAX;
	var styleWidth, styleHeight;
	
	// get parent node
	Parent = obj.parentNode;
	objTmp = document.createElement('SPAN');
	
		
	Parent.insertBefore(objTmp, obj);
	Parent.removeChild(obj);
	
	
	//obj.style.tableLayout = 'fixed';
	//obj.style.wordBreak   = 'keep-all';
	//obj.style.padding     = '3px';
	
	// get attribute
	bdcolor = obj.getAttribute('rborder');
	bgcolor = obj.getAttribute('rbgcolor');
	radius = parseInt(obj.getAttribute('radius'));
	if (radius == null || radius < 1) radius = 1;
	else if (radius > 6) radius = 6;
	
	MAX = radius * 2 + 1;
	
	/*
	create table {{
	*/
	Table = document.createElement('TABLE');
	TBody = document.createElement('TBODY');
	
	Table.cellSpacing = 0;
	Table.cellPadding = 0;
	
	
	for (trIDX=0; trIDX < MAX; trIDX++) 
	{
		
		TR = document.createElement('TR');
		Space = Math.abs(trIDX - parseInt(radius));
		
		
	
		for (tdIDX=0; tdIDX < MAX; tdIDX++) 
		{
			TD = document.createElement('TD');
	
			styleWidth = '1px'; styleHeight = '1px';
	
			if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
			else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
			else if (radius > 2) 
			{
				if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
				if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
			}
	
			if (styleWidth != null) TD.style.width = styleWidth;
			if (styleHeight != null) TD.style.height = styleHeight;
	
			// MAX / trIDX < 2 ||  <-- 반만 하고 싶다면...추가
			if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
			else if (tdIDX > Space && Space < MAX - tdIDX - 1) TD.style.backgroundColor = bgcolor;
	
			if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
			TR.appendChild(TD);
		}
		
		TBody.appendChild(TR);
		
	}
	
	/*
	}}
	*/
	
	Table.appendChild(TBody);
	
	// insert table and remove original table
	Parent.insertBefore(Table, objTmp);
	
}


function SetRoundButton(objID) 
{
	var obj = document.getElementById(objID);
	var Parent, objTmp, Table, TBody, TR, TD;
	var bdcolor, bgcolor, Space;
	var trIDX, tdIDX, MAX;
	var styleWidth, styleHeight;		
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//부모테이블 자식테이블과 부모테이블은 Sub 문자열로 처리된다. 20080618 김상민
	var parTable = document.getElementById(obj.id.substring(0,obj.id.length-3));					
	//글자수 20080618 김상민
	var sfontLength = 0;		
	//상위 td 20080618 김상민	
	var ParTd = parTable.parentNode;								
	//상위 td의 width 20080618 김상민
	var ParTdWidth = 0;	
	//텍스트 바로위 td  20080618 김상민
	var objtd = document.getElementById("td" + obj.id);
	
	//글자수에 쓰일 변수 셋팅 20080618 김상민
	var arrTextlenth = objtd.name.split('$$');
	//글자수로 사이즈를 잡는다. 20080618 김상민
	var fontSize = (arrTextlenth[1] * 8) + (arrTextlenth[0]*10/10);			
	
	//버튼상위td의 사이즈를 잡는다. 20080618 김상민
	if(ParTd.style.width != '')
	{	
		ParTdWidth = ParTd.style.width.replace('px','');
	}
	else if(ParTd.width != '')
	{		
		ParTdWidth = ParTd.width.replace('px','');
	}
	else //지정이 되어있지 않다면 넘어간다. 20080618 김상민
	{		
		ParTdWidth = 0;
	}
	
	//글자수의 사이즈로 상위 td의 width값을 지정한다.
	//td에 위드값이 글자수의 넓이 보다 작거고 지정을 했을경우. 20080618 김상민
	if(ParTdWidth < fontSize && ParTdWidth != 0)
	{		
		ParTd.width = fontSize;		
	}	
	
	//부모테이블의 스타일 widrh,height 을 자식개체에 준다.	20080618 김상민
	if(parTable.style.height != '')
	{
		obj.style.height = parTable.style.height.replace('px','');
	}
	else if(parTable.style.width != '')
	{
		obj.style.width = parTable.style.width.replace('px','') - 5;
	}
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	// get parent node
	Parent = obj.parentNode;
	objTmp = document.createElement('SPAN');
	
		
	Parent.insertBefore(objTmp, obj);
	Parent.removeChild(obj);
	
	
	//obj.style.tableLayout = 'fixed';
	//obj.style.wordBreak   = 'keep-all';
	//obj.style.padding     = '3px';
	
	// get attribute
	bdcolor = obj.getAttribute('rborder');
	bgcolor = obj.getAttribute('rbgcolor');
	radius = parseInt(obj.getAttribute('radius'));
	if (radius == null || radius < 1) radius = 1;
	else if (radius > 6) radius = 6;
	
	MAX = radius * 2 + 1;
	
	/*
	create table {{
	*/
	Table = document.createElement('TABLE');
	TBody = document.createElement('TBODY');
	
	Table.cellSpacing = 0;
	Table.cellPadding = 0;
	
	
	for (trIDX=0; trIDX < MAX; trIDX++) 
	{
		
		TR = document.createElement('TR');
		Space = Math.abs(trIDX - parseInt(radius));
		
		
	
		for (tdIDX=0; tdIDX < MAX; tdIDX++) 
		{
			TD = document.createElement('TD');	
			
			styleWidth = '1px'; styleHeight = '1px';
			
	
			if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
			else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
			else if (radius > 2) 
			{

				if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
				if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
			}
	
			if (styleWidth != null) TD.style.width = styleWidth;
			if (styleHeight != null) TD.style.height = styleHeight;
	
			// MAX / trIDX < 2 ||  <-- 반만 하고 싶다면...추가
			if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
			else if (tdIDX > Space && Space < MAX - tdIDX - 1) TD.style.backgroundColor = bgcolor;
	
			if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
			TR.appendChild(TD);
		}
		
		TBody.appendChild(TR);			
	}
	
	/*
	}}
	*/			
	
	Table.appendChild(TBody);		
	
	
	// insert table and remove original table
	Parent.insertBefore(Table, objTmp);	
}

// 키보드 입력이 문자인지 구분
function IsCharKeycode(pKeyCode)
{
	var arrKey = new Array(8,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,96,97,98,99,100,101,102,103,104,105,106,107,109,110,111,186,187,188,189,190,191,192,219,220,221,222);
	var bRtnVal = false;
	
	for(var i=0;i<arrKey.length;i++)
	{
		if(pKeyCode == arrKey[i])
		{
			bRtnVal = true;
			break;
		}
	}
	
	return 	bRtnVal;
	
}


// 핸드폰 보내기 팝업창
function OpenSmsSendPopUp(pHpNo)
{
	var hwnd=OpenWindow('/_CMON/CMONSmsSend.aspx?MSGN=1&HpNo='+ pHpNo.replace(/-/g,""),'SendSms',200,400,false, "no");
	hwnd.focus();	
}


// 근태현황 팝업창
function OpenAtPopUp(pUserId)
{

	var hwnd=OpenWindow('/_ATTE/ATTEAtYm.aspx?userid='+ pUserId,'At',550,760, 1, "no");
	hwnd.focus();	
}


//메일작성 팝업창을 연다.
function OpenPopMailSend(pEmail, pUserNm)
{
	var sEmail;
	if(pEmail)
	{
		sEmail = pEmail;
	}
	else
	{
	    sEmail = "";
	}
	var sUrl = escape("/_MAIL/MailPost.aspx?target=popupsend&email=" + sEmail + "&name=" + (pUserNm) +"<"+ pEmail +">");
	sUrl = "/_CMON/CMONPopFrame.aspx?url=" + sUrl + "&title=" + escape('MAIL') + "&target=popupsend";
	OpenWindow(sUrl, "", 900, 820, 0);

}
//메일작성 팝업창을 연다.
function OpenPopMailSend3(pEmail, pUserNm) {
    var sEmail;
    if (pEmail) {
        sEmail = pEmail;
    }
    else {
        sEmail = "";
    }
    var sUrl = escape("/_MAIL/MailPost.aspx?target=popupsend&email=" + sEmail + "&name=" + (pUserNm) + pEmail);
    sUrl = "/_CMON/CMONPopFrame.aspx?url=" + sUrl + "&title=" + escape('MAIL') + "&target=popupsend";
    OpenWindow(sUrl, "", 900, 820, 0);

}


//메일작성 팝업창을 연다2.
function OpenPopMailSend2(pEmail, pUserNm)
{
	var sEmail;
	if(pEmail)
	{
		sEmail = pEmail;
	}
	else
	{
	    sEmail = "";
	}
	var sUrl = "/_MAIL/MailPostPopup.aspx?target=popupsend&email=" + sEmail + "&name=" + encodeURI(pUserNm);
	sUrl + "&title=" + escape('MAIL') + "&target=popupsend";
	OpenWindow2(sUrl, "", 900, 920, 0);
}

//메일작성 팝업창을 연다.

function OpenPopMailSendWBLD(pBoardId, pSeq, pContent, pUrl, pLang)
{
	//alert(pBoardId);
	//alert(pSeq);
	//alert(pContent.substring(pContent.length-(pContent.length/6)));
	
	/*	
	_WBLD_CONTENT_ = pContent.replace(/<object/gi, "<OBJECT2").replace(/<script/gi, '<script2');
	_WBLD_CONTENT_ = pContent.replace(/<input/gi, "<INPUT2").replace(/<img/gi, '<IMG2');
	
		
	var objTmpFrm = "<IFRAME name='ifrmTmpMail' src='about:blank' width='0' height='0' scrolling=no></IFRAME>";
	document.body.insertAdjacentHTML("beforeEnd",objTmpFrm);
	
	ifrmTmpMail.document.write(_WBLD_CONTENT_);
	ifrmTmpMail.tbUpload.style.display = "none";
	ifrmTmpMail.trWebUpload.style.display = "none";
	ifrmTmpMail.trAXUpload.style.display = "none";
	
	_WBLD_CONTENT_ = ifrmTmpMail.document.body.innerHTML;
	*/
	
	
	var sUrl = escape("/_MAIL/MailPost.aspx?target=popupsend&email=&name=&sendtype=circular&bid=" + pBoardId + "&bseq=" + pSeq );
	sUrl = "/_CMON/CMONPopFrame.aspx?url=" + sUrl + "&title=" + escape('MAIL') + "&target=popupsend";
	OpenWindow(sUrl, "", 900, 820, 0);
	
	
	
	
}

function OpenCommonOrgan(pMode, pCallBack)
{
	OpenWindow("/_CMON/CMONOrgan.aspx?mode=" + pMode + "&callback=" + pCallBack,'CommonOrgan',1060,560, 1, "no");
}

function OpenCommonOrganPMSS(pMode, pCallBack,pKey1,pKey2)
{
	OpenWindow("/_CMON/CMONOrgan.aspx?mode=" + pMode + "&callback=" + pCallBack + "&pKey1=" + pKey1 + "&pKey2=" + pKey2 ,'CommonOrgan',1060,560, 1, "no");
}



function OpenCommonAcqu(pMode, pCallBack)
{
	OpenWindow("/_CMON/CMONAcquList.aspx?mode=" + pMode + "&callback=" + pCallBack,'CommonAcqu',980,560, false, "no");
}

function OpenCommonAcqu_Shinyoung(pMode, pCallBack)
{
	OpenWindow("/_CMON/CMONAcquComboList.aspx?mode=" + pMode + "&callback=" + pCallBack,'CommonAcqu',980,560, false, "no");
}

function CMONRestorePage()
{
	
		restorelist.IsRestore.value="1";
		restorelist.submit();
	
}



// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).

function getInternetExplorerVersion()
{
  var rv; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(navigator.userAgent) != null)
		rv = parseFloat( RegExp.$1 );
	else
		rv = -1;
  }
  else
	rv = -1;
  return rv;
}



function GetDivAbsX(elt) 
{ 
	return parseInt(elt.x) ? elt.x : GetDivAbsPos(elt,"Left"); 
}

function GetDivAbsY(elt) 
{ 
	return parseInt(elt.y) ? elt.y : GetDivAbsPos(elt,"Top"); 
}

function GetDivAbsPos(elt,which) 
{
	var iPosDiv = 0;
	while (elt != null) 
	{
		iPosDiv += elt["offset" + which];
		elt = elt.offsetParent;
	}

	return iPosDiv;
}

function SetPOPWBLDNo(no)
{
	var pPage='/_wbld/htmlpop/wbldpop' + no + '.html';
	window.open(pPage,pName,"left=" + 10 + ",top=" + 10 + ",width=" + 400 + ",height=" + 300 + ",status=yes,resizable=" + resizable + ",scrollbars=");
}
