//============================================
//
//  setCI
//
//============================================

var setCI = function(){
	var t;
	var pre = "/global_src/img/bottle/";
	var ex =".png";
	return function(callback){
		$("#ci ul li").bind("mouseover",function(){
			t = $(this).attr("id").slice(3);
			$("#ci p img").attr("src",pre+t+ex);
		});
		$("#ci p").animate(
			{top:"45px"},
			{
				duration:1200,
				easing:"easeOutBounce",
				complete:function(){if(callback != null) callback()}
			}
		);
	}
}();


//============================================
//
//  setLazy
//
//============================================

function setLazy(t){
	var param = {
		//placeholder : "img/grey.gif",
		/*effect: "fadeIn"*/
	};
	for(var i=0; i<t.length; i++) $(t[i]).lazyload(param);
}


//============================================
//
//  modalSet
//
//============================================

var modal = function(){
	//-----------------------------------------------------------------
	// variables
	//-----------------------------------------------------------------
	var
	that,
	doc,
	modalWrapID = 'modal_wrap',
	modalID = 'modal';
	// modalのタグ
	var tag = '\
		<div id="'+modalWrapID+'"></div>\
		<div id="'+modalID+'"></div>\
	';
	// modal_wrapのスタイル
	var modalWrapStyle = {
		display:'none',
		position:'absolute',
		top:0,
		left:0,
		margin:0,
		background:'#000',
		opacity:.5,
		zInddex:900
	};
	// modalのスタイル
	var modalStyle = {
		display:'none',
		position:'absolute',
		width:'480px',
		background:'#FFF',
		zInddex:901,
		padding:'15px'
	};
	var modalWrap;
	var modal;
	//-----------------------------------------------------------------
	// functions
	//-----------------------------------------------------------------
	function _init(){
		doc = $(document);
		$('body').append(tag);
		modalWrap = $('#'+modalWrapID);
		modalWrap
			.css(modalWrapStyle)
			.bind("click",_del);
		modal = $('#'+modalID);
		modal.css(modalStyle);
	}
	//-----------------------------------------------------------------
	function _set(t){
		modal.html(t);
		modal.css('display','block');
		modalWrap.css('display','block');
		$(window).bind('resize',function(){resize()});
		resize();
	}
	//-----------------------------------------------------------------
	function _del(){
		modal.css('display','none');
		modalWrap.css('display','none');
		$(window).unbind();
	}
	//-----------------------------------------------------------------
	function resize(){
		modalWrap.css({
			width:doc.width()+'px',
			height:doc.height()+'px'
		});
		var offsetY = $(window).height() / 2 + $(window).scrollTop();
		var offsetX = $(window).width() / 2 + $(window).scrollLeft();
		var _top = offsetY - modal.height() / 2;
		var _left = offsetX - modal.width() / 2;
		modal.css({top:_top+'px',left:_left+'px'});
	}
	//===================================
	//  PUBLIC
	//===================================
	return {
	//-----------------------------------------------------------------
		init:function(){that = this;_init()},
	//-----------------------------------------------------------------
		set:function(t){_set(t)},
	//-----------------------------------------------------------------
		del:function(t){_del()}
	}
}();

//============================================
//
//  mouseOverSet
//
//============================================

function mouseOverSet(){
	//-------------------------------------------------------------
	var
	stockID = '#img_stock',
	overClass = "img.over",
	tag = '<div id="'+stockID+'"></div>',
	contents = '',
	imgs = $("img.over"),
	num = imgs.length;
	//-------------------------------------------------------------
	$('body').append(tag);
	for(var i=0; i<num; i++){
		var str = imgs.eq(i).attr('src').replace('1.','2.');
		contents += '<img src="'+str+'" alt="" />';
	}
	$(stockID).html(contents);
	//-------------------------------------------------------------
	imgs.bind('mouseover',function(){
		$(this).attr('src',$(this).attr('src').replace('1.','2.'))
	});
	imgs.bind('mouseout',function(){
		$(this).attr('src',$(this).attr('src').replace('2.','1.'))
	});
}
