/*******************************************************************************
 *
 *  Copyright 1998-2007 Today & Tomorrow. All rights reserved.
 *  Page: TTMallBuilder
 *  Date: 2007-02-06
 *
 *  Logs : Global JavaScript Function's
 *
 *******************************************************************************/
/** Global os Function's */
function str2int(d) { // 2ÀÚ¸® ¼ýÀÚ·á º¯°æ
  var str = new String();

  if (parseInt(d) < 10) {
    str = "0" + parseInt(d);
  } else {
    str = "" + parseInt(d);
  }
  return str;
}

/** Member is Function's **/
function on_idpwd_find() { // È¸¿ø ¾ÆÀÌµð,ºñ¹ø Ã£±â
    window.open('mall.cgi?skin=idpwd_find', '', 'width=300,height=200');
}

function on_logout() { // ·Î±×¾Æ¿ô
    document.location.href = 'mall.cgi?act=Logout';
}

function on_modify() { //È¸¿øÁ¤º¸¼öÁ¤
    document.location.href = 'mall.cgi?skin=member_modify'
}

function on_member_withdraw() { // È¸¿ø Å»Åð
    if (confirm('È¸¿ø Å»Åð½ÅÃ»À» ÇÏ½Ã°Ú½À´Ï±î?\n\nÅ»ÅðÇÏ½Ã¸é ¹Ù·Î Àç°¡ÀÔÀÌ µÇÁö ¾Ê½À´Ï´Ù.  '))
        document.location.href = 'mall.cgi?act=MemberWithdraw&skin=member_withdraw';
}

/** ¼³¹®Á¶»ç Function S */

function onSurveySelect(frm,rPath, sCode, survey_date_end)
{
    if (!sCode) { alert("Á¸ÀçÇÏÁö ¾Ê´Â ¼³¹®Á¶»ç ÀÔ´Ï´Ù.");  return; }

    // ¼³¹®±â°£ Ã¼Å© S
    datToday = new Date();                                  // ÇöÀç ³¯ÀÚ ¼³Á¤
    NowThisYear = datToday.getFullYear();                   // ÇöÀç ³â
    NowThisMonth = datToday.getMonth()+1;                   // ÇöÀç ¿ù
    NowThisDay = datToday.getDate();                        // ÇöÀç ÀÏ
    NowDate =  NowThisYear + "-" + str2int(NowThisMonth).toString() + "-" + str2int(NowThisDay).toString();
    if (survey_date_end < NowDate) { alert("¼³¹®±â°£ÀÌ Áö³µ½À´Ï´Ù.");  return; }
    // ¼³¹®±â°£ Ã¼Å© E

    var bNotSelect = 1;

    if (n_example_select == 0) {
        alert("¿¹½Ã°¡ ¾ø½À´Ï´Ù.");
        return;
    }

    for (var i = 0; i < frm.example_select.length; i++) {
        if (frm.example_select[i].checked == true) {
            bNotSelect = 0;
            break;
        }
    }

    if (bNotSelect) {
        alert("¿¹½Ã¸¦ ÇÏ³ª ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À.");
        return;
    }

    frm.action = "mall.cgi?act=SurveyExampleSelect&skin=survey_example_select&return_path=" + rPath + "&survey_code=" + sCode;
    frm.submit();
}

function onSurveyResult(survey_code) {
    window.open("mall.cgi?skin=survey_result&survey_code="+survey_code+"", "", "scrollbars=yes,width=300,height=250");
}
/** ¼³¹®Á¶»ç Function E */

// ¸ÞÀÎ ÄíÅ°Ã³¸®
function view_getCookieVal(offset)
{
    var endstr = document.cookie.indexOf(';', offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape( document.cookie.substring(offset, endstr) );
}

function view_GetCookie(name)
{
    var arg = name + '=';
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return view_getCookieVal(j);

        i = document.cookie.indexOf(' ', i) + 1;
        if (i == 0) break;
    }

    return null;
}

function view_SetCookie(name, value)
{
    var argv = view_SetCookie.arguments;
    var argc = view_SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path    = (argc > 3) ? argv[3] : null;
    var domain  = (argc > 4) ? argv[4] : null;
    var secure  = (argc > 5) ? argv[5] : false;

    document.cookie = name + '=' + escape (value) +
        ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) +
        ((path    == null) ? '' : ('; path=' + path)) +
        ((domain  == null) ? '' : ('; domain=' + domain)) +
        ((secure  == true) ? '; secure' : '');
}

function view_DeleteCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = view_GetCookie(name);
    document.cookie = name + '=' + cval + '; expires=' + exp.toGMTString();
}

//
// °Ë»ö °ü·Ã
//
function on_search() {
  var frm = document.SearchForm;
  if (frm.srch_word.value == '') {
    alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
    frm.srch_word.focus();
    return;
    }

    frm.action = 'mall.cgi?skin=search_result';
    frm.submit();
}

function on_search_enter() {
   if (window.event.keyCode == 13) {
      on_search();
    }
}

function on_menu_search() { // »óÇ° °Ë»ö
    var frm = document.MenuSearchForm;
    if (frm.srch_word.value == '') {
        alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
        frm.srch_word.focus();
        return;
    }

    frm.action = 'mall.cgi?skin=search_result';
    frm.target = '_self';
    frm.submit();
}

function on_menu_search_detail() {
    var frm = document.MenuSearchForm;
    frm.action = 'mall.cgi?skin=search_detail';
    frm.target = '_self';
    frm.submit();
}

function on_menu_search_enter() {
    if (window.event.keyCode == 13) {
        on_menu_search();
    }
}


//
// ÁÖ¹®»óÇ° ¼±ÅÃ¿É¼Ç ·¹ÀÌ¾î
//
function msgposit_cart() {
    document.getElementById('message_cart').style.posLeft = event.x + 20 + document.body.scrollLeft;
    document.getElementById('message_cart').style.posTop  = event.y - 20 + document.body.scrollTop;
}

function msgset_cart(str) {
    if (str == '') return;
    var html= '<div class=cart_item><table><tr><th colspan=2>¼±ÅÃ»ç¾ç</th></tr>'+str+'</table></div>';
    document.getElementById('message_cart').innerHTML = html;
}

function msghide_cart() {
    document.getElementById('message_cart').innerHTML = '';
}


