////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   imgOver
//
//**************************************************************************************************************
//
//  Example)
//      <img src="/_image/common/ÀÌ¹ÌÁö.jpg" alt="" title="" onmouseover="imgOver(this)" onmouseout="imgOver(this,'out')">
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function imgOver(imgEl,opt) {
    var src = imgEl.getAttribute('src');
    var ftype = src.substring(src.lastIndexOf('.'), src.length);
    
    if (opt == 'out') imgEl.src = imgEl.src.replace("r"+ftype, ftype);
    else imgEl.src = imgEl.src.replace(ftype, "r"+ftype);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   setPng24
//
//**************************************************************************************************************
//
//  Usage) IE 7 ÀÌÇÏ¿¡¼­ png24 ÀÇ ¾ËÆÄÃ¤³Î Áö¿ø
//
//  Example)
//      <img src="ÀÌ¹ÌÁö" alt="" title="" class="png24">
//      -  css ÆÄÀÏ¶Ç´Â ¹®¼­³»¿¡ .png24{tmp:expression(setPng24(this));} °¡ ÁöÁ¤µÇÀÖ¾î¾ß »ç¿ë°¡´É
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function setPng24(obj) { 
      var browser = navigator.appName;
      var version = parseFloat(navigator.appVersion.replace (/^.*MSIE ([.0-9]+).*$/,"$1"));

      if(browser.indexOf("Internet Explorer") && version < 7.0 ) { // IE6 ÀÌÇÏ¿¡¼­¸¸ µ¿ÀÛ 2008-03-14 by zardsama
            obj.width=obj.height=1; 
            obj.className=obj.className.replace(/\bpng24\b/i,''); 
            obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
            obj.src='';  
            return ''; 
      }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   eaChg(
//
//**************************************************************************************************************
//
//  Usage) input text ¼ýÀÚ up & down
//
//  Example)
//      <img src="¾÷" alt="" title="" onclick="eaChg(f,pm)">
//      <img src="´Ù¿î" alt="" title="" onclick="eaChg(f,pm)">
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function eaChg(f,pm){
    if (pm == 1) {
        f.buy_ea.value++;
    }else {
		
        if (f.buy_ea.value <= 1) return;
        f.buy_ea.value--;
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   goFlash
//
//**************************************************************************************************************
//
//  Usage) ÇÃ·¡½Ã ¸µÅ© ÀÚ¹Ù½ºÅ©¸³Æ® ¿¬µ¿
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var flashLink=new Array();
flashLink['btn_logo']="/";

function goFlash(n){
	//alert(n);
    if (flashLink[n]) location.href=flashLink[n];    
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   backTop
//
//**************************************************************************************************************
//
//  Usage) »ó´ÜÀÌµ¿ top button
//
//  Example)
//      <img src="ÀÌ¹ÌÁö" alt="" title="" onclick="backTop()">
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function backTop() {
    x = document.body.scrollLeft;
    y = document.body.scrollTop;
    
    step = 2;

        while ((x != 0) || (y != 0)) {
            scroll (x, y);
            step += (step * step / 1);
            x -= step;
            y -= step;
            
            if (x < 0) x = 0;
            if (y < 0) y = 0;
        } 
    scroll (0, 0);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   bookmarksite
//
//**************************************************************************************************************
//
//  Usage) Áñ°ÜÃ£±â
//
//  Example)
//      <img src="ÀÌ¹ÌÁö" alt="" title="" onclick="addBookmark()">
//      -  À§»ç¸ôÀÇ °æ¿ì 
//         °°ÀÌ phpº¯¼ö¿Í ÇÔ²² »ç¿ë°¡´É
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function addBookmark() {
    var url = root_url;
    var title = document.title;

    if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, ""); 

    else if(window.opera && window.print) { // opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
    }

    else if(document.all) // IE
    window.external.AddFavorite(url, title);
}

////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   R2Slider 1.0
//
//  - 2008-03-20 by zardsama
//
//***************************************************************************************
//
//  Usage)
//      var º¯¼ö¸í = new R2Slider("·¹ÀÌ¾î ID","º¯¼ö¸í", ¼Óµµ, »ó´Ü¸¶Áø, DTD);
//      º¯¼ö¸í.slide();
//      -  ¼Óµµ, »ó´Ü¸¶ÁøÀº »ý·« °¡´É / ÃßÈÄ º¯°æ °¡´É
//      -  'º¯¼ö¸í.limitTop' È¤Àº 'º¯¼ö¸í.limitBottom' À¸·Î »ó/ÇÏ´Ü ÇÑ°è ÁöÁ¡ ¼³Á¤°¡´É
//
//  Example)
//      <div id="quickMenu" style="position:absolute; width: 100px; height: 400px;"></div>
//      <script type="text/javascript">
//          var sc = new R2Slider ("quickMenu","sc",null,10,document.body);
//          sc.limitTop = 132;
//          sc.limitBottom = 380;
//          sc.slide();
//      </script>
//
////////////////////////////////////////////////////////////////////////////////////////////

R2Slider = function(id, slider, divPitch, marginTop, dElement) {
    if (isNaN(parseInt(marginTop))) marginTop = 0;    // »ó´Ü ¸¶Áø µðÆúÆ®
    if (isNaN(parseInt(divPitch))) divPitch = 15;    // ÀÌµ¿ °£°Ý µðÆúÆ®
    if (!dElement) dElement = document.documentElement; // DTD strict ÀÏ¶§ ( Transitional ÀÏ¶§´Â document.body )

    this.timer;    // Å¸ÀÌ¸Ó º¯¼ö
    this.slider = slider;    // °´Ã¼ º¯¼ö¸í
    this.obj = document.getElementById (id);    // ¿ÀºêÁ§Æ®
    this.marginTop = parseInt(marginTop);    // »ó´Ü ¸¶Áø
    this.divPitch = parseInt(divPitch);    // ÀÌµ¿ °£°Ý
    this.dElement = dElement; // DTD ¿¡ µû¸¥ µµÅ¥¸ÕÆ® ¿¤¸®¸ÕÆ®
    this.limitTop;     // »ó´Ü ÇÑ°èÁ¡
    this.limitBottom;     // ÇÏ´Ü ÇÑ°èÁ¡
}


R2Slider.prototype.moveIt = function(){
    var pitch = (parseInt(this.dElement.scrollTop)+ parseInt(this.marginTop)) - parseInt(this.obj.style.top);

    if (pitch == 0) return;
    else nextPos = parseInt(this.obj.style.top) + pitch / this.divPitch
    nextPos = (pitch > 0) ? Math.ceil(nextPos) : Math.floor(nextPos);

    var limitBottom = this.dElement.scrollHeight - parseInt(this.limitBottom)- parseInt(this.obj.offsetHeight);
    if ( this.limitTop && nextPos  < this.limitTop ) nextPos = this.limitTop;
    if ( this.limitBottom && nextPos  > limitBottom ) nextPos = limitBottom;
    if (nextPos < this.marginTop) nextPos = this.marginTop;
    if (isNaN(nextPos)) nextPos = 0;

    this.obj.style.top = nextPos+"px";
}

R2Slider.prototype.slide = function() {
    this.timer = setInterval(""+this.slider+".moveIt()", 10);
}

function boxRound(mode,wh) { 
	if (mode=="top") {
			if (wh>0){
		document.write('<table width="'+wh+'" cellspacing="0" cellpadding="0" style="margin:0 auto;">');
			}else{
		document.write('<table width="100%" cellspacing="0" cellpadding="0" style="margin:0 auto;">');
			}
		document.write('<tr>');
		document.write('<td width="8" height="8"><img src="/_image/shop/box_left_top.gif" border="0" alt="" /></td>');
		document.write('<td width="100%" height="8" background="/_image/shop/box_top.gif"></td>');
		document.write('<td width="8" height="8"><img src="/_image/shop/box_right_top.gif" border="0" alt="" /></td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('<td colspan="3" bgcolor="#ececec" style="padding:0 1px;">');
		document.write('<table width="100%" cellspacing="0" cellpadding="0" bgcolor="#f3f3f3">');
		document.write('<tr>');
		document.write('<td style="padding:0 5px;">');
		document.write('<table width="100%" cellspacing="0" cellpadding="0" bgcolor="#ffffff">');
		document.write('<tr>');
		document.write('<td style="padding:3px 5px;">');
	}else if (mode=="bottom") {
		document.write('</td>');
		document.write('</tr>');
		document.write('</table>');
		document.write('</td>');
		document.write('</tr>');
		document.write('</table>');
		document.write('</td>');
		document.write('</tr>');
		document.write('<tr>');
		document.write('<td width="8" height="8"><img src="/_image/shop/box_left_bottom.gif" border="0" alt="" /></td>');
		document.write('<td width="100%" height="8" background="/_image/shop/box_bottom.gif"></td>');
		document.write('<td width="8" height="8"><img src="/_image/shop/box_right_bottom.gif" border="0" alt="" /></td>');
		document.write('</tr>');
		document.write('</table>');
	}
}

function eScroll()
{	
	/*********************************
	 * eScroll ( eNamoo scroll script )
	 * by mirrh
	 * 2006.07.16
	 ********************************/
	
	var thisObj = this;
	this.timeObj = null;
	
	/*** ¼³Á¤º¯¼ö ***/
	this.mode = "left";				// ½ºÅ©·Ñ ¹æÇâ (top|left)
	this.width = 70;			// ¶óÀÎ´ç °¡·Î°ª (pixel)
	this.height = 20;				// ¶óÀÎ´ç ³ôÀÌ°ª (pixel)
	this.line = 1;					// Ãâ·Â ¶óÀÎ¼ö
	this.delay = 50;				// ½ºÅ©·ÑÈÄ µô·¹ÀÌ ½Ã°£
	this.speed = 1;					// ½ºÅ©·Ñ ¼Óµµ (ÀÛÀ»¼ö·Ï ºü¸§)
	this.id = 'obj_eScroll';		// °´Ã¼ id (Å¬·¡½º ´ÙÁß »ç¿ë½Ã id ´Ù¸£°Ô ÁöÁ¤ ¿ä¸Á)
	this.contents = new Array();	// Ãâ·Â ³»¿ë (¹è¿­·Î ³»¿ë ÁöÁ¤ ¿ä¸Á)
	this.align = "left";			// ³»¿ë aligne
	this.valign = "middle";			// ³»¿ë valigne

	/*** ³»Àåº¯¼ö ***/
	this.gap = 0;
	this.direction = 1;
	this.mMode;

	this.add = add;
	this.exec = exec;
	this.start = start;
	this.stop = stop;
	this.scroll = scroll;
	this.direct = direct;
	this.go = go;

	function add(str)
	{
		this.contents[this.contents.length] = str;
	}
	
	function exec()
	{
		this.basis = (this.mode == "left") ? this.width : this.height;
		var outWidth = this.width * ((this.mode == "left") ? this.line : 1);
		var outHeight = this.height * ((this.mode == "top") ? this.line : 1);
		
		var outline = "<div id=" + this.id + " style='overflow:hidden;width:" + outWidth + ";height:" + outHeight + "'><table></table></div>";
		document.write(outline);
		this.obj = document.getElementById(this.id);
		
		var tb = this.obj.appendChild(document.createElement("table"));
		var tbody = tb.appendChild(document.createElement("tbody"));
		tb.cellPadding = 0 ;
		tb.cellSpacing = 0 ;
		tb.onmouseover = function(){thisObj.stop()};
		tb.onmouseout = function(){thisObj.start()};
		
		if (this.mode=="left") var tr = tbody.appendChild(document.createElement("tr"));
		for (k in this.contents){
			if (this.mode=="top") var tr = tbody.appendChild(document.createElement("tr"));
			var td = tr.appendChild(document.createElement("td"));
			td.noWrap = true;
			td.style.width = this.width;
			td.style.height = this.height;
			td.style.textAlign = this.align;
			td.style.verticalAlign = this.valign;
			td.innerHTML = this.contents[k];
		}
		
		var len = (this.contents.length<this.line) ? this.contents.length : this.line;
		for (i=0;i<len;i++){
			if (this.mode=="top") var tr = tbody.appendChild(document.createElement("tr"));
			td = tr.appendChild(document.createElement("td"));
			td.noWrap = true;
			td.style.width = this.width;
			td.style.height = this.height;
			td.style.textAlign = this.align;
			td.style.verticalAlign = this.valign;
			td.innerHTML = this.contents[i];
		}

		this.obj.parent = this;
		this.tpoint = this.basis * this.contents.length;
		this.start();
	}

	function scroll()
	{
		var out = (this.mode=="left") ? this.obj.scrollLeft : this.obj.scrollTop;
		if (out%this.basis==0){
			this.gap++;
			if (this.gap>=this.delay) this.gap = 0;
		}

		if (!this.gap){
			var ret = (out==this.tpoint) ? this.direction : out + this.direction;
			if (ret<0) ret = this.tpoint + ret;
			if (this.mode=="left") this.obj.scrollLeft = ret;
			else this.obj.scrollTop = ret;
		} 
	}

	function start(){
		this.timeObj = window.setInterval("(document.getElementById('" + this.id + "')).parent.scroll()",this.speed);
	}

	function stop() {	
		clearTimeout(this.timeObj);
	}

	function direct(d) {
		this.direction = d;
	}

	function go()
	{
		this.stop();
		var out = (this.mode=="left") ? this.obj.scrollLeft : this.obj.scrollTop;
		var ret = (parseInt(out / this.basis) + this.direction) * this.basis;
		if (ret<0) ret = this.tpoint + ret;
		if (ret>this.tpoint) ret = this.basis;
		if (this.mode=="left") this.obj.scrollLeft = ret;
		else this.obj.scrollTop = ret;
	}
}
