// JavaScript Document


//Image Preloader using jQuery
 $(function(){
                //ページ上の画像をすべて隠す
                $('.image-holder img').hide();
            });
            // 初期化
            var i = 0;
            // IEは固定
            var int=0;
            $(window).bind("load", function() {
                // ページが完全に読み込まれたときにロードイベント発生
                // 画像を0秒間隔で順番フェードイン表示
                var int=setInterval("doThis(i)",0);
            });
            function doThis() {
                // 画像数
                var imgs = $('.image-holder img').length;
                if (i >= imgs) {
                    // 最後の画像でタイマークリア
                    clearInterval(int);
                }
                // 0.5秒間隔で隠していた画像をフェードイン表示
                $('.image-holder img:hidden').eq(0).fadeIn(1000);
                i++;
            }


//a1bo_figure jQuery
$(function()
{
		var targetImgs = $('#header-inner-left img');
		
		targetImgs.each(function()
		{
			if(this.src.match('_off'))
			{
				
				this.rollOverImg = new Image();
				this.rollOverImg.src = this.getAttribute("src").replace("_off", "_on");;
				$(this.rollOverImg).css({position: 'absolute', opacity: 0});
				$(this).before(this.rollOverImg);
				
				$(this.rollOverImg).mousedown(function(){
					$(this).stop().animate({opacity: 0}, {duration: 0, queue: false});
				});
				
				$(this.rollOverImg).hover(function(){
					$(this).animate({opacity: 1}, {duration: 400, queue: false});
				},
				function(){
					$(this).animate({opacity: 0}, {duration: 400, queue: false});
				});
				
			}
		});
});


//a1bo_togo jQuery
$(function()
{
		var targetImgs = $('#header-inner-right img');
		
		targetImgs.each(function()
		{
			if(this.src.match('_off'))
			{
				
				this.rollOverImg = new Image();
				this.rollOverImg.src = this.getAttribute("src").replace("_off", "_on");;
				$(this.rollOverImg).css({position: 'absolute', opacity: 0});
				$(this).before(this.rollOverImg);
				
				$(this.rollOverImg).mousedown(function(){
					$(this).stop().animate({opacity: 0}, {duration: 0, queue: false});
				});
				
				$(this.rollOverImg).hover(function(){
					$(this).animate({opacity: 1}, {duration: 400, queue: false});
				},
				function(){
					$(this).animate({opacity: 0}, {duration: 400, queue: false});
				});
				
			}
		});
});


//nav menu jQuery
function mainmenu(){
$(" #globalNavi li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

 
 
 $(document).ready(function(){					
	mainmenu();
});


//tab jQuery
$(function(){
	$("ul.panel li:not("+$("ul.tab li a.selected").attr("href")+")").hide();
	$("ul.tab li a").click(function(){
		$("ul.tab li a").removeClass("selected");
		$(this).addClass("selected");
		var a =$(this);
		$("ul.panel li").hide();
		$($(this).attr("href")).show();
		return false;
	});
});


//colorbox
$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='example1']").colorbox();
			$("a[rel='example2']").colorbox({transition:"fade"});
			$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
			$("a[rel='example4']").colorbox({slideshow:true});
			$(".example5").colorbox();
			$(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
			$(".example7").colorbox({width:"80%", height:"80%", iframe:true});
			$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
			$(".example9").colorbox({
				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
			});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});
		});


//totop scroll
$(function(){
		$("#toTop a").click(function(){
									$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
									return false;
									})
		});


//sns-area jQuery PNG NG
$(function()
{
		var targetImgs = $('#footer-sns-area img');
		
		targetImgs.each(function()
		{
			if(this.src.match('_off'))
			{
				
				this.rollOverImg = new Image();
				this.rollOverImg.src = this.getAttribute("src").replace("_off", "_on");;
				$(this.rollOverImg).css({position: 'absolute', opacity: 0});
				$(this).before(this.rollOverImg);
				
				$(this.rollOverImg).mousedown(function(){
					$(this).stop().animate({opacity: 0}, {duration: 0, queue: false});
				});
				
				$(this.rollOverImg).hover(function(){
					$(this).animate({opacity: 1}, {duration: 400, queue: false});
				},
				function(){
					$(this).animate({opacity: 0}, {duration: 400, queue: false});
				});
				
			}
		});
});

