/*--------------------------------------------------------------//
//
//  °ø¿ë JavaScript
//
//  Copyright 1998 - 2005 Today and Tomorrow Co., Ltd.
//  All rights reserved.
//
//-------------------------------------------------------------*/

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&skin=logout";
}

function on_modify() {
   document.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();
}

/*************************************************************************
  »óÇ°ÀÇ ¿É¼Ç°ú ¼ö·®¿¡ µû¸¥ ÆÇ¸Å°¡¸¦ °è»êÇÏ¿© Àû¿ëÇÑ´Ù.

  ÆÄ¶ó¸ÞÅÍ : Æû°´Ã¼(document.ViewForm)
*************************************************************************/
function getGoodsOrderCost(form) {
    var amount = form.order_amount.value;
    var unit_price = form.goods_cost.value;
    var order_cost  = 0;

    unit_price = parseInt(unit_price.replace(",",""));
    order_cost = unit_price;

    /*
    //var iframe = document.createElement("<iframe id='GoodsInfoFrame' name='GoodsInfoFrame' style='display:none' src=''></iframe>");
    form.action = "mall.cgi?act=RequestGoodsCost&goods_code=" + goods_code;
    form.target = "GoodsInfoFrame";
    form.submit();
    form.target = "_self";
    */

    for (var i = 0; i < form.length; i++) {
    var elem = form.elements[i];
    var field_name = elem.name;
    var field_value;

    if (elem.type == "select-one") {
        field_value = elem.options[elem.selectedIndex].value;
    }
    else {
        field_value = elem.value;
    }

    if (field_value.indexOf("=+") != -1) {
        var add_price = field_value.substr(field_value.indexOf("=+")+2);
        order_cost += parseInt(add_price);
    }
    else if (field_value.indexOf("=-") != -1) {
        var sub_price = field_value.substr(field_value.indexOf("=-")+2);
        order_cost -= parseInt(sub_price);
    }
    }

    order_cost *= amount;

    /*
    var msg = "";
    msg += "--------------------<br>\n";
    msg += "amount="+ amount +"<br>\n";
    msg += "unit_price="+ unit_price +"<br>\n";
    msg += "order_cost="+ order_cost +"<br>\n";
    order_cost = msg;
    */

    document.getElementById("div_goods_cost").innerHTML = order_cost;
}

//ÆË¾÷¸®»çÀÌÁî ÇÔ¼ö Ãß°¡ 2008.1.31 ±è¼º±¸
//ÆË¾÷¿ë( IE7 IE6 FF opera ) - °¡·Î Å©±âµµ °è»ê ( »õ·Î°íÄ§½Ã °è¼Ó ´Ã¾î³ª´Â Çö»ó ¹ß»ý )
function resizepopup()
{
    if(document.all)
    {
        var  height = parseInt(document.body.scrollHeight);
        var  width = parseInt(document.body.scrollWidth);
    }
    else
    {
        var height = parseInt(document.body.offsetHeight);
        var width = parseInt(document.body.offsetWidth);
    }
    var odiv = document.createElement("div");
    odiv.style.position = "absolute";odiv.style.left = "0px";odiv.style.top = "0px";odiv.style.width = "100%";odiv.style.height = "100%";
    document.body.appendChild(odiv);window.resizeBy(width-odiv.offsetWidth+5, height-odiv.offsetHeight);document.body.removeChild(odiv);
}
//°´Ã¼ »çÀÌÁî±¸ÇÏ±â
function getBounds(tag)
{
    var ret = new Object();
    if(document.all) {
    var rect = tag.getBoundingClientRect();
    ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft);
    ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop);
    ret.width = rect.right - rect.left;
    ret.height = rect.bottom - rect.top;
    } else {
    var box = document.getBoxObjectFor(tag);
    ret.left = box.x;
    ret.top = box.y;
    ret.width = box.width;
    ret.height = box.height;
    }
    return ret;
}

//
// ÁÖ¹®»óÇ° ¼±ÅÃ¿É¼Ç ·¹ÀÌ¾î
//
// »óÇ° »ó¼¼³»¿ª ·¹ÀÌ¾î  (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('mMain'));
		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 = '';
}


