function chk_cost(f){
	var cost,aIdx = f.elements['goods_idx[]'];
	var oTotCost =  f.elements['PRICEPRINT'];
	var i,nLength,aEl = Array();
	
	if(aIdx.length === undefined){
		if(aIdx.checked === true){
			aEl.push(f.elements['usercost_'+aIdx.value]);
			cost = sumCost(aEl);
		}else { cost = 0; }
	}else {
		nLength = aIdx.length;
		for(i=0;i<nLength;i++){
			if(aIdx[i].checked === true){
				aEl.push(f.elements['usercost_'+aIdx[i].value]);
			}
		}
		cost = sumCost(aEl);
	}
	oTotCost.value=comma(cost);
}

function sumCost(pEl){
	var i,nLength = pEl.length;
	var cost=0;
	for(i=0;i<nLength;i++){
		cost += parseInt(pEl[i].value,10);
	}
	return cost;
}

function oneCart(pForm,pId){
	var i,nLength,aIdx = pForm.elements['goods_idx[]'];
	if(aIdx.length === undefined){
		aIdx.checked=true;
	}else {
			nLength = aIdx.length;
			for(i=0;i<nLength;i++){
				aIdx[i].checked=(aIdx[i].value === pId)?true:false;
			}
	}
	pForm.action='shop_pack.php?'+Date();
	pForm.submit();
}

function allCart(pForm){
	var i,nLength,aIdx = pForm.elements['goods_idx[]'];
	var bIsChk = false;
	if(aIdx.length === undefined){
		if(aIdx.checked==true) bIsChk=true;
	}else {
			nLength = aIdx.length;
			for(i=0;i<nLength;i++){
				if(aIdx[i].checked==true) bIsChk=true;
			}
	}
	if(bIsChk === false){
		alert('함께 구매할 상품을 체크해주세요!');
	}else{
		pForm.action='shop_pack.php?'+Date();
		pForm.submit();
	}
}
