/*********************************************
 common / 共通設定
*********************************************/

/*rollover*/

function initRollOverImagesFade() {
	var image_cache = new Object();
	$('.swap').each(function(i) {
	var imgsrc = this.src;
	var dot = this.src.lastIndexOf('.');
	var imgsrc_on = this.src.substr(0, dot) + '_o' + this.src.substr(dot, 4);
	image_cache[this.src] = new Image();
	image_cache[this.src].src = imgsrc_on;
	$(this).hover(
	function() { this.src = imgsrc_on; $(this).fadeTo(200, 0.6); $(this).fadeTo(200, 1.0); },
	function() { $(this).fadeTo(100, 1.0); this.src = imgsrc; });
	});
}

$(document).ready(initRollOverImagesFade);

/*********************************************
 top / トッププロモーション設定
*********************************************/

function initTopImagesFade() {
	$(function() {
		$('#p2').fadeIn(2500).fadeOut(3000);
	});
}

/*********************************************
 list / 商品一覧設定
*********************************************/

/*ListHoverLinks*/

function ListHoverLinks() {
		$(function(){
			$("ul.area_list").each(function(){
			var href = $(this).find('a').attr('href');
			$(this).hover(ListMover,ListMdown)
			$(this).click(function(){
				window.open(href,'_self');
				return false;
				});
			});
		});
}

function ListMover() { $(this).css({"background":"url('/joint/i/bg_p_list.gif') top left","cursor":"pointer"}) }
function ListMdown() { $(this).css({"background":"none #FFF","cursor":"default"}) }

$(document).ready(ListHoverLinks);

/*********************************************
 detail / 商品詳細設定
*********************************************/

/*detailchangeimg*/

function DetailChangeImages() {
		var regrep = "_d";
		$(function(){
		$("ul#thum_img img")
			.css("opacity","0.7")
			.hover(up,down).hover(changePhoto);
		});
		function up(){
		$(this).css({"opacity":"1.0",
					"border":"1px solid #333"})
		}
		function down(){
		$(this).css({"opacity":"0.7",
					"border":"1px solid #A9A9A9"})
		}
		function changePhoto(){
		setname = $(this).attr("src").replace(regrep,"");
		$("#main_img").attr("src",setname).css("opacity","0.2").fadeTo(300,1);
		}
}


/*********************************************
 order / オーダーメイド設定
*********************************************/

function initScrollFollow() {

var name = "#wrap_scrl";
var menuYloc = null;

	$(function(){
		menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
		$(window).scroll(function () { 
			offset = menuYloc+$(document).scrollTop()+"px";
			$(name).animate({top:offset},{duration:300,queue:false});
		});
	});
}

function initToggle() {

	$(function(){
	
		$("div.odr_sec").hide();

		$("h3.tt_odr_sec").toggle(function(){
			$(this).addClass("active"); 
			}, function () {
			$(this).removeClass("active");
		});
		
		$("h3.tt_odr_sec").click(hideMenu);

		function hideMenu(){
			$(this).next(".odr_sec").slideToggle("slow,");
		}

	});

}

