/*******************************************************************************
 *
 *  Copyright 1998-2008 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;
}

function commify(n) {   // ¼ýÀÚ ÀÚ¸®¼ö Ã³¸®
  var reg = /(^[+-]?\d+)(\d{3})/;   // Á¤±Ô½Ä
  n += '';                          // ¼ýÀÚ¸¦ ¹®ÀÚ¿­·Î º¯È¯

  while (reg.test(n))
    n = n.replace(reg, '$1' + ',' + '$2');

  return n;
}

/** 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();
    }
}

//ÆË¾÷¸®»çÀÌÁî ÇÔ¼ö Ãß°¡ 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('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 = '';
}


function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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];}
}

/****************************************************
 ÇÃ·¡½Ã Ãâ·Â ÇÔ¼ö 
 ¾ÆÀÌµð, URL, Æø, ³ôÀÌ¸¸ ÀÔ·Â¹Þ¾Æ¼­ Ãâ·Â
*****************************************************/
function FlashCommon( id, ObjUri, vWidth, vHeight ) {

	var str = "";
	str  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + vWidth + '" height="' + vHeight + ' id="' + id + '" align="middle">';
	str += '<param name="movie" value="' + ObjUri + '">';
	str += '<param name="quality" value="high">';
	str += '<param name="wmode" value="transparent">';
	str += '<param name="bgcolor" value="#ffffff">';
	str += '<embed src="' + ObjUri + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	str += '</object>';

	document.writeln(str);
}



/****************************************************
¸µÅ©½Ã ÀÌ¹ÌÁö Å×µÎ¸® »èÁ¦
*****************************************************/
 function bluring(){ 
  if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
 } 
 document.onfocusin=bluring; 





function wopen(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
