// ------------------------------------------------------------------------------
//  common js
// ------------------------------------------------------------------------------
/* 

   01........メインエリアフェードイン
   02........スムーズスクロール
   03........グローバルナビゲーション
   04........トップページ：メインビジュアル
   05........STUDIO FIVE：メインビジュアル
   06........U-style：メインビジュアル
   07........商品ブロックロールオーバー処理
   08........コンセプト
   
*/

$(function(){

// ------------------------------------------------------------------------------
// ***01 メインエリアフェードイン***
// ------------------------------------------------------------------------------

	$("ul#section_gnavi li ul").hide();//グローバルナビゲーション用(for IE)
	
	var area_main_inner = $("#area_main #area_main_inner");
	area_main_inner.css("opacity" , "0");

	//URLを取得
	var URL="";
	URL = document.location;
	//リンク先の「#」を調査
	anchor_link =  String(document.location).split("#");

	if(anchor_link[1]){
		 if (($.browser.msie && $.browser.version < 8)){
			area_main_inner.css({ visibility: "visible" });
			location.href = URL;
			area_main_inner.css({ opacity: 0 }).animate({ opacity: 1 }, 3600 , "easeOutExpo");
		}else{
			area_main_inner.css({ visibility: "visible" });
			area_main_inner.css({ opacity: 0 }).animate({ opacity: 1 }, 3600 , "easeOutExpo");
		}
	}else{
		area_main_inner.css({ visibility: "visible" });
		area_main_inner.css({ opacity: 0 }).animate({ opacity: 1 }, 3600 , "easeOutExpo");
	}

// ------------------------------------------------------------------------------
// ***02 スムーズスクロール***
// ------------------------------------------------------------------------------

	$("a[href*='#'].easingScroll").easingScroll({
		easing: "easeInOutCubic",
		duration: 1000
	});

// ------------------------------------------------------------------------------
// ***03 グローバルナビゲーション***
// ------------------------------------------------------------------------------

	//$("ul#section_gnavi li ul").hide(); ページ読み込み時に最初に実行↑
	
	$("ul#section_gnavi li").hover(function(){
		//IEの場合、ナビのopacityを調整する(for smoothRollOver.js)
		if ($.browser.msie){
			$("> ul" , this).stop(true, true).animate({
				height : "toggle",
				opacity : "0.8"
			}, 500 ); 
		}else{
			$("> ul" , this).stop(true, true).animate({
			height : "toggle",
			opacity : "1"
			}, 500 );
		}
	},
	function(){
		$("> ul" , this).slideUp(500);
	});

// ------------------------------------------------------------------------------
// ***04 トップページ：メインビジュアル***
// ------------------------------------------------------------------------------
 
	//メインビジュアル
	var top_mv_current = 0;//デフォルトで表示する画像
	var top_mv_num = 2;//画像の総枚数(-1)
	
	$("body#top #mainvisual ul.visual li:gt("+top_mv_current+") img").hide();
	
	//メインビジュアル制御
	var top_mv_change =  function(){
		//$("body#top #mainvisual ul.visual li:eq("+top_mv_current+")").fadeOut(1800);
		top_mv_current ++;
		$("body#top #mainvisual ul.visual li:eq("+top_mv_current+") img").fadeIn(1800);
	}

	//時間制御
	//--------------------------------------------------------------------------- 
	var top_currentIndexPlus = function(){
		setTimeout(top_mv_change,3000);
		clearTimeout(top_mv_change);
		setTimeout(top_mv_change,6500);
		clearTimeout(top_mv_change);
	}
	
	top_currentIndexPlus();
	


// ------------------------------------------------------------------------------
// ***05 products：メインビジュアル***
// ------------------------------------------------------------------------------
	   
	//メインビジュアル
	var sf_mv_current = 0;//デフォルトで表示する画像
	var sf_mv_num = 1;//画像の総枚数(-1)
	
	$("body#studiofive #mainvisual li:gt("+sf_mv_current+") img").hide();
	
	//時間制御
	//--------------------------------------------------------------------------- 
	var sf_currentIndexPlus = function(){
		if( sf_mv_current < sf_mv_num ){
			//$("body#studiofive #mainvisual li:eq("+sf_mv_current+")").fadeOut(1800);
			sf_mv_current ++;
			$("body#studiofive #mainvisual li:eq("+sf_mv_current+") img").fadeIn(1000);
		} else{
			clearInterval(sf_currentIndexPlus);
		}
	}
	 
	 var sf_mv_timer
     sf_mv_timer = setInterval(sf_currentIndexPlus,1500);	
	 
// ------------------------------------------------------------------------------
// ***05_01 SEASON：メインセクション***
// ------------------------------------------------------------------------------
	   
	//$('head').append('<style type="text/css">#square_blue1,#ib6230_box,#ib6210_box,#square_blue2,#ib6240_box,#ib6250_box,#square_blue3,#ib6260_box,#square_blue4,#ib6220_box,#square_blue5{display:none;}</style>');
	$('body#season #mainsection #square_blue1 img').hide();
	$('body#season #mainsection #ib6230_box img').hide();
	$('body#season #mainsection #ib6210_box img').hide();
	$('body#season #mainsection #square_blue2 img').hide();
	$('body#season #mainsection #ib6240_box img').hide();
	$('body#season #mainsection #ib6250_box img').hide();
	$('body#season #mainsection #square_blue3 img').hide();
	$('body#season #mainsection #ib6260_box img').hide();
	$('body#season #mainsection #square_blue4 img').hide();
	$('body#season #mainsection #ib6220_box img').hide();
	$('body#season #mainsection #square_blue5 img').hide();
	
	
	$(function(){
		var delaytime = 200;
			$('body#season #mainsection #square_blue1 img').fadeIn(800);
				 
	var _triger_count = 0; 
	var _triger_maxcount = 10; //何回処理を呼び出すか->5500÷500 = 11。
	var s_mainsection_trigger1 = function(){
		if(_triger_count < _triger_maxcount){
			if(_triger_count == 0){ //500+delaytime
			
			}else if(_triger_count ==1){ //1000+delaytime
				$('body#season #mainsection #ib6230_box img').fadeIn(800);
				
			}else if(_triger_count ==2){ //1500+delaytime
				$('body#season #mainsection #square_blue2 img').fadeIn(800);
				
			}else if(_triger_count ==3){ //2000+delaytime
				$('body#season #mainsection #ib6210_box img').fadeIn(800);
				
			}else if(_triger_count ==4){ //2500+delaytime
				$('body#season #mainsection #ib6240_box img').fadeIn(800);
				
			}else if(_triger_count ==5){ //3000+delaytime
				$('body#season #mainsection #square_blue3 img').fadeIn(800);
				
			}else if(_triger_count ==6){ //3500+delaytime
				$('body#season #mainsection #ib6250_box img').fadeIn(800);
				
			}else if(_triger_count ==7){ //4000+delaytime
				$('body#season #mainsection #ib6260_box img').fadeIn(800);
				
			}else if(_triger_count ==8){ //4500+delaytime
				$('body#season #mainsection #square_blue4 img').fadeIn(800);
				$('body#season #mainsection #square_blue5 img').fadeIn(800);
				
			}else if(_triger_count ==9){ //5000+delaytime
			    $('body#season #mainsection #ib6220_box img').fadeIn(800);
			}
			_triger_count ++;
		}else {
				clearInterval(s_mainsection_timer1);
		}
	};

	var s_mainsection_timer1 = setInterval(s_mainsection_trigger1,500+delaytime);

	});	

// ------------------------------------------------------------------------------
// ***06 U-style：メインビジュアル***
// ------------------------------------------------------------------------------
	   
	//メインビジュアル
	var us_mv_current = 0;//デフォルトで表示する画像
	var us_mv_num = 1;//画像の総枚数(-1)
	
	$("body#u-style #mainvisual li:gt("+us_mv_current+")").hide();
	
	//時間制御
	//--------------------------------------------------------------------------- 
	var us_currentIndexPlus = function(){
		if( us_mv_current < us_mv_num ){
			$("body#u-style #mainvisual li:eq("+us_mv_current+")").fadeOut(1800);
			us_mv_current ++;
			$("body#u-style #mainvisual li:eq("+us_mv_current+")").fadeIn(1800);
		} else{
			clearInterval(us_currentIndexPlus);
		}
	}
	 
	 var us_mv_timer
     us_mv_timer = setInterval(us_currentIndexPlus,3000);	


// ------------------------------------------------------------------------------
// ***07 商品ブロックロールオーバー処理***
// ------------------------------------------------------------------------------
//ロールオーバー画像のon,off機能実装にsmoothRollOver.jsを使用

	//商品画像ロールオーバー
	$(".section_itemlink .item").hover(function(){
			var img_item = $(this).parent().find(".item img");
			var img_btn = $(this).parent().find(".btn img");
			var img_btn_on = $(this).parent().find(".btn img.on");
			img_item.not('animated').stop(true, false).animate({opacity : "0.6"}, 300 );
			img_btn_on.stop(true, false).animate({opacity:"1"}, 300 );
		},function(){
			var img_item = $(this).parent().find(".item img");
			var img_btn = $(this).parent().find(".btn img");
			var img_btn_on = $(this).parent().find(".btn img.on");
			img_item.not('animated').stop(true, false).animate({opacity : "1"}, 300 );
			img_btn_on.stop(true, false).animate({opacity:"0"}, 300 );
		}
	);
	//ボタンロールオーバー
	$(".section_itemlink .btn").hover(function(){
			var img_item = $(this).parent().find(".item img");
			img_item.not('animated').stop(true, false).animate({opacity : "0.6"}, 300 );
		},function(){
			var img_item = $(this).parent().find(".item img");
			img_item.not('animated').stop(true, false).animate({opacity : "1"}, 300 );
		}
	);	

// ------------------------------------------------------------------------------
// ***08 コンセプト ***
// ------------------------------------------------------------------------------
		   
	//fancybox：サムネイルロールオーバー
	$("a.fancybox").hover(function(){
			$(this).stop(true, false).animate({opacity : "0.6"}, 300 );
		},function(){
			$(this).stop(true, false).animate({opacity : "1"}, 300 );
		}
	);		   
	
	//カルーセルメニュー制御
	var history_list = $("#box_history ul");
	var history_list_li = $("#box_history ul li");
	var history_list_li_num = history_list_li.length; // <li>の個数を取得
	var history_width = (136*history_list_li_num)-10; // #box_historyの横幅を取得
	var history_scroll_width = -(history_width-670); // スクロール可能領域の取得
	var history_scrollpos = $(history_list).css("left");
	var history_scroll_act = 0;

	// << スクロール
	var btn_prv_act = function(){
		history_scroll_act +=5;
		if (history_scroll_act >0 ){
			history_scroll_act =0;
		}
		history_list.css("left",history_scroll_act);
	}
	
	// スクロール >>
	var btn_nxt_act = function(){
		history_scroll_act -=5;
		if (history_scroll_act < history_scroll_width ){
			history_scroll_act = history_scroll_width;
		}
		if((parseInt(history_list.css("left")) <= 0) && (parseInt(history_list.css("left")) > history_scroll_width)){		
			history_list.css("left",history_scroll_act);
		}
	}

	var btn_prv_interval;
	var btn_nxt_interval;

    //戻るボタン
    $("#btn_prv").hover(
		function () {
			btn_prv_interval = setInterval(btn_prv_act,10);
		},
		function () {
			clearInterval(btn_prv_interval);
		}
	);
	
    //進むボタン
    $("#btn_nxt").hover(
		function () {
			btn_nxt_interval = setInterval(btn_nxt_act,10);
		},
		function () {
			clearInterval(btn_nxt_interval);
		}
	);

// ------------------------------------------------------------------------------

})
