function isEnableService(serviceId) {
	if (serviceId==null || serviceId=='' || serviceId=='35') {
		return false;
	} else {
		return true;
	}
}

function changeService(serviceId, btnId) {
	var btnObj = $('#'+btnId);
	if (isEnableService(serviceId)) {
		btnObj.css('visibility', 'visible');
	} else {
		btnObj.css('visibility', 'hidden');
	}
	
	dispHomeBtn();
}

function goService(selectId, goodsId) {
	var selectObj = $('#'+selectId)[0];
	var serviceId = selectObj.value;

	if (!isEnableService(serviceId)) {
		return;
	}
	
	var url = '/ajax/go_service'+'?goods_id='+goodsId+'&service_id='+serviceId;
	$.get(url, function(data){
		// to json data		
		var json = eval("("+data+")");
		
		// count_[goods_id]
		$('#count_'+goodsId)[0].value = json.count;
		// price_tax_[goods_id]
		$('#price_tax_'+goodsId).html(json.price_tax);
		// total_count
		$('#total_count').html(json.total_count+'');
		// total_price_tax
		$('#total_price_tax').html(json.total_price_tax);
		
		// home
		dispHomeBtn();
		
		window.open(json.url, "_blank");
	});
}

function dispHomeBtn() {
	var regex = new RegExp('select_service_.*');
	var isBreak = false;
	$("select").each(function(){
		if (this.id.match(regex)) {
			if (!isEnableService(this.value)) {
				// disp order btn
				$('#go_order_btn').css('display', 'block');
				$('#go_home_btn').css('display', 'none');
				isBreak = true;
				return;
			}
		}
	});
	
	if (isBreak) {
		return;
	}
	
	// disp home btn
	$('#go_order_btn').css('display', 'none');
	$('#go_home_btn').css('display', 'block');
}