﻿// JScript 파일
var _cContentID = "ctl00_cphOSH_";

/************************************************************************************************
* Procedure   : CheckRequired
* Description : 필수항목 체크..입력이 안되었을 경우 메시지 Alert 후 해당 컨트롤에 포커스 이동
* Parameter   : pObjID - string 컨트롤ID
*               pMsg   - string 메시지 
* Return      : true/false
*************************************************************************************************/
function CheckRequired(pObjID, pMsg) {
	if (Trim(document.getElementById(pObjID).value) == "") {
		alert(pMsg + "     ");
		
		try {
		    document.getElementById(pObjID).focus();
		}
		catch (E) {}
		
		return false; 
	}
	
	return true;
}


/************************************************************************************************
* Procedure   : Trim
* Description : 공백 제거 함수로 스페이스바로 입력 한 공백을 제거한다..
* Parameter   : pStr - string 확인할 내용
* Return      : string 공백을 제거한 내용
*************************************************************************************************/
function Trim(pStr) 
{		
    while (pStr.search(/^\s/) != -1)
        pStr = pStr.replace(/^\s/,"");	
    while (pStr.search(/\s$/) != -1)	
        pStr = pStr.replace(/\s$/,"");
    return pStr;
}

/*******************************************************************
* Procedure   : IsNumeric
* Description : 숫자(소수점 포함)인지 체크.
* Parameter   : pStr - string 확인할 내용
* Return      : true/false
*******************************************************************/
function IsDecimal(pStr){
	for(var i=0; i<pStr.length; i++) {
        var uniCode = pStr.charCodeAt(i);
        
        if(!((uniCode >= 48 && uniCode <= 57) || uniCode==46))
            return false;
    }
    return true;
}

/************************************************************************************************
* Procedure   : PreviewImg
* Description : 이미지 미리보기 함수
* Parameter   : objImg - 이미지객체
* Return      : 
*************************************************************************************************/
function PreviewImg(objImg)
   {
        x = (screen.availWidth - objImg.width) / 2;
        y = (screen.availHeight - objImg.height) / 2;

        var newImage = new Image();
        newImage.src = objImg.src;
        
        var pW = newImage.width + 40;
        var pH = newImage.height + 40;
      
        pop = window.open('','bigimg','top=' + y + ', left=' + x + ', width=' + pW + ',height=' + pH + ',resizable=1,scrollbars=1');
        
        if(pop != null) {
            myText = "<html><head><title>원본 이미지 보기</title></head><body>";
            myText += "<img src=\"" + objImg.src + "\" onclick=\"self.close()\" style=\"cursor:pointer\" title=\"클릭하면 닫힙니다\">";
            myText += "</body></html>";
            pop.document.write(myText);
        }
       
        pop.focus();
   }
   
/************************************************************************************************
* Procedure   : WinOpen
* Description : Popup 로 뛰운다.. (스크롤여부,Resize여부 지정)
* Parameter   : pUrl - string URL
*             : pWidth - int Width
*             : pHeight - int Height
*             : pWinName - string window name
*             : pScroll - string 스크롤여부(yes,no)
*             : pResize - string Resize여부(yes,no)
* Return      : void
*************************************************************************************************/
function WinOpen(pUrl, pWidth, pHeight, pWinName,pScroll,pResize)
{
	var nLeft  = screen.width/2 - pWidth/2 ;
	var nTop  = screen.height/2 - pHeight/2 ;
	
	var scl = "no";
	
	if ( pScroll == 'yes' ) scl = pScroll;
	 
	var opt = ",toolbar=no,menubar=no,location=no,scrollbars="  + scl + ",status=yes";		
	if (pResize)
		opt += ",resizable=" + pResize;
		
	var oNewWindow = window.open(pUrl, pWinName, "left=" + nLeft + ",top=" +  nTop + ",width=" + pWidth + ",height=" + pHeight  + opt );
	
	return oNewWindow;
} 

/************************************************************************************************
* Procedure   : GetObject
* Description : .NET 에서 master 를 쓸때 페이지에서 해당 컨트롤의 Object 값을 가져올때.
* Parameter   : pObjNm - string 컨트롤명
* Return      : Object
*************************************************************************************************/
function GetObject(pObjNm)
{
    return eval("document.getElementById('" + _cContentID + pObjNm + "')");
}

/************************************************************************************************
* Procedure   : ExceptionFile
* Description : 파일 확장자 체크
* Parameter   : pFileName - 파일명(풀 Path 포함 가능)
* Return      : boolean
*************************************************************************************************/
function ExceptionFile(pFileName)
{
    var strExt = pFileName.substring(pFileName.lastIndexOf("."));
    
    strExt = strExt.toLowerCase();
    
    switch(strExt)
    {
        case ".asp":
        case ".aspx":
        case ".exe":
        case ".bat":
        case ".php":
        case ".sqp":
        case ".html":
        case ".ashx":
        case ".js":
        case ".vbs":
        case ".dll":
        case ".com":
        case ".css":
        case ".cer":
        case ".htm":
        case ".asa":
            return false;
            break;
        
    }
}

/************************************************************************************************
* Procedure   : Calendar
* Description : Calendar
* Parameter   : pValue
*               pSource
*               pTarget
* Return      : Calendar(this, this.value)
*************************************************************************************************/
function Calendar(Object, strCurrentDate) 
{
    strUrl = "/OSH_Web/Common/Pages/Calendar.aspx";   
    strFeatures = "dialogWidth:340px; dialogHeight:380px; dialogTop:200px; dialogLeft:400px; help:no; status:no ";
    strDate = window.showModalDialog(strUrl, strCurrentDate, strFeatures);
    if (strDate != "")
        Object.value = strDate;
}