/* 머티리얼 추가 */
$(document).ready(function () {
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('.modal-trigger').leanModal();
$('select').material_select();
$(".phone-auto").keyup( function () {
this.value = autoHypenPhone(this.value);
});
});
function autoHypenPhone(str){
str = str.replace(/[^0-9]/g, '');
var tmp = '';
if( str.length < 4){
return str;
}else if(str.length < 7){
tmp += str.substr(0, 3);
tmp += '-';
tmp += str.substr(3);
return tmp;
}else if(str.length < 11){
var sn = str.substr(0, 2);
if(sn=="02") {
tmp += str.substr(0, 2);
tmp += '-';
tmp += str.substr(2, 4);
tmp += '-';
tmp += str.substr(6);
} else {
tmp += str.substr(0, 3);
tmp += '-';
tmp += str.substr(3, 3);
tmp += '-';
tmp += str.substr(6);
}
return tmp;
}else{
tmp += str.substr(0, 3);
tmp += '-';
tmp += str.substr(3, 4);
tmp += '-';
tmp += str.substr(7);
return tmp;
}
return str;
}
(function ($) {
$(function () {
$('.button-collapse').sideNav();
$('.parallax').parallax();
}); // end of document ready
})(jQuery); // end of jQuery name space
(function ($) {
$.fn.disableSelection = function () {
return this.bind(($.support.selectstart ? "selectstart" : "mousedown") +
".disableSelection", function (event) {
event.preventDefault();
});
};
$.fn.enableSelection = function () {
return this.unbind('.disableSelection');
};
})(jQuery);
function number_format(str)
{
str+="";
var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
while(objRegExp.test(str))
{
str = str.replace(objRegExp, '$1,$2');
}
return str;
}
/* 로그인 */
function login_check() {
var $emptys = $("#flogin .required").filter(function () { return this.value == ""; });
if ($emptys.length == 0) {
return true;
}
show_login_msg($emptys[0].placeholder);
$emptys[0].focus();
return false;
}
function show_login_msg(str) {
$("#login_msg").html(str);
$("#login_msg").removeClass("hide");
window.setTimeout(function () {
$("#login_msg").addClass("hide");
}, 3000);
}
function check_login() {
$.post("/member/act.php", "mode=check_login", function (result) {
if (result != "OK") {
$(".btn_top_login").leanModal({
dismissible: false
}).click();
}
});
}
$(document).ready(function () {
$(".login-modal-trigger").leanModal();
$("#menu").disableSelection();
$(".login-modal-trigger").click(function () {
$("#btn_login").data("move-url", $(this).attr('move-url'));
});
$("#btn_login").click(function () {
if (!login_check()) return false;
var murl = $(this).data("move-url");
console.log($("#flogin").serialize());
$.post("/member/act.php", $("#flogin").serialize(), function (result) {
if (result.result == "OK") {
// $("#login-pop").closeModal();
if (murl != "") location.href = murl;
else location.reload();
} else {
show_login_msg(result.msg);
}
}, "json");
return false;
});
$("#btn_login_cancel").click(function () {
location.href = '/';
});
$("#btn_logout, #btn_mlogout").click(function () {
$.post("/member/act.php", "mode=logout", function (result) {
location.href = '/';
});
});
$("#loginpass").keyup(function (e) {
var k = window.event ? e.keyCode : e.which;
if (k == 13) $("#btn_login").click();
});
$("#btn_pw_mail").click(function () {
var email = $("#pw_mail").val();
$.post("/member/act.php", "mode=password_change_mail&email=" + email, function (result) {
if (result == "EMAIL_NOT_FOUND") {
$("#pwc_msg").removeClass("hide");
window.setTimeout(function () {
$("#pwc_msg").addClass("hide");
}, 2000);
} else if (result == "OK") {
alert(email + "로 비밀번호변경 안내 메일이 발송 되었습니다.");
location.reload();
}
});
});
});
/* 메인 슬라이드 */
$(document).ready(function () {
$('.slider').slider({ full_width: true });
});
/* 탑버튼 */
$(document).ready(function () {
// Show or hide the sticky footer button
$(window).scroll(function () {
if ($(this).scrollTop() > 200) {
$('.go-top').fadeIn(200);
} else {
$('.go-top').fadeOut(200);
}
});
// Animate the scroll to top
$('.go-top').click(function (event) {
event.preventDefault();
$('html, body').animate({ scrollTop: 0 }, 300);
})
});
/* 이용가이드 팝업 */
function showCenterWindow(url, targetname, wi, hi, opt) {
var lf = eval((screen.availWidth / 2) - (wi / 2)); // get center position
var tp = eval((screen.availHeight / 2) - (hi / 2)); // get center position
window.open(url, targetname, "height=" + hi + ", width=" + wi + ", top=" + tp + ", left=" + lf + ", " + opt);
}
function popup(url) {
showCenterWindow(url, '_guide', 1200, 900, '');
}