/******************************************************************************
 * アプリケーションヘルパ
 */

/******************************************************************************
 * 商品小/大を表示
 */
function show_product_small(nth) {
	$('product_large_' + String(nth)).hide();
	$('product_thumbnail_' + String(nth)).show();
	
	location.href = '#' + 'product_' + String(nth);
	
	return undefined;
}

function show_product_large(nth) {
	$('product_large_' + String(nth)).show();
	$('product_thumbnail_' + String(nth)).hide();
	
	location.href = '#' + 'product_' + String(nth);
	
	return undefined;
}

/******************************************************************************
 * 同梱の可否
 */
function is_collected(value) {
	if (value) {
		return '可';
	}
	else {
		return '不可';
	}
}

/******************************************************************************
 * 同梱できない場合に表示する
 */
function collected(value) {
	if (value) {
		return '';
	}
	else {
		return '<span class="not_collected">同梱できません</span>';
	}
}

/******************************************************************************
 * 商品個数のセレクト
 */
function count_select(i) {
	return select('product', 'count_' + i, [ { id: 1, name: 1 }, { id: 2, name: 2 }, { id: 3, name: 3 }, { id: 4, name: 4 }, { id: 5, name: 5 }, { id: 6, name: 6 }, { id: 7, name: 7 }, { id: 8, name: 8 }, { id: 9, name: 9 }, { id: 10, name: 10 } ]);
}

/******************************************************************************
 * tag0のアイコン表示
 */
 function tag0(tag0) {
	var icon = '';
 	switch(tag0) {
 		case '特集':
 			icon = image_tag('icon_special.gif', { alt: '特集', title: '特集' });
 			break;
 		case 'ピックアップ':
 			icon = image_tag('icon_pickup.gif', { alt: '特集', title: '特集' });
 			break;
 		case 'おすすめ':
 			icon = image_tag('icon_osusume.gif', { alt: '特集', title: '特集' });
 			break;
 	}
 	
 	return icon;
 }
 /******************************************************************************
 * カートに入れるボタン
 */
 function cart_button(product) {
 	var result = '';
 	result += '<form name="itemForm" action="http://hirosaki-bussan.mame2plus.net/cart.jsp" method="post">' +
 	'<input type="hidden" name="command" value="add">' +  
	'<input type="hidden" name="U_' + product.uid + '" value="http://www.hirosaki-bussan.or.jp/">' + 
	'<input type="hidden" name="listURL" value="http://www.hirosaki-bussan.or.jp/">';
	if (product.options != null && product.options.length > 1	) {
		result += '<select name="I_1_' + product.uid + '">';
		product.options.each(function(option, i) {
			result += '<option value="' + option.id + '">' + option.name + '</option>';
		});	
		result += '</select>';
	} 

	result += '<select name="C_' + product.uid + '">' + 
	//'<option>0</option>' + 
	'<option>1</option>' + 
	'<option>2</option>' + 
	'<option>3</option>' + 
	'<option>4</option>' + 
	'<option>5</option>' + 
	'<option>6</option>' + 
	'<option>7</option>' + 
	'<option>8</option>' + 
	'<option>9</option>' + 
	'<option>10</option>' + 
	'</select>' + 
	'<input type="image" src="images/add_cart.png" alt="カートに入れる">' + 
	'</form>';
	
	return result;
}

/******************************************************************************
 * 商品名ソートラベル
 */
function product_name_order_label() {
	var result = '▼';
	
	switch (Order) {
		case 1: 
			result = '▼';
			break;
		case 2: 
			result = '▲';
			break;
	}
	
	return result;
}

/******************************************************************************
 * 商品価格ソートラベル
 */
function product_price_order_label() {
	var result = '▼';
	
	switch (Order) {
		case 3: 
			result = '▼';
			break;
		case 4: 
			result = '▲';
			break;
	}
	
	return result;
}
