/**
* サイトトップ 新入荷商品スライドショー
* 
* @since 2008.02.22
* @update 2008.02.23
* @auther info@rise-tec.com
* @copyright Copyright &copy; 2008, rise-tec.com
*/

jQuery.noConflict();

/*
	jQuery Cycle Plugin
	http://www.malsup.com/jquery/cycle/
*/

//onload event
jQuery(function($){
	if ($('#newArrivals').length == 0) {
		return;
	}
	
	//div#newArrivals の<h2>要素の次に、div#slideShowBox要素を作成する。
	$('#newArrivals :first').after(
		$(document.createElement('div')).attr('id', 'slideShowBox')
	);
	
	var box = $('#slideShowBox');
	box.append('<div id="imageBox"></div><div id="infoBox"></div>');
	var imgBox = $('#imageBox');
	var infoBox = $('#infoBox');
	var imgs = '';
	
	//各新入荷商品 (div.item)をloop
	$('div.item').each(function(idx) {
		var img = $('div.photo img', this);
		var src = img.attr('src');
		var title = img.attr('title');
		var href = $('div.photo a', this).attr('href');
		src = src.replace('_prev.jpg', '.jpg');
		
		var price = $('li.price', this).html();
		
		imgs += '<a href="' + href + '">';
		imgs += '<img src="' + src + '" width="220" alt="" title="' + title + '" price="' + price + '" /></a>' + "\n";
	});
	
	
	box.css({
		'margin': '0 0 10px 0',
		'overflow': 'hidden',
		'width': '550px',
		'height': '200px',
		'text-align': 'left',
		'background': 'transparent url(/images/skin/bg/slide_show_bg.jpg) no-repeat'
	});
	
	imgBox.css({
		'margin': '12px 0 0 22px',
		'width': '220px',
		'height': '180px',
		'overflow': 'hidden'
	});
	
	infoBox.css({
		'position': 'absolute',
		'width': '260px',
		'padding': '5px 5px',
		'top': '80px',
		'right': '20px',
		'color': '#fff',
		'text-align': 'center',
		//'border': '1px solid #9c6'	//greenバージョン
		'border': '1px solid #69c'	//blueバージョン
	});
	
	imgBox.html(imgs);
	
	var cycleCallback = function (current, next, obj) {
		var img = $('img', next);
		infoBox.html(
			'<a href=' + next.href + ' style="color:#fff;">' + img.attr('title') + '</a><br />' + img.attr('price')
		);
	}

	var effects = [
		{before: cycleCallback},	//fade
		{fx: 'zoom', delay: -3000, before: cycleCallback},
		{fx: 'turnDown', delay: -3000, before: cycleCallback},
		{fx: 'scrollUp',delay: -3000, before: cycleCallback},
		{fx: 'scrollDown',  delay: -3000, before: cycleCallback},
		{fx: 'scrollLeft',  delay: -3000, before: cycleCallback},
		{fx: 'scrollRight',  delay: -3000, before: cycleCallback},
		{fx: 'slideX',  delay: -3000, before: cycleCallback}
		
		//{fx: 'shuffle', delay: -3000},	//IEではoverflowが効かないので却下
		//{fx: 'slideY',  delay: -3000}	//IEでは乱れるので却下
	];
	
	//var effect = effects[Math.floor(Math.random() * effects.length)];
	var effect = effects[0];	//fadeのみに変更。2008.11.29
	imgBox.cycle(effect);
	//console.log(imgs);
});




















