$( document ).ready(function() {

	
	
});


/* 스크롤 위치에 따른 메뉴 효과 */
$(window).scroll(function(){

	var headerBodytId3 = $("#header");
	var headerBodytId3Height = headerBodytId3.height();
	var naviGuideLineTop = document.querySelector("#navi_guide_line").offsetTop - headerBodytId3Height + 55;

	if($(this).scrollTop() < naviGuideLineTop){
		// naviMenuBodyId.classList.remove("navi_menu_body_id");
        $('#navi_menu').removeClass('navi_menu_body_id');
	} 
	else if($(this).scrollTop() >= naviGuideLineTop){
		// naviMenuBodyId.classList.add("navi_menu_body_id");
		$('#navi_menu').addClass('navi_menu_body_id');
	} 

});



/* ※ 탑 이동 버튼 fade 효과 ※ */
/* $(window).scroll(function(){
	var section2Location = document.querySelector(".samsung_section2").offsetTop;
	if ($(this).scrollTop() > section2Location){
		$("#top_button").fadeIn(400);
	} else {
		$("#top_button").fadeOut(400);
	}
}); */



/* ※ 탑 이동 버튼 ※ */
/* function scrollHeader(n){
	$('html, body').stop().animate({
		scrollTop : $('#header_top').eq(n).offset().top
	}, 1000);
} */



/* 메뉴버튼 클릭시 스크롤 페이지 이동 효과 */
function scrollPage(n){

	var headerBodytId1 = $("#header");
	var headerBodytId1Height = headerBodytId1.height();

	var naviMenuId1 = $("#navi_menu");
	var naviMenuId1Height = naviMenuId1.height();

	var windowWidth = document.body.offsetWidth;
	/*     pc = min width 1024.99; */
	/* tablet = max width 1024.98; */
	/*        = min width 767.99; */
	/* mobile = max width 767.98; */
	
	var customNumberA = 1024.98;
	var customNumberB = 767.98;

	if(customNumberB >= windowWidth){
		/* mobile */
		$('html, body').stop().animate({
			scrollTop : $('.samsung_kiosk_wrap .section_point').eq(n).offset().top - naviMenuId1Height - headerBodytId1Height - 45
		}, 1000);
	} else if(customNumberB < windowWidth && customNumberA >= windowWidth){
		/* tablet */
		$('html, body').stop().animate({
			scrollTop : $('.samsung_kiosk_wrap .section_point').eq(n).offset().top - naviMenuId1Height - headerBodytId1Height - 45
		}, 1000);
	} else if(customNumberA < windowWidth){
		/* pc */
		$('html, body').stop().animate({
			scrollTop : $('.samsung_kiosk_wrap .section_point').eq(n).offset().top - naviMenuId1Height - headerBodytId1Height + 55
		}, 1000);
	};
	
}



/* 가로 세로 길이 값 구하기 */
/* $(document).ready(function(){
	var element = $(".samsung_section1");

	alert("height : "+element.height());
	alert("width : "+element.width());

	alert("padding + border + height : "+element.outerHeight());
	alert("padding + border + width : "+element.outerWidth());

	alert("padding + margin + border + height : "+element.outerHeight(true));
	alert("padding + margin + border + width : "+element.outerWidth(true));
}); */



/* 스크롤 페이지 이동시 메뉴 언더바 효과 */
$(window).scroll(function(){

	var headerBodytId2 = $("#header");
	var headerBodytId2Height = headerBodytId2.height();

	var naviMenuId2 = $("#navi_menu");
	var naviMenuId2Height = naviMenuId2.height();

	var windowWidth = document.body.offsetWidth;
	/*     pc = min width 1024.99; */
	/* tablet = max width 1024.98; */
	/*        = min width 767.99; */
	/* mobile = max width 767.98; */
	
	var customNumberA = 1024.98;
	var customNumberB = 767.98;

	if(customNumberB >= windowWidth){
		/* mobile */
		var section1Top = document.querySelector(".samsung_section1").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section2Top = document.querySelector(".samsung_section2").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section3Top = document.querySelector(".samsung_section3").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section4Top = document.querySelector(".samsung_section4").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section5Top = document.querySelector(".samsung_section5").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
	} else if(customNumberB < windowWidth && customNumberA >= windowWidth){
		/* tablet */
		var section1Top = document.querySelector(".samsung_section1").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section2Top = document.querySelector(".samsung_section2").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section3Top = document.querySelector(".samsung_section3").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section4Top = document.querySelector(".samsung_section4").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
		var section5Top = document.querySelector(".samsung_section5").offsetTop - naviMenuId2Height - headerBodytId2Height - 48;
	} else if(customNumberA < windowWidth){
		/* pc */
		var section1Top = document.querySelector(".samsung_section1").offsetTop - naviMenuId2Height - headerBodytId2Height + 52;
		var section2Top = document.querySelector(".samsung_section2").offsetTop - naviMenuId2Height - headerBodytId2Height + 52;
		var section3Top = document.querySelector(".samsung_section3").offsetTop - naviMenuId2Height - headerBodytId2Height + 52;
		var section4Top = document.querySelector(".samsung_section4").offsetTop - naviMenuId2Height - headerBodytId2Height + 52;
		var section5Top = document.querySelector(".samsung_section5").offsetTop - naviMenuId2Height - headerBodytId2Height + 52;
	};

	var naviLi = $('.navi_menu_li');
	var naviSpan = $('.navi_menu_span');

	if($(this).scrollTop() < section1Top){
		// console.log('메인');
		naviLi.find('.navi_menu1_span').addClass('active');
		naviSpan.not('.navi_menu1_span').removeClass('active');
	} 
	else if($(this).scrollTop() >= section1Top && $(this).scrollTop() < section2Top){
		// console.log('상담');
		naviLi.find('.navi_menu1_span').addClass('active');
		naviSpan.not('.navi_menu1_span').removeClass('active');
	} 
	else if($(this).scrollTop() >= section2Top && $(this).scrollTop() < section3Top){
		// console.log('렌탈');		
		naviLi.find('.navi_menu2_span').addClass('active');
		naviSpan.not('.navi_menu2_span').removeClass('active');
	} 
	else if($(this).scrollTop() >= section3Top && $(this).scrollTop() < section4Top){
		// console.log('특장점');
		naviLi.find('.navi_menu3_span').addClass('active');
		naviSpan.not('.navi_menu3_span').removeClass('active');
	} 
	else if($(this).scrollTop() >= section4Top && $(this).scrollTop() < section5Top){
		// console.log('디자인');
		naviLi.find('.navi_menu4_span').addClass('active');
		naviSpan.not('.navi_menu4_span').removeClass('active');
	} 
	else if($(this).scrollTop() >= section5Top){
		// console.log('주요스펙');
		naviLi.find('.navi_menu5_span').addClass('active');
		naviSpan.not('.navi_menu5_span').removeClass('active');
	}
});


