// ÇÃ·¡½Ã º¸¿©ÁÖ±â
function show_flash(swf, width, height)
{
    // flash player 8.x
    document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,24,0\" width=\""+width+"\" height=\""+height+"\" align=\"middle\">\n");
    // flash player 7.x
    //document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\""+width+"\" height=\""+height+"\" align=\"middle\">\n");
    document.write("<param name=\"movie\" value=\""+swf+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#FFFFFF\" /><param name=wmode value=\"transparent\">\n");
    document.write("<embed src=\""+swf+"\" width=\""+width+"\" height=\""+height+"\" align=\"middle\" quality=\"high\" bgcolor=\"#FFFFFF\" wmode=\"transparent\" name=\"skin_navigation\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n");
    document.write("</object>\n");
}

// ÀÌ¹ÌÁö º¯°æÇÏ±â
function image_change(img, src, des)
{
    if(img.src.indexOf(src) != -1)
        img.src = img.src.replace(src, des);
}

// ÆäÀÌÁö ÀÌµ¿ÇÏ±â
function pageMove(url_loc)
{
    location.href = url_loc;
}

// ÀÚ·á¿¡ °ø¹éÀÌ ÀÖ´ÂÁö Ã¼Å©
function IsEmpty(data)
{
    for (var i=0;i<data.length;i++) { if (data.substring(i,i+1) != " ") return false;  }
    return true; 
}

// ÇØ´ç ¹®ÀÚ°¡ ÀÖ´ÂÁö Ã¼Å©
function chk_string(str, word)
{
    var chk = str.indexOf(word);
    if (chk > -1) return true;
    else  return false; 
}

// ÀÚ·á°¡ ¿µ¹®,¼ýÀÚ·Î¸¸ ÀÌ·ç¾î Á³´ÂÁö Ã¼Å©
function IsAlphaNumeric(checkStr)
{
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";
    for (i = 0; i < checkStr.length; i++ )
    {
      	ch = checkStr.charAt(i);
      	for (j = 0; j < checkOK.length; j++)  if (ch == checkOK.charAt(j)) break;
       	if (j == checkOK.length) { 
      	    return false;
      		break;
      	}
    }
    return true; 
}


//ÀÚ·á°¡ ¿µ¹® ·Î¸¸ ÀÌ·ç¾î Á³´ÂÁö Ã¼Å©
function IsAlpha(checkStr)
{
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    for (i = 0; i < checkStr.length; i++ )
    {
      	ch = checkStr.charAt(i);
      	for (j = 0; j < checkOK.length; j++)  if (ch == checkOK.charAt(j)) break;
       	if (j == checkOK.length) { 
      	    return false;
            break;
      	}
    }
    return true; 
}


// ÀÚ·á°¡ ¿µ¹®,ÇÑ±Û ·Î¸¸ ÀÌ·ç¾î Á³´ÂÁö Ã¼Å©
function IsAlphaHangul(checkStr)
{
    for (i=0; i < checkStr.length; i++)
    {
        ch = checkStr.charAt(i);    
        if ( (ch >= '0' && ch <= '9') || !((ch >= 'a' && ch <='z') || (ch == '_') || (ch < 255) || (ch > 0) || (ch >= '°¡' && ch <= 'ÆR')) ) {
            return false;
            break;
        }
    }
    
    return true;
}

// µ¥ÀÌÅÍ ÀÔ·ÂÀ» ¼ýÀÚ·Î¸¸ ÇÒ ¼ö ÀÖ°Ô ÇÏ´Â ÇÔ¼ö
function onlyNum()
{
    if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)) {
    } else {
        if(event.keyCode != 13 && event.keyCode != 9 && event.keyCode != 8 && event.keyCode != 46)
        {
            alert('¼ýÀÚ¸¸ ÀÔ·ÂÇÒ¼ö ÀÖ½À´Ï´Ù!');
            event.returnValue = false;	
        }
    }
    return true;
}

// ÀÚ·á°¡ ¼ýÀÚ, ÄÞ¸¶ ÀÎÁö Ã¼Å©
function checkDigit_comma(tocheck)
{
    var isnum = true;
    if ((tocheck ==null) || (tocheck == "")) {
        isnum = false;
        return isnum; 
    }
    
    for (var j= 0 ; j< tocheck.length; j++ )
    {
        if ( ( tocheck.substring(j,j+1) != "0" ) &&
            ( tocheck.substring(j,j+1) != "1" ) &&
            ( tocheck.substring(j,j+1) != "2" ) &&
            ( tocheck.substring(j,j+1) != "3" ) &&
            ( tocheck.substring(j,j+1) != "4" ) &&
            ( tocheck.substring(j,j+1) != "5" ) &&
            ( tocheck.substring(j,j+1) != "6" ) &&
            ( tocheck.substring(j,j+1) != "7" ) &&
            ( tocheck.substring(j,j+1) != "8" ) &&
            ( tocheck.substring(j,j+1) != "9" ) &&
            ( tocheck.substring(j,j+1) != "," ) ) {
            isnum = false; }  
    }
    return isnum;
}

//3ÀÚ¸® ´ÜÀ§·Î ÄÞ¸¶ »ðÀÔÇÏ±âÀü Æû°ª Ã¼Å©
//onblur="comma(ÆûÀÌ¸§.ÆûÇÊµå)" ½ÄÀ¸·Î input Çü½Ä¿¡ »ðÀÔ
function comma(f)
{
    if (IsEmpty(f.value) == true)  return  false;
	  
    if (!checkDigit_comma(f.value) == true)
    { 
        alert("¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
        f.value = '';
        f.focus();
        return false;
    }
    
    var price, tmp;
    price = f.value;
    tmp = price.replace(/,/g, "");
    f.value = commaNum(tmp);  
}


//3ÀÚ¸® ´ÜÀ§·Î ÄÞ¸¶ »ðÀÔÇÏ±â
function commaNum(num)
{
    if (num < 0) { num *= -1; var minus = true} 
    else var minus = false 
    
    var dotPos = (num+"").split(".");
    var dotU = dotPos[0];
    var dotD = dotPos[1];
    var commaFlag = dotU.length%3;
    
    if (commaFlag)
    {
        var out = dotU.substring(0, commaFlag)
        if (dotU.length > 3) out += ",";
    } 
    else var out = "";
    
    for (var i=commaFlag; i < dotU.length; i+=3)
    {
        out += dotU.substring(i, i+3);
        if( i < dotU.length-3) out += ",";
    } 
    
    if (minus) out = "-" + outl
    if (dotD) return out + "." + dotD;
    else return out;
}

// ¿øµµ¿ì Ã¢ ¿ÀÇÂ (ÇØ»óµµ¿¡ µû¶ó °¡¿îµ¥·Î ¿­±â)
function winOpenCenter (doc, wname, width, height)
{
    var screenWidth  = screen.availWidth;
    var screenHeight = screen.availHeight;
    
    var intLeft = (screenWidth - width) / 2;
    var intTop  = (screenHeight - height) / 2
    
    window.open(doc, wname, 'scrollbars=no,resizable=no,top='+intTop+',left='+intLeft+',width='+width+',height='+height);
}

// ¿øµµ¿ì Ã¢ ¿ÀÇÂ (½ºÅ©·Ñ, ÇØ»óµµ¿¡ µû¶ó °¡¿îµ¥·Î ¿­±â)
function winOpenCenterB (doc, wname, width, height)
{
    var screenWidth  = screen.availWidth;
    var screenHeight = screen.availHeight;
    
    var intLeft = (screenWidth - width) / 2;
    var intTop  = (screenHeight - height) / 2
    
    window.open(doc, wname, 'scrollbars=yes,resizable=no,top='+intTop+',left='+intLeft+',width='+width+',height='+height);
}

function winopenFull()
{
    self.moveTo(0,0); 
    self.resizeTo(screen.availWidth,screen.availHeight);
}

function winClose()
{ 
    self.close(); 
}

// iframe »ç¿ë ÇÒ °æ¿ì ÇÁ·¹ÀÓ »çÀÌÁî ÄÁÅÙÃ÷ »çÀÌÁî¿¡ ¸ÂÃß±â
function init_iframe(height)
{
  reSize(height);
  setTimeout('init_iframe('+height+')', 200)
}

function reSize(height)
{
  try {
    var objBody = ifrm.document.body;
    var objFrame = document.all["ifrm"];
    ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);

    if (ifrmHeight > height)  ifrmHeight = height;
		
    if (ifrmHeight > 0)  objFrame.style.height = ifrmHeight
    else  objFrame.style.height = 0;
    objFrame.style.width = '100%';
  }
  catch(e) {}
}

// ÄíÅ° ±Á±â
function setCookie(name, value, expiredays)
{
    var todayDate = new Date();
    todayDate.setDate(todayDate.getDate() + expiredays);   
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

// trim ÇÔ¼ö 
function trim(str)
{
    // Á¤±Ô Ç¥Çö½ÄÀ» »ç¿ëÇÏ¿© È­ÀÌÆ®½ºÆäÀÌ½º¸¦ ºó¹®ÀÚ·Î ÀüÈ¯
    str = str.replace(/^\s*/,'').replace(/\s*$/, ''); 
    return str;
}

// È®ÀåÀÚ ¸®ÅÏ
function findExtension(fname)
{
    //var s = fname.lastIndexOf("\\");
    var m = fname.lastIndexOf(".");
    var e = fname.length;
    //var filename = fname.substring(s+1,m);
    var extname = fname.substring(m+1, e);
    
    return extname;
}

// ¸µÅ©ÀÚ±¹ Áö¿ì±â
function allblur() {
  for (i = 0; i < document.links.length; i++) document.links[i].onfocus = document.links[i].blur;
}

// È¸¿øÁ¤º¸ ·¹ÀÌ¾î
function move_box(an, box, popup)
{
    //¸µÅ©µÈ À§Ä¡¿¡¼­ ºÎÅÍÀÇ ¼³Á¤°ª ÁöÁ¤
    var cleft = 20;  //¿ÞÂÊ¸¶Áø  
    var ctop = -10;  //»ó´Ü¸¶Áø
    var obj = an;
    if(popup)
    {
        box.style.top = 90 + 'px';
        box.style.left = 100 + 'px';
    }
    else
    {
        while (obj.offsetParent)
        {
            cleft += obj.offsetLeft;
            ctop += obj.offsetTop;
            obj = obj.offsetParent;
        }
        if(cleft > 550) cleft = cleft - 400;
        box.style.left = cleft + 'px';
        ctop += an.offsetHeight + 8;
        if (document.body.currentStyle && document.body.currentStyle['marginTop'])
        {
            ctop += parseInt(document.body.currentStyle['marginTop']);
        }
        box.style.top = ctop + 'px';
    }
}

function show_hide_box(an, width, height, borderStyle, popup)
{
    var href = an.href;
    var boxdiv = document.getElementById(href);
    
    if (boxdiv != null)
    {
        if (boxdiv.style.display=='none')
        {
            move_box(an, boxdiv);
            boxdiv.style.display='block';
        }
        else
            boxdiv.style.display='none';
        return false;
    }
    
    boxdiv = document.createElement('div');
    boxdiv.setAttribute('id', href);
    boxdiv.style.display = 'block';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = width + 'px';
    boxdiv.style.height = height + 'px';
    boxdiv.style.border = borderStyle;
    boxdiv.style.backgroundColor = '#fff';
    boxdiv.style.zIndex = '1000';
    
    var contents = document.createElement('iframe');
    contents.scrolling = 'no';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = height + 'px';
    contents.src = href;
    
    boxdiv.appendChild(contents);
    document.body.appendChild(boxdiv);
    move_box(an, boxdiv, popup);
    
    return false;
}

// Äü¸Þ´º ·¹ÀÌ¾î °ü·Ã
function initMoving(target, position, topLimit, btmLimit) {
    if (!target)
        return false;
 
    var obj = target;
    obj.initTop = position;
    obj.topLimit = topLimit;
    obj.bottomLimit = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) - btmLimit - obj.offsetHeight;
 
    obj.style.position = "absolute";
    obj.top = obj.initTop;
    obj.left = obj.initLeft;
 
    if (typeof(window.pageYOffset) == "number") {   //WebKit
        obj.getTop = function() {
            return window.pageYOffset;
        }
    } else if (typeof(document.documentElement.scrollTop) == "number") {
        obj.getTop = function() {
            return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        }
    } else {
        obj.getTop = function() {
            return 0;
        }
    }
 
    if (self.innerHeight) {   //WebKit
        obj.getHeight = function() {
            return self.innerHeight;
        }
    } else if(document.documentElement.clientHeight) {
        obj.getHeight = function() {
            return document.documentElement.clientHeight;
        }
    } else {
        obj.getHeight = function() {
            return 500;
        }
    }
 
    obj.move = setInterval(function() {
        if (obj.initTop > 0) {
            pos = obj.getTop() + obj.initTop;
        } else {
            pos = obj.getTop() + obj.getHeight() + obj.initTop;
            //pos = obj.getTop() + obj.getHeight() / 2 - 15;
        }
 
        if (pos > obj.bottomLimit)
            pos = obj.bottomLimit;
        if (pos < obj.topLimit)
            pos = obj.topLimit;
 
        interval = obj.top - pos;
        obj.top = obj.top - interval / 3;
        obj.style.top = obj.top + "px";
    }, 30)
}

function onTotalMenuView()
{
    var obj = document.getElementById('total_menu_div');
    obj.style.display = "block";
}

function onTotalMenuClose()
{
    var obj = document.getElementById('total_menu_div');
    obj.style.display = "none";
}

// ÀÌ¹ÌÁö preloading
allblur();
