var CartFormArray=0;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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 WindowOpen(title,url,p,w,h){
	window.open(url,title,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=0,left="+p+",width="+w+",height="+h);
}

function MoveCategori(pid){
	var f=document.MoveCate;
	f.p_kind.value=pid;
	f.submit();
}
function MoveDirect(pid){
	var f=document.MoveDirect;
	f.p_kind.value=pid;
	f.submit();
}
function MoveOutlet(pid,bCode){
	var f=document.MoveOutlet;
	
	f.p_kind.value=pid;
	f.brendCode.value=bCode;
	f.submit();
}
function MoveBrend(bCode){
	var f=document.MoveBrend;
	f.action="/shopping/shop_Club/brend_sub.asp";
	f.bCode.value=bCode;
	f.submit();
}
function MoveOutletBrend(bCode){
	var f=document.MoveBrend;
	f.action="/shopping/shop_Club/outletBrend_sub.asp";
	f.bCode.value=bCode;
	f.submit();
}
function ExtMoveBrend(n){
	if (n!="")
	{
		MoveBrend(n);
	}	
}
function showProd(pid,pKind){
	var f=document.showProd;
	f.pid.value=pid;
	f.pkind.value=pKind;
	f.submit();
}
function showOutletProd(pid,pKind){
	var f=document.showOutletProd;
	f.pid.value=pid;
	f.pkind.value=pKind;
	f.submit();
}
function showGongguProd(pid,pKind){
	var f=document.showGongguProd;
	f.pid.value=pid;
	f.pkind.value=pKind;
	f.submit();
}
function showDirectProd(pid,pKind){
	var f=document.showDirectProd;
	f.pid.value=pid;
	f.pkind.value=pKind;
	f.submit();
}
function sortChg(){
	var f=document.orderList;
	var url="/shopping/inc/CategoriChgSub.asp";
	if (f.chgSort.value!="")
	{
		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=1";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&strOrder=" + f.chgSort.value;
		displaySort.location.href=url;
	}	
}
function sortChg_Outlet(){
	var f=document.orderList;
	var url="/shopping/inc/OutletChgSub.asp";
	if (f.chgSort.value!="")
	{
		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=1";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&strOrder=" + f.chgSort.value;
		displaySort.location.href=url;
	}	
}
function sortChg_Direct(){
	var f=document.orderList;
	var url="/shopping/inc/DirectChgSub.asp";
	if (f.chgSort.value!="")
	{
		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=1";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&strOrder=" + f.chgSort.value;
		displaySort.location.href=url;
	}	
}
function NewSortChg(){
	var f=document.orderList;
	var url="/shopping/inc/CategoriChgSub.asp";

	var ordMenu;
	
		ordMenu= "		<TABLE width='741' background='/shopping/images/sort_bar.gif'>";
		ordMenu=ordMenu + "		<TR>";
		ordMenu=ordMenu + "			<td width='133' height='38'>&nbsp;</td>";
		ordMenu=ordMenu + "			<td width=490><strong><span id='listCount'></span>&nbsp;°³</strong></td>";
		ordMenu=ordMenu + "			<TD>";
		ordMenu=ordMenu + "				<select name='chgSort' onChange='sortChg();' style='background:#3366CC;color:#FFFFFF;width:100;height:13;FONT-SIZE: 8pt;'>";
		ordMenu=ordMenu + "				<option value=''>--»óÇ°Á¤·Ä--</option>";
		ordMenu=ordMenu + "				<option value='p_brendCode'>Á¦Á¶»çº°</option>";
		ordMenu=ordMenu + "				<option value='p_id desc'>½Å»óÇ°º°</option>";
		ordMenu=ordMenu + "				<option value='p_priceReal'>°¡°Ýº°</option>";
		ordMenu=ordMenu + "				</select>";
		ordMenu=ordMenu + "			</TD>			";		
		ordMenu=ordMenu + "		</TR>";
		ordMenu=ordMenu + "		</TABLE>";
		

		ord.innerHTML=ordMenu;

		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=1";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&strOrder=" + f.chgSort.value;
		displaySort.location.href=url;
		
}
function NewSortChg_outlet(){
	var f=document.orderList;
	var url="/shopping/inc/outletChgSub.asp";

	var ordMenu;
	
		ordMenu= "		<TABLE width='741' background='/shopping/images/sort_bar.gif'>";
		ordMenu=ordMenu + "		<TR>";
		ordMenu=ordMenu + "			<td width='133' height='38'>&nbsp;</td>";
		ordMenu=ordMenu + "			<td width=490><strong><span id='listCount'></span>&nbsp;°³</strong></td>";
		ordMenu=ordMenu + "			<TD>";
		ordMenu=ordMenu + "				<select name='chgSort' onChange='sortChg_Outlet();' style='background:#3366CC;color:#FFFFFF;width:100;height:13;FONT-SIZE: 8pt;'>";
		ordMenu=ordMenu + "				<option value=''>--»óÇ°Á¤·Ä--</option>";
		ordMenu=ordMenu + "				<option value='p_brendCode'>Á¦Á¶»çº°</option>";
		ordMenu=ordMenu + "				<option value='p_id desc'>½Å»óÇ°º°</option>";
		ordMenu=ordMenu + "				<option value='p_priceReal'>°¡°Ýº°</option>";
		ordMenu=ordMenu + "				</select>";
		ordMenu=ordMenu + "			</TD>			";		
		ordMenu=ordMenu + "		</TR>";
		ordMenu=ordMenu + "		</TABLE>";
		

		ord.innerHTML=ordMenu;

		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=1";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&strOrder=" + f.chgSort.value;
		displaySort.location.href=url;
		
}
function brendsortChg(n){
	var f=document.orderList;
	var url="/shopping/inc/BrendChgSub.asp";
	if (f.chgSort.value!="")
	{
		if (n<7)
		{
			url=url+"?pKind=" + f.pKind.value;
			url=url+"&n="+n;
		}
		else 
		{
			url=url+"?n="+n;
		}
		url=url+"&brendCode=" + f.bCode.value;
		url=url+"&strOrder=" + f.chgSort.value;
		url=url+"&selProd=" + f.selProd.value;
		displaySort.location.href=url;
	}	
}
function gongGUsortChg(){
	var f=document.orderList;
	var url="/shopping/inc/GongguChgSub.asp";
	if (f.chgSort.value!="")
	{
		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=1";
		url=url+"&strOrder=" + f.chgSort.value;
		displaySort.location.href=url;
	}	
}
function nowBrend(str,n){
	var f=document.orderList;
	var url="/shopping/inc/BrendChgSub.asp";
	var ordMenu;
		
		f.bCode.value=str;

		ordMenu= "		<TABLE width='741' background='/shopping/images/sort_bar04.gif'>";
		ordMenu=ordMenu + "		<TR>";
		ordMenu=ordMenu + "			<td width='133' height='38'>&nbsp;</td>";
		ordMenu=ordMenu + "			<td width=490><strong><span id='listCount'>" + n + "</span>&nbsp;°³</strong></td>";
		ordMenu=ordMenu + "			<TD>";
		ordMenu=ordMenu + "				<select name='chgSort' onChange='brendsortChg(2);' style='background:#3366CC;color:#FFFFFF;width:100;height:13;FONT-SIZE: 8pt;'>";
		ordMenu=ordMenu + "				<option value=''>--»óÇ°Á¤·Ä--</option>";
		ordMenu=ordMenu + "				<option value='p_id desc'>½Å»óÇ°º°</option>";
		ordMenu=ordMenu + "				<option value='p_priceReal'>°¡°Ýº°</option>";
		ordMenu=ordMenu + "				</select>";
		ordMenu=ordMenu + "			</TD>			";		
		ordMenu=ordMenu + "		</TR>";
		ordMenu=ordMenu + "		</TABLE>";
		

		ord.innerHTML=ordMenu;

		

		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=2";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&brendCode=" + str;
		
		displaySort.location.href=url;
		
}
function OutletBrend(str,n){
	var f=document.orderList;
	var url="/shopping/inc/OutletBrendChgSub.asp";
	var ordMenu;
		
		f.bCode.value=str;

		ordMenu= "		<TABLE width='741' background='/shopping/images/sort_bar04.gif'>";
		ordMenu=ordMenu + "		<TR>";
		ordMenu=ordMenu + "			<td width='133' height='38'>&nbsp;</td>";
		ordMenu=ordMenu + "			<td width=490><strong><span id='listCount'>" + n + "</span>&nbsp;°³</strong></td>";
		ordMenu=ordMenu + "			<TD>";
		ordMenu=ordMenu + "				<select name='chgSort' onChange='sortChg_Outlet(2);' style='background:#3366CC;color:#FFFFFF;width:100;height:13;FONT-SIZE: 8pt;'>";
		ordMenu=ordMenu + "				<option value=''>--»óÇ°Á¤·Ä--</option>";
		ordMenu=ordMenu + "				<option value='p_id desc'>½Å»óÇ°º°</option>";
		ordMenu=ordMenu + "				<option value='p_priceReal'>°¡°Ýº°</option>";
		ordMenu=ordMenu + "				</select>";
		ordMenu=ordMenu + "			</TD>			";		
		ordMenu=ordMenu + "		</TR>";
		ordMenu=ordMenu + "		</TABLE>";
		

		ord.innerHTML=ordMenu;

		

		url=url+"?pKind=" + f.pKind.value;
		url=url+"&n=2";
		url=url+"&selProd=" + f.selProd.value;
		url=url+"&brendCode=" + str;
		
		displaySort.location.href=url;
		
}
function MaxView(ccc)
{
	window.open('/shopping/shop_Club/golf_image.asp?aa='+ccc,'new','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,width=450,height=500,top=170,left=200')
}
function goPay(n1,n2){
	var f1=document.prodDetail;
	var f2=document.payForm;
	var temp;

	if (n1==1)
	{
		alert("ÁË¼ÛÇÕ´Ï´Ù. º» »óÇ°Àº Ç°ÀýµÇ¾ú½À´Ï´Ù.");
	}
	else {
		f2.cnt.value=f1.howmuch.value;

		if (!isNaN(f2.opt.value) && (f2.opt.value>-1))
		{
			alert("¿É¼Ç»çÇ×À» È®ÀÎÇÏ¿© ÁÖ¼¼¿ä.");
			return;
		}
		else {
			temp=f2.opt.value.split(";");
			for (var i=0;i<temp.length ;i++ )
			{
				if (temp[i]=="")
				{
					alert("¿É¼Ç»çÇ×À» È®ÀÎÇÏ¿© ÁÖ¼¼¿ä.");
					return;
				}
			}
		}
		switch(n2){
			case 1: //¹Ù·Î±¸¸Å				
				f2.action="Cashing_Order_Info.asp?order_Type=1";
				f2.submit();
				break;
			case 2: //Àå¹Ù±¸´Ï
				f2.action="Cashing_Order_Info.asp?order_Type=2";
				f2.submit();
				break;
			case 3: //wishList
				f2.action="Cashing_Order_Info.asp?order_Type=3";
				f2.submit();
				break;
			case 4: //Ä£±¸ÃßÃµ
				f2.action="Cashing_Order_Info.asp?order_Type=4";
				f2.submit();
				break;
		}
	}
}
function sumUp(theForm){
	theForm.howmuch.value=parseInt(theForm.howmuch.value)+1;
}
function sumDown(theForm){
	theForm.howmuch.value=parseInt(theForm.howmuch.value)-1;
	if (theForm.howmuch.value<1)
	{
		theForm.howmuch.value=1;
	}
}
function plusComma(value){
	var n;
	var extra;
	var subN;
	
	n=parseInt(value/1000);
	extra=parseInt(value-1000*n);
	extra=extra.toString();
	if (n>0)
	{	
		if (extra>99)
		{
			extra=extra.toString();
		}
		else if (extra>9)
		{
			extra="0" + extra.toString();
		}
		else
		{
			extra="00" + extra.toString();
		}
	}
	if (n>0)
	{
		subN=plusComma(n)+","+extra;
	}
	else {
		return extra;
	}
	return subN;
}

function sumChange(theForm){
	var temp;
	if (!isNaN(theForm.cnt.value))
	{	
		if ((parseInt(theForm.cnt.value)<1))
		{
			theForm.cnt.value=1;
		}
		chgCookies(theForm);
		temp=parseInt(theForm.cnt.value) * parseInt(theForm.perPrice.value);
		theForm.price.value=plusComma(temp);
	}
}
function chgCookies( theForm )
{
	chgCart.chgForm.idx.value=theForm.idx.value;
	chgCart.chgForm.pcode.value=theForm.pcode.value;
	chgCart.chgForm.price.value=theForm.perPrice.value;
	chgCart.chgForm.cnt.value=theForm.cnt.value;
	chgCart.chgForm.opt.value=theForm.opt.value;
	chgCart.chgForm.selltype.value=theForm.selltype.value;
	chgCart.chgForm.submit();
}
function sumUp2(theForm){
	var temp;
	var n=CartFormArray;

	theForm.cnt.value=parseInt(theForm.cnt.value)+1;
	chgCookies(theForm);
	temp=parseInt(theForm.cnt.value) * parseInt(theForm.perPrice.value);
	theForm.price.value=plusComma(temp);
	
	temp=0;
	
	if (n>1)
	{
		for (var i=0;i<n ;i++ )
		{
			temp+=parseInt(document.cart_subForm[i].cnt.value * document.cart_subForm[i].perPrice.value);
		}
	}
	else {
		temp=parseInt(document.cart_subForm.cnt.value * document.cart_subForm.perPrice.value);
	}

	totPr.value=plusComma(temp);
}

function sumDown2(theForm){
	var temp;
	var n=CartFormArray;

	theForm.cnt.value=parseInt(theForm.cnt.value)-1;
	
	if (theForm.cnt.value<1)
	{
		theForm.cnt.value=1;
	}
	chgCookies(theForm);
	temp=parseInt(theForm.cnt.value) * parseInt(theForm.perPrice.value);
	theForm.price.value=plusComma(temp);
	temp=0;
	
	if (n>1)
	{
		for (var i=0;i<n ;i++ )
		{
			temp+=parseInt(document.cart_subForm[i].cnt.value * document.cart_subForm[i].perPrice.value);
		}
	}
	else {
		temp=parseInt(document.cart_subForm.cnt.value * document.cart_subForm.perPrice.value);
	}

	totPr.value=plusComma(temp);
}
function reoption(Nprice,total){
	var f=document.payForm;
	var optPrice=0;
	var chkStringCNT=0;
	var chkStringCNT2=0;
	var chkWon;
	var temp;
	var tempTxt;
	var strTxt="";
	var re = /,/g;                    // Á¤±Ô½Ä
	
	price=eval(f.price.value);

	f.opt.value="";
	
	if (total==0)
	{
		tempTxt=document.prodDetail.prodOpt.value.split(",");
		for (var j=0;j<tempTxt.length ;j++ )
		{
			strTxt=strTxt+tempTxt[j];
		}
		

		chkStringCNT=strTxt.lastIndexOf("+"); 
		chkStringCNT2=strTxt.lastIndexOf("-"); 

		if (chkStringCNT>0) {
			temp=strTxt.split("+");
			if (temp.length==2)
			{
				chkWon=temp[1].lastIndexOf("¿ø"); 
				if (chkWon>0)
				{
					
					temp[1]=temp[1].replace(re,"");
					optPrice=optPrice + parseInt(temp[1].substring(0,chkWon));
				}
			}
			
		}
		else if (chkStringCNT2>0) {
			temp=strTxt.split("-");
			if (temp.length==2)
			{
				chkWon=temp[1].lastIndexOf("¿ø"); 
				if (chkWon>0)
				{
					
					temp[1]=temp[1].replace(re,"");
					optPrice=optPrice - parseInt(temp[1].substring(0,chkWon));
				}
			}
			
		}
		//f.opt.value=strTxt+";";
	}
	else {

		for (var i=0;i<document.prodDetail.prodOpt.length ;i++ )
		{
			tempTxt=document.prodDetail.prodOpt[i].value.split(",");
			for (var j=0;j<tempTxt.length ;j++ )
			{
				strTxt=strTxt+";"+tempTxt[j];
			}
			chkStringCNT=document.prodDetail.prodOpt[i].value.lastIndexOf("+"); 
			chkStringCNT2=document.prodDetail.prodOpt[i].value.lastIndexOf("-"); 
			
			if (chkStringCNT>0) {
				temp=strTxt.split("+");
				if (temp.length==2)
				{
					chkWon=temp[1].lastIndexOf("¿ø"); 
					if (chkWon>0)
					{
						
						temp[1]=temp[1].replace(re,"");
						optPrice=optPrice+parseInt(temp[1].substring(0,chkWon));
					}
				}
			}
			else if (chkStringCNT2>0) {
				temp=strTxt.split("-");
				if (temp.length==2)
				{
					chkWon=temp[1].lastIndexOf("¿ø"); 
					if (chkWon>0)
					{
						
						temp[1]=temp[1].replace(re,"");
						optPrice=optPrice - parseInt(temp[1].substring(0,chkWon));
					}
				}
			}
		}
	}
	f.opt.value+=strTxt + ";" ;
	f.price.value=price+optPrice;
	f.opt.value=f.opt.value.substring(1,f.opt.value.length-1);

}
function blankPos(the) {
		var n=screen.width;
		var cnt;
		var tableWidth=935;
		cnt=n/216;
		
		if (n>tableWidth)
		{
			 if (n==1024)
			{
				n=32;
			}
			else if (n==1152)
			{
				n=90;
			}
			else if (n==1280)
			{
				n=140;
			}
			else {
				n=(n-tableWidth)/2 -5.5*cnt;	
			}
		}
		else { n=0; }

	the.width=n;
	
}

function delOrder(theForm){
	theForm.submit();
}

function onlyNum() {
	var flag;
	
	flag=false;

	if ( event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46) {
		flag = true;
	}
	else {
		if (!event.shiftKey) {
			if (event.keyCode > 47) {
				if ( event.keyCode < 58){
					flag = true;
				}
				else if (unescape(event.keyCode) > 95 && unescape(event.keyCode)<107 ){
					
						flag = true;
						flag2=true;
				}
				else
					flag = false;
			}
			else if ( event.keyCode == 8 || event.keyCode == 9) {
				flag = true;
			}
			else {
				flag = false;
			}
		}
		else {
			flag = false;
		}
	}
	event.returnValue=flag;
}
function calpoint(theForm,totPrice,mine){
	
	var temp=parseInt(theForm.meth2.value);
	
	if (isNaN(temp))
	{
		temp=0;
	}
	if (totPrice>=mine)
	{
		if (temp>mine)
		{
			if (confirm("È¸¿ø´ÔÀÌ °¡Áö°í °è½Å Æ÷ÀÎÆ® º¸´Ù ´õ ¸¹Àº Æ÷ÀÎÆ®¸¦ ÀÔ·ÂÇÏ¼Ì½À´Ï´Ù.\n\n¼ÒÁöÇÏ½Å Æ÷ÀÎÆ®¸¸Å­ »ç¿ëÇÏ½Ã°Ú½À´Ï±î?"))
			{
				theForm.meth2.value=mine;
				temp=mine;
			}
			else {
				theForm.meth2.value=0;
				alert("Æ÷ÀÎÆ®¸¦ ´Ù½Ã ¼±ÅÃÇÏ¿© ÁÖ¼¼¿ä.");			
				return false;
			}
		}

	}
	else {	
		if (temp>totPrice)
		{
				if (confirm("°áÀç±Ý¾×º¸´Ù ´õ ¸¹Àº Æ÷ÀÎÆ®¸¦ ÀÔ·ÂÇÏ¼Ì½À´Ï´Ù.\n\n°áÀç±Ý¾×¸¸Å­¸¸ »ç¿ëÇÏ½Ã°Ú½À´Ï±î?"))
			{
				theForm.meth2.value=totPrice;
				temp=totPrice;
			}
			else {
				theForm.meth2.value=0;
				alert("Æ÷ÀÎÆ®¸¦ ´Ù½Ã ¼±ÅÃÇÏ¿© ÁÖ¼¼¿ä.");			
				return false;
			}
		}
	}
	theForm.meth2.value=temp;
	temp=(parseInt(totPrice) - parseInt(temp));
	theForm.totprice.value=plusComma(temp);
	if (theForm.totprice.value=="000")
	{
		theForm.totprice.value=0;
	}
	document.shopping2.totprice.value=temp;
	document.shopping2.point.value=theForm.meth2.value;
}
function ProdSearch(){
	var f=document.ProdSearchForm;
	if (f.searchtxt.value=="")
	{
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
	}
	else {
		f.submit();
	}
}