﻿// JScript 파일
function c2max_window_resize(width, height) {
    window.resizeTo(width, height);
    var window_left = (screen.width - width) / 2;
    var window_top = (screen.height - height) / 2;
    window.moveTo(window_left, window_top);
}

//하이비즈
function fn_home_top_search() {
    if (document.all.txt_top_search_key.value.length == 0) {
        alert('검색어를 입력하세요.');
        document.all.txt_top_search_key.focus();
        return false;

    } else {
        var key = document.all.txt_top_search_key.value;
        key = escape(key);
        key = encodeURI(key);
        location.href = '/shop/lists/list_2.aspx?sst=1&ssk=' + key + '&sss=1&pt=5&k=' + key + '';
    }
}


function fn_home_top_search2() {
    if (document.all.txt_top_search_key.value.length == 0) {
        alert('검색어를 입력하세요!');
        document.all.txt_top_search_key.focus();
        return false;
    } else {

        var key = document.all.txt_top_search_key.value;
        key = escape(key);
        key = encodeURI(key);
        location.href = '/shop/lists/list_2.aspx?k=' + key + '';
    }
}


// 공지사항 스크롤하기
var m_live_width = 800								// 영역의 폭
var m_live_height = 15								// 영역의 높이
var m_live_bgcolor = ''								// 영역의 배경색
var m_live_cnt = 0									// 메세지 갯수
var m_live_speed = '0'								// 스크롤 속도(단위:ms)
var m_live_wait = '4000'								// 메세지 멈춤 시간(단위:ms)
var m_live_timerID = ''								// 타이머 ID
var m_live_idx = 0									// 첨자

function fn_notice_roll() {
    document.writeln("<style>")
    document.writeln(" #m_live_layer1 { position:absolute; width:'+m_live_width+'; height:'+m_live_height+'; top:0; left:0;}")
    document.writeln(" #m_live_layer2 { position:absolute; width:'+m_live_width+'; height:'+m_live_height+'; top:0; left:0;}")
    document.writeln(" #m_live_layer3 { position:absolute; width:'+m_live_width+'; height:'+m_live_height+'; top:0; left:0;}")
    document.writeln(" #m_live_layer4 { position:absolute; width:'+m_live_width+'; height:'+m_live_height+'; top:0; left:0;}")
    document.writeln(" #m_live_layer5 { position:absolute; width:'+m_live_width+'; height:'+m_live_height+'; top:0; left:0;}")
    document.writeln("</style>")

    document.writeln('<span style="position:relative;width:' + m_live_width + ';height:' + m_live_height + ';top:2;left:0;background-color:' + m_live_bgcolor + '">')
    document.writeln('<div onMouseOver="m_live_mouseover()" onMouseOut="m_live_mouseout()" style="position:absolute;width:' + m_live_width + ';height:' + m_live_height + ';top:0;left:0;clip:rect(0 ' + m_live_width + ' ' + m_live_height + ' 0);overflow:hidden;">')

    document.writeln("<div id='m_live_layer1'>")
    document.write(m_live[0])
    document.writeln("</div>")

    document.writeln("<div id='m_live_layer2'>")
    document.write(m_live[1])
    document.writeln("</div>")

    document.writeln("<div id='m_live_layer3'>")
    document.write(m_live[2])
    document.writeln("</div>")

    document.writeln("</div>")
    document.writeln("</span>")

    m_live_cnt = m_live.length
    m_live_StartScroll()

}
//공지사항 스크롤 
function m_live_mouseover() {
    if (m_live_timerID) clearTimeout(m_live_timerID)
}
function m_live_mouseout() {
    m_live_timerID = setTimeout("m_live_scroll()", m_live_speed)
}
function m_live_scroll() {
    document.all["m_live_layer1"].style.pixelTop = document.all["m_live_layer1"].style.pixelTop - 15
    document.all["m_live_layer2"].style.pixelTop = document.all["m_live_layer2"].style.pixelTop - 15
    document.all["m_live_layer3"].style.pixelTop = document.all["m_live_layer3"].style.pixelTop - 15

    if (document.all["m_live_layer2"].style.pixelTop == 0) {
        m_live_timerID = setTimeout("m_live_scroll()", m_live_wait)
    } else if (document.all["m_live_layer3"].style.pixelTop == 0) {
        document.all["m_live_layer1"].style.pixelTop = 0
        document.all["m_live_layer1"].innerHTML = m_live[m_live_idx]

        m_live_idx = (m_live_idx + 1) % m_live_cnt
        document.all["m_live_layer2"].style.pixelTop = m_live_height + 15
        document.all["m_live_layer2"].innerHTML = m_live[m_live_idx]

        m_live_idx = (m_live_idx + 1) % m_live_cnt
        document.all["m_live_layer3"].style.pixelTop = (m_live_height * 2) + 15
        document.all["m_live_layer3"].innerHTML = m_live[m_live_idx]

        m_live_timerID = setTimeout("m_live_scroll()", m_live_wait)
    } else {
        m_live_timerID = setTimeout("m_live_scroll()", m_live_speed)
    }
}
function m_live_StartScroll() {											// 페이지가 로드되면 단 한 번 실행되는 문장
    document.all["m_live_layer1"].innerHTML = m_live[0]

    document.all["m_live_layer2"].style.pixelTop = m_live_height + 15
    document.all["m_live_layer2"].innerHTML = m_live[1]

    document.all["m_live_layer3"].style.pixelTop = (m_live_height * 2) + 15
    document.all["m_live_layer3"].innerHTML = m_live[2]

    m_live_idx = 2

    m_live_timerID = setTimeout("m_live_scroll()", m_live_speed)
}
// 공지사항 스크롤끝



function base_confirm(msg) {
    if (confirm(msg)) {
        return true;
    } else {
        return false;
    }
}




function fn_set_txtEnabled_chk(chk, txt) {
    if (document.forms[0][chk].checked) {
        document.forms[0][txt].disabled = '';
        document.forms[0][txt].style.backgroundColor = 'white';
    }
    else {
        document.forms[0][txt].disabled = 'true';
        document.forms[0][txt].style.backgroundColor = '#eeeeee';
    }
}

//수량에 숫자만 입력받기
function base_check_numeric(textbox) {
    if (document.forms[0][textbox].value == '0') {
        document.forms[0][textbox].value = 1;
    }
    return base_check_numeric(textbox, 1);
}
function base_check_numeric(textbox, baseValue) {
    var Digit = '1234567890';
    for (i = 0; i < document.forms[0][textbox].value.length; i++)
        if (Digit.indexOf(document.forms[0][textbox].value.substring(i, i + 1)) < 0) {
        alert('수량에는 숫자만 입력하세요.');
        document.forms[0][textbox].value = baseValue;
        return false;
    }
    if (document.forms[0][textbox].value > 10000) {
        document.forms[0][textbox].value = 10000;
        return false;
    }
    return true;
}

function base_check_numeric_plus(textbox) {
    return base_check_numeric_plus(textbox, 1);
}

function base_check_numeric_plus(textbox, baseValue) {
    if (!base_check_numeric(textbox, baseValue)) {
        document.forms[0][textbox].value = baseValue;
        return false;
    }

    if (document.forms[0][textbox].value < 0) {
        document.forms[0][textbox].value = baseValue;
        alert('[+]숫자만 입력하세요.');
        return false;
    }
}



function changeAmountCommon(amount, txtSumPrice, unitPrice) {
    if (document.forms[0][amount].value == '0') {
        document.forms[0][amount].value = 1;
        document.forms[0][txtSumPrice].value = unitPrice;
        document.forms[0][txtSumPrice].value = InsertComma(document.forms[0][txtSumPrice].value, 3);
    }
    var Digit = '1234567890';
    for (i = 0; i < document.forms[0][amount].value.length; i++)
        if (Digit.indexOf(document.forms[0][amount].value.substring(i, i + 1)) < 0) {
        alert('수량에는 숫자만 입력하세요.');
        document.forms[0][amount].value = 1;
        document.forms[0][txtSumPrice].value = unitPrice;
        document.forms[0][txtSumPrice].value = InsertComma(document.forms[0][txtSumPrice].value, 3);
        return false;
    }
    if (document.forms[0][amount].value > 10000) {
        document.forms[0][amount].value = 10000;
        document.forms[0][txtSumPrice].value = document.forms[0][amount].value * unitPrice;
        document.forms[0][txtSumPrice].value = InsertComma(document.forms[0][txtSumPrice].value, 3);
        return false;
    }
    document.forms[0][txtSumPrice].value = document.forms[0][amount].value * unitPrice;
    document.forms[0][txtSumPrice].value = InsertComma(document.forms[0][txtSumPrice].value, 3);
}


function InsertComma(str) {
    str = str.toString();
    var i = 0, j = 0, k = 0;
    var nLen = 0;
    var desStr = '';
    nLen = str.length;
    k = nLen % 3
    if (k == 0) k = 3;
    i = 0;
    desStr = str.substring(i, k);
    i = k;
    while (i < nLen) {
        desStr = desStr + ',' + str.substr(i, 3);
        i = i + 3;
    }
    return desStr;
}



//콤마제거
function getNumber(str) {
    str = "" + str.replace(/,/gi, ''); // 콤마 제거
    str = str.replace(/(^\s*)|(\s*$)/g, ""); // trim
    return (new Number(str));
}



//textbox 폼체크
function textbox_startup_focus(txt_id) {
    txt = eval("document.all." + txt_id);
    //txt.value = '';
    //공백으로 만들면 로그인시 쿠키저장을 사용할수 없다..
    txt.focus();
}


function file_down(sourceUrl) {
    hyperLink_get_popup(sourceUrl, 'dd', 10, 10, 'no');

    return false;
}


//hyperlink 새창열기
function hyperLink_get_popup(sourceUrl, wname, width, height, scrollBarsYesOrNo) {
    var window_left = (screen.width - width) / 2;
    var window_top = (screen.height - height) / 2;
    var ow = window.open(sourceUrl, wname, 'left=' + window_left + ', top=' + window_top + ', width=' + width + ',resizible height=' + height + ', scrollbars=' + scrollBarsYesOrNo);
    //ow.close();

    return false;
}
function hyperLink_opener_location(url) {
    opener.location.href = url;
    self.close();
}





// 플래시 파일 로드
function get_flash(filename, width, height) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width=' + width + ' height=' + height + '>');
    document.write('<param name="movie" value="' + filename + '">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<embed src="' + filename + '" quality=high pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width=' + width + ' height=' + height + '></embed></object>');
}


//텍스트 submit차단
function checkCR(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type == 'text')) { return false; }
    if ((evt.keyCode == 13) && (node.type == 'password')) { return false; }
    if ((evt.keyCode == 13) && (node.type == 'radio')) { return false; }
    if ((evt.keyCode == 13) && (node.type == 'checkbox')) { return false; }
    if ((evt.keyCode == 13) && (node.type == undefined)) { return false; }
}
document.onkeypress = checkCR;









function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}


var left_mn_old_menu = null;
function toggleMenu(currMenu) {
    thisMenu = eval("document.all." + currMenu + ".style");
    thisMenu.display = "block";
    left_mn_old_menu = thisMenu;

    //		if(thisMenu.display == "block"){
    //			thisMenu.display = "none";
    //		}else{

    //			thisMenu.display = "block";
    //			left_mn_old_menu = thisMenu;
    //		}
}


function mp_init() {
    if (left_mn_old_menu != null) left_mn_old_menu.display = "none";
}
		



