(function(){
	var topImgConf = {
		width:730
		,height:270
		,speed:500
		,interval:5000
		,easing:"swing"
		,length:0
		,cursor:0
			,inTouch:false
	}
	var clctnConf = {
		viewWidth:680
		,padding:10
		,moveWidth:300
		,speed:500
		,interval:6000
		,easing:"swing"
		,allWidth:0
	}
	$(function(){
		// -----------------------------------------------------
		// global navigation
		// -----------------------------------------------------
		$('#globalNavi div.button').hover(function(){
			$(this).find('ul').css('display',"block");
		},function(){
			$(this).find('ul').css('display',"");
		});
		// -----------------------------------------------------
		// top image slide
		// -----------------------------------------------------
		topImgConf.length = $('#topImage ul li').length;
		$('#topImage ul').width(topImgConf.length * topImgConf.width);
		if(topImgConf.length > 1){
			setInterval(function(){
				if(topImgConf.inTouch) return;
				topImgConf.cursor++;
				if(topImgConf.cursor < topImgConf.length){
					$('#topImage ul').animate({
						left:("-="+topImgConf.width)
					},topImgConf.speed, topImgConf.easing);
				}else{
					$('#topImage ul').animate({
						left:"0"
					},topImgConf.speed, topImgConf.easing);
					topImgConf.cursor = 0;
				}
			},topImgConf.interval);
			$('#topImage ul').width(topImgConf.length * topImgConf.width);
		}
		// -----------------------------------------------------
		// collection slide
		// -----------------------------------------------------
		$('#collection div.slide ul li').each(function(){
			clctnConf.allWidth += $(this).width() + clctnConf.padding * 2;
		});
		clctnConf.length = $('#collection div.slide ul li').length;
		$('#collection div.slide ul').width(clctnConf.allWidth);
		$('#collection div.moveNext').click(function(){
			var pos = $('#collection div.slide ul').position();
			if(-1 * pos.left < clctnConf.allWidth - clctnConf.viewWidth){
				$('#collection div.slide ul').animate({
					left:("-="+ Math.min(clctnConf.moveWidth, (clctnConf.allWidth - clctnConf.viewWidth) + pos.left))
				},clctnConf.speed, clctnConf.easing);
			}
		});
		$('#collection div.movePrev').click(function(){
			var pos = $('#collection div.slide ul').position();
			if(pos.left < 0){
				$('#collection div.slide ul').animate({
					left:("+="+ Math.min(clctnConf.moveWidth, -1 * pos.left))
				},clctnConf.speed, clctnConf.easing);
			}
		});
	});
})();
