$( document ).ready( function () {
	//オプション
	$( '#primaryNavigation' ).scrollFollow( {
		//アニメーションの速度の設定。0 にするとアニメーションなしになります。
		speed: 500,
		//ブラウザの領域とフロート要素との余白。0にするとぴったりくっつきます。
		offset: 0
	} );
	
	
//===========================================================
//　ブランドリストの挙動
//===========================================================	
if( $("#brand_list_box").length > 0){

	brandlogowidth = 147;
	brandlogomove = false;
	brandlogoAutochangeCnt = 0;
	brandlogoAutochangeTime = 5;
	brandlogoAutochangeCntFlg = true;

	wrap_brandlogo = "#brand_list_box #brand_logo_inner ul";
  	last_brandlogo = "#brand_list_box #brand_logo_inner li:last";
	first_brandlogo = "#brand_list_box #brand_logo_inner li:first";

	$("#brand_list_box #btn_prev").click(
	  function () {
		slide_logo(-1);
	  }
	);
	
	$("#brand_list_box #btn_next").click(
	  function () {
		slide_logo(1);
	  }
	);
	
	brandlist_timer = setInterval(function(){
		if(brandlogoAutochangeCntFlg){
			brandlogoAutochangeCnt++;
			if(brandlogoAutochangeCnt >= brandlogoAutochangeTime){
				slide_logo(1);
				brandlogoAutochangeCnt = 0;
			}
		}
		
	}, 1000);
	
	$(wrap_brandlogo).hover(
	  function () {
		brandlogoAutochangeCntFlg = false;
	  },
	  function () {
		brandlogoAutochangeCntFlg = true;
	  }
	);
	
	
	function logohtml(logoid){
		switch(logoid){
		  case "brandlogo_kobemeat": return('<li id="brandlogo_kobemeat"><a href="/kobebeef/" class="png_bg">神戸牛のミートパイ</a></li>'); break;
		  case "brandlogo_juchheim": return('<li id="brandlogo_juchheim"><a href="/juchheim/" class="png_bg">ユーハイム</a></li>'); break;
  		  case "brandlogo_meister": return('<li id="brandlogo_meister"><a href="/mj/" class="png_bg">マイスターユーハイム</a></li>'); break;
  		  case "brandlogo_diemeister": return('<li id="brandlogo_diemeister"><a href="/die-meister/" class="png_bg">ユーハイム・ディーマイスター</a></li>'); break;
  		  case "brandlogo_karljuchheim": return('<li id="brandlogo_karljuchheim"><a href="/karl/" class="png_bg">カールユーハイム</a></li>'); break;
  		  case "brandlogo_bobbyjuchheim": return('<li id="brandlogo_bobbyjuchheim"><a href="/bobby/" class="png_bg">ボビーユーハイム</a></li>'); break;
  		  case "brandlogo_meisterbaum": return('<li id="brandlogo_meisterbaum"><a href="/mb/" class="png_bg">マイスターバウム</a></li>'); break;
  		  case "brandlogo_rosenheim": return('<li id="brandlogo_rosenheim"><a href="/rosenheim/" class="png_bg">ローゼンハイム</a></li>'); break;
  		  case "brandlogo_peltier": return('<li id="brandlogo_peltier"><a href="/peltier/" class="png_bg">ペルティエ</a></li>'); break;
  		  
		}
		
		
	}
	

	function slide_logo(moveval) {
	if(!brandlogomove){	
		brandlogomove = true;
		brandlogoAutochangeCnt = 0;
		
		if(moveval > 0){
			
			//移動前に一番右にあるブランドを左に移動して見えないようにしておく
			sasikae = logohtml($(last_brandlogo).attr("id"));
			$(first_brandlogo).before(sasikae);
			$(last_brandlogo).remove();
			$(wrap_brandlogo).css("margin-left",-1 * brandlogowidth);
			//移動
			$(wrap_brandlogo).animate({ 
				marginLeft: "0"
			 },  {
			 	duration: 300,
				easing: "linear",
     			complete: function(){
					brandlogomove = false;
				}
			 });//animate end
			
		}else{
		
			//移動
			$(wrap_brandlogo).animate({ 
				marginLeft: -1 * brandlogowidth
			 },  {
			 	duration: 300,
				easing: "easeInOutQuad",
     			complete: function(){
					sasikae = logohtml($(first_brandlogo).attr("id"));
					$(last_brandlogo).after(sasikae);
					$(first_brandlogo).remove();
					$(wrap_brandlogo).css("margin-left",0);
					brandlogomove = false;
				}
			 });//animate end

		}
	

    	return;
	}
	}//slido_logo end


	
	
}
//↑↑↑↑↑↑ブランドリストの挙動end↑↑↑↑↑↑↑↑↑↑↑



//===========================================================
//　ブランドサークルの挙動
//===========================================================	
if( $("#brand_circle").length > 0){

	var offset = $("#brand_circle").offset();
	active_text = $("#bc_juchheim_text");
	active_text_top = 80;
	active_text_left = 25;

	//マウスオーバー時の処理
	function hover_prop(target_no){
		//ロゴを半透明に
		$(".bc_logo").eq(target_no).siblings(".bc_logo").each(function(){
			$(this).hide();
		});
		$(".bc_hover").eq(target_no).show();;//選択された大画像を表示
		$(".bc_photo").hide();//選択された小画像を非表示
		$(".bc_photo_off").eq(target_no).hide();//選択された小画像を非表示
		
		
		$(".bc_text").hide();//テキストを非表示
		$(".bc_text").eq(target_no).show();//選択されたテキストを表示
		active_text = $(".bc_text").eq(target_no);
		return true;
	}

	//マウスアウト時の処理
	function hout_prop(){

		//ロゴを元に戻す
		$(".bc_logo").show();
		$(".bc_hover").hide();//選択された大画像を非表示
		$(".bc_photo").show();;//選択された小画像を表示
		$(".bc_photo_off").show();;//選択された小画像を表示
		$(".bc_text").hide();//選択されたテキストを非表示
		return true;
	}
	
	//mousemoveイベントの動作設定
	$("html").mousemove(function(event){
		
		active_text.css({
			top : event.pageY - offset.top - 80,
			left : event.pageX - offset.left + 25
		});
	});

	
	$(".bc_photo").hover(
		function(){
			hover_prop($(".bc_photo").index(this));
		},
		function(){
		}
	);
	
	$(".bc_text").hover(
		function(){
			hover_prop($(".bc_text").index(this));
		},
		function(){
			hout_prop();
		}
	);

	
	$(".bc_hover").hover(
		function(){
		},
		function(){
			hout_prop();
			
		}
	);
	
	$("#brand_circle").mouseover(
		function(event){
			if( $(event.target).attr("id")=="brand_circle" ){
				hout_prop();
			}
		}
	);




}
	
//↑↑↑↑↑↑ブランドサークルの挙動end↑↑↑↑↑↑↑↑↑↑↑



} );//jquery

