function imgRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("__roll."))
			{
				images[i].onmouseover = function() {
					if(this.getAttribute("className")!="noroll" && this.getAttribute("class")!="noroll"){
						this.setAttribute("src", this.getAttribute("src").replace("__roll.", "__rollon."));
					}
				}
				images[i].onmouseout = function() {
					if(this.getAttribute("className")!="onactive" && this.getAttribute("class")!="onactive"){
						this.setAttribute("src", this.getAttribute("src").replace("__rollon.", "__roll."));
					}
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", imgRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", imgRollover);
}
$(document).ready(function(){
	$("a img").hover(function(){
		if(!$(this).attr('src').match("__roll.")){
			$(this).parent().addClass('a_hover');
			$(this).animate({opacity:0.7},100);
		}
	},
	function(){
		$(this).animate({opacity:1.0},100,function(){$(this).parent().removeClass('a_hover');});
	}
	);
	
	if(activeCategory){
		$.each($(".globalMenu a img"), function(i, val) {
			var matches = new RegExp(activeCategory +"__roll.jpg$");
			if($(val).attr("src").match(matches) != null){
				//alert($(val).attr("src").replace(/__roll.jpg/ig , "__rollon.jpg"));
				$(val).attr("src",$(val).attr("src").replace(/__roll.jpg/ig , "__rollon.jpg"));
				$(val).attr("class",'onactive');
				$(this).unwrap();
			}
		});
	}
});

if(window.addEventListener) {
	window.addEventListener("load", imgRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", imgRollover);
}
$(document).ready(function(){
	$('a[href*=#]').click(function() {  
		var target = $(this.hash);  
		target = target.length && target;  
		if (target.length) {  
			var sclpos = 30;  
			var scldurat = 1200;  
			var targetOffset = target.offset().top - sclpos;  
			$('html,body')  
				.animate({scrollTop: targetOffset},'slow');  
			return false;  
		}  
	});
	$("a img").hover(function(){
		if(!$(this).attr('src').match("__roll.")){
			$(this).parent().addClass('a_hover');
			$(this).animate({opacity:0.7},100);
		}
	},
	function(){
		$(this).animate({opacity:1.0},100,function(){$(this).parent().removeClass('a_hover');});
	}
	);
});
//アコーディオン開閉
$(function() {
	$('dl.sideMenu>dd').hide();
	$('dl.sideMenu>dt.menuHeading').click(function() {
		$(this).toggleClass('opened');
		$(this).nextUntil('dl.sideMenu>dt').slideToggle('slow');
	});
	$('dl.sideMenu>dt.menuHeading2').click(function() {
		$(this).toggleClass('opened2');
		$(this).nextUntil('dl.sideMenu>dt').slideToggle('slow');
	});
});
