/* =========================================
==== 주의 ==================================
web, mobile 공통 js
============================================
========================================== */
$(document).ready(function(){

	$('img[usemap]').rwdImageMaps();

	$('.info20200325 .info_slider .slider_tab > div').slick({
		slidesToShow: 8,
		asNavFor: '.info20200325 .info_slider .slider_con',
		dots: false,
		focusOnSelect: true,
		arrows: false,
		infinite: false,
		variableWidth: false,
	});
	$('.info20200325 .info_slider .slider_con').slick({
		dots: false,
		infinite: true,
		slidesToShow:1,
		slidesToScroll: 1,
		speed: 400,
		autoplay : false,
		autoplaySpeed: 5000,
		cssEase: 'ease-in-out',
		arrows: false,
		swipe : true,
		focusOnSelect: true,
		variableWidth: false,
		adaptiveHeight: true,
		asNavFor: '.info20200325 .info_slider .slider_tab > div',
	});

	$('.info20200518 .info_slider .slider_tab > div').slick({
		slidesToShow: 10,
		asNavFor: '.info20200518 .info_slider .slider_con',
		dots: false,
		focusOnSelect: true,
		arrows: false,
		infinite: false,
		variableWidth: false,
	});
	$('.info20200518 .info_slider .slider_con').slick({
		dots: false,
		infinite: true,
		slidesToShow:1,
		slidesToScroll: 1,
		speed: 400,
		autoplay : false,
		autoplaySpeed: 5000,
		cssEase: 'ease-in-out',
		arrows: false,
		swipe : true,
		focusOnSelect: true,
		variableWidth: false,
		adaptiveHeight: true,
		asNavFor: '.info20200518 .info_slider .slider_tab > div',
	});

	$('.weekend20200709 .weekend_slider .slider_tab').slick({
		slidesToShow: 20,
		asNavFor: '.weekend20200709  .weekend_slider .slider_con',
		dots: false,
		focusOnSelect: true,
		arrows: false,
		infinite: false,
		variableWidth: false,
		adaptiveHeight: true,
	});
	$('.weekend20200709  .weekend_slider .slider_con').slick({
		dots: false,
		infinite: true,
		slidesToShow:1,
		slidesToScroll: 1,
		speed: 400,
		//autoplay : true,
		//autoplaySpeed: 5000,
		cssEase: 'ease-in-out',
		arrows: false,
		swipe : true,
		focusOnSelect: true,
		variableWidth: false,
		adaptiveHeight: true,
		asNavFor: '.weekend20200709  .weekend_slider .slider_tab',
	});

	$('.weekend_slider.st1 .slider_tab').slick({
		slidesToShow: 3,
		asNavFor: '.weekend_slider.st1 .slider_con',
		dots: false,
		focusOnSelect: true,
		arrows: false,
		infinite: false,
		variableWidth: true,
		adaptiveHeight: true,
	});
	$('.weekend_slider.st1 .slider_con').slick({
		dots: false,
		infinite: true,
		slidesToShow:1,
		slidesToScroll: 1,
		speed: 400,
		//autoplay : true,
		//autoplaySpeed: 5000,
		cssEase: 'ease-in-out',
		arrows: false,
		swipe : true,
		focusOnSelect: true,
		variableWidth: false,
		adaptiveHeight: true,
		asNavFor: '.weekend_slider.st1 .slider_tab',
	});

	$('.weekend_slider.st2 .slider_tab').slick({
		slidesToShow: 18,
		asNavFor: '.weekend_slider.st2 .slider_con',
		dots: false,
		focusOnSelect: true,
		arrows: false,
		infinite: false,
		variableWidth: true,
		adaptiveHeight: true,
	});
	$('.weekend_slider.st2 .slider_con').slick({
		dots: false,
		infinite: true,
		slidesToShow:1,
		slidesToScroll: 1,
		speed: 400,
		//autoplay : true,
		//autoplaySpeed: 5000,
		cssEase: 'ease-in-out',
		arrows: false,
		swipe : true,
		focusOnSelect: true,
		variableWidth: false,
		adaptiveHeight: true,
		fade: true,
		asNavFor: '.weekend_slider.st2 .slider_tab',
	});

	/* 오디오 설정 */
	var audio = new Audio();
	$('.weekend20200910 .weekend_slider .slider_con .audio_list ul li .box button').click(function() {
		var class_id = $(this).attr('id');
		console.log(class_id);
		switch (class_id) {
			case "playlist01":
				audio.src = 'https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileMediaPlay.do?fileTp=audio/mp3&filePath=L2Rpc2sxL25ld2RhdGEvMjAxOS8yMS9DTFMxMDAwMi8xMzIyMDc1M19XUlRfMjAxOTExMjFfMQ==';
				audio.type = 'audio/mp3';
				break;
			case "playlist02":
				audio.src = 'https://static.wixstatic.com/preview/4159e6_24a55ec40e814b189d10138c8e6ff5c5-128.mp3';
				audio.type = 'audio/mp3';
				break;
			case "playlist03":
				audio.src = 'https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileMediaPlay.do?fileTp=audio/mp3&filePath=L2Rpc2sxL25ld2RhdGEvMjAxOS8yMS9DTFMxMDAwMi8xMzIyMDk5MF9XUlRfMjAxOTExMjFfMQ==';
				audio.type = 'audio/mp3';
				break;
			case "playlist04":
				audio.src = 'https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileMediaPlay.do?fileTp=audio/mp3&filePath=L2Rpc2sxL25ld2RhdGEvMjAxOS8yMS9DTFMxMDAwMi8xMzIyMDczN19XUlRfMjAxOTExMjFfMQ==';
				audio.type = 'audio/mp3';
				break;
			case "playlist05":
				audio.src = 'https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileMediaPlay.do?fileTp=audio/mp3&filePath=L2Rpc2sxL25ld2RhdGEvMjAxOS8yMS9DTFMxMDAwMi8xMzIyMDc1Nl9XUlRfMjAxOTExMjFfMQ==';
				audio.type = 'audio/mp3';
				break;
			case "playlist06":
				audio.src = 'https://static.wixstatic.com/preview/4159e6_3d6035357cdc40e79293b24d8deb258a-128.mp3';
				audio.type = 'audio/mp3';
				break;
			case "playlist07":
				audio.src = 'https://static.wixstatic.com/preview/4159e6_c11f639420494120a570924cbc9416b3-128.mp3';
				audio.type = 'audio/mp3';
				break;
			case "playlist08":
				audio.src = 'https://static.wixstatic.com/preview/4159e6_328baebb0a0645f297db4f6faddf3a5a-128.mp3';
				audio.type = 'audio/mp3';
				break;
			case "playlist09":
				audio.src = 'https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileMediaPlay.do?fileTp=audio/mp3&filePath=L2Rpc2sxL25ld2RhdGEvMjAxOS8yMS9DTFMxMDAwMi8xMzIyMDc4Nl9XUlRfMjAxOTExMjFfMQ==';
				audio.type = 'audio/mp3';
				break;
			case "playlist10":
				audio.src = 'https://static.wixstatic.com/preview/4159e6_795d412bfe634d3e95fe9b04146c5097-128.mp3';
				audio.type = 'audio/mp3';
				break;
			case "playlist11":
				audio.src = 'https://static.wixstatic.com/preview/4159e6_54efb62919df465e93988d022962120f-128.mp3';
				audio.type = 'audio/mp3';
				break;
			case "playlist12":
				audio.src = 'https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileMediaPlay.do?fileTp=audio/mp3&filePath=L2Rpc2sxL25ld2RhdGEvMjAxOS8yMS9DTFMxMDAwMi8xMzIyMDg0MV9XUlRfMjAxOTExMjFfMQ==';
				audio.type = 'audio/mp3';
				break;
		}

		if($(this).text() == '시작' ){
			audio.play();
			$('.weekend20200910 .weekend_slider .slider_con .audio_list ul li .box button').not(this).parent().removeClass('rotation');
			$('.weekend20200910 .weekend_slider .slider_con .audio_list ul li .box button').not(this).removeClass('pause');
			$('.weekend20200910 .weekend_slider .slider_con .audio_list ul li .box button').not(this).text('시작');
			$(this).text('멈춤');
			$(this).addClass('pause');
			$(this).parent().addClass('rotation');
		}else{
			audio.pause()
			$(this).text('시작');
			$(this).removeClass('pause');
			$(this).parent().removeClass('rotation');
		}

	});


	$(".weekend_section_info div.wrow:first-child").css("height", $('.weekend_section_info .wrow .wcol:first-child .txt').outerHeight() + $(".weekend_section_info .wcol.on button").height());

	$(".weekend_section_info button").click(function(){
		var btnH = $(this).outerHeight();
		$(this).parent().addClass("on").siblings().removeClass("on");
		$(this).parent().parent().css('height', $(this).next('.txt').outerHeight() + btnH);
		$(this).parent().parent().siblings().removeAttr("style").children().removeClass("on");
		$('.weekend_slider.st1 .slider_con').slick('resize');
	});

	$(window).resize(function(){
		var btnH = $(".weekend_section_info .wcol.on button").height();
		$(".weekend_section_info .wcol.on button").parent().parent().css("height", $('.weekend_section_info .wcol.on .txt').outerHeight()+ btnH);
	});

	$('.info20211115 .info_slider .slider_tab > div').slick({
		slidesToShow: 10,
		asNavFor: '.info20211115 .info_slider .slider_con',
		dots: false,
		focusOnSelect: true,
		arrows: false,
		infinite: false,
		variableWidth: false,
	});
	$('.info20211115 .info_slider .slider_con').slick({
		dots: false,
		infinite: true,
		slidesToShow:1,
		slidesToScroll: 1,
		speed: 400,
		autoplay : false,
		autoplaySpeed: 5000,
		cssEase: 'ease-in-out',
		arrows: false,
		swipe : true,
		focusOnSelect: true,
		variableWidth: false,
		adaptiveHeight: true,
		asNavFor: '.info20211115 .info_slider .slider_tab > div',
	}).on('afterChange', function(event, slick, currentSlide, nextSlide){
		$(".info20211115 .info_box_txt ul li").each(function(i){
			if(i + 1 == currentSlide+1){
				$(this).show();
			}else{
				$(this).hide();
			}
		});
	});

	$(".weekend_section_tab a").click(function(e){
		$(this).parent().addClass('active').siblings().removeClass("active");
		$(this.hash).show().siblings(".weekend_section_tab_cont").hide();
		$('.weekend_slider.st1 .slider_con').slick('resize');
		$('.weekend_slider.st1 .slider_con').slick('init');
		$('.weekend_slider_type1').slick('setPosition');
		e.preventDefault();
	});

	/*
	$(".weekend202120318 .weekend_tab li:first-child").addClass("active");
	$(".weekend202120318 .weekend_tab a").click(function(){
		$(this).parent().addClass('active').siblings().removeClass("active");
		$(this.hash).show().siblings(".weekend_tab_cont").hide();
		return false;
	});
	*/

	$('.weekend_tab button').on('click',function(e){
		$(this).parent().addClass('active').siblings().removeClass("active");
		var idx = $(this).parent().index();
		$(this).parent().parent().parent().next().children('.weekend_tab_cont').eq(idx).show().siblings(".weekend_tab_cont").hide();
		$('.weekend_slider_type1').slick('setPosition');
		e.preventDefault();
	});

	$('.weekend_slider_type1').slick({
		slidesToShow: 1,
		slidesToScroll: 1,
		infinite: true,
		arrows: true,
		dots: true,
		adaptiveHeight:true,
		speed: 800
	});

	$('.weekend20221007_info .map_c1').on('click',function(e){
		$("html").animate({scrollTop:$(".weekend20221007_info #mapc").offset().top},300);
		$('.weekend20221007_info .weekend_tab ul li:nth-child(1)').addClass('active');
		$('.weekend20221007_info .weekend_tab ul li:nth-child(2)').removeClass('active');
		$('.weekend20221007_info .weekend_tab ul li:nth-child(3)').removeClass('active');
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(1)').show();
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(2)').hide();
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(3)').hide();
		$('.weekend_slider_type1').slick('setPosition');
		e.preventDefault();
	});
	$('.weekend20221007_info .map_c2').on('click',function(e){
		$("html").animate({scrollTop:$(".weekend20221007_info #mapc").offset().top},300);
		$('.weekend20221007_info .weekend_tab ul li:nth-child(2)').addClass('active');
		$('.weekend20221007_info .weekend_tab ul li:nth-child(1)').removeClass('active');
		$('.weekend20221007_info .weekend_tab ul li:nth-child(3)').removeClass('active');
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(2)').show();
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(3)').hide();
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(1)').hide();
		$('.weekend_slider_type1').slick('setPosition');
		e.preventDefault();
	});
	$('.weekend20221007_info .map_c3').on('click',function(e){
		$("html").animate({scrollTop:$(".weekend20221007_info #mapc").offset().top},300);
		$('.weekend20221007_info .weekend_tab ul li:nth-child(3)').addClass('active');
		$('.weekend20221007_info .weekend_tab ul li:nth-child(1)').removeClass('active');
		$('.weekend20221007_info .weekend_tab ul li:nth-child(2)').removeClass('active');
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(3)').show();
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(1)').hide();
		$('.weekend20221007_info .weekend_tab_cont_wrap > div:nth-child(2)').hide();
		$('.weekend_slider_type1').slick('setPosition');
		e.preventDefault();
	});

	$('.weekend20230420 .weekend_tab button').on('click',function(e){
		$("html").animate({scrollTop:$(".weekend20230420 .weekend_tab_cont_wrap").offset().top - 100},300);
		e.preventDefault();
	});

	$('.notify_event .terms_open').click(function(){
		$('.notify_event .terms').fadeIn();
		return false;
	});
	$('.notify_event .terms_close').click(function(){
		$('.notify_event .terms').fadeOut();
		return false;
	});

	$('.weekend20231110 .map_img .mapGo').on('click',function(e){
		var idx = $('.weekend20231110 .map_img .mapGo').index(this),
			tab = $('.weekend20231110 .tab_wrap .tab ul li').eq(idx + 1);
		tab.addClass('active').children('button').attr('title','선택됨');
		tab.siblings().removeClass('active').children('button').attr('title','');
		$('.weekend20231110 .tab_cont_t .cont').eq(idx + 1).show().siblings(".weekend20231110 .tab_cont_t .cont").hide();
		$("html").animate({scrollTop:$(".weekend20231110 .tab_wrap").offset().top - 100},300);
	});

	$('.weekend20231110 .tab_wrap .tab button').on('click',function(e){
		$(this).parent().addClass('active').siblings().removeClass("active");
		var idx = $(this).parent().index();
		$(this).parent().addClass('active').children('button').attr('title','선택됨');
		$(this).parent().siblings().removeClass('active').children('button').attr('title','');
		$('.weekend20231110 .tab_cont_t .cont').eq(idx).show().siblings(".weekend20231110 .tab_cont_t .cont").hide();
		$("html").animate({scrollTop:$(".weekend20231110 .tab_wrap").offset().top - 100},300);
	});

	$('.Olympics2024paris .tab_wrap .tab button').on('click',function(e){
		$(this).parent().addClass('active').siblings().removeClass("active");
		var idx = $(this).parent().index();
		$(this).parent().addClass('active').children('button').attr('title','선택됨');
		$(this).parent().siblings().removeClass('active').children('button').attr('title','');
		$('.Olympics2024paris .tab_cont_t .cont').eq(idx).addClass('active').siblings('.Olympics2024paris .tab_cont_t .cont').removeClass('active');
		$("html").animate({scrollTop:$('.Olympics2024paris .tab_cont_t').offset().top - 100},300);
		playerListMore();
	});
	playerListMore();

	function playerListMore() {
		$('.Olympics2024paris .tab_cont_t .cont.active .player_list > li').slice(0, 9).css("display", "block");
		if($('.Olympics2024paris .tab_cont_t .cont.active .player_list > li:hidden').length == 0){
			$('.Olympics2024paris .tab_cont_t .cont.active .player_list_more').hide();
		}
		$('.Olympics2024paris .tab_cont_t .cont.active .player_list_more').off().on('click',function(e){
			e.preventDefault();
			$(this).parent().find('.player_list > li:hidden').slice(0, 9).addClass('active');
			if($(this).parent().find('.player_list > li:hidden').length == 0){
				$(this).hide();
			}
		});
	};


	$('.weekend20241008 .top_wrap .mapGo').on('click', function(e) {
		$('html').animate({scrollTop : $(this.hash).offset().top},300);
	});
	$('.weekend20241008 .tab_wrap .tab button').on('click',function(e){
		$(this).parent().addClass('active').siblings().removeClass("active");
		var idx = $(this).parent().index();
		$(this).parent().addClass('active').children('button').attr('title','선택됨');
		$(this).parent().siblings().removeClass('active').children('button').attr('title','');
		$("html").animate({scrollTop:$('.weekend20241008 .tab_cont_t .cont').eq(idx).offset().top},300);
		//$('.weekend20241008 .tab_cont_t .cont').eq(idx).show().siblings(".weekend20231110 .tab_cont_t .cont").hide();
		//$("html").animate({scrollTop:$(".weekend20241008 .tab_wrap").offset().top - 100},300);
	});
	$('.weekend20241008 .tab_wrap .tab_cont_t .cont .btn_layerpop').on('click',function(e){
		$(this).parent().next('.layerpop').addClass('active');
		return false;
	});
	$('.weekend20241008 .layerpop .close').on('click',function(e){
		$('.weekend20241008 .layerpop').removeClass('active');
		return false;
	});
	if($('.weekend20241008 .layerpop .alink').length > 0){
		$(document).on('click', function(e) {
			if(!$('.weekend20241008 .layerpop .alink').is(e.target) && $('.weekend20241008 .layerpop .alink').has(e.target).length === 0){
				$('.weekend20241008 .layerpop').removeClass('active');
			}
		});
	}
	
	$('.weekend20250318 .weekend_tab button').on('click',function(e){
		$("html").animate({scrollTop:$(".weekend20250318 .weekend_tab_cont_wrap").offset().top - 150},300);
		e.preventDefault();
	}); 
	
});