// Image RollOver action
$(document).ready( function() {
	PEPS.rollover.init();
});

PEPS = {};
PEPS.rollover = {
	init: function() {
		this.preload();
		$(".overImg").hover(
			function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
			function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
		);
	},
	preload: function() {
		$(window).bind('load', function() {
			$('.overImg').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
		});
	},
	newimage: function( src ) {
		return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_on' + src.match(/(\.[a-z]+)$/)[0];
	},
	oldimage: function( src ) {
		return src.replace(/_on\./, '.');
	}
};


// Head Search Focus action
$(function(){
	$('#KwdSearch').val("キーワードを入力")
	.css('color','#999999');

	$('#KwdSearch').focus(function(){
		if(this.value == "キーワードを入力"){
			$(this).val("").css('color','#000000');
		}
	});

	$('#KwdSearch').blur(function(){
		if(this.value == ""){
			$(this).val("キーワードを入力")
			.css('color','#999999');
		}
		if(this.value != "キーワードを入力"){
			$(this).css('color','#000000');
		}
	});
});


//Left Column Accordion Menu
$(document).ready(function(){
	$(".ctgryLinkBox").not('.opened').hide();			//Hide (Collapse) the toggle containers on load

	$(".trigger").toggle(function(){	//Switch the "Open" and "Close" state per click
			$(this).addClass("active");
		},
		function () {
		$(this).removeClass("active");
	});

	$(".trigger").click(function(){	//Slide up and down on click
		$(this).next(".ctgryLinkBox").slideToggle("slow");
	});
});

//Product List Change Limit
function change_limit(obj, path){
//  var curr_url = location.href;
  var protocol = location.protocol;
  var host = location.host;
  var index = obj.selectedIndex;
  var value = obj.options[index].value;
  location.href = protocol+"//"+host+path+'/limit/'+value;
}

