//부드러운 스크롤
$(document).ready(function()
{
$("#top").css("cursor", "pointer").click(function()
{
    $('body, html').animate({scrollTop:0}, 300);
});
$("#top2").css("cursor", "pointer").click(function()
{
    $('body, html').animate({scrollTop:0}, 300);
});
});

function fncCheckAll() {
	let checkField = document.listForm.checkField;
	if (document.listForm.checkAll.checked) {
		if (checkField) {
			if (checkField.length > 1) {
				for (let i = 0; i < checkField.length; i++) {
					checkField[i].checked = true;
				}
			} else {
				checkField.checked = true;
			}
		}
	} else {
		if (checkField) {
			if (checkField.length > 1) {
				for (let j = 0; j < checkField.length; j++) {
					checkField[j].checked = false;
				}
			} else {
				checkField.checked = false;
			}
		}
	}
}



// 탭 메뉴 
function tab_menu(num){	
	var f = $('.menu_tab').find('li');
	for ( var i = 0; i < f.length; i++ ) {			
		if ( i == num) {			
			f.eq(i).addClass('active');	
			$('.menu_tab0' + i ).show();
		} else {
			f.eq(i).removeClass('active');					
			$('.menu_tab0' + i ).hide();
		}
	}
}
//faq

$(function(){
	$(".qna dd:not(:first)").css("display","none");
	$("dt:first").addClass("selected");
	$("dl dt").click(function(){
		if($("+dd",this).css("display")=="none"){
			$("dd").slideUp("fast");
			$("+dd",this).slideDown("fast");
			$("dt").removeClass("selected");
			$(this).addClass("selected");
		}
	}).mouseover(function(){
		$(this).addClass("over");
	}).mouseout(function(){
		$(this).removeClass("over");
	});
});

class FormValidator {
	constructor(selector, validateFunction, message, extraValidation) {
		this.form = document.querySelector(selector);
		this.validateFunction = validateFunction;
		this.confirmMessage = message;
		this.extraValidation = extraValidation;
	}
	validate(){
		return this.validateFunction(this.form);
	}
	submit(){
		if (!this.validate(this.form)) {
			return false;
		} else {
			if (this.extraValidation && !this.extraValidation(this.form)) {
				this.extraValidation(this.form);
			}

			if (confirm(this.confirmMessage)) {
				this.form.submit();
			}
		}
	}
}
