﻿/*
* 프로그램ID : HCC_Common
* 프로그램명 : 공통 처리 스크립트
* 설      명 : 공통 처리 스크립트     
* 최초작성자 : ST, 김보성
* 최초작성일 : 2010-04-13(화)
* 최종수정자 : 
* 최종수정일 : 
* 변경  내용 :	2010-04-13 최초 개발
*/

// 팝업창 열기 (주소, 넓이, 높이, 팝업창명)
function openWindow(sURL, iWidth, iheight, sFormName) {
    var Win;
    Win = window.open(sURL, sFormName, 'width=' + iWidth + ', height=' + iheight + ', status=no,toolbar=no, top=50, left=50, location=no, scrollbars=auto,menubar=no', 'false');
    Win.focus();
}

// 팝업창 열기 (주소, 넓이, 높이, 팝업창명, 스크롤 사용 여부)
function openWindow(sURL, iWidth, iheight, sFormName, isScroll) {
    var Win;
    Win = window.open(sURL, sFormName, 'width=' + iWidth + ', height=' + iheight + ', status=no,toolbar=no, top=50, left=50, location=no, scrollbars=' + isScroll + ',menubar=no', 'false');
    Win.focus();
}

// 함 수 명	: SwapImage()	
// 설 명	    : onmousemove시 활성화 이미지로 변경
// 전달인수	: imgid(이미지를 변경할 이미지아이디)
// 반 환 값	: None
function SwapImage(imgid, layerid, issubmenu)
{
    document.getElementById(imgid).src = "../Resources/Images/menu/" + imgid + "_on.gif";

    // 해당 메뉴가 서브메뉴라면 부모메뉴의 활성화 이미지를 유지한다.
    if(issubmenu == true)
    {
        var parentid = layerid.replaceAll('_sub', '');
        document.getElementById(parentid).src = "../Resources/Images/menu/" + parentid + "_on.gif";
    }
}

// 함 수 명	: SwapImgRestore()	
// 설 명	    : onmouseout시 비활성화 이미지로 변경
// 전달인수	: imgid(이미지를 변경할 Image id)
// 반 환 값	: None
function SwapImgRestore(imgid, layerid, issublayer)
{   
    // 현재페이지ID 조회, 부모페이지ID + 자식페이지ID - (ctl00_hidPageId는 페이지에서 지정한 히든 컨트롤의 ClientID, 변경하지 말것!!)
    var pageids = document.getElementById("ctl10_hidPageId").value.split(',');

    var parentid = pageids[0]; // 현재페이지의 부모페이지 아이디
    var subid    = pageids[1]; // 현재페이지 아이디

	// 메뉴아이디가 현재 페이지 아이디와 다르면 비활성화 이미지로 교체한다.
    if (imgid != subid) 
    {
        // 서브메뉴가 존재한다면
        if (issublayer == true) 
        {
            var obj = document.getElementById(layerid);

            // 해당 서브레이어가 확장되지 않았을 경우 비활성화 이미지로 교체한다.
            if (obj.style.display == 'none') 
            {
                document.getElementById(imgid).src = "../Resources/Images/menu/" + imgid + ".gif"
            }
        }
        else 
        {   
            document.getElementById(imgid).src = "../Resources/Images/menu/" + imgid + ".gif"
        }
    }
}

// 함 수 명	: FocusMenuImage()	
// 설 명	    : 페이지 접속시 해당 페이지에 대한 메뉴를 활성화 시킨다.
// 전달인수	: imgid(이미지를 변경할 Image id), divsubid(SubMenu Area ID)
// 반 환 값	: None
function FocusMenuImage(imgid, divsubid)
{
	document.getElementById(imgid).src = "../Resources/Images/menu/" + imgid + "_on.gif";

    if(divsubid != "")
    {
        var mainid = divsubid.replaceAll('_sub', '');
        document.getElementById(divsubid).style.display = "";
        document.getElementById(mainid).src = "../Resources/Images/menu/" + mainid + "_on.gif";
    }
}

// 함 수 명	: ShowHideLayer()	
// 설 명	    : 해당 메뉴에 대한 서브메뉴를 보여주거나 감춘다.
// 전달인수	: layerid(서브메뉴 레이어 아이디)
// 반 환 값	: None
function ShowHideLayer(layerid) 
{   
    var obj = document.getElementById(layerid);
    var pageids = document.getElementById("ctl10_hidPageId").value.split(',');
    var parentid = pageids[0];
    var subid = pageids[1];

    if (obj.style.display == '') 
    {
        if(parentid != layerid.replaceAll('_sub', ''))
        {
            obj.style.display = 'none';
        }
    }
    else 
    {
        obj.style.display = '';
    }
}

// 함 수 명	: CommentInsertCheck()	
// 설 명	    : 댓글 입력시 로그인 여부 체크
// 전달인수	: layerid(서브메뉴 레이어 아이디)
// 반 환 값	: None
function CommentInsertCheck(message)
{
    var result = confirm(message)

    if (result == true) 
    {
        location.href = '../Member/Login.aspx';
    }
}




/*
Function명 : fn_RowColor
내용 : 리스트 행 선택값 유지

onmouseover="fn_RowColor('', this, 'over');" 
onmouseout="fn_RowColor('', this, 'out');" 
onclick="fn_RowColor('', this, 'click');"
*/
function SetRowColor(hiddenId, rowId, type) {
    var RowIdNm = document.getElementById(hiddenId);
    var el = document.getElementById(rowId);
    if (el == null)
        return;

    if (type == "click") {
        if (RowIdNm.value != "" && RowIdNm.value != rowId) {
            document.getElementById(RowIdNm.value).style.backgroundColor = "#FFFFFF";
        }

        RowIdNm.value = rowId;
        cellClick(el);
    }

    if (type == "over") {
        if (RowIdNm.value != rowId) {
            cellOver(el);
        }
    }

    if (type == "out") {
        if (RowIdNm.value != rowId) {
            cellOut(el);
        }
    }

    if (type == "init") {
        document.getElementById(RowIdNm.value).style.backgroundColor = "#FFFFFF";
    }
}


/* table */
function cellClick(el) {
    el.style.backgroundColor = "#F9F9F9";
}

function cellOver(el) {
    el.style.backgroundColor = "#F9F9F9";
    //el.style.backgroundColor="#cccccc";
}

function cellOut(el) {
    //el.style.backgroundColor="#FFFFFF";
    el.style.backgroundColor = "#FFFFFF";
}

function TabSelect(allindex, index, imagepath)
{
    for (i = 0; i < allindex; i++) {
        $("#index_" + (i + 1)).css("display", "none");
        $("#title_" + (i + 1)).attr("src", "../Resources/Images/" + imagepath + (i + 1) + ".gif");
    }
    $("#index_" + index).css("display", "");
    $("#title_" + index).attr("src", "../Resources/Images/" + imagepath + index + "_on.gif");
}

function fn_Enter() 
{
    if (event.keyCode == 13)
        return false;
}

// 팝업창 항상 화면 중앙에서 열기(수조, 넓이 높이, 팝업창 명, 스크롤 사용여부)
function openWindowCenter(sURL, iWidth, iheight, sFormName, isScroll) {
    LeftPosition = (screen.width) ? (screen.width - iWidth) / 2 : 100;
    TopPosition = (screen.height) ? (screen.height - iheight) / 2 : 100;

    settings = 'width=' + iWidth + ',height=' + iheight + ', top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + isScroll + ',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no';

    win = window.open(sURL, sFormName, settings);

    if (win.focus) {
        win.focus();
    }
}

function WorkingMessage() {
    alert('준비중입니다.');
}

function PrintWebPage() {
    window.print()
}; 


