$(function() {
	cui = 0;
	
	//メインバナー設定
	var mainImage = $('div#mainImage > a > img'	);
	var num = $(mainImage).size();
	
	$(mainImage).each(function(index) {
		if(index != 0) {
			$(this).hide();
		}
	});
	
	//メインバナー切り替え
	var subImage = $('div#mainBanner > ul > li > img');
	
	$(subImage).mouseover(function() {
		clearInterval(timer);
		var cu = $(subImage).index(this);
		cui = cu;
		
		$(mainImage).each(function(index) {
			if(index == cu) {
            	$(this).fadeIn('1000');
			} else {
				$(this).fadeOut('1000');
			}
        });
	});
	
	$(subImage).mouseout(function() {
		changeBanner();
	});
	
	changeBanner();
	
	//サイドメニュー
	var li = $('div.design > ul > li > ul');
	$(li).hide();
	
	var swl = $('div.design > ul > li > div');
	$(swl).click(function() {
		$('div.design > ul > li > ul').animate({
			height: 'toggle',
			opacity: 'toggle'
		}, 500), function() {
			$('div.design > ul > li > ul').fadeOut('slow')
		};
	});
	
	//お客様の声
	var voice = $('div.voice > div');
	var maxHeight = 0;
	$(voice).each(function() {
		if($(this).height() > maxHeight) {
			maxHeight = $(this).height();
		}
	});
	$(voice).height(maxHeight);
	
	//カテゴリーページ
	var catStd =$('div.category > div.standard > ul > li');
	var stdMaxHeight = 0;
	$(catStd).each(function() {
		if($(this).height() > stdMaxHeight) {
			stdMaxHeight = $(this).height();
		}
	});
	$(catStd).height(stdMaxHeight);
	
	var catRed =$('div.category > div.red > ul > li');
	var redMaxHeight = 0;
	$(catRed).each(function() {
		if($(this).height() > redMaxHeight) {
			redMaxHeight = $(this).height();
		}
	});
	$(catRed).height(redMaxHeight);
	
	var catPink =$('div.category > div.pink > ul > li');
	var pinkMaxHeight = 0;
	$(catPink).each(function() {
		if($(this).height() > pinkMaxHeight) {
			pinkMaxHeight = $(this).height();
		}
	});
	$(catPink).height(pinkMaxHeight);
	
	var catYellow =$('div.category > div.yellow > ul > li');
	var yellowMaxHeight = 0;
	$(catYellow).each(function() {
		if($(this).height() > yellowMaxHeight) {
			yellowMaxHeight = $(this).height();
		}
	});
	$(catYellow).height(yellowMaxHeight);
	
	var catViolet =$('div.category > div.violet > ul > li');
	var violetMaxHeight = 0;
	$(catViolet).each(function() {
		if($(this).height() > violetMaxHeight) {
			violetMaxHeight = $(this).height();
		}
	});
	$(catViolet).height(violetMaxHeight);
	
	var catArrange =$('div.category > div.arrange > ul > li');
	var arrangeMaxHeight = 0;
	$(catArrange).each(function() {
		if($(this).height() > arrangeMaxHeight) {
			arrangeMaxHeight = $(this).height();
		}
	});
	$(catArrange).height(arrangeMaxHeight);
});

function changeBanner() {
	timer =setInterval(function() {
		var num = $('div#mainImage > a > img').size() - 1;
		var next = cui + 1;
		if(next > num) {
			next = 0;
		}
		$('div#mainImage > a > img').each(function(index) {
			if(index == next) {
            	$(this).fadeIn('1000');
			} else {
				$(this).fadeOut('1000');
			}
		});
		cui = next;
	}, 5000);
}
