﻿function igGrid_ScriptObj(name) {
    return eval(name + 'ObjC');
}
/*
Header Define
컬럼정의 ==> 컬럼배열담기 ==> 컬럼배열을 로우에 추가 ==> 로우들를 로우배열에 담기
==> 헤더정의에 추가
*/

//UcDnHeaderInfo Obj
//Grid의 논리적인 Header정의를 나타낸다...
//Rows배열을 담고 있다
function UcDnHeaderInfo(hRows) {
    this.hRows = hRows;
    this.rowsLength;
    this.UcDnHRow = getHRowByIndex;
    if (hRows.Collections != undefined) {
        this.rowsLength = hRows.Collections.length;
    }
    else {
        throw 'Grid Error : Collections in UcDnHeaderInfo not found';
    }
}

function getHRowByIndex(idx) {

    return this.hRows.Collections[idx];
}

//UcDnHRows Obj
//UcDnHRow 로우의 배열을 가지고 있다
function UcDnHRows() {
    this.Collections;
    this.add = add_UcDnHRow;
}

function add_UcDnHRow(UcDnHRow) {
    if (this.Collections == undefined) {
        this.Collections = new Array();
        this.Collections[0] = UcDnHRow;
    }
    else {
        this.Collections[this.Collections.length] = UcDnHRow;
    }
}

//UcDnHRow Obj
//Grid Header의 논리적인 행이며, Header 컬럼의 배열과 height 속성을 가지고 있다
function UcDnHRow(cols, height) {
    this.cols = cols;
    this.height = height;
    this.UcDnHColumn = getHColumnByIndex;
}

function getHColumnByIndex(idx) {
    return this.cols.Collections[idx];
}


//UcDnHColumns Obj
//HEAD 컬럼의 배열
function UcDnHColumns() {
    this.Collections;
    this.add = add_UcDnHColumn;
}

function add_UcDnHColumn(UcDnHColumn) {
    if (this.Collections == undefined) {
        this.Collections = new Array();
        this.Collections[0] = UcDnHColumn;
    }
    else {
        this.Collections[this.Collections.length] = UcDnHColumn;
    }
}

//UcDnHColumn Obj
//HEAD 컬럼의 정의를 나타낸다
function UcDnHColumn(spanX, spanY, caption, hAlign, vAlign, width, isRightBorder, captionImage) {
    this.spanX = spanX;
    this.spanY = spanY;
    this.caption = caption;
    this.hAlign = hAlign;
    this.vAlign = vAlign;
    this.width  = width;
    this.isRightBorder = isRightBorder;
    this.captionImage = captionImage;
}
/***********************************************************************************************************************************/
//UcDnItemInfo Obj
//Grid의 논리적인 Item정의를 나타낸다...
//Rows배열을 담고 있다
function UcDnItemInfo(iRows) {
    this.iRows = iRows;
    this.rowsLength;
    this.UcDnIRow = getIRowByIndex;
    if (iRows.Collections != undefined) {
        this.rowsLength = iRows.Collections.length;
    }
    else {
        throw 'Grid Error : Collections in UcDnItemInfo not found';
    }
}

function getIRowByIndex(idx){
    
    return this.iRows.Collections[idx];
}

//UcDnIRows Obj
//UcDnIRow 로우의 배열을 가지고 있다
function UcDnIRows() {
    this.Collections;
    this.add = add_UcDnIRow;
}

function add_UcDnIRow(UcDnIRow) {
    if (this.Collections == undefined) {
        this.Collections = new Array();
        this.Collections[0] = UcDnIRow;
    }
    else {
        this.Collections[this.Collections.length] = UcDnIRow;
    }
}

//UcDnIRow Obj
//Grid Item의 논리적인 행이며, Item 컬럼의 배열과 height 속성을 가지고 있다
function UcDnIRow(cols, height) {
    this.cols = cols;
    this.height = height;
    this.UcDnIColumn = getIColumnByIndex;
}

function getIColumnByIndex(idx) {
    return this.cols.Collections[idx];
}

//UcDnIColumns Obj
//Item 컬럼의 배열
function UcDnIColumns() {
    this.Collections;
    this.add = add_UcDnIColumn;
}

function add_UcDnIColumn(UcDnIColumns) {
    if (this.Collections == undefined) {
        this.Collections = new Array();
        this.Collections[0] = UcDnIColumns;
    }
    else {
        this.Collections[this.Collections.length] = UcDnIColumns;
    }
}

//UcDnIColumn Obj
//Item 컬럼의 정의를 나타낸다
function UcDnIColumn(spanX, spanY, key, cellType, hAlign, vAlign, isRightBorder, tooltip, IsHidden, maxLength) {
    this.spanX = spanX;
    this.spanY = spanY;
    this.key = key;
    this.cellType = cellType;
    this.hAlign = hAlign;
    this.vAlign = vAlign;
    this.isRightBorder = isRightBorder;
    this.tooltip = tooltip;
    this.IsHidden = IsHidden;
    this.maxLength = maxLength;
}
/***********************************************************************************************************************************/
/*
Event Define
*/

//UcDnHColumns Obj
//HEAD 컬럼의 배열
function UcDnEvents() {
    this.Collections;
    this.add = add_UcDnEvent;
}

function add_UcDnEvent(UcDnEvent) {
    if (this.Collections == undefined) {
        this.Collections = new Array();
        this.Collections[0] = UcDnEvent;
    }
    else {
        this.Collections[this.Collections.length] = UcDnEvent;
    }
}

//UcDnEvent Obj
//HEAD 컬럼의 정의를 나타낸다
function UcDnEvent( bindGroupSet,initGroupSet,initAttachPosit,
                    applyEmptyRow,applyEmptyRowCheckKey,applyEventColumns,eventName,
                    isClientScriptCall,
                    message,messageDisplay,messageType,
                    addGroupSetKey,addGroupSetName,callServiceName,groupSetName,
                    popupOpenType,programLocation,transferParamsKeys,windowHeight,windowWidth,popupConstValue,
                    confirmMessage, 
                    fireEvtColsDataExist, fireEvtColNames,
                    windowScroll) {
    this.bindGroupSet           = bindGroupSet;
    this.initGroupSet           = initGroupSet;
    this.initAttachPosit        = initAttachPosit;
    this.applyEmptyRow          = applyEmptyRow;
    this.applyEmptyRowCheckKey  = applyEmptyRowCheckKey;
    this.applyEventColumns      = applyEventColumns;
    this.fireEvtColsDataExist   = fireEvtColsDataExist;
    this.fireEvtColNames        = fireEvtColNames;
    this.eventName              = eventName;
    this.isClientScriptCall     = isClientScriptCall;
    this.message                = message;
    this.messageDisplay         = messageDisplay;
    this.messageType            = messageType;
    this.addGroupSetKey         = addGroupSetKey;
    this.addGroupSetName        = addGroupSetName;
    this.callServiceName        = callServiceName;
    this.groupSetName           = groupSetName;
    this.popupOpenType          = popupOpenType;
    this.programLocation        = programLocation;
    this.transferParamsKeys     = transferParamsKeys;
    this.windowHeight           = windowHeight;
    this.windowWidth            = windowWidth;
    this.popupConstValue        = popupConstValue;
    this.confirmMessage         = confirmMessage;
    this.windowScroll           = windowScroll;
}
/***********************************************************************************************************************************/
//UcDnGrid Obj
function UcDnGrid(ID,UcDnHeaderInfoObj, UcDnItemInfoObj, UcDnEventInfo,
                IsOddEven, IsHeadersHidden, IsNumberHidden,
                RowOddbackColor, RowOddForeColor, RowEvenBackColor, RowEvenForeColor,
                ForeColor, BackColor, InitDataRowCount,
                IsSetMouseOverColor) {
    /*
        parameter-property
    */
    this.ID                 = ID;
    this.UcDnHeaderInfoObj  = UcDnHeaderInfoObj;
    this.UcDnItemInfoObj    = UcDnItemInfoObj;
    this.UcDnEventInfo      = UcDnEventInfo;
    this.IsOddEven          = IsOddEven;
    this.IsHeadersHidden    = IsHeadersHidden;
    this.IsNumberHidden     = IsNumberHidden;
    this.IsSetMouseOverColor = IsSetMouseOverColor;
    this.RowOddbackColor    = RowOddbackColor;
    this.RowOddForeColor    = RowOddForeColor;
    this.RowEvenBackColor   = RowEvenBackColor;
    this.RowEvenForeColor   = RowEvenForeColor;
    this.ForeColor          = ForeColor;
    this.BackColor          = BackColor;
    this.InitDataRowCount   = InitDataRowCount;
    /*
        internal-property
    */
    this.DataSource;
    this.currPageNumber;
    this.currPageBlockNumber        = 1;
    this.maxPageNumber;
    this.maxPageBlockNumber;
    this.maxCurrentPageRangeNumber  = 0;
    this.minCurrentPageRangeNumber  = 0;
    this.currPageBlockSize          = 10;
    this.currPageBlockSizeCalc      = this.currPageBlockSize - 1;
    /*
        method
    */
    this.Initialize             = Initialize;
    this.DataBind               = DataBind;
    this.getTextByKey           = getTextByKey;
    this.setHeaderText          = setHeaderText;
    this.setDecorationColor     = setDecorationColor;
    this.setBgColorByKey        = setBgColorByKey;
    this.setForeColorByKey      = setForeColorByKey;
    this.setBgAndForeColorByKey = setBgAndForeColorByKey;
    this.RowsClear              = RowsClear;
    this.viewCurrentPage        = viewCurrentPage;
    this.pageDeco               = pageDeco;
    this.nextPage               = nextPage;
    this.prePage                = prePage;
    this.goStartPage            = goStartPage;
    this.goEndPage              = goEndPage;
    this.viewPageByPageNumber   = viewPageByPageNumber;
    this.setPageNumber          = setPageNumber;
    this.setPageNuberBold       = setPageNuberBold;
    this.eventHandlerFn         = eventHandlerFn;
    this.onMouseOver_Handler    = onMouseOver_Handler;
    this.onMouseOut_Handler     = onMouseOut_Handler;
    this.eventColumnsCheck      = eventColumnsCheck;
    this.getMergeColumnIndex    = getMergeColumnIndex;
}


var colspanCnt = 0;
var colspan = 0;
function Initialize() {
    this.RowsClear();
    var gridObj = document.getElementById('tbl' + this.ID);
    var cssName = "";
    //Header 정보 setting
    for(i = 0 ; i < this.UcDnHeaderInfoObj.hRows.Collections.length ; i++) 
    {
        row = gridObj.insertRow();
        var rowheight = this.UcDnHeaderInfoObj.UcDnHRow(i).height;
        
        for(j = 0 ; j < this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections.length ; j++) {
            colspanCnt++;
            cell = row.insertCell();
            cell.height = rowheight;
            if(i == 0)
                cell.width = this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].width + "%";
            cell.colSpan = this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].spanX;
            cell.rowSpan = this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].spanY;
            //alert(this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].spanX + " , " + this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].spanY);
            if (this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].captionImage != "")
                cell.innerHTML = "<img src='" + this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].captionImage + "' />";
            else
                cell.innerHTML = "<span class='smallfont3'>" + this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].caption + "</span>";
                
            cell.align = this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].hAlign;
            cell.vAlign = this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].vAlign;
            cell.bgColor = "#F0F3F7";

            if(i == 0)
                colspan += this.UcDnHeaderInfoObj.UcDnHRow(i).cols.Collections[j].spanX;
        }
    }
    
    this.DataBind();
}

function DataBind() {
    //Bind된 행 clear!!!!!!
    this.RowsClear();
    
    this.currPageNumber = 1;
    this.viewCurrentPage();
    if(this.DataSource != null) {
        this.maxPageNumber = Math.ceil(this.DataSource.Rows.length/this.InitDataRowCount);
        if(this.maxPageNumber > 1) {
            document.getElementById('pageNumber_' + this.ID).style.display = 'inline';
            this.maxPageBlockNumber = Math.ceil(this.maxPageNumber/this.currPageBlockSize);
            this.setPageNumber();
            this.setPageNuberBold(this.currPageNumber);
        }
        else {
            document.getElementById('pageNumber_' + this.ID).style.display = 'none';
        }
    }
    if(this.IsHeadersHidden) {
        var gridObj = document.getElementById('tbl' + this.ID);
        gridObj.deleteRow(0);
        for(i = 0 ; i < this.UcDnHeaderInfoObj.hRows.Collections.length ; i++) 
        {
            //gridObj.deleteRow(i);
            gridObj.rows[i].style.display = 'none';
        }
    }
}

function getTextByKey(row, key) {
    if(this.DataSource != null) {
        if(this.DataSource.Rows.length <= row || this.DataSource.Rows[row][key] == undefined)
            return "";
        else {
            return this.DataSource.Rows[row][key];
        }
    }
    else {
        return "";
    }
}

function setHeaderText(row,col,text) {
    var gridObj = document.getElementById('tbl' + this.ID);
    gridObj.rows[row].cells[col].innerHTML = "<strong>" + text + "</strong>";
}

function setBgColorByKey(row, key, bgColor) {
    return this.setDecorationColor(row,key,bgColor,null,1);
}

function setForeColorByKey(row, key, foreColor) {
    return this.setDecorationColor(row,key,null,foreColor,2);
}

function setBgAndForeColorByKey(row, key, bgColor, foreColor) {
    return this.setDecorationColor(row,key,bgColor,foreColor,3);
}

function setDecorationColor(row, key, bgColor, foreColor, flag) {
    var gridObj = document.getElementById('tbl' + this.ID);
    headerItemCnt = this.UcDnHeaderInfoObj.hRows.Collections.length;
    logicalItemCnt = this.UcDnItemInfoObj.iRows.Collections.length;
    realRowIdx = ((row + 1) * logicalItemCnt) + headerItemCnt;
    
    var el = gridObj.rows[realRowIdx];

    for(i = el.startId ; i < el.finishId ; i++) {
        el1 = document.getElementById(el.logicalId + i);
        for(j = 0 ; j < el1.cells.length; j++) {
            if(el1.cells[j].key == key) {
                if(flag == 1 || flag == 3)
                    el1.cells[j].bgColor = bgColor;
                if(flag == 2 || flag == 3)
                    el1.cells[j].style.color = foreColor;
                return true;
            }
        }
    }
    return false;
}

function setPageNumber() {
    var pageView = document.getElementById('pageView' + this.ID);
    var pageNumberSrc = "";
    
    this.currPageBlockNumber = Math.ceil(this.currPageNumber/this.currPageBlockSize);
    var maxPageRangeNumTemp = (this.maxCurrentPageRangeNumber == 0 ? this.currPageBlockSize : this.currPageBlockNumber * this.currPageBlockSize);
    
    this.maxCurrentPageRangeNumber = (this.maxPageNumber > maxPageRangeNumTemp ? maxPageRangeNumTemp : this.maxPageNumber);
    this.minCurrentPageRangeNumber = (this.maxCurrentPageRangeNumber == 0 ? 1 : 
                                    (this.currPageBlockNumber == this.maxPageBlockNumber ? ( (this.currPageBlockNumber - 1) * this.currPageBlockSize) + 1 : this.maxCurrentPageRangeNumber - this.currPageBlockSizeCalc)
                                    );
    
    for(i=this.minCurrentPageRangeNumber-1 ; i < this.maxCurrentPageRangeNumber ; i++) 
    {
        pageNumberSrc += '<a id="' + this.ID + 'page_' + (i+1) + 
                                    '" style="cursor:hand" onclick="var grid = igGrid_ScriptObj(' + "'" + this.ID + "'" + ');grid.viewPageByPageNumber(' + (i+1) + ');grid.setPageNuberBold(' + (i+1) + ')">' + 
                                    (i+1) + 
                                    '</a>' + 
                                    (i + 1 == this.maxCurrentPageRangeNumber ? '' : '<img src="/Images/DnGrid/board_num_line.gif" align="absmiddle" />');
    }
    pageView.innerHTML = pageNumberSrc;
}
function setPageNuberBold(pageNumber) {
    this.currPageBlockNumber = Math.ceil(this.currPageNumber/this.currPageBlockSize);
    var maxPageRangeNumTemp = (this.maxCurrentPageRangeNumber == 0 ? this.currPageBlockSize : this.currPageBlockNumber * this.currPageBlockSize);
    
    this.maxCurrentPageRangeNumber = (this.maxPageNumber > maxPageRangeNumTemp ? maxPageRangeNumTemp : this.maxPageNumber);
    this.minCurrentPageRangeNumber = (this.maxCurrentPageRangeNumber == 0 ? 1 : 
                                    (this.currPageBlockNumber == this.maxPageBlockNumber ? ( (this.currPageBlockNumber - 1) * this.currPageBlockSize) + 1 : this.maxCurrentPageRangeNumber - this.currPageBlockSizeCalc)
                                    );
    
    for(i=this.minCurrentPageRangeNumber-1 ; i < this.maxCurrentPageRangeNumber ; i++) 
    {
        if( (i + 1) == pageNumber)
            document.getElementById(this.ID + 'page_' + (i + 1)).innerHTML = '<span class="redtitle2">' + (i + 1) + '</span>';
        else
            document.getElementById(this.ID + 'page_' + (i + 1)).innerHTML = '<span class="notice">' + (i + 1) + '</span>';
    }
}
function pageDeco(flag) {
    if(flag == 1)
        this.setPageNumber();
    
    this.viewCurrentPage();
    this.setPageNuberBold(this.currPageNumber);
}
function goStartPage() {
    this.currPageNumber = 1;
    this.pageDeco(1);
}
function goEndPage() {
    this.currPageNumber = this.maxPageNumber;
    this.pageDeco(1);
}
function prePage() {
    if(1 <= this.currPageNumber - 1) {
        this.currPageNumber = this.currPageNumber - 1;
        this.pageDeco(1);
    }
}
function nextPage() {
    if(this.maxPageNumber >= this.currPageNumber + 1) {
        this.currPageNumber = this.currPageNumber + 1;
        this.pageDeco(1);
    }
}
function viewPageByPageNumber(pageNumber) {
    if(this.maxPageNumber >= pageNumber) {
        this.currPageNumber = pageNumber;
        this.pageDeco(0);
    }
}
function viewCurrentPage() {
    var gridObj = document.getElementById('tbl' + this.ID);
    this.RowsClear();
    var startCnt = (this.currPageNumber == 1 ? 0 : (this.currPageNumber - 1) * this.InitDataRowCount);
    var endCnt = this.currPageNumber * this.InitDataRowCount;

    //Item 정보 setting
    for(itemBindCnt = startCnt ; itemBindCnt < endCnt ; itemBindCnt++) 
    {
        for(i = 0 ; i < this.UcDnItemInfoObj.iRows.Collections.length ; i++)  
        {
            row = gridObj.insertRow();
            //Row에 logical ID를 부여한다
            row.startId = 0;
            row.finishId = this.UcDnItemInfoObj.iRows.Collections.length;
            row.logicalId = this.ID + "_" + itemBindCnt + "_";
            row.id = this.ID + "_" + itemBindCnt + "_" + i;
            
            //Odd,Even 및 MouseOver , MouseOut시 그리드효과 적용
            if(itemBindCnt%2 == 0) {
                row.bgColor = this.RowOddbackColor;
                row.style.color = '6c6c6c'; //this.RowOddForeColor;
                row.OddEvenColor = this.RowOddbackColor;
            }
            else {
                //row.bgColor = this.RowEvenBackColor;
                //row.style.color = this.RowEvenForeColor;
                //row.OddEvenColor = this.RowEvenBackColor;
                //홀수행색깔 그대 적용
                row.bgColor = this.RowOddbackColor;
                row.style.color = '6c6c6c'; //this.RowOddForeColor;
                row.OddEvenColor = this.RowOddbackColor;
            }
            if (this.IsSetMouseOverColor) {
                row.attachEvent('onmouseover', this.onMouseOver_Handler);
                row.attachEvent('onmouseout', this.onMouseOut_Handler);
            }
            var rowheight = this.UcDnItemInfoObj.UcDnIRow(i).height;

            for(j = 0 ; j < this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections.length ; j++) {

                if(! this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].IsHidden) {
                    cell = row.insertCell();
                    
                    //cell.style.layoutGridType = 'fixed';
                    //cell.style.wordWrap = 'break-word';

                    cell.height = rowheight + "px";
                    cell.colSpan = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].spanX;
                    cell.rowSpan = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].spanY;
                    cell.align = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].hAlign;
                    cell.vAlign = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].vAlign;
                    
                    maxLength = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].maxLength
                    
                    //DataBind
                    key = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].key;
                    cell.key = key;
                    var cellText = "&nbsp;";
                    
                    if(this.DataSource != null && this.DataSource.Rows.length - 1 >= itemBindCnt) {
                        cellText = this.DataSource.Rows[itemBindCnt][key] + "";
                        
                        //2009.01.30
                        //cellText = cellText.replace(/&/g, '&amp;');
                        
                        if(cellText.indexOf("&nbsp;") == -1)
                            cellText = cellText.replace(/&/g, '&amp;');

                        //CellType별로 text대신에 image로 렌더링한다... 
                        cellType = this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].cellType;
                        if (cellType != "text" && cellText.replace(/ /g, '') != "" && cellText != "&nbsp;") {
                            switch(cellType)
                            {
                                case "popup":
                                    cellText = "<img src='/common/images/icon/icon8.gif' />";
                                    break;
                                case "delete1":
                                    cellText = "<img src='/common/images/icon/del2.gif' />";
                                    break;
                                case "delete2":
                                    cellText = "<img src='/common/images/icon/del3.gif' />";
                                    break;
                                case "downloadfile":
                                    cellText = "<img src='/common/images/icon/download-page-blue.gif' />";
                                    break;
                            }
                            //cell.style.backgroundImage = 'url(/common/images/UcDnGrid/icon_hard.gif)';
                            //cell.style.backgroundPosition = 'right';
                            //cell.style.backgroundRepeat = 'no-repeat';
                            //cell.style.marginRight = '2px';
                        }
                    }

                    //tooltip
                    tooltip = (cellText.length > maxLength ? cellText + "\r\n" : "") + this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].tooltip;
                    if (tooltip != "")
                        cell.title = tooltip;
                    else if (cellText.length > maxLength)
                        cell.title = tooltip;
                    
                    if (cell.align == "left")
                        cell.style.paddingLeft = '5px'
                    else if (cell.align == "right")
                        cell.style.paddingRight = '5px'

                    cell.innerHTML = (cellText.length > maxLength ? cellText.replace('null', '&nbsp;').substr(0, maxLength) + "..." : cellText.replace('null', '&nbsp;'));
                    if (cell.innerHTML == "")
                        cell.innerHTML = "&nbsp;";

                    cell.className = 'smallfont';
                    
                    //Event처리
                    if (this.UcDnEventInfo.Collections != undefined) {
                        for(evt=0 ; evt < this.UcDnEventInfo.Collections.length ; evt++) {
                            applyEventColumns = this.UcDnEventInfo.Collections[evt].applyEventColumns;
                            fireEvtColsDataExist = this.UcDnEventInfo.Collections[evt].fireEvtColsDataExist;
                            fireEvtColNames = this.UcDnEventInfo.Collections[evt].fireEvtColNames;

                            var cellDataCheck = false;
                            if (fireEvtColsDataExist) 
                            {
                                if (this.DataSource != null && this.DataSource.Rows.length - 1 >= itemBindCnt) {
                                    var cellDataCheckString = "";
                                    var fireEvtColNamesArr = fireEvtColNames.split(';');
                                    for (fireEvt = 0; fireEvt < fireEvtColNamesArr.length; fireEvt++) {
                                        dummy = this.DataSource.Rows[itemBindCnt][fireEvtColNamesArr[fireEvt]] + "";
                                        if (dummy.replace(/null/g,'').replace(/ /g,'') == "") {
                                            cellDataCheckString = "false";
                                        }
                                    }
                                    if (cellDataCheckString == "")
                                        cellDataCheck = true;
                                }
                            }
                            else {
                                cellDataCheck = true;
                            }
                            if (cellDataCheck) {

                                var eventAllow = false;
                                var evtColsCheck = this.eventColumnsCheck(applyEventColumns, key);
                                if (applyEventColumns == "*" || evtColsCheck) {
                                    if (!this.UcDnEventInfo.Collections[evt].applyEmptyRow) {
                                        if (this.DataSource != null && this.DataSource.Rows.length - 1 >= itemBindCnt) {
                                            if(this.DataSource.Rows[itemBindCnt][key] != "")
                                                eventAllow = true;
                                        }
                                    }
                                    else {
                                        eventAllow = true;
                                    }
                                    if (eventAllow) {
                                        //Event적용
                                        cell.style.cursor = 'hand';
                                        cell.eventRow = itemBindCnt;
                                        cell.gridID = this.ID;
                                        cell.key = key;

                                        cell.bindGroupSet = this.UcDnEventInfo.Collections[evt].bindGroupSet;

                                        cell.initGroupSet = this.UcDnEventInfo.Collections[evt].initGroupSet;
                                        cell.initAttachPosit = this.UcDnEventInfo.Collections[evt].initAttachPosit;

                                        cell.isClientScriptCall = this.UcDnEventInfo.Collections[evt].isClientScriptCall;

                                        cell.message = this.UcDnEventInfo.Collections[evt].message;
                                        cell.messageDisplay = this.UcDnEventInfo.Collections[evt].messageDisplay;
                                        cell.messageType = this.UcDnEventInfo.Collections[evt].messageType;

                                        cell.confirmMessage = this.UcDnEventInfo.Collections[evt].confirmMessage;

                                        cell.addGroupSetKey = this.UcDnEventInfo.Collections[evt].addGroupSetKey;
                                        cell.addGroupSetName = this.UcDnEventInfo.Collections[evt].addGroupSetName;
                                        cell.callServiceName = this.UcDnEventInfo.Collections[evt].callServiceName;
                                        cell.groupSetName = this.UcDnEventInfo.Collections[evt].groupSetName;

                                        cell.popupOpenType = this.UcDnEventInfo.Collections[evt].popupOpenType;
                                        cell.programLocation = this.UcDnEventInfo.Collections[evt].programLocation;
                                        cell.transferParamsKeys = this.UcDnEventInfo.Collections[evt].transferParamsKeys;
                                        cell.windowHeight = this.UcDnEventInfo.Collections[evt].windowHeight;
                                        cell.windowWidth = this.UcDnEventInfo.Collections[evt].windowWidth;
                                        cell.windowScroll = this.UcDnEventInfo.Collections[evt].windowScroll;
                                        cell.popupConstValue = this.UcDnEventInfo.Collections[evt].popupConstValue;

                                        eventName = 'on' + this.UcDnEventInfo.Collections[evt].eventName;
                                        cell.eventName = eventName;
                                        cell.attachEvent(eventName, this.eventHandlerFn);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        this.currRowNumber++;
    }
////merge code.....
//    var pre_MergeNameValue = "";
//    var mergeColumnNames = "FACULT_NM;N_NM";
//    var mergeGroup = mergeColumnNames.split(';');
//    var mergeGroupIndexObj = new Array();

//    var mergeResultInfo = new Array();
//    
//    var mergeGroupValue = new Array();
//    var pre_mergeGroupValue = new Array();
//    var rowSpan = 0;
//    var initialSpanIndex = 1;
//    var currSpanIndex = 0;
//    
//    for (mergeGroupIdx = 0; mergeGroupIdx < mergeGroup.length; mergeGroupIdx++) {
//        mergeGroupIndexObj[mergeGroup[mergeGroupIdx]] = this.getMergeColumnIndex(mergeGroup[mergeGroupIdx]);
//    }
//    
//    if (this.DataSource != null && this.DataSource.Rows.length - 1 >= startCnt) {
//        var rowCurrIndex = 0;
//        
//        for (mergeCnt = startCnt; mergeCnt < endCnt; mergeCnt++) {
//            mergeGroupValue = new Array();
//            for (innerloop = 0; innerloop < mergeGroup.length; innerloop++) {
//                mergeGroupValue.push(this.DataSource.Rows[mergeCnt][mergeGroup[innerloop]]);
//            }
//            if (pre_mergeGroupValue.length > 0) {
//                //이전 group과 현재 group값을 비교해서 다르면 현재group 까지 merge
//                for (chk = 0; chk < mergeGroupValue.length; chk++) {
//                    if (pre_mergeGroupValue[chk] != mergeGroupValue[chk]) {
//                        //중간merge후 마지막 그룹merge반영을 위해서
//                        currSpanIndex = i;
//                        //중간merge후 첫 그룹merge반영을 위해서
//                        if (initialSpanIndex == 1) {
//                            initialSpanIndex = i;
//                        }
//                        if (rowSpan > 0) {
//                            for (mergeCol = 0; mergeCol < mergeGroup.length; mergeCol++) {
//                                mergeResultInfo.push(new Array(rowCurrIndex - rowSpan, mergeGroupIndexObj[mergeGroup[mergeCol]], rowSpan));
//                                //this.spreadObj.AddCellSpan(mergeGroup[mergeCol], i - rowSpan, 1, rowSpan);
//                            }
//                        }
//                        rowSpan = 0;
//                    }
//                }
//            }
//            rowSpan++;
//            rowCurrIndex++;
//            pre_mergeGroupValue = mergeGroupValue;
//        }
//        var headerRowCnt = this.UcDnHeaderInfoObj.hRows.Collections.length + 1;
//        for (mergeIdx = 0; mergeIdx < mergeResultInfo.length; mergeIdx++) {
//            if (mergeResultInfo[mergeIdx][2] > 0) {
//                currCellIdx = mergeResultInfo[mergeIdx][1];
//                rowSpanCnt = mergeResultInfo[mergeIdx][2];
//                mergeRowSIdx = mergeResultInfo[mergeIdx][0] + headerRowCnt;
//                mergeRowEIdx = mergeRowSIdx + rowSpanCnt;

//                for (mergeRowSIdx; mergeRowSIdx < mergeRowEIdx; mergeRowSIdx++) {
//                    if (mergeRowSIdx == mergeResultInfo[mergeIdx][0] + headerRowCnt) {
//                        gridObj.rows[mergeRowSIdx].cells[currCellIdx].rowSpan = rowSpanCnt;
//                    }
//                    else {
//                        gridObj.rows[mergeRowSIdx].deleteCell(currCellIdx);
//                    }
//                }
//            }
//        }
//    }
}
function getMergeColumnIndex(key) {
    for (i = 0; i < this.UcDnItemInfoObj.iRows.Collections.length; i++) {
        for (j = 0; j < this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections.length; j++) {
            if (this.UcDnItemInfoObj.UcDnIRow(i).cols.Collections[j].key == key)
                return j;
        }
    }
    return -1;
}
function onMouseOver_Handler() {
    var el;
    if(event.srcElement.tagName == "TD")
        el = event.srcElement.parentNode;
    else
        el = event.srcElement;

    for(i = el.startId ; i < el.finishId ; i++) {
        el1 = document.getElementById(el.logicalId + i);
        //el1.bgColor='#DADEEA';
        //el1.style.color='#435791';
        el1.bgColor = '#f3f3f3';
        el1.style.color = '424242';
    }
}
function onMouseOut_Handler() {
    var el;
    if(event.srcElement.tagName == "TD")
        el = event.srcElement.parentNode;
    else
        el = event.srcElement;

    for(i = el.startId ; i < el.finishId ; i++) {
        el1 = document.getElementById(el.logicalId + i);
        el1.bgColor = el1.OddEvenColor;
        el1.style.color = '6c6c6c';
    }
}
function eventHandlerFn() {
    srcEl = event.srcElement;
    //grid안에 image버튼이 있을경우...해당 상위 노드td object를 가져온다
    if (srcEl.tagName == 'IMG') {
        srcEl = srcEl.parentNode;
    }
    row = srcEl.eventRow;
    grid = srcEl.gridID;
    confirmMessage = srcEl.confirmMessage;
    var cMsg = true;
    if(confirmMessage != "") {
       cMsg = confirm(confirmMessage);
    }
    if(cMsg) {
        //control-bind
        if(srcEl.bindGroupSet != "") {
            groupName = srcEl.bindGroupSet;
            setHtmlBindForDnGrid(groupName.split(';'), grid, row);
        }
        //control-init
        if(srcEl.initGroupSet != "" && srcEl.initAttachPosit == "pre") {
            clearDataGroupSet(srcEl.initGroupSet.split(';'));
        }
        //popup-call...
        if(srcEl.programLocation != "") {
            url = srcEl.programLocation;
            width = srcEl.windowWidth;
            height = srcEl.windowHeight;
            scrollbar = srcEl.windowScroll;
            queryString = "";
            if(srcEl.transferParamsKeys != "") {
                gridObj = igGrid_ScriptObj(grid);
                dnGridKeyValues = srcEl.transferParamsKeys.split(';');
                for(i = 0 ; i < dnGridKeyValues.length ; i++) {
                    if(i == 0)
                        queryString += "?" + srcEl.popupConstValue + (srcEl.popupConstValue == "" ? "" : "&");
                    
                    queryString += dnGridKeyValues[i] + "=" + gridObj.getTextByKey(row, dnGridKeyValues[i]);
                    
                    if(i + 1 != dnGridKeyValues.length)
                        queryString += "&";
                }
            }
            if (srcEl.popupOpenType == 'normal') {
                OpenWindow(url + queryString, '', width, height, 'no', 'no', 'no', 'no', 'no', 'no', scrollbar);
            }
            else {
                ShowModalDialogWindow(url + queryString, this, width, height, 'no', 'no', 'no', 'no', scrollbar, 'no', 'no', 'no');
            }
        }
        //service-call...
        if(srcEl.callServiceName != "" && srcEl.groupSetName != "") {
            try {
                var param = GetGroupSet(srcEl.groupSetName.split(';'));
                addGroupSetKey = srcEl.addGroupSetKey;
                addGroupSetName = srcEl.addGroupSetName;
                if(addGroupSetName != "" && addGroupSetKey != "") {
                    addGroupSetKeyRow = addGroupSetKey.split(';');
                    gridObj = igGrid_ScriptObj(grid);
                    for(i = 0 ; i < addGroupSetKeyRow.length ; i++) {
                        addGroupSetKeyInfo = addGroupSetKeyRow[i].split(',');
                        dataValue = (gridObj.DataSource != null ? gridObj.DataSource.Rows[row][addGroupSetKeyInfo[1]] + "" : "");
                        groupSetAdd(param, addGroupSetName, addGroupSetKeyInfo[0], dataValue);
                    }
                }
                var rObj = serviceInvoke(param,srcEl.callServiceName,'');
                var ruleResultSet = processingForResult(rObj);
            } catch(e) { alert(e); }
        }
        //client-script-call
        if(srcEl.isClientScriptCall == true) {
            try {
                eval(srcEl.gridID + "_" + srcEl.eventName + "(" + row + ",'" + srcEl.key + "')");
            }
            catch (e) {alert("클라이언트 script 호출도중 오류가 발생하였습니다\r\n" + 
                            srcEl.gridID + "_" + srcEl.eventName + "(" + row + ",'" + srcEl.key + "')");}
        }
        //message
        if(srcEl.messageDisplay == "true" && srcEl.message != "") {
            if(srcEl.messageType == "scriptalert") {
                alert(srcEl.message);
            }
            else {
                var args = new Array();
                args["MSG"] = srcEl.message;
                openSuccessPage(args);
            }
        }
        //control-init
        if(srcEl.initGroupSet != "" && srcEl.initAttachPosit == "next") {
            clearDataGroupSet(srcEl.initGroupSet.split(';'));
        }
    }
}

function eventColumnsCheck(evtCols,key){
    var result = false;
    if(evtCols != undefined) {
        var evtColsArray = evtCols.split(';');
        for(check = 0 ; check < evtColsArray.length ; check++) {
            if(evtColsArray[check] == key)
                result = true;
        }
    }
    return result;
}

function RowsClear() {
    var gridObj = document.getElementById('tbl' + this.ID);
    var headerCnt = this.UcDnHeaderInfoObj.hRows.Collections.length;// 끝에 1은 헤더 바로아래 row는 삭제안함
    
    for(i = gridObj.rows.length - 1; i>=-1 ; i--) {
        if(headerCnt - 1 < i)
            gridObj.deleteRow(i);
    }
}


function PagingControl()
{
    var gridObj = document.getElementById('tbl' + this.ID);
    
    row = gridObj.insertRow();
    cell = row.insertCell();   
    cell.height = "30px";
    cell.align = "Left";
    if(this.DataSource != null)
        cell.innerText = "총갯수: " + this.DataSource.Rows.length;
    else
        cell.innerText = "총갯수: 0";
    
}

