﻿
/*====================================================================


 ■　index.js


--------------------------------------------------------------------*/

(function($) {
$(function(){


/*====================================================================

 □　Main Visual Gallery

--------------------------------------------------------------------*/

/*--------------------------------------------
	setting
--------------------------------------------*/

	var _targetIndex = 0;	// startVisual
	var _fadeSpeed = 1200;	// fadeSpeed
	var _slideSpeed = 6000;	// slideSpeed
	

/*--------------------------------------------
	define
--------------------------------------------*/

	var visualBoxParent = '#category-IndexVisual';
	var visualBox = '#visualBox';
	visualBox = {
		_li:'#visualBox li',
		_length:$('#visualBox li').length
	};
	var _timer;
	var thumbBox = '#thumbBox';
	var thumbBoxli = '#thumbBox li';
	var thumbClassCur = 'thumbCur_On';
	

/*--------------------------------------------
	create Thumbnails
--------------------------------------------*/

/*
	$('#category-IndexVisual').append('<ul id="thumbBox"></ul>');
	for(i=0; i<visualBox._length; i++){
		var appendTxt = '<li>thumb'+i+'</li>';
		$(thumbBox).append(appendTxt);
	}
	$(thumbBoxli).eq(_targetIndex).addClass(thumbClassCur);
	$('#visualBox,#thumbBox').hover(
		function(){
			$(thumbBox).css('display','block');
		},
		function(){
			$(thumbBox).css('display','none');
		}
	);
*/


/*--------------------------------------------
	gallery function
--------------------------------------------*/

	$('#visualBox li:eq('+_targetIndex+')').fadeIn(_fadeSpeed,function(){
		$(visualBoxParent).css('background','none');
		document.getElementById('visualBox').style.backgroundImage = 'url(../images/index_bg_main_visual.gif)';	//for IE
	});
	_timer = setInterval(onTimer,_slideSpeed);

	function onTimer(){
		var _oldIndex = _targetIndex;
		_targetIndex = ++_targetIndex % visualBox._length;
		visualSlide(_oldIndex,_targetIndex);
	}

	function visualSlide(_oldIndex,_targetIndex){
		if(_oldIndex==_targetIndex) return false;
		//$('#thumbBox li:not(:eq('+_targetIndex+'))').removeClass(thumbClassCur);
		//$(thumbBoxli).eq(_targetIndex).addClass(thumbClassCur);
		$(visualBox._li).eq(_oldIndex).stop(true,true).fadeOut(_fadeSpeed);
		$(visualBox._li).eq(_targetIndex).stop(true,true).fadeIn(_fadeSpeed);
	}


/*--------------------------------------------
	click Thumbnails
--------------------------------------------*/

/*
	$(thumbBoxli).click(function(){
		clearInterval(_timer);
		var _thumbIndex = $(thumbBoxli).index(this);
		var _oldIndex = _targetIndex;
		_targetIndex = _thumbIndex;
		visualSlide(_oldIndex,_targetIndex);
		_timer = setInterval(onTimer,_slideSpeed);
	});
*/



/*====================================================================

 □　RollOver Image

--------------------------------------------------------------------*/

	hoverimgs = $("#category-IndexBrand img");
	//hoverimgs = $(hoverimgs).add("#category-IndexMain img");
	
	$(hoverimgs).each(function(){
		this.originalSrc = this.src;
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_ov" + "$1");
		sitePreloadImage(this.rolloverSrc);
	}).hover(function(){ 
		this.src = this.rolloverSrc;
	},function(){
		if(!navActive) this.src = this.originalSrc;
	});
	
});
})(jQuery);



/*====================================================================

 □　Category Select / Image Change

--------------------------------------------------------------------*/

function changeImg(){
	n = Math.floor(Math.random() * 3);
	for(i = 0; i < 3; i++){ document.getElementById('MainBtn'+i).style.display = 'none'; }
	document.getElementById('MainBtn'+n).style.display = 'block';
}

