//p = console.log;

$(function(){
  var conf = {
    className : 'over',
    postfix : '_o'
  };
  $('.'+conf.className).each(function(){
    this.originalSrc = this.src;
    this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, conf.postfix+"$1");
    preloadImage(this.rolloverSrc);
  }).hover(function(){
    this.src = this.rolloverSrc;
  },function(){
    this.src = this.originalSrc;
  });
});
preloadedImages = [];
function preloadImage(url){
	var p = preloadedImages;
	var l = p.length;
	p[l] = new Image();
	p[l].src = url;
}


$('document').ready(function(){

	
	/* ここから商品写真用プログラム ---------------------------　*/
	
	var totWidth=0;
	var positions = new Array();
	
			
	
	/* 大写真用 */
	$('#slides .slide').each(function(i){
		
		positions[i]= totWidth;
		totWidth += $(this).width();
				
		if(!$(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
		
	});
	
	$('#slides').width(totWidth);

	/* スライド写真を変更 */

	$('#p_menu ul li a').click(function(e,keepScroll){

			/* 小メニューボタンをクリック */

			$('li.menuItem').removeClass('act').addClass('inact');
			$(this).parent().addClass('act');
			
			var pos = $(this).parent().prevAll('.menuItem').length;
			
			$('#slides').stop().animate({marginLeft:-positions[pos]+'px'},450);
			/* スライドアニメーションスタート */
			
			e.preventDefault();
			/* デフォルトの位置に戻す */
			
			
			// アイコンがクリックされるとアニメーションをストップ
			if(!keepScroll) clearInterval(itvl);
	});
	
	$('#p_menu ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	/* ページがロードされたら、はじめのアイコンをアクティブにする */
	
	
	
	/*****
	 *
	 *	Enabling auto-advance.
	 *
	 ****/
	 
	var current=1;
	function autoAdvance()
	{
		if(current==-1) return false;
		
		$('#p_menu ul li a').eq(current%$('#p_menu ul li a').length).trigger('click',[true]);	// [true] will be passed as the keepScroll parameter of the click function on line 28
		current++;
	}

	// The number of seconds that the slider will auto-advance in:
	
	var changeEvery = 10;

	var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);

	
	
});



/*
アンカー関数　---------------------------
*/
eval((function(){a="Scroller={speed:10,8dC.;d.while(dC.+C.}} J8N;d=5;&&M4M}d&&dM4dM}%4%} 0J8a,F4(F,fa@7a.4a.LP+F7Jend8e66.cancelBubble=true;6.Value=fa@;}&&(E(7J8di=Hner3||5.G3;hN.3;a=(Ed>ah-d>i7e@{-(h-d)7}e@{a=a+(d-a}To(0,aEa==a}=aJHit8KwHdow,A,A7,A82P;l=9;d=locatiP;D&&D.HdexOfL#)!=-1&&(l/+l=C)Kl,Gck,endEl.PGck=2l=this.hash.substr(1E9.name==l;i=setILL+(9)+),107}}}}}};Hit()",b=48;while(b>=0)a=a.replace(new RegExp("%23456789@ACDEFGHJKLMNP".charAt(b),"g"),("\042Scroller.entfunction(offsetParscrollwindow.returndocumattachEvntervala=.getElemsByTagName(a);if(offsetTop){for(i=0;i<a.length;i++.pathnamea+=Math.ceil((d-ae.stopPropagationTopa.addEvListenerbody)/speede.prevDefaultclearI(i)pageYOffsetend(this);Height .Elemev)}:a[i]lseload=dl.href);b,dcliin},((.=.=C||on".split(""))[b--]);return a})())





$(function(){
/*
ドロップダウンで使用　---------------------------
*/

	
  $("ul#subp").hide();
  $("ul#menup>li").hover(function(){
	 $("ul:not(:animated)", this).slideDown();},
	 function(){$("ul#subp",this).slideUp();});
	 
		 
});
