// JavaScript Document
$(document).ready(function(){

	$('a img').hover(function(){
			$(this).stop();
			$(this).fadeTo("normal", 0.6);
	},function(){
			$(this).stop();
			$(this).fadeTo("normal", 1.0);
	});
	$('a[class=none] > img').hover(function(){
			$(this).stop();
			$(this).fadeTo("normal", 1.0);
	},function(){
			$(this).stop();
			$(this).fadeTo("normal", 1.0);
	});

	/* メガメニューの処理 */
	/* cssでの定義 #pulldown-menu li:hover ul*/
	$('.lv1 > ul').hover(function(){
			$src = $(".lv1i").attr('src');
			$srcb = ($src.replace(/_off./g,"_on."));
			$('.lv1i').attr('src', $srcb);
	},function(){
			$srcb = $src.replace(/_on./g,"_off.");
			$('.lv1i').attr('src', $srcb);
	});
	$('.lv2 > ul').hover(function(){
			$srca = $(".lv2i").attr('src');
			$srcb = ($srca.replace(/_off./g,"_on."));
			$('.lv2i').attr('src', $srcb);
	},function(){
			$srcb = $srca.replace(/_on./g,"_off.");
			$('.lv2i').attr('src', $srcb);
	});
	$('.lv3 > ul').hover(function(){
			$src = $(".lv3i").attr('src');
			$srcb = ($src.replace(/_off./g,"_on."));
			$('.lv3i').attr('src', $srcb);
	},function(){
			$srcb = $src.replace(/_on./g,"_off.");
			$('.lv3i').attr('src', $srcb);
	});

	/* ボタン画像入れ替え */
	function smartRollover() {
		if(document.getElementsByTagName) {
			var images = document.getElementsByTagName("img");
			for(var i=0; i < images.length; i++) {
				if(images[i].getAttribute("src").match("_off."))
				{
					images[i].onmouseover = function() {
						this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
					}
					images[i].onmouseout = function() {
						this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
					}
				}
			}
		}
	}
	if(window.addEventListener) {
		window.addEventListener("load", smartRollover, false);
	}
	else if(window.attachEvent) {
		window.attachEvent("onload", smartRollover);
	}
});
