var h1_fadeOut = 0; var h5_fadeOut = 0; var mb_timer = { "change_h1" : null, "change_h5" : null, "fadein_h1" : null, "fadein_h5" : null, "fadeout" : null }; $(function() { var new_sel = 0; var $window = $(window); var $mainVideo = $("#mainVideo"); var $newsWrap = $("#newsWrap > .container"); var $mainSlideImgs = [ 'https://yklaw9.cdn3.cafe24.com/upload/bn/dete_main_banner_pc_20220107162957_0.jpg', 'https://yklaw9.cdn3.cafe24.com/upload/bn/dete_main_banner_pc_20220107162957_1.jpg', 'https://yklaw9.cdn3.cafe24.com/upload/bn/dete_main_banner_20230908112222_2.jpg', 'https://yklaw9.cdn3.cafe24.com/upload/bn/dete_main_banner_pc_20220107162957_3.jpg', 'https://yklaw9.cdn3.cafe24.com/upload/bn/dete_main_banner_20230414174937_4.jpg', 'https://yklaw9.cdn3.cafe24.com/upload/bn/dete_main_banner_20231013101059_5.jpg', ]; // 메인 비디오 스크롤 반응형 동작 /* $window.bind("scroll.sda_video", function(){ if($window.scrollTop() + $window.height() >= (($mainVideo.height() / 2) + $mainVideo.offset().top)){ $mainVideo[0].play(); } else { $mainVideo[0].pause(); } }); */ // 메인 뉴스 스크롤 반응형 동작 $window.bind("scroll.sda_middle", function(){ if($window.scrollTop() + $window.height() >= (($newsWrap.height() / 2) + $newsWrap.offset().top)){ if(!$('.news_wrap .box_L ul li:eq('+new_sel+') a .line').is(":animated")){ rotate_timer(); } } else { $('.news_wrap .box_L ul li a .line').stop().css({"width" : "0%"}); } }); // 메인 이미지 사전 로딩 for(var i = 0; i < $mainSlideImgs.length; i++){ var img = $("
"); img.css({ "background-image": "url(" + $mainSlideImgs[i] + ")" }); $(".visual_inner").append(img); } $.each($(".countdown"), function(i, o){ var $o = $(o), $standard = $o.offset().top, $o_strLen = $o.text().length; if($o.css("opacity") == 0){ $o.css({"opacity" : "", "display" : "none"}); } var counterAnimation = function(){ var $event_ix = i; var $this = $window, $st = $this.scrollTop(), $w_height = $window.height(); if($st + ($w_height - $o.height()) >= $standard){ $o.fadeIn(400); $o.counter({ autoStart: true, duration: 3500, countFrom: 0, countTo: 0, easing: "easeOutCirc", numberFormatter: function(number) { var pad = function(n, width) { n = n + ''; return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n; }; return pad(Math.floor(number),4); } }); $window.unbind("scroll.counter_" + $event_ix); } }; $window.bind("scroll.counter_" + i, function(){ counterAnimation(); }); counterAnimation(); }); // insight var mainsuccessRollingTimer = null, mainsuccessRollingIx = 1; $('.success:not(:eq(0)) > a > div > .insight_txt').hide(); $('.success:eq(0)').addClass('active'); setMainsuccessRolling(); //var num=0; $('.success > a').click(function(event) { if (!$(this).parent().is(":hover")) { setMainsuccessRolling(); } if (!$(this).parent().hasClass("active")) { mainsuccessRollingIx = $(".success").index($(this).parent()) + 1; if (mainsuccessRollingIx > $(".success").length - 1) { mainsuccessRollingIx = 0; } $('.success').removeClass('active'); $(this).parent().addClass('active'); event.preventDefault(); num = $(this).parent().index(); changeImg(num); var $this = $(this), $siblings = $this.parent().siblings(".success"); $this.find(".insight_txt").stop().slideDown(); $siblings.find(".insight_txt").stop().slideUp(); } }); $('.img_num li a').click(function(e) { e.preventDefault(); num = $(this).parent().index(); changeImg(num); }); $('.img_slide li a').click(function(e) { e.preventDefault(); }); function changeImg(num) { $('.img_num li.active').removeClass('active'); $('.img_num li').eq(num).addClass('active'); $('.img_slide').stop().animate({ left: -465 * num }, 700) } function setMainsuccessRolling() { clearInterval(mainsuccessRollingTimer); mainsuccessRollingTimer = setInterval(function() { $('.success:eq(' + mainsuccessRollingIx + ') > a').trigger("click"); }, 3500); } $(".success").bind("mouseenter", function() { clearInterval(mainsuccessRollingTimer); }); $(".success").bind("mouseleave", function() { setMainsuccessRolling(); }); // review var slide02moving = false; $('.review_wrap .prevBtn').click(function() { if (!slide02moving) { slide02moving = true; $('.review_wrap .box_R ul li:first').clone().appendTo('.review_wrap .box_R ul'); //clone:! $('.review_wrap .box_R ul').stop().animate({ left: '-=310px' }, 600, function() { slide02moving = false; $('.review_wrap .box_R ul li:first').remove(); $('.review_wrap .box_R ul').css({ left: '+=310px' }); }); } }); $('.review_wrap .nextBtn').click(function() { if (!slide02moving) { slide02moving = true; $('.review_wrap .box_R ul li:last').clone().prependTo('.review_wrap .box_R ul'); //clone:! $('.review_wrap .box_R ul').css({ left: '-=310px' }); $('.review_wrap .box_R ul').stop().animate({ left: '+=310px' }, 600, function() { slide02moving = false; $('.review_wrap .box_R ul li:last').remove(); }); }; }); $('.news_wrap .box_L ul li').bind("click",function(e){ news_select($(this).index()); new_sel=$(this).index(); e.preventDefault(); $('.news_wrap .box_L ul li a .line').css({'width':'0%'}).clearQueue().stop(); rotate_timer(); }) $('.slidewrap').hover(function(){ $('.news_wrap .box_L ul li:eq('+new_sel+') a .line').pause(); },function(){ $('.news_wrap .box_L ul li:eq('+new_sel+') a .line').resume(); }) function rotate_timer(){ $('.news_wrap .box_L ul li:eq('+new_sel+') a .line').stop().css({'width':'0%'}).animate({'width':'100%'}, 7000,"linear", function(){ $('.news_wrap .box_L ul li a .line').css({'width':'0%'}) new_sel++; if(new_sel==3){ new_sel=0; } news_select(new_sel) rotate_timer(); }); } function news_select(p){ $('.news_wrap .box_L ul li').removeClass('active') $('.news_slide ul.slideul li').removeClass('active'); $('.news_wrap .box_L ul li:eq('+p+')').addClass('active') $('.news_slide ul.slideul > li:eq('+p+')').addClass('active'); } var main_sel=0; $('.main_bottom .container > a').bind("click",function(e){ main_select($(this).index()); main_sel=$(this).index(); e.preventDefault(); $('.main_bottom .container a .show_box .line').css({'width':'0%'}).clearQueue().stop(); main_rotate_timer(); //$('.main_banner .visual_inner > div').removeClass('active'); }); function getRandomIntInclusive(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function textSplit(target){ var input=""; var txt=""; var text=$(target).text(); for(i=0; i <= text.length-1; i++){ if(text.substr(i,1)==" "){ input = " " txt += "" + input + ""; } else if(text.substr(i,1)=="|"){ input = "
"; txt += input; } else if(text.substr(i,1)=="/" && opts.ignored.indexOf("/") == -1){ input = "
"; txt += input; } else { input = text.substr(i,1); txt += ""+input+""; } } $(target).html(txt); } main_rotate_timer(); function main_rotate_timer(){ clearInterval(mb_timer.change_h1); clearInterval(mb_timer.change_h5); clearInterval(mb_timer.fadein_h1); clearInterval(mb_timer.fadein_h5); clearInterval(mb_timer.fadeout); switch(main_sel){ case 0 : mb_timer.change_h1 = setTimeout(function(){ $(".main_banner .textwrap h1.title").html("형사사건, 누구나 말할 수 있지만|아무나 증명할 수 없습니다.");textSplit('.main_banner .textwrap h1.title'); }, h1_fadeOut); mb_timer.change_h5 = setTimeout(function(){$(".main_banner .textwrap h5.title").html("In criminal cases; many might say it, but only few can prove it.");textSplit('.main_banner .textwrap h5.title'); }, h5_fadeOut); break; case 1 : mb_timer.change_h1 = setTimeout(function(){ $(".main_banner .textwrap h1.title").html("억울하고 어려운 형사사건, |우리는 당신 편이 될 것입니다.");textSplit('.main_banner .textwrap h1.title'); }, h1_fadeOut); mb_timer.change_h5 = setTimeout(function(){$(".main_banner .textwrap h5.title").html("For the falsely accused, a competitive and talented team of |criminal defense attorneys will always be at your side.");textSplit('.main_banner .textwrap h5.title'); }, h5_fadeOut); break; case 2 : mb_timer.change_h1 = setTimeout(function(){ $(".main_banner .textwrap h1.title").html("신뢰받는 로펌 YK.");textSplit('.main_banner .textwrap h1.title'); }, h1_fadeOut); mb_timer.change_h5 = setTimeout(function(){$(".main_banner .textwrap h5.title").html("Trusted Lawfirm ‘YK’");textSplit('.main_banner .textwrap h5.title'); }, h5_fadeOut); break; case 3 : mb_timer.change_h1 = setTimeout(function(){ $(".main_banner .textwrap h1.title").html("선택하세요. |당신의 가장 가까운 곳에 YK가 있습니다.");textSplit('.main_banner .textwrap h1.title'); }, h1_fadeOut); mb_timer.change_h5 = setTimeout(function(){$(".main_banner .textwrap h5.title").html("Your selection is correct. |YK is closest to you.");textSplit('.main_banner .textwrap h5.title'); }, h5_fadeOut); break; case 4 : mb_timer.change_h1 = setTimeout(function(){ $(".main_banner .textwrap h1.title").html("");textSplit('.main_banner .textwrap h1.title'); }, h1_fadeOut); mb_timer.change_h5 = setTimeout(function(){$(".main_banner .textwrap h5.title").html("");textSplit('.main_banner .textwrap h5.title'); }, h5_fadeOut); break; case 5 : mb_timer.change_h1 = setTimeout(function(){ $(".main_banner .textwrap h1.title").html("단기간 이뤄낸 성장과 규모|결과로 증명해 내겠습니다.");textSplit('.main_banner .textwrap h1.title'); }, h1_fadeOut); mb_timer.change_h5 = setTimeout(function(){$(".main_banner .textwrap h5.title").html("Prove as a result");textSplit('.main_banner .textwrap h5.title'); }, h5_fadeOut); break; } mb_timer.fadein_h1 = setTimeout(function(){ $('.main_banner .textwrap h1.title span').each(function(e) { $(this).clearQueue().stop().delay(getRandomIntInclusive(800, 000)).animate({ 'opacity': '1' }, 1500) }); }, h1_fadeOut + 100); mb_timer.fadein_h5 = setTimeout(function(){ $('.main_banner .textwrap h5.title span').each(function(e) { $(this).clearQueue().stop().delay(getRandomIntInclusive(800, 000)).animate({ 'opacity': '1' }, 1500) }); }, h5_fadeOut + 100); var $main_sel_next = $('.main_banner .visual_inner > div:eq(' + main_sel + ')'); $('.main_banner .visual_inner > div').not($main_sel_next).removeClass("active").css("z-index", ""); $main_sel_next.css({'z-index':'1'}).addClass('active'); if (main_sel==0) { setTimeout(function() { $('#snap1').css('display','none'); $('#snap2').fadeIn(); }, 3500); setTimeout(function() { $('#snap1').css('display','block'); $('#snap2').css('display','none'); }, 7000); } $('.main_bottom .container a:eq('+main_sel+') .show_box .line').stop().css({'width':'0%'}).animate({'width':'100%'}, 7000,"linear", function(){ $('.main_bottom .container a .show_box .line').css({'width':'0%'}) main_sel++; if(main_sel==6){ main_sel=0; } main_select(main_sel); main_rotate_timer(); }); mb_timer.fadeout = setTimeout(function(){ if($(".main_banner .textwrap h1.title").find("span").length > 0){ $('.main_banner .textwrap h1.title span').each(function(e) { $(this).clearQueue().stop().delay(getRandomIntInclusive(800, 000)).animate({ 'opacity': '0' }, 1500); }); } if($(".main_banner .textwrap h5.title").find("span").length > 0){ $('.main_banner .textwrap h5.title span').each(function(e) { $(this).clearQueue().stop().delay(getRandomIntInclusive(800, 000)).animate({ 'opacity': '0' }, 1500); }); } }, 4800); } function main_select(p){ $('.main_bottom .container > a').removeClass('active') // $('.news_slide ul.slideul li').removeClass('active'); $('.main_bottom .container > a:eq('+p+')').addClass('active') // $('.news_slide ul.slideul > li:eq('+p+')').addClass('active'); } });