var len = 0; $(function(){ var cnt = 1; len = $(".section1 > div.slidebg").length; //alert(len); $("#footer").delay(5000).queue(function(){anim(cnt);}) setimg(); setscrl(); //setdef(); }); $(window).load(function(){ setimg(); setscrl(); setdef(); seth(); }); $(window).scroll(function(){ setscrl(); }); var timer = false; var timer2 = false; $(window).resize(function() { setimg(); setscrl(); if (timer !== false) { clearTimeout(timer); } timer = setTimeout(function() { //console.log('resized'); seth(); }, 500); if (timer2 !== false) { clearTimeout(timer2); } timer2 = setTimeout(function() { //console.log('resized'); seth(); }, 1000); }); $(window).on('orientationchange', function(){ setimg(); setscrl(); }); function anim(cnt){ cnt2 = cnt + 1; if(cnt2>len){ cnt2 = 1;} $(".section1 .slide"+cnt2).css("z-index","3").fadeTo(1000,1).delay(5000).queue(function(){ $(".section1 .slide"+cnt).fadeTo(0,0); $(".section1 .slide"+cnt2).css("z-index","2") $(".section1 .slidebg").not(".section1 .slide"+cnt2).finish().css("z-index","1"); anim(cnt2); }); } function setimg(){ //console.log($(".section4 > .contents > div > div.img").css("margin-right")); if($(".section4 > .contents > div > div.img").css("margin-right") != "0px"){ var num = $(".section4 div.contents").length; for(n=2;n<=(num + 1);n++){ var boxh = $(".section4 > .contents:nth-child("+n+") > div > div.detail").outerHeight(); var imgw = $(".section4 > .contents:nth-child("+n+") > div > div.img").width(); var mh = -40; var imgw2 = $(".section4 > .contents:nth-child("+n+") > div > div.img img").width(); var imgleft = (imgw - imgw2)/2; var wrapbox = $(".section4 > .contents:nth-child("+n+") > div").outerHeight(); var boxh2 = $(".section4 > .contents:nth-child("+n+") > div > div.detail").height(); //console.log(boxh2+":"+wrapbox+":"+(wrapbox - boxh2)); if((wrapbox - boxh2) > 60){ $(".section4 > .contents:nth-child("+n+") > div > div.detail").css("padding-top",((wrapbox - boxh2)/2) + "px"); }else{ $(".section4 > .contents:nth-child("+n+") > div > div.detail").removeAttr("style"); } if((boxh - imgw) > -40) { mh = (boxh - imgw) / 2; } var mh2 = mh*2; if(mh > 0){ mh2 = 0; } var bd = imgw / 2; $(".section4 .contents:nth-child("+n+") > div > div.img").css({"height":imgw + "px","border-radius":bd+"px","-moz-border-radius":bd+"px","-webkit-border-radius":bd+"px","top":mh+"px","margin-bottom":mh2+"px"}); $(".section4 .contents:nth-child("+n+") > div > div.img img").css({"margin-left":imgleft+"px"}); } }else{ $(".section4 .contents > div > div.img, .section4 .contents > div > div.img img").removeAttr("style"); } } function setscrl(){ var scl = $('body').scrollTop(); if(scl==0){scl = $('html').scrollTop();} var maxh = $(document).height() - $(window).height(); var wh = $(window).height(); var set1 = $(".section3").offset().top; var set2 = $(".section4").offset().top; var set3 = $(".section6").offset().top; //console.log(scl+":"+set1+":"+set2+":"+set3+":"+maxh); if(scl > (set1 - (wh/2))) { if(!$(".section3").hasClass("setanim")){ $(".section3").addClass("setanim"); } }else{ if($(".section3").hasClass("setanim")){ $(".section3").removeClass("setanim"); } } if(scl > (set2 - (wh/2))) { if(!$(".section4").hasClass("setanim")){ $(".section4").addClass("setanim"); } }else{ if($(".section4").hasClass("setanim")){ $(".section4").removeClass("setanim"); } } if(scl > (set3 - (wh/2)) || scl>=maxh) { if(!$(".section6").hasClass("setanim")){ $(".section6").addClass("setanim"); $(".section6 ul li img").finish(); startanim(1); } }else{ if(scl <= (set3 - wh)){ if($(".section6").hasClass("setanim")){ $(".section6").removeClass("setanim"); startanim(0); } } } } function setdef(){ var num = $(".section3 .contents > ul").length; for(n=1;n<=num;n++){ $(".section3 .contents > ul:nth-child("+(n+1)+")").css("transition-delay",(0.2 * n)+"s"); } var num = $(".section4 div.contents").length; var del = 0; for(n=2;n<=(num+1);n++){ $(".section4 > .contents:nth-child("+n+") > div > div.detail h2").css("transition-delay",del+"s"); del+=0.2; $(".section4 > .contents:nth-child("+n+") > div > div.detail p").css("transition-delay",del+"s"); del+=0.2; } $(".section3 .contents > ul:nth-child(1) li, .section3 .contents > ul:nth-child(2) li").matchHeight(); } function seth(){ if($("#main .section.section3 .contents ul li p.body").css("font-size")!="14px"){ $(".section3 .contents > ul:nth-child(4) li").removeAttr("style"); $(".section3 .contents > ul:nth-child(3) li").removeAttr("style"); var ul3 = $(".section3 .contents > ul:nth-child(3)").outerHeight(); var ul4 = $(".section3 .contents > ul:nth-child(4)").outerHeight(); //console.log(ul3-ul4); if((ul3 - ul4) < 0 ){ var ulh = $(".section3 .contents > ul:nth-child(3) li").outerHeight(); //console.log(ulh); $(".section3 .contents > ul:nth-child(3) li").css("height",(ulh + (ul4-ul3)) +"px"); $(".section3 .contents > ul:nth-child(4) li").removeAttr("style"); }else{ var ulh = $(".section3 .contents > ul:nth-child(4) li:nth-child(2)").outerHeight(); var ulh2 = ulh + ((ul3-ul4)/2); $(".section3 .contents > ul:nth-child(4) li:nth-child(1)").css("height",ulh2+"px"); $(".section3 .contents > ul:nth-child(4) li:nth-child(2)").css("height",ulh2+"px"); $(".section3 .contents > ul:nth-child(3) li").removeAttr("style"); } }else{ $(".section3 .contents > ul:nth-child(4) li").removeAttr("style"); $(".section3 .contents > ul:nth-child(3) li").removeAttr("style"); } } function startanim(n){ if(n==0){ $(".section6 ul li img").stop().css("display","none").fadeTo(0,0); $(".section6 ul li img").finish(); }else{ $(".section6.setanim ul li:nth-child(1) img").stop().fadeTo(200,1).delay(300).queue(function(){ //alert(1); $(".section6.setanim ul li:nth-child(2) img").stop().fadeTo(200,1).delay(300).queue(function(){ //alert(2); $(".section6.setanim ul li:nth-child(3) img").stop().fadeTo(200,1).delay(300).queue(function(){ n+=1; if(n<=2){ $(".section6 ul li img").stop().css("display","none").fadeTo(0,0).delay(300).queue(function(){ $(".section6 ul li img").finish(); startanim(n); }); } }); }); }); } }