$(function(){
	
	// bodyにディレクトリ名クラス付与
	var path = shift.getURL();
	$('body').addClass(path['parent']);
	
	// グローバルナビゲーション
	$('#gNavi li').hover(function(){
		var t = $(this);
		clearTimeout(this._tim2);
		this._tim1 = setTimeout(function(){ t.find('ul:first').fadeIn(); }, 150);
		},function(){
		var t = $(this);
		clearTimeout(this._tim1);
		this._tim2 = setTimeout(function(){ t.find('ul').hide(); }, 300);
	});
	
	// 透過設定
	$('body').hoverAlpha({opacity:0.5});
	
	/*$('#footerArea a').addCaption();
	$('#header').addCaption({img:true});
	$('#header').addCaption();
	$('#contentsBody #topicsArea:not()').addCaption({img:true});
	$('#contentsBody #topicsArea:not()').addCaption({img:false});
	$('#contentsBody #sideArea').addCaption();*/
	$('.buttons button').button();
	$('.buttons a').button();

	shift.smoothScroll();
	
	// product order
	$('.productOrder').each(function(){
		$(this).submit(function(){
			var min = $(this).find('.order-min_qty').val() - 0;
			var max = $(this).find('.order-max_qty').val() - 0;
			var qty = $(this).find('.order-qty').val() - 0;
			if (!qty) {
				alert('数量を入力してください。');
				return false;
			} else if (isNaN(qty) || (Math.floor(qty) != qty)) {
				alert('数量は数値で入力してください。');
				return false;
			} else if (min && qty < min) {
				alert(min + '以下の注文はできません。');
				return false;
			} else if (max && max < qty) {
				alert(max + '以上の注文はできません。');
				return false;
			}
		});
	});
	// product result
	$('.order-qty').each(function(){
		$(this).change(function(){
			if (isNaN(this.value)) {
				return false;
			}
			var id     = this.id.split('-')[1];
			var target = '#span_order_qty-' + id;
			var lot    = $('#order_lot-' + id).val() - 0;
			$(target).html(vw.util.numberFormat(this.value * lot));
		});
	});

});

