/*
* jQuery_Auto 0.9
************************************************************************************************************************************************************************************ */

// Automatic functions for webpages (using the wonderful jQuery library)

// Copyright: (c) 2006, Michal Tatarynowicz (tatarynowicz@gmail.com)
// Licenced as Public Domain (http://creativecommons.org/licenses/publicdomain/)
// $Id: jquery_auto.js 426 2006-05-06 19:54:39Z Michał $


// Initialization

$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};

$(document).ready($.auto.init);


// Auto-hidden elements

$.auto.hide = {
	init: function() {
		$('.Hide').hide();
	}
};

// Mouse hover
$.auto.hover = {
	init: function() {
		$(".Hover").fadeTo(0,1.0);
		$(".Hover").hover(function(){
				$(this).fadeTo(200,0.55);
			},
			function(){
				$(this).fadeTo(300,1.0);
			});
	
		//ブラウザバック対策のためデフォは使わない。
		//ここで実行条件を指定。下で実行処理
		$('IMG.Hover2').rollover('_over');
		$('INPUT.Hover2').rollover('_over');
	}
};

/**
 * jQuery.rollover ブラウザバック対策用スクリプト上で実行条件を定義。下は実行処理
 *
 * @version    1.0.3
 * @author     Hiroshi Hoaki <rewish.org@gmail.com>
 * @copyright  2010 Hiroshi Hoaki
 * @license    http://rewish.org/license/mit The MIT License
 * @link       http://rewish.org/javascript/jquery_rollover_plugin
 *
 * Usage:
 * jQuery(document).ready(function($) {
 *   // <img>
 *   $('#nav a img').rollover();
 *
 *   // <input type="image">
 *   $('form input:image').rollover();
 *
 *   // set suffix
 *   $('#nav a img').rollover('_over');
 * });
 */
jQuery.fn.rollover = function(suffix) {
	suffix = suffix || '_on';
	var check = new RegExp(suffix + '\\.\\w+$');
	return this.each(function() {
		var img = jQuery(this);
		var src = img.attr('src');
		if (check.test(src)) return;
		var _on = src.replace(/\.\w+/, suffix + '$&');
		jQuery('<img>').attr('src', _on);
		img.hover(
			function() { img.attr('src', _on); },
			function() { img.attr('src', src); }
		);
	});
};


/* ブラウザバック対策　bodyにonpageshow="resetRollover();"でリセット */
function resetRollover() {
	var images = $('img.Hover2');
	var suffix = '_over';
	for(var i = 0; i < images.length; i++){
		if(images[i].getAttribute("src").match(suffix)) {
			images[i].setAttribute("src", images[i].getAttribute("src").replace(suffix, ""));
		}
	}
}


// Auto-submitting SELECTs

$.auto.submit = {
	init: function() {
		$('SELECT.Submit').bind('change', this.on_change);
	},

	on_change: function() {
		if (this.value) this.form.submit();
	}
};


// Auto-selected text in text fields after a label click

$.auto.select = {
	init: function() {
		$('LABEL.Select').each(this.label_action);
		$('INPUT.Select').bind('click', function(){ this.select(); });
	},

	label_action: function() {
		var field = $('#'+this.htmlFor).get(0);
		if (field && field.focus && field.select) {
			$(this).bind('click', function(){ field.focus(); field.select(); });
		}
	}
};


// Switches tabs on click

$.auto.tabs = {

	init: function() {

		$('.Tabs').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.Tab', group).each(function(){
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'_body').hide();
			}).filter(':first').trigger('click');
		});

	},

	click: function() {
		var tab = $('#'+this.id+'_body').get(0);
		$('.Tab', this.group).each(function(){
			$(this).removeClass('Active');
			$('#'+this.id+'_body').hide();
		});

		$(this).addClass('Active');
		$(tab).show();
		this.blur();

		return false;
	}

};

//ページトップへ

$(function(){
					 
	$('.btn_gopageTop a').click(function(){
		//$('html,body').animate({scrollTop: 0},-100);
		$('html,body').animate({scrollTop: 0},200);
		return false;
	});
	
});




/*
* 個別関数
************************************************************************************************************************************************************************************ */

/*
* ログインエラー
*/

// タイマーでページ移動
function locationTimer(time,url)
{
		window.onload=function(){
			time2 = time/1000;
			//alert("ダイアログを閉じると"+time2+"秒後に移動します");
			ti=setTimeout('window.location="'+url+'"',time)
		}
}

/*
* オンラインショップ
*/

// フェードイン表示
function viewFadeIn(target,time)
{
	$(function(){
		//ターゲットを非表示化
		$(target).css('display', 'none');
		
		//ターゲットをフェードイン表示
		$(target).fadeIn(time);
	});
}

/*
* 商品詳細
*/


//フェードイン表示
function viewFadeItem()
{
	$(function(){
		$.each($(".fade_body").slice(), function() {
			$(this).hide().delay(function() {
				$(this).fadeIn(1500);
			});
		});
		$.resume(200);
	});
}


//成分表示
function view_ingredients()
{	
	/*
	$(function(){	
		//div#box_ingredientsの表示、非表示切り替え	
		$("#btn_ingredients a").each(function(i){	
			$(this).click(function(){
				$("#box_ingredients").eq(i).toggle();
			});	
		});	
	});
	*/
	$(function(){	
		$(".open").click(function(){
			$(".open").css('display', 'none');
			$(".close").css('display', 'block');
			//$("#box_ingredients").css('display', 'block');
			$("#box_ingredients").slideDown('fast');
		});
		$(".close").click(function(){
			$(".open").css('display', 'block');
			$(".close").css('display', 'none');
			//$("#box_ingredients").css('display', 'none');
			$("#box_ingredients").slideUp('fast');
		});
	});
}


//セルジュカテゴリ切替
function viewCategoryChild(flg)
{
	
	var category = document.searchCategory.category_kbn.value;
	
	$(".block_category").css('display', 'none');
	$("#block_category_"+category).css('display', 'block');
}

/*
* 人気カウンター
*/
function addPopularity(item_id,flg)
{
	url = '/raw/add_popularity.php';
	params = "item_id=" + item_id;	
	
	/* 引数 'params' を伴って、引数 'url' へ POST による
	* 非同期通信します
	* 処理完了後 インライン関数(function)を実行します
	*/
	$.ajax({
		type: "POST",
		url: url,
		data: params,
		cache: false,
		dataType: "json",
		success: function(message, status){
			if(message){
				if(message['error'] == 1){
					return false;
				}
				
				if(message['popularity']){
					//商品詳細のカウント数を更新
					if(flg == 1){
						$("#view_popularity").html(message['popularity']);
					}
				
					//アイコンの選択
					var ran = Math.floor(Math.random()*6)+1;
					var icon_id = '#icon_popularity_'+ran;
					
					//吹き出し作成
					$('#popularity_'+item_id).append('<span id="icon_popularity_'+ran+'" style="display:none;"><img src="/img/common/icon_thank_'+ran+'.png" alt="Thank you !!" /></span>');
					
					p_left = '-5px';
					p_top = '-30px';
					
					$(icon_id).css('position', 'absolute');
					$(icon_id).css('left', p_left);
					$(icon_id).css('top', p_top);
					$(icon_id).css('z-index', 3);
						
					//アイコン表示
					$(icon_id).fadeIn(
						'fast',
						function(){
							setTimeout("hidepopularity("+ran+")",2000);
						}
					);
					
					message['error'] = 1;
				}
			}
		}
	});
	
	return false;
}
//吹き出しを消す
function hidepopularity(ran)
{
	var icon_id = '#icon_popularity_'+ran;
	$(icon_id).fadeOut(
		'slow',
		function(){
			$(icon_id).remove();
		}
	);
}



/*
* お気に入り追加
*/
function addFavorite(item_id)
{
	url = '/raw/add_favorite.php';
	params = "item_id=" + item_id;
	
	/* '#ajax_block' で示すエリアをクリアします */
	//$('#zip_addr0').html('');
	/* '#ajax_progress' で示す Ajax Loader イメージを表示して、
	* 処理中を促します
	*/
	//$('#ajax_progress').css('display', 'block');
	
	/* 引数 'params' を伴って、引数 'url' へ POST による
	* 非同期通信します
	* 処理完了後 インライン関数(function)を実行します
	*/
	$.ajax({
		type: "POST",
		url: url,
		data: params,
		cache: false,
		dataType: "json",
		success: function(message, status){
			//商品詳細のカウント数を更新
			//$("#view_favorite").html(message['message']);
			
			//吹き出し作成
			$("#btn_addfavorite").append('<span id="view_favorite" style="display:none;"><img src="/img/branditem/icon_favorite_'+message['result']+'.gif" alt="'+message['message']+'" /></span>');
			
			p_left = '-5px';
			p_top = '-30px';
			
			$("#view_favorite").css('position', 'absolute');
			$("#view_favorite").css('left', p_left);
			$("#view_favorite").css('top', p_top);
			$("#view_favorite").css('z-index', 3);
			
			//アイコン表示
			$("#view_favorite").fadeIn(
				'fast',
				function(){
					setTimeout("hidefavorite()",2000);
				}
			);
		}
	});
	
	return false;
}
//吹き出しを消す
function hidefavorite()
{
	$('#view_favorite').fadeOut(
		'slow',
		function(){
			$('#view_favorite').remove();
		}
	);
}
/*
function addFavorite(item_id)
{
	url = '/raw/add_favorite.php';
	params = "item_id=" + item_id;
	$.ajax({
		type: "POST",
		url: url,
		data: params,
		cache: false,
		dataType: "json",
		success: function(message, status){
			//商品詳細のカウント数を更新
			$("#view_favorite").html(message['message']);
			
			//アイコン表示
			$("#view_favorite").fadeIn(
				'fast',
				function(){
					setTimeout("hidefavorite()",2000);
				}
			);
		}
	});
	
	return false;
}
//吹き出しを消す
function hidefavorite()
{
	$('#view_favorite').fadeOut('slow');
}
*/


/*
* 追加設定
************************************************************************************************************************************************************************************ */
$(document).ready(function(){
	
	//次への吹き出し
	$(".pgChangeNext").mousemove(function(e){
		var iconX = e.pageX - 10; //最後は画像の横幅に合わせた位置調整
		var iconY = e.pageY - 30;
		$('#pg_over_next').css('display', 'block');
		$('#pg_over_next').css('top', iconY);
		$('#pg_over_next').css('left', iconX);
	});
	
	$(".pgChangeNext").mouseout(function(e){
			$('#pg_over_next').css('display', 'none');
	});
	
	//戻るの吹き出し
	$(".pgChangeBack").mousemove(function(e){
		var iconX = e.pageX - 60; //最後は画像の横幅に合わせた位置調整
		var iconY = e.pageY - 30;
		$('#pg_over_back').css('display', 'block');
		$('#pg_over_back').css('top', iconY);
		$('#pg_over_back').css('left', iconX);
	});
	
	$(".pgChangeBack").mouseout(function(e){
		$('#pg_over_back').css('display', 'none');
	});
	
	//商品ラインアップの吹き出し
	$(".pgChangeLineup").mousemove(function(e){
		var iconX = e.pageX - 13; //最後は画像の横幅に合わせた位置調整
		var iconY = e.pageY - 30;
		$('#pg_over_lineup').css('display', 'block');
		$('#pg_over_lineup').css('top', iconY);
		$('#pg_over_lineup').css('left', iconX);
	});
	
	$(".pgChangeLineup").mouseout(function(e){
		$('#pg_over_lineup').css('display', 'none');
	});
	
	//商品リストの吹き出し
	$(".pgChangeList").mousemove(function(e){
		var iconX = e.pageX - 13; //最後は画像の横幅に合わせた位置調整
		var iconY = e.pageY - 30;
		$('#pg_over_list').css('display', 'block');
		$('#pg_over_list').css('top', iconY);
		$('#pg_over_list').css('left', iconX);
	});
	
	$(".pgChangeList").mouseout(function(e){
		$('#pg_over_list').css('display', 'none');
	});
	
	//ショッピングバッグに追加の吹き出し
	$(".pgChangeBag").mousemove(function(e){
		var iconX = e.pageX - 130; //最後は画像の横幅に合わせた位置調整
		var iconY = e.pageY - 30;
		$('#pg_over_bag').css('display', 'block');
		$('#pg_over_bag').css('top', iconY);
		$('#pg_over_bag').css('left', iconX);
	});
	
	$(".pgChangeBag").mouseout(function(e){
		$('#pg_over_bag').css('display', 'none');
	});
	
	//フォローするに追加の吹き出し
	$(".pgChangeFollow").mousemove(function(e){
		var iconX = e.pageX - 10; //最後は画像の横幅に合わせた位置調整
		var iconY = e.pageY - 30;
		$('#pg_over_follow').css('display', 'block');
		$('#pg_over_follow').css('top', iconY);
		$('#pg_over_follow').css('left', iconX);
	});
	
	$(".pgChangeFollow").mouseout(function(e){
		$('#pg_over_follow').css('display', 'none');
	});
	
});



$(function() {
$("#btn01").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks img").fadeIn(3000).fadeOut(3000);
　});
　　　});

$(function() {
$("#btn02").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks2 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn03").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks3 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn04").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks4 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn05").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks5 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn06").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks6 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn07").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks7 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn08").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks8 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn09").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks9 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn10").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks10 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn11").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks11 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn12").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks12 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn0113").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks13 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn14").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks14 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
$(function() {
$("#btn15").click(function(){
// フェードイン･アウト処理間隔を時間指定しています。(3000 = 3秒)
$("#thanks15 img").fadeIn(3000).fadeOut(3000);
　});
　　　});
