function ret_bmax(barisel,m){
	if(barisel == null) return parseInt(m);
	var tmp = barisel.options[barisel.selectedIndex].value;
	str = tmp.split(":");
	return parseInt(str[1]);
}

function numup(numtext,barisel,m){
	var max = ret_bmax(barisel,m);
	numtext.value = parseInt(numtext.value) + 1;
	if(isNaN(numtext.value)){ numtext.value = max; }
	if(numtext.value > max){ numtext.value = max; }
	return;
}

function numdown(numtext){
	numtext.value = parseInt(numtext.value) - 1;
	if(isNaN(numtext.value)){ numtext.value = 0; }
	if(numtext.value <= 0){ numtext.value = 0; }
	return;
}

function checknum(numtext,barisel,m){
	var max = ret_bmax(barisel,m);
	max = parseInt(max);
	if(max <= 0){
		alert("在庫が切れています。");
		if(numtext){
			numtext.value=0;
			numtext.focus();
		}
		return false;
	}
	numtext.value = parseInt(numtext.value);
	if(isNaN(numtext.value)){
		alert("半角数のみ入力して下さい。");
		if(numtext){
			numtext.value=0;
			numtext.focus();
		}
		return false;
	}
	if(numtext.value < 1){
		alert("この商品の最小購入数は1個です。この数より少ない数量を購入することができません。");
		if(numtext){
			numtext.value=0;
			numtext.focus();
		}
		return false;
	}
	if(numtext.value > max){
		alert("この商品の最大購入数は"+max+"個です。この数より多い数量を購入することができません。");
		if(numtext){
			numtext.value=max;
			numtext.focus();
		}
		return false;
	}
	return true
}