﻿
    var SSL_SSO = 'https://sso.homeplus.co.kr';
    var WEB_DNS = 'http://school.homeplus.co.kr';
    
    /*
     로그인 체크후 해당 url로 이동한다.
    */
    function jsGoLocation(flag,link) {
		link= link.replace("culture.", "school.");

      if ( jsGoLoginPage(flag,link) == false) {
		    return;
	    }else{
		     location.href = link;
	    }
    }


    /*
     로그인 체크후 해당 url로 이동한다.
    */
    function jsGoLoginLocation(flag,link) {
      if ( jsGoMainLoginPage(flag,link) == false) {
		    return;
	    }else{
		     location.href = link;
	    }
    }


    
    /**
    * SSO 로그인 페이지 이동
    */
    function jsGoLoginPage(flag,link) {
        
        if(flag == 'Y') {
            return true;
        }
        else {
            CenterOpenWindow(SSL_SSO+"/login/login.jsp?ReturnURL=" + WEB_DNS + link+ "&access_system=APP02", "Login", "400","285", "scrollbars=no,status=no");
        }
	    return false;
    }


    /**
    *  메인 로그인 페이지 이동
    */
    function jsGoMainLoginPage(flag,link) {
        
        if(flag == 'Y') {
            return true;
        }
        else {
            CenterOpenWindow(WEB_DNS+"/login.aspx?ReturnURL=" + WEB_DNS + link+ "&access_system=APP02", "Login", "400","245", "scrollbars=no,status=no");
        }
	    return false;
    }
    
 /**
      * 화면중앙에 새창열기
      * window.open 에서 사용되는 방식으로 features 설정
      * @param theURL    새창의 Url
      * @param winName   새창의 name
      * @param features  새창의 세부 설정
      * @return
      */
    function CenterOpenWindow(theURL, winName, width, height, fstate ) {
        var features = "width=" + width ;
        features += ",height=" + height ;

		var state = "";

		if (fstate == "") {
			state = features + ", left=" + (screen.width-width)/2 + ",top=" + (screen.height-height)/2;
		} else {
			state = fstate + ", " + features + ", left=" + (screen.width-width)/2 + ",top=" + (screen.height-height)/2;
		}

		//popupWin = window.open(theURL,winName,state+",resizable=1 ");
		popupWin = window.open(theURL,winName,state);
		
        popupWin.focus();
    }

/***************************************************************************************
함 수 명	: fnOnlyNumber
내    용	: 숫자만 입력 받는다.
Parameter   :
Return      : event.returnValue
작 성 자	: 김민근
작 성 일	:
수 정 일	:
***************************************************************************************/
function fnOnlyNumber() {
    var key = event.keyCode;

    if (!(key == 8 || key == 9 || key == 13 || key == 46 || key == 144 || (key >= 48 && key <= 57) || key == 110 || key == 190)) {
        alert('숫자만 입력 가능합니다');

        event.returnValue = false;
    }
}

/**
      * 입력 받은 폼태그(Object)의 문자열의 길이가 특정 길이(Int) 이면
      * 다른 객체(Object)로 포커스를 이동
      * @param obj   대상 폼태그(Object)
      * @param len   비교할 길이
      * @param dest  포커스를 이동할 폼태그(Object)
      * @return
     */
    function ChkLenMoveFocus(obj, len, dest) {
            if (obj.value.length == len)
            SetFocus(dest);
    }
    
 /**
      * 입력 받은 객체로 포커스 이동
      * @param obj   포커스를 이동할 폼태그(Object)
      * @return
     */
    function SetFocus(obj) {
      obj.focus();
    }
    
    
    
//이메일 주소 체크 - Ver2
function isemail_new(strEmail) {
        if (strEmail == '' || strEmail.indexOf('@') == -1 || strEmail.indexOf('.') == -1) {
                return false;
        } else {
                return true;
        }
}


/***************************************************************************************
함 수 명	: viewMoviePlayer
내    용	: 동영상 플레이어 처리
Parameter   :
Return      : 
작 성 자	: dolfly
작 성 일	:
수 정 일	:
***************************************************************************************/
function viewMoviePlayer(seq, w, h)
{
    if (w == "" || w == null) w = "500";
    if (h == "" || h == null) h = "415";

    document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='" + w + "' height='" + h + "' id='main' align='middle' VIEWASTEXT>");
    document.write("	    <param name='allowScriptAccess' value='always' />");
    document.write("	    <param name='allowFullScreen' value='true' />");
    document.write("	    <param name='movie' value='" + WEB_DNS + "/player/Main.swf?content=" + WEB_DNS + "/player/content.aspx?seq=" + seq + "' />");
    document.write("	    <param name='quality' value='high' />");
    document.write("	    <param name='bgcolor' value='#ffffff' />");
    document.write("</object>");
        
//    document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='" + w + "' height='" + h + "' id='main' align='middle' VIEWASTEXT>");
//    document.write("	<param name='allowScriptAccess' value='always' />");
//    document.write("	<param name='allowFullScreen' value='true' />");
//    document.write("	<param name='movie' value='http://culturecafe.homeplus.co.kr/player/Main.swf?content=http://culturecafe.homeplus.co.kr/player/content.aspx?seq=1274' />");  // 1274
//    document.write("	<param name='quality' value='high' />");    
//    document.write("	<param name='bgcolor' value='#ffffff' />");
//    document.write("</object>");
}

/***************************************************************************************
함 수 명	: fnOpenCommonMailPop
내    용	: 메일 팝업창 호출
Parameter   :
Return      : 
작 성 자	: dolfly
작 성 일	:
수 정 일	:
***************************************************************************************/
function fnOpenCommonMailPop(gbn, to_username, to_email )
{	
    /*			
    var argParams = new Object();

    argParams.ToUserName = to_username;
    argParams.ToEmail = to_email;

    returnValue = window.showModalDialog("/Common/Popup/CommonMailPop.aspx", argParams, "dialogWidth:600px;dialogHeight:597px");
    */
    
    CenterOpenWindow("/Common/Popup/CommonMailPop.aspx?EmailType=&ToUserName=" + escape(to_username) + "&ToEmail="+ escape(to_email), "MailPop", "600", "597", "scrollbars=no,status=no,resizable=no");
}

function fnOpenCommonAdminMailPop(to_username, to_email )
{	
    /*			
    var argParams = new Object();

    argParams.ToUserName = to_username;
    argParams.ToEmail = to_email;
    argParams.EmailType = '00'; // 관리자메일

    returnValue = window.showModalDialog("/Common/Popup/CommonMailPop.aspx", argParams, "dialogWidth:600px;dialogHeight:597px");
    */
    
    CenterOpenWindow("/Common/Popup/CommonMailPop.aspx?EmailType=00&ToUserName=" + escape(to_username) + "&ToEmail="+ escape(to_email), "MailPop", "700", "597", "scrollbars=no,status=no,resizable=no");
}


/*********************************************************************
기능        : 체크 박스에 선택된것이 있는지 체크
형식        : CheckSelect(폼, 체크 박스 네임)
예제        : CheckSelect(document.forms[0],'chkSelect')
예제페이지  : WebAdmin/AdminManage/AdminList.aspx
결과        : true(한개라도 선택한것이 있음), false(선택한것이 하나도 없음)
**********************************************************************/
function CheckSelect(form, InputName) {
    var i = 0;
    while (i < form.elements.length) {
        if (form.elements[i].name == InputName) {
            if (form.elements[i].checked == true) {
                return true
            }
        }
        i++;
    }
    return false
}  

// 엔터키 막음(prototype.js 추가 필요)
//Event.observe(document, "keydown", function(event) {
//    //텍스트 박스때문에 Input도 걸었음(문제 되면 타입체크)
//    if (event.keyCode == 13) {        
//        if (event.element().tagName.toUpperCase() == "DIV" ||
//	            event.element().tagName.toUpperCase() == "SPAN" ||
//	            event.element().tagName.toUpperCase() == "TABLE" ||
//	            event.element().tagName.toUpperCase() == "TR" ||
//	            event.element().tagName.toUpperCase() == "TD" ||
//	            (event.element().tagName.toUpperCase() == "INPUT" && event.element().type != "image")
//	            ) {
//            event.stop();
//        }
//    }
//});

/************************************************************************************************
* Procedure   : chkEnterKey
* Description : Enter 키 막음(TEXTAREA제외)
* Parameter   : 
* Return      : 
*************************************************************************************************/
function chkEnterKey() {
	if (event.keyCode == 13)
	{
	    if (event.srcElement.tagName.toUpperCase() != "TEXTAREA")
	    {
			event.returnValue = false;
        }
	}
}
document.onkeydown = chkEnterKey; 

/************************************************************************************************
* Procedure   : KeyDownClick
* Description : Enter 를 클릭했을 경우 특정 버튼 이벤트를 주기 위한 메소드
* Parameter   : 
* Return      : 
*************************************************************************************************/
function KeyDownClick(strObjID)
{
	if(window.event.keyCode == 13)
	{
		document.getElementById(strObjID).click()
		if (window.navigator.userAgent.indexOf('IE') > -1) {
		    event.returnValue = false;
		}
		else {
		    event.preventDefault();
		}
	}
}
