var script = document.createElement( 'script' );
script.src = "//www.youtube.com/iframe_api";
var firstScript = document.getElementsByTagName( 'script' )[ 0 ];
firstScript.parentNode.insertBefore( script , firstScript );
var player;
var vid = 'V1Zn_T8pSh8';
function onYouTubeIframeAPIReady(){
player = new YT.Player( 'mov',{
width: '100%',
height: '500',
videoId: vid,
playerVars: {'showinfo':0, 'controls':1, 'rel':0, 'loop':0},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerStateChange(){}
function onPlayerReady(){
$('.btn-movie').click(function(){
player.playVideo();
});
$('.btn-close').click(function(){
player.stopVideo();
});
}
jQuery(function(){
$('.btn-movie').hover(function(){
$(this).velocity({opacity:0.5},300);
},function(){
$(this).velocity({opacity:1},300);
});
// load Event
$(window).on('load',function(){
function startIntroduction(e){
$('#logo').fadeIn(500,'easeInOutQuad', function(){
e.find('.bg').css({opacity:0.4}).delay(1500).velocity({opacity:1},1000,'easeInOutQuad');
e.find('.e1,.e3,.e6,.e8').delay(1500).velocity({width:0},500,'easeInQuart',function(){$(this).hide()});
e.find('.e2,.e4,.e5,.e7').delay(1500).velocity({height:0},500,'easeInQuart',function(){$(this).hide()});
$(this).delay(1200).fadeOut(1200,'easeInOutQuad',function(){
setTimeout(function(){
$('header').velocity({top:0, opacity:1},800);
$('#mv').addClass('layer');
$('.pc #news .inner').delay(500).velocity({opacity:1},500);},300);
e.find('.btn-movie').css({display:'block',opacity:0,bottom:20}).delay(1000).velocity({opacity:1,bottom:40},800,'easeOutQuart');
});
});
}
setTimeout(function(){
mvHeight();
startIntroduction($('#mv'));
},50);
});
function mvHeight(){
var _h = $(window).innerHeight();
var _w = $(window).innerWidth();
var _mvh = (_h-100);
if((1036/500) < (_w/_mvh) && (1340/500) > (_w/_mvh)){
$('#mv, #mv .mv-box').css({height:_mvh});
}else{
$('#mv, #mv .mv-box').removeAttr('style')
}
$('#mv .eff').css({height: Math.ceil($('#mv').height()/2)+1});
}
$(window).on('resize', function() {
mvHeight();
});
$('.btn-movie').click(function(){
movieModalOpen();
});
$('.btn-close').click(function(){
movieModalClose();
});
function movieModalOpen(){
$('#m-overlay').removeClass().addClass('show');
$('#player').removeClass().addClass('show');
}
function movieModalClose(){
$('#m-overlay').removeClass().addClass('hide');
$('#player').removeClass().addClass('hide');
}
var _pos =[ $('.pc #fleva').offset().top, //0
$('.pc #products').offset().top, //1
$('.pc #history').offset().top, //2
$('.pc #equipment').offset().top, //3
$('.pc #gallery').offset().top, //4
$('.pc #m-sports').offset().top //6
];
var $fleva = $('.pc #fleva'),
$products = $('.pc #products'),
$history = $('.pc #history'),
$equipment = $('.pc #equipment'),
$m_sports = $('.pc #m-sports'),
$gallery = $('.pc #gallery'),
lineH = 24,
hoverLarge = $('.pc #history, .pc #m-sports, .pc #gallery');
var timer = null;
hoverLarge.hover(function(){
if($(this).hasClass('anm-end')){
$(this).find('.bg').not(':animated').velocity({width:2000, marginLeft:-1000, height:271, marginTop:-135},400);
}
},function(){
$(this).find('.bg').velocity({width:1920, marginLeft:-960, height:260, marginTop:-130},400);
});
$(window).on('scroll',function(){
/* products */
function sttlShow(e,d){
e.find('.sttl span').velocity({height:lineH},500,function(){
if(d==='l'){
e.find('.sttl img').show().css({opacity:0,marginLeft:-70}).delay(300).velocity({opacity:1,marginLeft:50},300);
}
else{
if(e.attr('id')==='m-sports'){
e.find('.sttl img').show().css({opacity:0,position:'relative', right:-70}).delay(300).velocity({opacity:1,right:51},300);
}else{
e.find('.sttl img').show().css({opacity:0,marginRight:-70}).delay(300).velocity({opacity:1,marginRight:52},300);
}
}
});
}
function flevaAnime(e){
if(!e.find('.o1').is(':animated')){
e.addClass('anm-end');
e.find('.o1').velocity({opacity:0},1200,function(){
e.find('#copy span').velocity({width:'100%'},300,'easeInQuint',function(){
e.find('#copy img').attr('src',e.find('#copy img').attr('src').replace('maskcopy_fleva.png','maskcopy_fleva_on.png'));
e.find('#copy span').hide();
e.find('#copy').delay(1500).velocity({opacity:0},800);
e.find('.o2').delay(1300).velocity({opacity:0},1000);
});
});
}
}
function equipmentAnime(e){
if(!e.find('.sttl span').is(':animated')){
e.addClass('anm-end');
sttlShow(e,'l');
e.find('ul').show().css({opacity:0}).delay(1500).velocity({opacity:1},1000);
}}
function productsAnime(e){
if(!e.find('.sttl span').is(':animated')){
e.addClass('anm-end');
sttlShow(e,'l');
e.find('.bg').show().css({opacity:0}).velocity({opacity:1},1500,function(){
e.find('.lineup > li').each(function(i){
$(this).show().css({bottom:80,opacity:0}).delay(i*100).velocity({bottom:110,opacity:1},700);
});
});
}}
function wideColumnAnime(e){
/*if(!e.find('.sttl span').is(':animated')){
e.addClass('anm-end');
sttlShow(e);
e.find('.wrap').css({opacity:1});
e.find('.wrap .bg').css({opacity:0,top:'53%'}).delay(900).velocity({opacity:1,top:'50%'},1000);
}*/
if(!e.find('.sttl span').is(':animated')){
e.addClass('anm-end');
setTimeout(function(){sttlShow(e,'r');},300);
e.find('.wrap').css({opacity:1});
e.find('.wrap .bg').css({opacity:0,top:'53%'}).velocity({opacity:1,top:'50%'},1000);
}
}
function asideAnime(e){
if(!e.find('.sttl span').is(':animated')){
e.addClass('anm-end');
e.find('.object').show().css({opacity:0}).velocity({opacity:1},1000,function(){
sttlShow(e,'l');
});
}}
var f, scrollPosition,bottom_y ;
clearTimeout(timer);
timer = setTimeout(function() {
if(_wsize == 'pc'){
var _sctop = $(this).scrollTop();
scrollPosition = $(this).height() + $(this).scrollTop();
bottom_y = $(document).height() - scrollPosition;
/* scroll action */
if(_sctop > (Number(_pos[0])-_h/2) && !$fleva.hasClass('anm-end')) { flevaAnime($fleva);}
if(_sctop > (Number(_pos[1])-_h/2) && !$products.hasClass('anm-end')) { productsAnime($products);}
if(_sctop > (Number(_pos[2])-_h/2) && !$history.hasClass('anm-end')) { wideColumnAnime($history); }
if(_sctop > (Number(_pos[3])-_h/2) && !$equipment.hasClass('anm-end')){ equipmentAnime($equipment); }
if(_sctop > (Number(_pos[4])-_h/2) && !$gallery.hasClass('anm-end')) { wideColumnAnime($gallery); }
if(_sctop > (Number(_pos[4])-_h*.4) && !$m_sports.hasClass('anm-end')) { wideColumnAnime($m_sports); }
if(_sctop > 0 && _sctop<(Number(_pos[0])-_h/2 && !$fleva.hasClass('anm-end'))){
f = _sctop/(Number(_pos[0])-_h*0.5);
$fleva.find('.bg').css({opacity:f});
}
if(_sctop === 0 && !$fleva.hasClass('anm-end')){
$fleva.find('.bg').css({opacity:0});
}
if(_sctop>(Number(_pos[0])-_h/2)){
$fleva.find('.bg').css({opacity:1});
}
}
}, 20);
});
});