// JavaScript Document


//rollover

jQuery(document).ready(function(){
	
	//droppy	
	jQuery('#menu').droppy({speed: 100}); 
	
	
	jQuery('#menu > li,.headerMain .lang li,.headerMain .btn_access,.rssBtn li,.topindex h2,.blog_pagetop')
	.each(function(){
		var bgName = jQuery(this).find('img').attr('src').replace('.gif', '_o.gif');
		jQuery(this).css('background', 'url('+bgName+') no-repeat')
	})
	.find('img:not([src$="_o.gif"])').hover(
		function(){  
			jQuery(this).stop().animate({'opacity' : '0'}, 200);  
		},
		function(){
			jQuery(this).stop().animate({'opacity' : '1'}, 200);
		}
	);
	
	
	//headerNews
	jQuery('.topindex ul.link li,.topindex #rightBox .blog,.footerLinksIn li,.blog ul.blog_link li').click(function(){
		var target = jQuery(this).find("a").attr("target");
		
		if(target){
			window.open(jQuery(this).find("a").attr("href") , "_blank");
		}
		else {
         window.location=jQuery(this).find("a").attr("href");
         }
         return false;
    });
    
    
	jQuery('ul.link li,#rightBox .blog').hover(
		function(){
			change_color(jQuery(this), 'a', '#58C7C7','#ffffff');
			jQuery('h3',this).css({	color: '#ffffff'}),
			jQuery('span',this).css({color: '#ffffff'})
		},
		function(){
			change_color(jQuery(this), 'a', '#ffffff','#000000');
			jQuery('h3',this).css({	color: '#CC9900'}),
			jQuery('span',this).css({color: '#aaaaaa'})
		}
	);

	
	jQuery('.blog #leftBox ul.blog_link li,.blog .tagCategory a,.searchlist .searchlistIn h3 a,.map_spot h3 a').hover(
		function(){
			change_color(jQuery(this), 'a', '#58C7C7','#ffffff');
		},
		function(){
			change_color(jQuery(this), 'a', '#F5f5f5','#000000');
		}
	);
	jQuery('#menu > li li a,.footerLinksIn li').hover(
		function(){
			change_color(jQuery(this), 'a', '#333333','#ffffff');
		},
		function(){
			change_color(jQuery(this), 'a', '#ffffff','#333333');
		}
	);
	function change_color(target, child, bgcolor, color){
		target.animate({
			backgroundColor: bgcolor,
			color: color
		}, 200),
		jQuery(child ,target).animate({
			color: color
		}, 200)
	};
	
	//Hide (Collapse) the toggle containers on load
	jQuery(".toggle_container").hide();
 
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	jQuery("dt.trigger").click(function(){
	jQuery(this).toggleClass("active").next().slideToggle("slow");
		return false; //Prevent the browser jump to the link anchor
	});
	
    //jQuery('.map_spotList_in').jScrollPane({showArrows:true});
});


//pagetopアニメーション

var height = 80;
var fps = 12;
var frame = 0;
var max_frame = 22;
var onceFlg = true;

jQuery(document).ready(function (){
	
	jQuery('.pageTop a').hover(
		function(){
			jQuery(this).stop().animate({'opacity' : '0'}, 1);
			var interval = 1/fps*500;
			animation = setInterval(intervalEvent, interval);
		},
		function(){
			jQuery(this).stop().animate({'opacity' : '1'}, 1);
			clearInterval(animation);
		}
	);
});

function intervalEvent(){
	jQuery('.pageTop p').css({
		"background-position":"0 "+ -height * frame +"px"
	});
	frame++;
	if(frame>=max_frame){
		if(onceFlg) clearInterval( animation );
		frame = 0;
	};
}

//サイト内検索select

jQuery(document).ready(function(){
	jQuery('#status').easySelectBox();
	jQuery('#categories').easySelectBox({speed:100});
});



//画像のプリローダー

jQuery(function () {
     jQuery('#container .imgBox img,#bnrBox img').hide();//ページ上の画像を隠す
});
 
var i = 0;
var int=0;
jQuery(window).bind("load", function() {//ページコンテンツのロードが完了後、機能させる
     var int = setInterval("doThis(i)",500);//フェードするスピード
});
 
function doThis() {
     var images = jQuery('img').length;//画像の数を数える
     if (i >= images) {// ループ
          clearInterval(int);//最後の画像までいくとループ終了
    }
    jQuery('img:hidden').eq(0).fadeIn(500);//一つずつ表示する
    i++;
} 


