﻿/************************************************************************
파 일 명	: FormEvent.js
작성목적	: 공통 폼 속성 및 이벤트 설정
작 성 자	: 공성의( (주) 인터데브 )
최초작성일	: 2006.06.15
최종작성일	:
수정내역	:
*************************************************************************/

/************************************************************************
함수명		: fn_WindowOnLoad
작성목적	: 화면 처리 ASPX가 클라이언트에 Load된 후 실행해야 될 로직 처리
작 성 자	: 공성의( (주) 인터데브 )
최초작성일	: 2006.06.15
최종작성일	:
수정내역	:
*************************************************************************/
function fn_WindowOnLoad()
{
	try
	{
		// 상태바의 URL없애기
		//window.document.onmouseover=fn_hideURL;
		//window.document.onclick=fn_hideURL;
		//fn_hideURL();
		// 1. 에러 메시지가 있는 경우 팝업 출력
		if ( document.all.errorMessage.value.length > 0 )
			fn_OpenErrorMessage(document.all.errorMessage.value);
		// 2. Information이 있는 경우 팝업 출력
		if ( document.all.informationMessage.value.length > 0 )
			fn_OpenInformation(document.all.informationMessage.value);
		// 3. Confirm이 있는 경우 팝업 출력
		if ( document.all.confirmMessage.value.length > 0 )
			return fn_OpenConfirm(document.all.confirmMessage.value);
		// 4. 팝업창 닫기
		var strClose = ""
		strClose = document.all.winClosed.value;
		if ( strClose == "closed" )
		{
			if ( document.all.winClosed.getAttribute("return").length > 0 )
					window.returnValue = document.all.winClosed.getAttribute("return");
			window.close();
			return;
		}
		// 5. 백스페이스로 이전 페이지로 가는 것을 막는다.
		document.onkeydown = fn_PreventNavigateBack;
		// 6. 오른쪽 마우스 처리
		document.oncontextmenu = fn_PreventRightMouse;
	}
	catch ( exception ) 
	{ 
		fn_OpenErrorMessage(exception.description);
	}
	
	try
	{
		// 7. 폼 Unload 확인
		document.onbeforeunload = fn_ClosingCheck;
		// 8. 사용자 정의 폼 로드 함수 호출
		FormLoad();
	}
	catch(exception){} //위두함수에는 exception처리가 있으면 안됨.. 함수가 존재하지 않을수도 있기땜시...
	
	try
	{
		// 9. 각종 환경 설정
		document.title = TITLE;
		// 10. 상태바 Text 변경
		window.status = "";
	}
	catch(exception)
	{
		fn_OpenErrorMessage(exception.description);
	}

	/*try
	{
		//  파일 컨트롤 삭제 버튼 삭제
		if (document.all.himgFileDel != undefined) 
		{
			fn_DisableImageButton(document.all.himgFileDel);
		}
	}
	catch(exception)
	{
		fn_OpenErrorMessage(exception.description);
	} */
		
}

/************************************************************************
함수명		: fn_ClosingCheck
작성목적	: Window_OnUnLoad 이벤트 발생전에 발생되는 이벤트, 페이지 닫기 취소를 할 수 있다.
		  OnBeforeUnLoad 이벤트에 별도의 이벤트 핸들러를 연결하여 처리한다.
		  ex) window.onbeforeunload = fnClosingChecker;
작 성 자	: 공성의( (주) 인터데브 )
최초작성일	: 2006.06.15
최종작성일	:
수정내역	:
*************************************************************************/
function fn_ClosingCheck()
{
	try
	{
		var strMsg = FormBeforeUnLoad();
		
		if ( strMsg.length > 0 )
		{
			strMsg = "\n" + strMsg;
			return strMsg;
		}
	}
	catch ( exception )
	{
	}
}

/************************************************************************
함수명		: fn_PreventHistoryBack
작성목적	: 텍스트 박스 이외는 backspace 입력을 제한한다.
작 성 자	: 공성의( (주) 인터데브 )
최초작성일	: 2006.06.15
최종작성일	:
수정내역	:
*************************************************************************/
function fn_PreventNavigateBack()
{
	var strTagType;
	if ( window.event.keyCode == 8 )
	{
		if ( window.event.srcElement.tagName.toUpperCase() == "INPUT" )
		{
			strTagType = window.event.srcElement.getAttribute("type").toUpperCase();
			if ( strTagType == "TEXT")
			{
				window.event.returnValue = true;
				return;
			}
		}
		else if( window.event.srcElement.tagName.toUpperCase() == "TEXTAREA" )
		{
			window.event.returnValue = true;
			return;
		}
		else
		{
			// 일단 TextArea에서의 벡스페이스가 않되기 때문에 이 기능을 막는다. - 정기남
			window.event.returnValue = false;
		}
	}
	else
	{
		window.event.returnValue = true;
	}
	
}

/************************************************************************
함수명		: fn_PreventRightMouse
작성목적	: 오른쪽 마우스 이벤트를 막는다.
작 성 자	: 공성의( (주) 인터데브 )
최초작성일	: 2006.06.15
최종작성일	:
수정내역	:
*************************************************************************/
function fn_PreventRightMouse()
{
	window.event.returnValue = false;	
}


/************************************************************************
함수명		: fn_hideURL
작성목적	: 상태바의 링크URL없애기
작 성 자	: 공성의( (주) 인터데브 )
최초작성일	: 2006.06.15
최종작성일	:
수정내역	:
*************************************************************************/
function fn_hideURL() {
    window.status = "";	
    timerID= window.setTimeout("fn_hideURL()", 0);
}
