
$(document).ready(function(){

	ROfunction("rover", "");
	
	
	$('.aover').hover(
		function(){
			$(this).stop().fadeTo(200,0.5);
		},
		function(){
			$(this).stop().fadeTo(500,1);
		}
	);
	
	
	// アコーディオンを実装
	var i = 0;
	$('.accordion').each(function(){
		$('.title > img', this).each(function(i){
			
			if(i == 0){
				$(this).attr('src', "/images/btn_accordion_close.gif");
			}else{
				$(this).parent().next().hide();
			}
			
			$(this).click(function(){
				$(this).parent().parent().find('.outline').slideUp("normal");
				$(this).parent().parent().find('.title > img').attr('src', "/images/btn_accordion_open.gif");
				$(this).parent().next().slideDown("normal");
				$(this).attr('src', "/images/btn_accordion_close.gif");
			});
		});
	});
	
	
	// メガドロップ
	$('#Gmenu').find('.parent').each(function(){
		$(this).hover(
			function(){
				$(this).find('ul').fadeIn();
			},
			function(){
				$(this).find('ul').fadeOut();
			}
		);
	});
	
});

function ROfunction(classname, prefix){

	var imgNum = document.getElementsByTagName("img");
	var inputNum = document.getElementsByTagName("input");
	
	overNum = new Array;
	
	if(prefix == ''){
		prefix = '_o';
	}
	
	for (i = 0; i < imgNum.length; i++) {
		overNum[i] = imgNum[i];
	}
	
	for (i = 0; i < inputNum.length; i++) {
		overNum[i + imgNum.length] = inputNum[i];
	}
	
	for (i = 0; i < overNum.length; i++) {
		if (overNum[i].className.indexOf(classname) != -1 && overNum[i].src.indexOf(prefix + ".") == -1) {
			overNum[i].overimg = new Image();
			if (overNum[i].className.indexOf(":") != -1) {
				Replace = overNum[i].className.split(":");
				Replace = Replace[1].split(" ");
				overNum[i].overimg.src = Replace[0];
			}
			else {
				Replace = overNum[i].src.length;
				overNum[i].overimg.src = overNum[i].src.substring(0, Replace - 4) + prefix + overNum[i].src.substring(Replace - 4, Replace);
			}
			overNum[i].setAttribute("out", overNum[i].src);
			overNum[i].onmouseover = new Function('this.src=this.overimg.src;');
			overNum[i].onmouseout = new Function('this.src=this.getAttribute("out");');
		}
	}
}

