jQuery(document).ready(function($) {
	// Service下画像部分
	var imgList = {
		"topimg01":"img/top_img01_b.gif",
		"topimg02":"img/top_img02_b.gif",
		"topimg03":"img/top_img03_b.gif",
		"topimg04":"img/top_img04_b.gif"
	};

	$(function(){
		var isAnimated = {
			"topimg01":false,
			"topimg02":false,
			"topimg03":false,
			"topimg04":false
		};
		$('#list_nav').find('a').hover(function(){
			var bglink = $(this).attr("id");
			isAnimated[bglink] = true;
			$("div.bg_" + bglink).css("background-image","url("+imgList[bglink]+")").stop(true,true).fadeTo(500,1.0);
		}, 
		function(){
			var bglink = $(this).attr("id");
			var fadeDuration = 500;
			for(var ia in isAnimated)
			{
				if(isAnimated[ia]) {
					fadeDuration = 15;
					break;
				}
			}
		$("div.bg_" + bglink).stop(true,true).fadeTo(fadeDuration,0);
	});
});


    // div要素をリンク
    $(function(){
        $(".sideBox").click(function(){
            window.location=$(this).find("a").attr("href");
            return false;
        });
    });

    $(function(){
        $(".hdBox").click(function(){
            window.location=$(this).find("a").attr("href");
            return false;
        });
    });

    $(function(){
        $(".projectBox").click(function(){
            window.location=$(this).find("a").attr("href");
            return false;
        });
    });



    // Hover for homepage client-banner project list
    var fancyHover = {
        init: function() {
                  var project = $('#client-banner li');

                  project.hover(
                          function () { 
                              $(this).children('.hover').removeClass('offscreen'); 
                          }, 
                          function () { 
                              $(this).children('.hover').addClass('offscreen');
                          }
                          );

              }
    };
    fancyHover.init();


    // Hover for homepage client-banner project list
    var hoverAnim = {
        init: function() {
                  var project = $('#client-banner li');
                  var projectTxt = project.children('.hover');
                  var projectInfo = project.children('.project-info');
                  var originalBG = "#272623"; 
                  var fadeColor = "#44423e";

                  project.children('.hover').css({left: '0px'})
                      project.children().children('.hover-bg').fadeTo(1, 0.0)
                      project.children().children('.hover-content').css({left: '-250px'})

                      project.hover(
                              function () {
                                  $(this).children().children('.hover-content').css({left: '-250px'});
                                  $(this).children().children('.hover-bg').stop().fadeTo(600, 0.7);
                                  $(this).children().children('.hover-content').stop().animate({left: '0px'} , { queue: false, duration: 450, easing: 'easeOutQuint' });
                                  $(this).children('.project-info').stop().animate({backgroundColor:fadeColor}, 750);
                              }, 
                              function () {
                                  $(this).children().children('.hover-bg').stop().fadeTo(800 , 0.0);
                                  $(this).children().children('.hover-content').stop().animate({left: '250px'} , { queue: false, duration: 300, easing: 'easeOutQuint' });
                                  $(this).children('.project-info').stop().animate({backgroundColor:originalBG},850);
                              }
                              );

              }
    };
    hoverAnim.init();


});

/* ----------------------------------------------------*/
// video
/* ----------------------------------------------------*/
$(function(){
	if($('video').length){
		var video = $('video').get(0);
		var clickArea = $('#videoControls');
		
		$(clickArea).click(function() {
			if(video.ended) {
				video.currentTime = 0;
				video.play();
			} else if(video.paused) {
				video.play();
			} else {
				video.pause();
			}
		});
	}
});

