$(document).ready(function(){
	// 初期化
	$(".accordion").each(function(){
		src = $(this).attr('src') ;
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '_open'+ftype);
		$(this).attr('hsrc',hsrc) ;
		$(this).hover(
			function(){
				$(this).css('cursor','pointer') ;
			},
			function(){
				$(this).css('cursor','default') ;
			}
		) ;
	}) ;
	$(".accordion").parent().children(".right_cot_inbox_bg").children(".right_cot_inbox").hide() ;
}) ;

$(function(){
	var image_path	= 'images/common/' ;
	$(".accordion").click(function(){
		$no_anime	= this ;

		$(".accordion").each(function(){
			if( $no_anime!=this ){
				//$(this).parent().children(".right_cot_inbox_bg").children(".right_cot_inbox").hide() ;
				val = $(this).parent().children(".right_cot_inbox_bg").children(".right_cot_inbox").css('display') ;
				if( val=='block' ){
					$(this).parent().children(".right_cot_inbox_bg").children(".right_cot_inbox").slideToggle() ;
					// 画像切り替え
					src		= $(this).attr('src') ;
					hsrc	= $(this).attr('hsrc') ;
					$(this).attr('src',hsrc) ;
					$(this).attr('hsrc',src) ;
				}
			}
		}) ;
		$(this).parent().children(".right_cot_inbox_bg").children(".right_cot_inbox").slideToggle() ;

		// 画像切り替え
		src		= $(this).attr('src') ;
		hsrc	= $(this).attr('hsrc') ;
		$(this).attr('src',hsrc) ;
		$(this).attr('hsrc',src) ;
	}) ;

	/* 各種ロールオーバー（共通） */
	initRollovers();
	initAlphaOvers() ;
}) ;


/*	画像ロールオーバー
-----------------------------------------------------------*/
function initRollovers() {
	if (!document.getElementById) return;
	
	var aPreLoad = new Array();
	var sTempSrc;

	var aImages = document.getElementsByTagName('img');

	for (var i=0; i < aImages.length; i++) {
		if (aImages[i].className.match(/imgover/) ) {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_ov'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ov'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

/*	画像アルファ値
-----------------------------------------------------------*/
function initAlphaOvers() {
	if (!document.getElementById) return;

	var aImages = document.getElementsByTagName('img');

	for (var i=0; i < aImages.length; i++) {
		if (aImages[i].className.match(/imgalpha/) ) {
			var src = aImages[i].getAttribute('src');

			aImages[i].onmouseover = function() {
				this.style.filter='alpha(opacity=80)';
				this.style.opacity='0.80';
			}	
			
			aImages[i].onmouseout = function() {
				this.style.filter='';
				this.style.opacity='';
			}
		}
	}
}
