﻿/*
UBCare RND 3 Team
Author : 김철원 
CreateDate : 2008-09-12
*/

/* 전역변수 선언 */
var explorer    = (navigator.appName.indexOf("Microsoft") != -1);   // Explorer 구분자
var firefox     = (navigator.appName.indexOf("Netscape") != -1);    // FireFox 구분자
var tempID; // 마우스가 클릭한 객체 ID 정보

/* 
ID값을 통한 HTML 객체 접근 
ex.) document.getElementById(id) -> $(id)로 대체
*/
function $(id) {
    var element = "";
    element = document.getElementById(id);
    return element;
}

/*
IE/FF별 Flash Object 생성
*/
function fctMakeFlashObject(source, id, width, height) {
    var str = ""

    // IE 
    if (explorer) {
        str = "<embed src=\"" + source + "\" quality=\"high\" type=\"application/x-shockwave-flash\" "
        + "quality=\"high\" wmode=\"transparent\" "
        + "pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" "
        + "width=\"" + width + "\" height=\"" + height + "\"/>";
    }
    // Firefox
    if (firefox) {
        str = "<object width=\"" + width + "\" height=\"" + height + "\" type=\"application/x-shockwave-flsh\" data=\"" + source + "\" wmode=\"transparent\" >"
        + "<param name=\"" + id + "\" value=\"" + source + "\" />"
        + "</object>";
    }
    
    document.write(str);
}

/*
팝업 클릭시 이벤트
*/
function fctClickPopup(strUrl) {

    if (opener != null) {
        opener.location.href = strUrl;
    }
    else {
        alert('부모페이지가 없습니다 (' + strUrl + ')');
    }
} 


// 퀵메뉴 Move
function fctInitMoving(target, position, topLimit, btmLimit) {
    if (!$(target)) return false;
    
    var obj = $(target);
    
    obj.initTop = position;
    obj.topLimit = topLimit;
    obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;
    
    obj.style.position = "absolute";
    obj.top = obj.initTop;
    obj.left = obj.initLeft;
    
    if (typeof(window.pageYOffset) == "number") {
        obj.getTop = function() {
            return window.pageYOffset;
        }
    } else if (typeof(document.documentElement.scrollTop) == "number") {
        obj.getTop = function() {
            return document.documentElement.scrollTop;
        }
    } else {
        obj.getTop = function() {
            return 0;
        }
    }
    
    if (self.innerHight) {
        obj.getHeight = function() {
            return self.innerHeight;
        }
    } else if (document.documentElement.clientHeight) {
        obj.getHeight = function() {
            return document.documentElement.clientHeight;
        }
    } else {
        obj.getHeight = function() {
            return 500;
        }
    }
    
    obj.move = setInterval(function() {
        if (obj.initTop > 0) {
            pos = obj.getTop() + obj.initTop;
        } else {
            pos = obj.getTop() + obj.getHeight() + obj.initTop;
        }
        
        if (pos > obj.bottomLimit) pos = obj.bottomLimit;
        if (pos < obj.topLimit) pos = obj.topLimit;
            
        interval = obj.top - pos;
        obj.top = obj.top - interval / 3;
        obj.style.top = obj.top + "px";
        
        // 퀵메뉴 위치잡기
        left = document.body.offsetWidth / 2 + 420;
        obj.style.left = left + "px";
    }, 30)
}

// 퀵메뉴 Layer 위치 잡기
function fctLayerPosition(target) {
    var obj = $(target);
    
    layerLeftPosition = document.body.offsetWidth / 2 + 420;
    
    if (layerLeftPosition <= 960) {
        layerLeftPosition = 960;
    }
    
    obj.style.left = layerLeftPosition + "px";
    
    fctSetheader_notice();
    fctSetheader_background();
}

// div header_notice 위치 잡기
function fctSetheader_notice()
{
    var obj = $('header_notice');
    var objLogin = $('divLogin_black');
        
    obj.left = fctLeft();
    obj.style.left = obj.left + "px";
    
    objLogin.left = fctLeft() + 485;
    objLogin.style.left = objLogin.left + "px";
}

// div header_background 크기 조절
function fctSetheader_background()
{
    var obj = $('header_background')
    var w = fctWidth();
    
    if (w > 960)
    {
        obj.style.width = w + "px";
    }
    else
    {
        obj.style.width = "960px";
    }
}


// 현재 스크롤의 위치 계산
function fctGetNowScroll()
{
    var de = document.documentElement;
    var b = document.body;
    var now = {};

    now.X = document.all ? (!de.scrollLeft ? b.scrollLeft : de.scrollLeft) : (window.pageXOffset ? window.pageXOffset : window.scrollX);
    now.Y = document.all ? (!de.scrollTop ? b.scrollTop : de.scrollTop) : (window.pageYOffset ? window.pageYOffset : window.scrollY);

    return now;
}

// 현재 스크롤의 위치를 가져와서 header_notice 위치 잡기
function fctCurrentScroll()
{
    var obj = $('header_notice');
    var hobj = $('header_background');
    
    nowScroll = fctGetNowScroll();
    
    if (nowScroll.Y > 136)
    {
        obj.top = nowScroll.Y;
        obj.style.top = obj.top + "px";
        
        obj.left = fctLeft();
        obj.style.left = obj.left + "px";
        
        
        hobj.top = nowScroll.Y;
        hobj.style.top = hobj.top + "px";
        hobj.style.display = "block";
    }
    else
    {
        obj.top = 96;
        obj.style.top = obj.top + "px";
        
        obj.left = fctLeft();
        obj.style.left = obj.left + "px";
        
        hobj.style.display = "none";
    }
}

// header_notice의 left위치 계산
function fctLeft()
{
    var w = 0;
    var wt = 0;
    
    w = fctWidth();
    
    if (w > 960)
    {
        wt = (w - 960) / 2;
    }
   
    return wt
}
    
// 현재 창의 크기를 구하는 함수   
function fctWidth()
{
    var w = 0;
    
    if( document.documentElement && ( document.documentElement.clientWidth )) {
        //IE 6+ in 'standards compliant mode'
        w = document.documentElement.clientWidth;
            
    } else if( document.body && ( document.body.offsetWidth)) {
        
        w = document.body.offsetWidth;
    }
    
    return w;
}

// ========================================================================================
// 작 성 일 : 2008-11-11 14:45
// 작 성 자 : 김재환
// 설    명 : target 보여주기
// 목    적 : target 보여주기
// ========================================================================================
function fctShowTarget(target)
{
    obj = $(target);
    obj.style.display = "block";
}

// ========================================================================================
// 작 성 일 : 2008-11-11 14:45
// 작 성 자 : 김재환
// 설    명 : target 숨기기
// 목    적 : target 숨기기
// ========================================================================================
function fctHideTarget(target)
{
    obj = $(target);
    obj.style.display = "none";
}

// ========================================================================================
// 작 성 일 : 2008-11-11 14:45
// 작 성 자 : 김재환
// 설    명 : 패스워드 background 변경
// 목    적 : 패스워드 background 변경
// ========================================================================================
function fctChgBackground(strEvent)
{
    obj = $('ctl00_txtPw');
    
    if (strEvent == "focus")
    {
        obj.style.background = "#FFFFFF url()";
    }
    else if (strEvent == "blur")
    {
        if(obj.value.length == 0)
        {
            obj.style.background = "#FFFFFF url('/images/main/p_pw.jpg') no-repeat center left";
        }
    }        
}


// ========================================================================================
// 작 성 일 : 2008-11-19 11:34
// 작 성 자 : 임경우
// 설    명 : 패스워드 텍스트박스를 위한 워터마크
// 목    적 : AJAX 대신 사용
// ========================================================================================
function fctTxtPwWaterMark_black(target, targetDiv)
{
    var obj = $(target);

    if(obj.value.length == 0)
    {
        fctShowTarget(targetDiv);
    }
    else
    {
        fctHideTarget(targetDiv);
    }
}

// ========================================================================================
// 작 성 일 : 2008-11-19 11:34
// 작 성 자 : 임경우
// 설    명 : 매개변수 'target' control 로 포커스 이동
// 목    적 : 
// ========================================================================================
function fctMoveFocus_black(target)
{
    var obj = $(target);
    obj.focus();
}


function fctChkLogin()
{
    if(!fctEmptyElementCheck('ctl00_txtId', '아이디를 입력하십시요.', 'focus();'))
    {
        return false;
    }
    
    if(!fctEmptyElementCheck('ctl00_txtPw', '비밀번호를 입력하십시요.', 'focus();'))
    {
        return false;
    }
    
    return true;
}


// ========================================================================================
// 작 성 일 : 2009-03-05 11:24
// 작 성 자 : 임경우
// 설    명 : Misomall 로 이동
// 목    적 : 
// ========================================================================================

function fctMisoMallOpen(strMisoUrlObj) {

    var obj = document.getElementById(strMisoUrlObj);

    if (obj.value != "") {
        window.open(obj.value, "", "", "");
    }
}

