/*--------------------------------------------------------------//
//
//  °ø¿ë JavaScript
//
//-------------------------------------------------------------*/

function on_idpwd_find()
{
   window.open('mall.cgi?skin=idpwd_find','','width=300,height=200');
}

function on_logout()
{
   location.href="mall.cgi?act=Logout&skin=logout";
}

function on_modify()
{
   location.href="mall.cgi?skin=member_modify"
}

/* »óÇ° °Ë»ö °ü·Ã ÇÔ¼ö */
function on_menu_search()
{
   var Form=document.MenuSearchForm;
   if( Form.srch_word.value=="" )
   {
      alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
      Form.srch_word.focus();
      return;
   }
   Form.action="mall.cgi?skin=search_result";
   Form.submit();
}

function on_menu_search_detail()
{
   var Form=document.MenuSearchForm;
   Form.action="mall.cgi?skin=search_detail";
   Form.submit();
}

function on_menu_search_enter()
{
   if(event.keyCode==13)
      on_menu_search();
}

/* Main Cookie Ã³¸® ÇÔ¼ö */
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 Form=document.SearchForm;
   if( Form.srch_word.value=="" )
   {
      alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
      Form.srch_word.focus();
      return;
   }
   Form.action="mall.cgi?skin=search_result";
   Form.submit();
}
function on_search_enter()
{
   if(event.keyCode==13)
      on_search();
}

function commify(n) {   // ¼ýÀÚ ÀÚ¸®¼ö Ã³¸®
  var reg = /(^[+-]?\d+)(\d{3})/;   // Á¤±Ô½Ä
  n += '';                          // ¼ýÀÚ¸¦ ¹®ÀÚ¿­·Î º¯È¯

  while (reg.test(n))
    n = n.replace(reg, '$1' + ',' + '$2');

  return n;
}

//
// ÁÖ¹®»óÇ° ¼±ÅÃ¿É¼Ç ·¹ÀÌ¾î
//
// »óÇ° »ó¼¼³»¿ª ·¹ÀÌ¾î  (IE & FF)
function msgposit_cart(event) {
    isIE=document.all;
    var x = (isIE)?event.x:event.clientX;
    var y = (isIE)?event.y:event.clientY;

    if (isIE==undefined) {
        document.getElementById('message_cart').style.left = x+(Math.max(document.documentElement.scrollLeft, document.body.scrollLeft))+20+'px';
        document.getElementById('message_cart').style.top = y+(Math.max(document.documentElement.scrollTop, document.body.scrollTop))-30+'px';
    } else {
        var box = getBounds(document.getElementById('mBody'));
        document.getElementById('message_cart').style.left = x+box.left+20+'px';
        document.getElementById('message_cart').style.top = y+box.top-30+'px';
    }
}

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 = '';
}
