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.01
  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 && d.getElementById) x=d.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];}
}
function goBrand (o) {
	if (o.selectedIndex != 0) {
		document.location.href='/shop/item/brandFirst.do?brandId='+o.options[o.selectedIndex].value;
	}
}
function popLogin () {
	window.open ('/member/tryLoginPop.do', 'popLogin','width=550,height=335');
}
function popFindIdPass () {
	window.open ('/member/findIdPass.do', 'popLogin','width=550,height=335');
}
function decimalFormat(v) {
  var format = "";
  var a=removeFormat(v.toString(),',');
  a = parseInt(a, 10);
  var money =a.toString();

  money = reverse(money);

  for(var i = money.length-1; i > -1; i--) {
    if((i+1)%3 == 0 && money.length-1 != i) format += ",";
    format += money.charAt(i);
  }
  return format;
}
function reverse(s) {
  var rev = "";

  for(var i = s.length-1; i >= 0 ; i--) {
    rev += s.charAt(i);
  }

  return rev;
}
function removeFormat(content, sep) {
  var real = "";
  var contents = content.split(sep);

  for(var i = 0; i < contents.length; i++) {
    real += contents[i];
  }

  return real;
}
function TopScroll () {
	this.version = "0.2";
	this.name = "themeE";
	this.divId = "list";
	this.item = new Array();
	this.itemcount = 0;
	this.currentspeed = 0;
	this.scrollspeed = 50;
	this.pausedelay = 10000000;
	this.pausemouseover = false;
	this.stop = false;
	this.height = 20;
	this.width = 450;
	this.stopHeight=0;
	this.i=0;
	this.reloadData = 0;

	this.add = function () {
		var text = arguments[0];
		this.item[this.itemcount] = text;
		this.itemcount = this.itemcount + 1;
	};

	this.start = function () {
		if ( this.itemcount == 1 ) {
			this.add(this.item[0]);
		}
		this.display();
		this.currentspeed = this.scrollspeed;
		this.stop = true;
		setTimeout(this.name+'.scroll()',this.currentspeed);
		window.setTimeout(this.name+".stop = false", this.pausedelay);
	};

	this.display = function () {
        var htmlCode;
		htmlCode = '<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">';
		for(var i = 0; i < this.itemcount; i++) {
			htmlCode += '<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; ">';
			htmlCode += this.item[i];
			htmlCode += '</div>';
		}
		htmlCode += '</div>';

        document.getElementById(this.divId).innerHTML=htmlCode;
	};

	this.scroll = function () {
		if ( this.pause == true ) {
			window.setTimeout(this.name+".scroll()",this.pausedelay);
			this.pause = false;
		} else {
			this.currentspeed = this.scrollspeed;
			if ( !this.stop ) {
				for (var i = 0; i < this.itemcount; i++) {
					obj = document.getElementById(this.name+'item'+i).style;
					obj.top = parseInt(obj.top) - 1;
					if ( parseInt(obj.top) <= this.height * (-1) ) obj.top = this.height * (this.itemcount-1);
					if ( parseInt(obj.top) == 0 ) {
						this.currentspeed = this.pausedelay;
						this.i = i;
					}
				}
			}
            if( !this.stop && i == this.itemcount && parseInt(obj.top) == 0 && this.reloadData == 1 ) {
				this.reloadData = 0;
            }
            else {
				window.setTimeout(this.name+".scroll()",this.currentspeed);
            }
		}
	};

	this.rolling = function () {
		if ( this.stop == false  ) {
			this.next();
		}
		window.setTimeout(this.name+".rolling()",this.scrollspeed);
	}

	this.onmouseover = function () {

			this.stop = true;

	};

	this.onmouseout = function () {
		if ( this.pausemouseover ) {
			this.stop = false;
		}
	};

	this.next = function() {

		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) < 1 ) {
				width = this.width + parseInt(obj.left);
				break;
			}
		}
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) < 1 ) {
				obj.left = this.width * (this.itemcount-1);
			} else {
				obj.left = parseInt(obj.left) - width;
			}
		}

	}

	this.prev = function() {

		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) < 1 ) {
				width = parseInt(obj.left) * (-1);
				break;
			}
		}
		if ( width == 0 ) {
			total_width = this.width * (this.itemcount-1);
			for (i = 0; i < this.itemcount; i++) {
				obj = document.getElementById(this.name+'item'+i).style;
				if ( parseInt(obj.left) + 1 > total_width ) {
					obj.left = 0;
				} else {
					obj.left = parseInt(obj.left) + this.width;
				}
			}
		} else {
			for (i = 0; i < this.itemcount; i++) {
				obj = document.getElementById(this.name+'item'+i).style;
				if ( parseInt(obj.left) < 1 ) {
					obj.left = 0;
				} else {
					obj.left = parseInt(obj.left) + width;
				}
			}
		}
	}

	this.unext = function () {
		this.onmouseover();
		this.next();
		window.setTimeout(this.name+".onmouseout()",this.pausedelay);
	}

	this.uprev = function () {
		this.onmouseover();
		this.prev();
		window.setTimeout(this.name+".onmouseout()",this.pausedelay);
	}
}

function bookmark(){
	window.external.AddFavorite ("http://www.goodsnt.co.kr", "°¨»çÆÐµå¸²");
}
function displayCategory(state) {
	if (state == "show") {
		Layers_displayLayers('category_menu','','show');
	} else {
		Layers_displayLayers('category_menu','','hide');
	}
}
function Layers_displayLayers(strArg1, strArg2, strArg3) {
	var i,p,v,obj,args=Layers_displayLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=Layers_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 Layers_findObj(n, d) {
	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=Layers_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";
function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

function viewQuickMenu () {
	if (isNS4) {
		var divMenu = document["divMenu"];
		divMenu.top = top.pageYOffset + 35;
		divMenu.visibility = "visible";
		moveRightEdge();
	} else if (isDOM) {
		var divMenu = getRef('divMenu');
		divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 135;
		divMenu.style.visibility = "visible";
		moveRightEdge()
	}
}

function moveRightEdge() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
	divMenuD = document.getElementById ("divMenu");
	if (isNS4) {
		yMenuFrom   = divMenuD.top;
		yMenuTo     = windows.pageYOffset + 360;   // ??? ?g.
	} else if (isDOM) {
		yMenuFrom   = parseInt (divMenuD.style.top, 10);
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 135; // ??? ?g.
	}
	timeoutNextCheck = 100;

	if (yMenuFrom != yMenuTo) {
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
		if (yMenuTo < yMenuFrom)
			yOffset = -yOffset;
		if (isNS4)
			divMenuD.top += yOffset;
		else if (isDOM)
			divMenuD.style.top = parseInt (divMenuD.style.top, 10) + yOffset;
			timeoutNextCheck = 10;
	}

	if(document.body.clientWidth <= 900){
		divMenuD.style.left = "903px";
	} else {
		divMenuD.style.left = 900+((document.body.clientWidth - 900)/2)+3 + "px";
	}

	setTimeout ("moveRightEdge()", timeoutNextCheck);

}
function viewImg (src) {
	var win = window.open("/board/imgView.do?src=" + src,"imgView","resizable,scrollbars=yes,width=100,height=100");
	win.focus();
}
function viewGalImg (src) {
	var win = window.open("/gallery/galImgView.do?src=" + src,"galImgView","fullscreen,scrollbars=yes");
	win.focus();
}
function resizeImage(num) {
	if(document.all) {
		var width = eval('document.all.ursImg'+num+'.width');
		if( width > 690 ) {
			eval('document.all.ursImg'+num+'.width = 690');
		}
	} else {
		var width = eval("document.getElementById('ursImg"+num+"').width");
		if( width > 690 ) {
			eval("document.getElementById('ursImg"+num+"').width = 690");
		}
	}
}
function checkSearchForm (o) {
	if (o.searchWord.value == "") {
		alert ("°Ë»ö¾î¸¦ ³Ö¾îÁÖ¼¼¿ä.");
		return false;
	} else if (o.searchWord.value.length <2) {
		alert ("°Ë»ö¾î¸¦ 2ÀÚÀÌ»ó ³Ö¾îÁÖ¼¼¿ä.");
		return false;
	}
	return true;
}
function showFlash(strUrl, nWidth, nHeight, strFlashID)
{
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'" + "id='" + strFlashID + "' width='" + nWidth +"' height='" + nHeight + "' align='middle'>");
	document.write("    <param name='allowScriptAccess' value='always' />");
	document.write("	<param name='movie' value='"+ strUrl +"' />");
	document.write("	<param name='quality' value='high' />");
	document.write("	<param name='wmode' value='transparent' />");
	document.write("	<embed src='"+ strUrl + "' quality='high' width='" + nWidth + "' height='" + nHeight + "' name='main_goods' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent' />");
	document.write("</object>");
}
function viewPrivacyInfo (memberId) {
	var win = window.open ('/privacyInfo.htm', 'privacy','scrollbars,width=635,height=600');
	win.focus ();
}
function viewOrderDraft (orderId) {
	var win = window.open ('/shop/order/getOrderDraft.do?orderId=' + orderId, 'draftWin','scrollbars,width=870,height=600');
	win.focus ();
}
function smsConsole () {
	var win = window.open ('/desk/smsConsole.do', 'smsConsole','width=395,height=300');
	win.focus ();
}
function orderGuide () {
	var win = window.open ('/desk/orderGuide.do', 'orderGuide','scrollbars,width=690,height=600');
	win.focus ();
}
function faxFileDownload (name) {
	if (name == "hwp") {
		fileIframe.location.href = "/garden/fileDownload?filename=/images/fax_hangul.hwp";		
	} else if (name == "word") {
	 	fileIframe.location.href = "/garden/fileDownload?filename=/images/fax_word.doc";
	}
}
function fileDownload (filename) {
		downIf.location.href = "/garden/fileDownload?filename=" + filename;		
}
function popExamGuide (area) {
	var win = window.open ('/desk/examGuide.do?mode=pop&kindId=1&area=' + area, 'examWin','scrollbars,width=750,height=600');
	win.focus ();
}
function validateNumber1 (o) {
	if (isNaN (o.value)) {
		alert ("¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.");
		o.value = "0";
		return false;
	}
	return true;
}
function validateNumber2 (o, initValue) {
	if (isNaN (o.value)) {
		alert ("¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.");
		o.value = initValue;
		return false;
	}
	return true;
}
function validateNumberKey (e) {
	if (!e.preventDefault) {
		if((event.keyCode<48) || (event.keyCode>57)) {
	    	event.returnValue=false;
	  	}
	} else {
         if (e.which > 31 && (e.which < 48 || e.which > 57)) {
	    	e.preventDefault();
	  	}	
	}
	 
}
function updateCartContent (cartItemId) {
	var win = window.open("/shop/order/getCartItemContent.do?cartItemId=" + cartItemId,"cartContent","scrollbars=yes,width=660,height=500");
	win.focus();
}
function updateOrderContent (orderItemId) {
	var win = window.open("/shop/order/getOrderItemContent.do?orderItemId=" + orderItemId,"cartContent","scrollbars=yes,width=660,height=500");
	win.focus();
}