// 전역 변수
var errmsg = "";
var errfld;
function _blank(url) {
window.open(url, '_blank');
}
function new_popup(url, name) {
window.open(url, name, 'height=' + screen.height + ',width=' + screen.width + 'fullscreen=yes');
}
function reload() {
window.location.reload();
}
function link_replace(url) {
window.location.replace(url);
}
function link(url) {
window.location.href = url;
}
function popup_full(url, name) {
window.open(url, name,'height=' + screen.height + ',width=' + screen.width + 'fullscreen=yes');
}
function popup_close() {
self.close();
}
var custom_modal_alert_opts = {
id : '',
title : '',
width : '400px',
// height : '200px',
height : 'auto',
zIndex : '99999',
btn_confirm_text : '확인',
btn_close_show : true,
event_esc_key : true,
}
var custom_modal_confirm_opts = {
id : '',
title : '',
desc : '',
width : '400px',
// height : '200px',
height : 'auto',
zIndex : '99999',
btn_cancel_text : '취소',
btn_confirm_text : '확인',
btn_close_show : true,
event_esc_key : true,
}
// $(document).on("add_custom_modal_alert_keyup_event", "#custom_modal_alert", function(e){
// // console.log($("#custom_modal_alert").css("display") == "flex");
// // if (e.key === "Escape") {
// // console.log(e.keyCode);
// // }
//
// console.log('aaaa');
// });
$(document).on("add_custom_modal_alert_keyup_event", "#custom_modal_alert", function(e){
custom_modal_alert_close();
if(typeof custom_modal_alert_opts.id != "undefined" && $.trim(custom_modal_alert_opts.id) != "" && $("#"+custom_modal_alert_opts.id).attr("type") != "hidden") {
$("#"+custom_modal_alert_opts.id).focus();
}
});
$(document).on("add_custom_modal_confirm_keyup_event", "#custom_modal_confirm", function(e){
custom_modal_confirm_close();
if(typeof custom_modal_confirm_opts.id != "undefined" && $.trim(custom_modal_confirm_opts.id) != "" && $("#"+custom_modal_confirm_opts.id).attr("type") != "hidden") {
$("#"+custom_modal_confirm_opts.id).focus();
}
});
//alert 오픈
function custom_modal_alert_open() {
$("#custom_modal_alert").removeClass("hide");
}
//alert 닫음
function custom_modal_alert_close() {
$("#custom_modal_alert").addClass("hide");
}
//alert 창
function custom_modal_alert(opts, callback) {
//option setting
for(var i in opts) {
custom_modal_alert_opts[i] = opts[i];
}
//제목
$("#custom_modal_alert_title").html(custom_modal_alert_opts.title.replace(/\n/g, "
").replace(/\\n/g, "
"));
//확인 버튼
$("#btn_custom_modal_alert_proc").text(custom_modal_alert_opts.btn_confirm_text);
if(custom_modal_alert_opts.btn_close_show != true) {
$("#custom_modal_alert #btn_custom_modal_alert_close").hide();
}
$("#custom_modal_alert").zIndex(custom_modal_alert_opts.zIndex);
$("#custom_modal_alert .custom--pop--wrapper--inner").css({width: custom_modal_alert_opts.with, height: custom_modal_alert_opts.height});
// console.log(custom_modal_alert_opts);
custom_modal_alert_open();
$(document).on("keyup", function(e){
if(custom_modal_alert_opts.event_esc_key == true) {
var custom_modal_alert_display = $("#custom_modal_alert").css("display");
if ($.inArray(custom_modal_alert_display, ['block', 'flex']) != -1 && e.key === "Escape") {
$("#custom_modal_alert").trigger("add_custom_modal_alert_keyup_event", []);
}
}
});
//확인
$("#btn_custom_modal_alert_proc").on("click", function() {
// console.log(1)
$("#btn_custom_modal_alert_proc").unbind("click");
$("#btn_custom_modal_alert_close").unbind("click");
if(typeof callback === 'function') {
callback(true);
}else {
custom_modal_alert_close();
}
});
//닫기
$("#btn_custom_modal_alert_close").on("click", function() {
// console.log(2)
$("#btn_custom_modal_alert_proc").unbind("click");
$("#btn_custom_modal_alert_close").unbind("click");
custom_modal_alert_close();
});
}
//2023-03-28 팝업 신규 디자인 반영
function custom_modal_alert_new(opts, callback) {
//option setting
for(var i in opts) {
custom_modal_alert_opts[i] = opts[i];
}
$("#custom_modal_alert_title").html(custom_modal_alert_opts.title.replace(/\n/g, "
").replace(/\\n/g, "
"));
$(document).on("keyup", function(e){
if(custom_modal_alert_opts.event_esc_key == true) {
var custom_modal_alert_display = $("#custom_modal_alert").css("display");
if ($.inArray(custom_modal_alert_display, ['block', 'flex']) != -1 && e.key === "Escape") {
$("#custom_modal_alert").trigger("add_custom_modal_alert_keyup_event", []);
}
}
});
//확인
$("#btn_custom_modal_alert_proc").on("click", function() {
// console.log(1)
$("#btn_custom_modal_alert_proc").unbind("click");
$("#btn_custom_modal_alert_close").unbind("click");
if(typeof callback === 'function') {
callback(true);
}else {
custom_modal_alert_close();
}
});
//닫기
$("#btn_custom_modal_alert_close").on("click", function() {
// console.log(2)
$("#btn_custom_modal_alert_proc").unbind("click");
$("#btn_custom_modal_alert_close").unbind("click");
custom_modal_alert_close();
});
}
//modal open
function custom_modal_confirm_open() {
$("#custom_modal_confirm").removeClass("hide");
}
//modal close
function custom_modal_confirm_close() {
$("#custom_modal_confirm").addClass("hide");
$(".dimLayer").remove();
}
//modal open
function custom_modal_confirm(opts, callback) {
//option setting
for(var i in opts) {
custom_modal_confirm_opts[i] = opts[i];
}
//제목
//<br/>
$("#custom_modal_confirm #custom_modal_confirm_title").html(custom_modal_confirm_opts.title.replace(/\n/g, "
").replace(/\\n/g, "
"));
//내용
$("#custom_modal_confirm #custom_modal_confirm_desc").text(custom_modal_confirm_opts.desc);
//확인 버튼
$("#custom_modal_confirm #btn_custom_modal_confirm_proc").text(custom_modal_confirm_opts.btn_confirm_text);
//취소 버튼
$("#custom_modal_confirm #btn_custom_modal_confirm_cancel").text(custom_modal_confirm_opts.btn_cancel_text);
if(custom_modal_confirm_opts.btn_close_show != true) {
$("#custom_modal_confirm #btn_custom_modal_confirm_close").hide();
}
$("#custom_modal_confirm").zIndex(custom_modal_confirm_opts.zIndex);
$("#custom_modal_confirm .custom--pop--wrapper--inner").css({width: custom_modal_confirm_opts.width, height: custom_modal_confirm_opts.height});
custom_modal_confirm_open();
$(document).on("keyup", function(e){
if(custom_modal_confirm_opts.event_esc_key == true) {
var custom_modal_confirm_display = $("#custom_modal_confirm").css("display");
if ($.inArray(custom_modal_confirm_display, ['block', 'flex']) != -1 && e.key === "Escape") {
$("#custom_modal_confirm").trigger("add_custom_modal_confirm_keyup_event", []);
}
}
});
//modal confirm
$("#btn_custom_modal_confirm_proc").on("click", function() {
$("#btn_custom_modal_confirm_cancel").unbind("click");
$("#btn_custom_modal_confirm_proc").unbind("click");
$("#btn_custom_modal_confirm_close").unbind("click");
// console.log(1)
if(typeof callback === 'function') {
callback(true);
}else {
custom_modal_confirm_close();
}
});
//modal cancel
$("#btn_custom_modal_confirm_cancel").on("click", function() {
// console.log(2)
$("#btn_custom_modal_confirm_cancel").unbind("click");
$("#btn_custom_modal_confirm_proc").unbind("click");
$("#btn_custom_modal_confirm_close").unbind("click");
custom_modal_confirm_close();
});
//modal close
$("#btn_custom_modal_confirm_close").on("click", function() {
// console.log(3)
$("#btn_custom_modal_confirm_cancel").unbind("click");
$("#btn_custom_modal_confirm_proc").unbind("click");
$("#btn_custom_modal_confirm_close").unbind("click");
custom_modal_confirm_close();
});
}
function custom_modal_confirm2(opts, callback) {
custom_modal_confirm_open();
if(typeof opts.title != "undefined") {
$("#custom_modal_confirm #custom_modal_confirm_title").text(opts.title);
}
if(typeof opts.desc != "undefined") {
$("#custom_modal_confirm #custom_modal_confirm_desc").text(opts.desc);
}
if(typeof opts.btn_cancel_text != "undefined") {
$("#custom_modal_confirm #btn_custom_modal_confirm_cancel").text(opts.btn_cancel_text);
}
if(typeof opts.btn_confirm_text != "undefined") {
$("#custom_modal_confirm #btn_custom_modal_confirm_proc").text(opts.btn_confirm_text);
}
// console.log("AAAAA", opts.btn_close_show);
if(typeof opts.btn_close_show != "undefined" && opts.btn_close_show != true) {
$("#custom_modal_confirm #btn_custom_modal_confirm_close").hide();
}
//modal confirm
$("#btn_custom_modal_confirm_proc").on("click", function() {
$("#btn_custom_modal_confirm_cancel").unbind("click");
$("#btn_custom_modal_confirm_proc").unbind("click");
$("#btn_custom_modal_confirm_close").unbind("click");
// console.log(1)
if(typeof callback === 'function') {
callback(true);
}else {
custom_modal_confirm_close();
}
});
//modal cancel
$("#btn_custom_modal_confirm_cancel").hide();
$("#btn_custom_modal_confirm_cancel").on("click", function() {
// console.log(2)
$("#btn_custom_modal_confirm_cancel").unbind("click");
$("#btn_custom_modal_confirm_proc").unbind("click");
$("#btn_custom_modal_confirm_close").unbind("click");
custom_modal_confirm_close();
});
//modal close
$("#btn_custom_modal_confirm_close").on("click", function() {
// console.log(3)
$("#btn_custom_modal_confirm_cancel").unbind("click");
$("#btn_custom_modal_confirm_proc").unbind("click");
$("#btn_custom_modal_confirm_close").unbind("click");
custom_modal_confirm_close();
});
}
function viewLayerPopup(obj){
var _this = $("."+obj + "_popup");
var _thisW = _this.width() / 2;
var _thisH = _this.height() / 2;
_this.css('margin-left',-_thisW);
_this.css('margin-top',-_thisH);
_this.show();
$("body").append("
");
}
function closeLayerPopup(obj){
$("." + obj + "_popup").hide();
$(".dim").remove();
}
/**
* console.log() 대용(콘솔 사용불가시 자바스크립트 오류발생 방지)
**/
function debugPrint(msg) {
if (typeof console == 'object' && typeof console.log == 'function') {
console.log(msg);
}
}
/**
* 필드 검사
**/
function check_field(fld, msg) {
if((fld.value = trim(fld.value)) == '') {
error_field(fld, msg);
} else {
clear_field(fld);
}
return;
}
/**
* 필드 오류 표시
**/
function error_field(fld, msg) {
if(msg != "") errmsg += msg + "\n";
if(!errfld) errfld = fld;
fld.style.background = "#BDDEF7";
}
/**
* 필드를 깨끗하게
**/
function clear_field(fld) {
fld.style.background = "#FFFFFF";
}
/**
* @TODO 함수 설명 필요
**/
function trim(s) {
var t = '';
var from_pos = to_pos = 0;
for(i = 0; i < s.length; i++) {
if(s.charAt(i) == ' ') {
continue;
} else {
from_pos = i;
break;
}
}
for(i = s.length; i >= 0; i--) {
if(s.charAt(i - 1) == ' ') {
continue;
} else {
to_pos = i;
break;
}
}
t = s.substring(from_pos, to_pos);
return t;
}
/**
* 자바스크립트로 PHP의 number_format 흉내를 냄
* 숫자에 , 를 출력
**/
function number_format(data) {
var tmp = '';
var number = '';
var cutlen = 3;
var comma = ',';
var i;
len = data.length;
mod = (len % cutlen);
k = cutlen - mod;
for(i = 0; i < data.length; i++) {
number = number + data.charAt(i);
if(i < data.length - 1) {
k++;
if((k % cutlen) == 0) {
number = number + comma;
k = 0;
}
}
}
return number;
}
/**
* 새 창
**/
function popup_window(url, winname, opt) {
window.open(url, winname, opt);
}
/**
* a 태그에서 onclick 이벤트를 사용하지 않기 위해
* @TODO 설명문구 수정
**/
function win_open(url, name, option) {
var popup = window.open(url, name, option);
popup.focus();
}
/**
* 폼메일 창
**/
function popup_formmail(url) {
opt = 'scrollbars=yes, width=417, height=385, top=10, left=20';
popup_window(url, 'wformmail', opt);
}
/**
* , 를 없앤다.
* @TODO 문자열 치환하는데 왜 loop를 돌지?
**/
function no_comma(data) {
var tmp = '';
var comma = ',';
var i;
for(i = 0; i < data.length; i++) {
if(data.charAt(i) != comma) tmp += data.charAt(i);
}
return tmp;
}
/**
* 삭제 검사 확인
**/
function del(href) {
if(confirm("한번 삭제한 자료는 복구할 방법이 없습니다.\n\n정말 삭제하시겠습니까?")) {
document.location.href = href;
}
}
/**
* 쿠키 입력
* @TODO 쿠키 플러그인으로 대체
**/
function set_cookie(name, value, expirehours, domain) {
var today = new Date();
today.setTime(today.getTime() + (60 * 60 * 1000 * expirehours));
document.cookie = name + '=' + escape( value ) + '; path=/; expires=' + today.toGMTString() + ';';
if(domain) {
document.cookie += 'domain=' + domain + ';';
}
}
/**
* 쿠키 얻음
* @TODO 쿠키 플러그인으로 대체
**/
function get_cookie(name) {
var find_sw = false;
var start, end;
var i = 0;
for(i = 0; i <= document.cookie.length; i++) {
start = i;
end = start + name.length;
if(document.cookie.substring(start, end) == name) {
find_sw = true;
break;
}
}
if(find_sw == true) {
start = end + 1;
end = document.cookie.indexOf(';', start);
if(end < start) end = document.cookie.length;
return document.cookie.substring(start, end);
}
return '';
}
/**
* 쿠키 지움
* @TODO 쿠키 플러그인으로 대체
**/
function delete_cookie(name) {
var today = new Date();
today.setTime(today.getTime() - 1);
var value = get_cookie(name);
if(value != '') {
document.cookie = name + '=' + value + '; path=/; expires=' + today.toGMTString();
}
}
var last_id = null;
/**
* @TODO 함수설명 필요
**/
function menu(id) {
if(id != last_id) {
if(last_id != null) {
jQuery('#' + last_id).hide();
}
jQuery('#' + id).show();
last_id = id;
} else {
jQuery('#' + id).hide();
last_id = null;
}
}
/**
* @TODO 함수설명 필요
**/
function textarea_decrease(id, row) {
if(document.getElementById(id).rows - row > 0) {
document.getElementById(id).rows -= row;
}
}
/**
* @TODO 함수설명 필요
**/
function textarea_original(id, row) {
document.getElementById(id).rows = row;
}
/**
* @TODO 함수설명 필요
**/
function textarea_increase(id, row) {
document.getElementById(id).rows += row;
}
/**
* 글숫자 검사
* @TODO 함수설명 보완
**/
function check_byte(content, target) {
var i = 0;
var cnt = 0;
var ch = '';
var cont = document.getElementById(content).value;
for(i = 0; i < cont.length; i++) {
ch = cont.charAt(i);
if(escape(ch).length > 4) {
cnt += 2;
} else {
cnt += 1;
}
}
// 숫자를 출력
document.getElementById(target).innerHTML = cnt;
return cnt;
}
/**
* 브라우저에서 오브젝트의 왼쪽 좌표
* @TODO jQuery 함수로 대체
**/
function get_left_pos(obj) {
var parentObj = null;
var clientObj = obj;
var left = obj.offsetLeft;
while((parentObj = clientObj.offsetParent) != null) {
left = left + parentObj.offsetLeft;
clientObj = parentObj;
}
return left;
}
/**
* 브라우저에서 오브젝트의 상단 좌표
* @TODO jQuery 함수로 대체
**/
function get_top_pos(obj) {
var parentObj = null;
var clientObj = obj;
var top = obj.offsetTop;
while((parentObj=clientObj.offsetParent) != null) {
top = top + parentObj.offsetTop;
clientObj = parentObj;
}
return top;
}
/**
* @TODO 함수설명 필요
**/
function flash_movie(src, ids, width, height, wmode) {
var wh = '';
if(parseInt(width) && parseInt(height)) {
wh = " width='"+width+"' height='"+height+"' ";
}
return "";
}
/**
* @TODO 함수설명 필요
**/
function obj_movie(src, ids, width, height, autostart) {
var wh = "";
if (parseInt(width) && parseInt(height))
wh = " width='"+width+"' height='"+height+"' ";
if (!autostart) autostart = false;
return "";
}
/**
* @TODO 함수설명 필요
**/
function doc_write(cont) {
document.write(cont);
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/, '');
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/, '');
}
/**
* 한글, 영문, 숫자 검사
**/
function chk_hanalnum(s) {
var pattern = /([^가-힣ㄱ-ㅎㅏ-ㅣ^a-z^0-9])/i;
return pattern.test(s);
}
/**
*도메인 체크
*/
function chk_url(s) {
var pattern =/^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/;
return pattern.test(s);
}
/**
* 이메일주소 검사
**/
function chk_email(s) {
var pattern = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/;
return pattern.test(s);
}
function chk_date(s){
var pattern = /[0-9]{4}-[0-9]{2}-[0-9]{2}/;
return pattern.test(s);
}
/**
* 전화번호
**/
function chk_hp(s) {
var pattern = /^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-?[0-9]{3,4}-?[0-9]{4}$/;
return pattern.test(s);
}
function chk_tel(s) {
var pattern = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
return pattern.test(s);
}
/**
* 포인트 창
**/
var win_point = function(href) {
var new_win = window.open(href, 'win_point', 'left=100,top=100,width=600, height=600, scrollbars=1');
new_win.focus();
}
/**
* 쪽지 창
**/
var win_memo = function(href) {
var new_win = window.open(href, 'win_memo', 'left=100,top=100,width=620,height=500,scrollbars=1');
new_win.focus();
}
/**
* 메일 창
**/
var win_email = function(href) {
var new_win = window.open(href, 'win_email', 'left=100,top=100,width=600,height=580,scrollbars=0');
new_win.focus();
}
/**
* 우편번호 창
**/
var win_zip = function(href) {
var new_win = window.open(href, 'win_zip', 'width=616, height=460, scrollbars=1');
new_win.focus();
}
// 게시물 이름 클릭하면 나오는 레이어
var div_sidebox = null;
jQuery(function($) {
$('.win_point').click(function() {
win_point(this.href);
return false;
});
$('.win_memo').click(function() {
win_memo(this.href);
return false;
});
$('.win_email').click(function() {
win_email(this.ref);
return false;
});
$('.win_scrap').click(function() {
win_scrap(this.href);
return false;
});
$('.win_profile').click(function() {
win_profile(this.ref);
return false;
});
$('.win_homepage').click(function() {
win_homepage(this.ref);
return false;
});
$('.win_zip_find').click(function() {
win_zip(this.href);
return false;
});
$('.win_password_lost').click(function() {
win_password_lost(this.href);
return false;
});
$('.win_poll').click(function() {
win_poll(this.href);
return false;
});
//==========================================================================
// 게시물 이름 레이어
//--------------------------------------------------------------------------
div_sidebox = document.createElement('DIV');
div_sidebox.id = 'sidebox';
div_sidebox.style.display = 'none';
div_sidebox.style.position = 'absolute';
document.body.appendChild(div_sidebox);
var click_document_area = false;
document.onclick = function() {
if(!click_document_area) {
div_sidebox.style.display = 'none';
} else {
click_document_area = false;
}
}
$('.sidebox').bind('click', function() {
var $this = $(this);
click_document_area = true;
var top = $this.offset().top;
var left = $this.offset().left;
var width = $this.width();
var height = $this.height();
$('#sidebox').css({'top' : top + height / 3, 'left' : left + width - 5});
var aflds = this.rel.split('&');
var fld;
for(var i = 0; i < aflds.length; i++) {
fld = aflds[i].split('=');
eval('var ' + fld[0] + ' = "' + fld[1] + '";');
}
var html = '';
var first = ' class="first-child"';
// 쪽지보내기
if(mb_id) {
html += "쪽지보내기";
first = '';
}
// 메일보내기
if(email) {
html += "메일보내기";
first = '';
}
// 홈페이지
if(homepage) {
html += "홈페이지";
first = '';
}
// 자기소개
if(mb_id) {
html += "자기소개";
first = '';
}
// 아이디로 검색, 이름으로 검색
if(g4_bo_table) {
if(mb_id) {
html += "아이디로 검색";
}
html += "이름으로 검색";
first = '';
}
// 전체게시물
if(mb_id) {
html += "전체게시물";
first = '';
}
// 최고관리자일 경우
if(g4_is_admin == 'super') {
if(mb_id) {
// 회원정보변경
html += "회원정보변경";
// 포인트내역
html += "포인트내역";
first = "";
}
}
if(html) {
html = '';
$('#sidebox').html(html).show('fast');
}
});
// 배경색상 변경
$('.board_list tbody tr:odd, .table_list tbody tr:odd' ).addClass('list_odd');
$('.board_list tbody tr:even, .table_list tbody tr:even').addClass('list_even');
$('.board_list tbody tr, .table_list tbody tr').toggleClass('mouse_over');
//==========================================================================
// @FIXME 자동완성 기능을 왜 죄다 꺼버리는가?
$('form').each(function(i) {
$(this).attr('autocomplete', 'off');
});
});
//메인메뉴 롤오버 이미지처리
$(function() {
$(".gnbSub").hide(); // 2뎁스 메뉴를 모두 숨김
$(".gnbMain").hover(function(){
var Img = $(this).contents().contents("img").attr("src").replace("_off.", "_on."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
$(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
$(this).contents("ul").slideDown("fast"); // 2뎁스 노출
},
function(){
var Img = $(this).contents().contents("img").attr("src").replace("_on.", "_off."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
$(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
$(this).contents("ul").slideUp("fast");// 2뎁스 숨김
});
$(".gnbSub li").each(function(e){
$(this).mouseenter(function(e){
var subImg = $(this).contents().contents("img").attr("src").replace("_off.", "_on.");
$(this).contents().contents("img").attr("src", subImg);
});
$(this).mouseleave(function(e){
var subImg = $(this).contents().contents("img").attr("src").replace("_on.", "_off.");
$(this).contents().contents("img").attr("src", subImg);
});
});
});
// 왼쪽사이드바 서브메뉴 롤오버 이미지처리
$(function() {
$(".snbSub").hide(); // 2뎁스 메뉴를 모두 숨김
$(".snbMain").hover(function(){
var Img = $(this).contents().contents("img").attr("src").replace("_off.", "_on."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
$(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
$(this).contents("ul").slideDown("fast"); // 2뎁스 노출
},
function(){
var Img = $(this).contents().contents("img").attr("src").replace("_on.", "_off."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
$(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
$(this).contents("ul").slideUp("fast");// 2뎁스 숨김
});
$(".snbSub li").each(function(e){
$(this).mouseenter(function(e){
var subImg = $(this).contents().contents("img").attr("src").replace("_off.", "_on.");
$(this).contents().contents("img").attr("src", subImg);
});
$(this).mouseleave(function(e){
var subImg = $(this).contents().contents("img").attr("src").replace("_on.", "_off.");
$(this).contents().contents("img").attr("src", subImg);
});
});
});
// rollover이미지 처리 : right_sidebar
$(function(){
$("img.rollover").mouseover(function(){
$(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
}).mouseout(function(){
$(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
}).each(function(){
$("
").attr("src",$(this).attr("src").replace("_off.", "_on."));
});
});
//패밀리사이트
$(function() {
$("#family_site").hide();
$(".family").click(function(){
$("#family_site").slideDown();
$("#family_site").mouseleave(function(){closeFamily();return false;})
}
);
$("#family_site a.close").click(function(){closeFamily();return false;});
$("#family_site").hover(
function(){
$("#family_site").slideDown();
},function(){
closeFamily();return false;
}
);
});
function closeFamily(){
$("#family_site").slideUp();
}
//슬라이딩배너
//new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);
function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
this.FloatingObj = FloatingObj;
this.MarginX = (MarginX) ? MarginX : 0;
this.MarginY = (MarginY) ? MarginY : 0;
//this.MarginX = document.getElementById('body_cus').offsetLeft + 985;
this.Percentage = (Percentage) ? Percentage : 15;
this.setTime = (setTime) ? setTime : 10;
this.FloatingObj.style.position = "absolute";
this.Body = null;
this.setTimeOut = null;
this.Run();
}
Floating.prototype.Run = function () {
if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
this.Body = document.documentElement;
} else {
this.Body = document.body;
}
var This = this;
var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
var DocLeft = this.MarginX;
var DocTop = this.Body.scrollTop + this.MarginY;
var MoveX = Math.abs(FloatingObjLeft - DocLeft);
MoveX = Math.ceil(MoveX / this.Percentage);
var MoveY = Math.abs(FloatingObjTop - DocTop);
MoveY = Math.ceil(MoveY / this.Percentage);
if (FloatingObjLeft < DocLeft) {
this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
} else {
this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
}
if (FloatingObjTop < DocTop) {
this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
} else {
this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
}
window.clearTimeout(this.setTimeOut);
this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}
/* 공통 함수 */
String.prototype.trim = function() {
return this.replace(/\s/g, "");
}
String.prototype.IsNumber = function()
{
return (/^[0-9]+$/).test();
}
/* Byte계산 */
String.prototype.bytes = function() {
var str = this;
var len = 0;
for (var i = 0; i < str.length; i++) {
len += (str.charCodeAt(i) > 128) ? 2 : 1;
}
return len;
}
//문자열자르기
String.prototype.cut = function(len) {
var str = this;
var s = 0;
for (var i = 0; i < str.length; i++) {
s += (str.charCodeAt(i) > 128) ? 2 : 1;
if (s > len) {
return str.substring(0,i);
}
}
return str;
}
//시간형태 체크 24시
function timechk(value) {
var input = String(value);
var pattern = /([0-2][0-3])(h|:)([0-5][0-9])/g;
return pattern.test(input);
}
function popupCenter(URL,w, h, s, r) {
width=screen.width;
height=screen.height;
x=(width/2)-(w/2);
y=(height/2)-(h/2);
opt = "left=" + x + ", top=" + y + ", width=" + w + ", height=" + h;
opt = opt + ", toolbar=no,location=no,directories=no,status=no,menubar=no";
opt = opt + ",scrollbars=" + s;
opt = opt + ",resizable=" + r;
window.open(URL, "_blank", opt);
}
//가운데띄우기
// 숫자, 영문 체크
var alpha_numeric = new String("0123456789abcdefghijklmnopqrstuvwxyz.")
function fnCheckAlphaNumber(str) {
var rtrn;
for(j = 0 ; j < str.length; j++) {
rtn = fnIsAlphaNumeric(str.charAt(j))
if(rtn == false) {
return rtn;
}
}
return rtn;
}
function fnIsAlphaNumeric(cha1) {
for(i=0;i 16) {
alert("비밀번호는 6 ~ 16 자리로 입력해주세요.");
return false;
}
return true;
}
/*--------------------------------------------------------------
form 문자열 입력 확인
사용법 : fnCheckForm(fieldlist)
. fieldlist : 배열["form elements", "이름"]
--------------------------------------------------------------*/
function fnCheckForm(fieldlist, locale) {
var add_check_elements = ["checkbox", "radio"];
if(locale==null || locale==""){locale=="ko";}
for (i = 0; i < fieldlist.length; i++) {
var frm = document.getElementById(fieldlist[i][0]);
//checkbox, radio 는 체크 하지 못해 수정
if(frm != null) {
if(frm.value == ""){
if(locale=="en"){
alert("Please Check " + fieldlist[i][1]);
}else{
// alert(fieldlist[i][1] + "을(를) 확인하세요.1");
var custom_opts = {
id : fieldlist[i][0],
title : fieldlist[i][1] + "을(를) 확인하세요.",
btn_close_show : false, //닫기 버튼 안보이게
}
custom_modal_alert(custom_opts, function() {
custom_modal_alert_close();
if(frm.type != "hidden"){
frm.focus();
}
});
}
return false;
}
// console.log("null");
}else {
var $el = $("input[name="+fieldlist[i][0]+"]");
if($el.length > 0 && $.inArray($el.prop("type"), add_check_elements)) {
var val = "";
switch ($el.prop("type")) {
case "radio":
case "checkbox":
val = $("input[name="+fieldlist[i][0]+"]:checked").val();
$("input[name="+fieldlist[i][0]+"]").eq(0).focus();
break;
default:
break;
}
if($.trim(val) == "") {
if(locale=="en"){
alert("Please Check " + fieldlist[i][1]);
}else{
// alert(fieldlist[i][1] + "을(를) 확인하세요.");
var custom_opts = {
id : fieldlist[i][0],
title : fieldlist[i][1] + "을(를) 확인하세요.",
btn_close_show : false, //닫기 버튼 안보이게
}
custom_modal_alert(custom_opts, function() {
custom_modal_alert_close();
if(frm.type != "hidden"){
frm.focus();
}
});
}
return false;
}
}
}
}
return true;
}
// 쿠키생성
function fnSetCookie(name, value, expiredays,domain ){
var today = new Date();
today.setDate( today.getDate() + expiredays );
var cook = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
if (domain) cook += "domain=" + domain + ";";
document.cookie = cook;
}
// 쿠키값 확인
function fnGetCookie( name ) {
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length ) {
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 )
break;
}
return "";
}
//쿠키삭제
function fnDeleteCookie(cookieName)
{
var expireDate = new Date();
//어제 날짜를 쿠키 소멸 날짜로 설정한다.
expireDate.setDate( expireDate.getDate() - 1 );
document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}
function fnShowLoading(sEl) {
$('#'+ sEl).html('
');
}
// ajax 가 처리되는 동안 진행되는 작업
var objLoadingHandlers = {
onCreate: function() {
if($(sDiv))
Element.show(sDiv);
}
, onComplete: function() {
if(Ajax.activeRequestCount == 0) {
if($(sDiv))
Element.hide(sDiv);
}
}
}
// ajax가 처리되는 동안 처리되는 작업을 등록
//Ajax.Responders.register(objLoadingHandlers);
// nodevalue 가져오기
function fnGetNodeValue(oXml, oNode){
var pNode = oXml.getElementsByTagName(oNode);
if(pNode[0]){
if(pNode[0].childNodes[0])
return pNode[0].childNodes[0].nodeValue;
else
return "";
}else{
return "";
}
}
// child nodevalue 가져오기
function fnGetChildNodeValue(oNode) {
if(oNode.childNodes[0])
return oNode.childNodes[0].nodeValue;
else
return "";
}
// select box 만들기
function fnSetXmlSelectList(oXML, oSelect, iStart) {
if(!iStart || iStart == "undefined") {
iStart = 1;
} else {
iStart = parseInt(iStart);
}
var pNode = oXML.getElementsByTagName("itemlist");
var id = null;
var desc = null;
var objSelect = document.getElementById(oSelect) ? document.getElementById(oSelect) : false;
if(objSelect) fnSetInitSelect(objSelect, iStart);
for(i = 0; i < pNode.length; i++) {
var cNode = pNode[i].childNodes;
for(j = 0; j < cNode.length; j++) {
if(cNode[j].nodeName == "id") id = fnGetChildNodeValue(cNode[j]);
if(cNode[j].nodeName == "desc") desc = fnGetChildNodeValue(cNode[j]);
}
if(objSelect) {
var option = new Option(desc, id);
objSelect.options[i + iStart] = option;
}
}
}
// select box 초기화
function fnSetInitSelect(obj, iStart) {
if(obj) {
if(obj.options) {
for(i = obj.options.length - 1; i >= iStart; i--) {
obj.options[i] = null;
}
}
}
}
// checkbox 선택
function fnSetCheckAll(objCheck, objTarget) {
var obj = document.getElementsByName(objTarget);
for(var i = 0; i < obj.length; i ++) {
if(document.getElementById(objCheck).checked) {
obj[i].checked = true;
} else {
obj[i].checked = false;
}
}
}
// 위 함수랑 이름이 같아서 오류 발생함
// function fnSetCheckAll(objTarget) {
// var obj = document.getElementsByName(objTarget);
// for(var i = 0; i < obj.length; i ++) {
// obj[i].checked = true;
// }
// }
// 체크박스 체크한 개수
function fnGetCheckCnt(obj) {
var iCnt = 0;
var o = document.getElementsByName(obj);
for(var i = 0; i < o.length; i ++) {
if(o[i].checked) iCnt ++;
}
return iCnt;
}
//체크박스 체크값 가져 온다,
function fnGetCheckVal(obj){
var strVal='';
var o = document.getElementsByName(obj);
for(var i = 0; i < o.length; i ++) {
if(o[i].checked) strVal= o[i].value;
}
return strVal;
}
// 올바른 날짜인지 확인
// 날짜는 yyyy-mm-dd 또는 yyyymmdd 형식으로 입력되어져야 함
function fnCheckDate(obj) {
var sValue = obj.value.replace(/-/g,"");
var iYear = sValue.substr(0, 4);
var iMonth = sValue.substr(4, 2) - 1;
var iDay = sValue.substr(6, 2);
var newDate = new Date(iYear, iMonth, iDay);
// 입력받은 값과 새로 생성된 날짜를 비교
if(iYear != newDate.getFullYear()
|| iMonth != newDate.getMonth()
|| iDay != newDate.getDate()) {
obj.value = "";
return false;
} else {
obj.value = iYear +"-"+ sValue.substr(4, 2) +"-"+ iDay;
return true;
}
}
//교사팝업 외부 인터페이스
//플래시 메뉴와 인터페이스시 이용한다.
function getCookie(name){
var nameOfCookie = name + "=";
var x = 0;
while( x <= document.cookie.length ){
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) {
endOfCookie = document.cookie.length;
}
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 )
break;
}
return "";
}
function fnInstallquickLink(){
alert("퀵메뉴 설치 됩니다");
var WshShell = new ActiveXObject("WScript.Shell");
strDesktop = WshShell.SpecialFolders("Desktop");
var oURLLink = WshShell.CreateShortcut(strDesktop + "\\\\Dogfoot.URL");
oURLLink.TargetPath = "http://www.readingwell.com";
oURLLink.Save();
}
//DIV영역만 프린트
function printIt(printThis){
var win = window.open();
win.document.open();
win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
win.document.write('body, td { font-family: Verdana; font-size: 10pt;}');
win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');
win.document.write(printThis);
win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
win.document.close();
win.print();
win.close();
}
// 특정영역만 프린트2
function fnPrintDiv(sDiv){
var win = window.open('about:blank', '', 'width=670, height=500, scrollbars=yes');
win.document.open();
win.document.write('');
win.document.write('');
win.document.write('');
win.document.write('');
win.document.write($(sDiv).innerHTML);
win.document.write('document.getElementById("copy_btn").style.display = "none";');
//win.document.write('');
win.document.write('');
win.document.close();
win.print();
win.close();
}
// 특정영역만 관리자
function fnPrintDivAdmin(sDiv){
var win = window.open('about:blank', '', 'width=670, height=500, scrollbars=yes');
win.document.open();
win.document.write('');
win.document.write('');
win.document.write('');
win.document.write('');
win.document.write($(sDiv).innerHTML);
win.document.write('');
win.document.close();
win.print();
win.close();
}
/***************************************************************
* COMMON CHECK
**************************************************************/
// 공백체크
function chkSpace( str ){
if(str.search(/\s/) != -1){
return false;
} else {
return true;
}
}
// 특수문자 체크
function checkSpecialChar(expression) {
var strSpecial = ",`~#$%^&*()_+|\;\\/:=-<>.'\"";
for(i=0;i^&*\()\-=+_\']/gi; //특수문자 정규식 변수 선언
for (i = 0; i < strValue.length; i++) {
var retCode = strValue.charCodeAt(i);
var retChar = strValue.substr(i,1).toUpperCase();
retCode = parseInt(retCode);
//입력받은 값중에 한글이 있으면 에러
if ((retChar < "0" || retChar > "9") && (retChar < "A" || retChar > "Z") && ((retCode > 255) || (retCode < 0)) ) {
intErr = -1;
break;
//입력받은 값중에 특수문자가 있으면 에러
} else if(re.test(strValue)) {
intErr = -1;
break;
}
}
return (intErr);
}
function han_check(Objectname) {
var intErr;
var strValue = Objectname;
var retCode = 0;
for (i = 0; i < strValue.length; i++) {
var retCode = strValue.charCodeAt(i);
var retChar = strValue.substr(i,1).toUpperCase();
retCode = parseInt(retCode);
//입력받은 값중에 한글이 있으면 에러
if ((retChar < "0" || retChar > "9") && (retChar < "A" || retChar > "Z") && ((retCode > 255) || (retCode < 0)) ) {
intErr = -1;
break;
}
}
return (intErr);
}
/*주민번호 체크 JS*/
function jumin_check(jumin1, jumin2) {
var er = 0;
var erm = "주민등록 번호가 잘못되었습니다.";
var rm = "주민등록번호를 확인하였습니다.";
var l1 = jumin1;
var l2 = jumin2;
if (l1 != 6 || l2 != 7) er=1;
if (Number(jumin1) == NaN || Number(jumin2) == NaN) er=1;
var dfdf = jumin1.split(".");
var fdfd = jumin2.split(".");
if (dfdf[1] || dfdf[1]){
er=1;
}
var array1 = jumin1.split("");
var array2 = jumin2.split("");
var y = array1[0]+array1[1];
if (Number(array1[2]) == 0) {
var m = array1[3];
}
else if (Number(array1[2])==1){
var m = array1[2]+array1[3];
}
else{
er=1;
}
if (Number(m)>12 || Number(m)<1){
er=1;
}
if (Number(array1[4]) == 0){
var d = array1[5];
}else{
var d = array1[4]+array1[5];
}
var f = 0;
if (Number(y)%4 == 0 && Number(y)%1000 != 0){
f = 1;
}
if (f == 0){
var ererr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
}else if(f == 1){
var ererr = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
}
else{
er=1;
}
if (ererr[m-1] < Number(d)) {
er=1;
}
var now = new Date();
var ny = now.getYear();
var nm = now.getMonth()+1;
var nd = now.getDate();
nc = Math.floor(ny/100)+1-20;
if (Number(array2[0]) != s_minus(nc, 2) && Number(array2[0]) != s_minus(nc, 1) && Number(array2[0]) != nc && Number(array2[0]) != s_plus(nc, 1) && Number(array2[0]) != s_plus(nc, 2) && Number(array2[0]) != s_plus(nc, 3)){
er=1;
}
nc += 20;
y = changeC(nc, Number(array2[0]))+y;
if (ny < Number(y)){
er=1;
}
if (ny == Number(y) && nm < Number(m)){
er=1;
}
if (ny == Number(y) && nm == Number(m) && nd < Number(d)){
er=1;
}
var num=(Number(array1[0])*2)+(Number(array1[1])*3)+(Number(array1[2])*4)+(Number(array1[3])*5)+(Number(array1[4])*6)+(Number(array1[5])*7)+(Number(array2[0])*8)+(Number(array2[1])*9)+(Number(array2[2])*2)+(Number(array2[3])*3)+(Number(array2[4])*4)+(Number(array2[5])*5);
num=11-(num%11)
var check=num%10
if (check != Number(array2[6])){
er=1;
}
if (er==1) {
alert(erm);
return false;
} else if (er==0) {
return true;
} else {
alert(erm);
return false;
}
}
function s_minus(a, b) {
var r = a-b;
while(1) {
if (r<0){
r+=10;
}
else if(r>=10) {
r-=10;
}
else{
break;
}
}
return r;
}
function s_plus(a, b) {
var r = a+b;
while(1) {
if (r<0){
r+=10;
}else if (r>=10) {
r-=10;
}else {
break;
}
}
return r;
}
function changeC(nc, s) {
while(1) {
if ((nc%5) != 4){
nc--;
}else {
break;
}
}
var ret = nc+s/2-1;
ret = ""+ret;
return ret;
}
function onlyNumber2(loc) {
if(/[^0123456789]/g.test(loc.value)) {
return false;
}else{
return true;
}
}
// 숫자만 입력 가능
function fnOnlyNumber(e) {
if (!e) var e = window.event;
// 숫자입력이 아닌 경우
if((e.keyCode < 48)||(e.keyCode > 57)) {
// key 패드에서 숫자입력이 아닌 경우
if((e.keyCode < 96) || (e.keyCode > 105)) {
// backspace, tab 허용
if(e.keyCode != 8 && e.keyCode != 9) {
if (e.preventDefault) {
e.preventDefault(); // firefox/모질라에서 event 발생시 자체 제공하는 특별기능 끄기.
} else {
e.returnValue = false; // IE에서 event 발생시 자체 제공하는 특별기능 끄기.
}
}
}
}
}
//기타벨리데이션 체크
//정규식타입 케이스별...
//사용법 isValid('amma76@test.com','regEmail');
function isValid(field, regExp){
var regNumber = /^[0-9]+$/; // 숫자
var regAlphabet = /^[a-zA-Z]+$/; // 알파벳(대문자,소문자)
var regAlphabetCapital = /^[A-Z]+$/; // 알파벳(대문자)
var regKorean = /^[가-힣]*$/; // 한글
var regPhone = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/; // 집전화
var regMobilePHone = /^[0-9]{3}-[0-9]{3,4}-[0-9]{4}$/; // 휴대폰
var regEmail =/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i; // 이메일
var regDomain = /^[.a-zA-Z0-9-]+.[a-zA-Z]+$/; // 도메인
var regIp = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; // IP
var result = false;
var fieldValue = field;
pattern = eval(regExp);
result = pattern.test(fieldValue);
return result;
}
/**
* 포커스 자동이동
*
* @param id_from - 현재 인풋박스 id
* @param id_to - 포커스 이동될 인풋 박스 id
* @param maxSize - 인풋박스에 입력될 글자수
* 사용예
* 6글자 입력후 포커스가 id=b 인풋 박스로 이동된다.
***/
var next_go = true;
var cur_val = null;
function moveNext(id_from,id_to,maxSize) {
var cur = document.getElementById(id_from).value;
curSize = cur.length;
if (curSize == maxSize) {
if(next_go || cur_val != cur)
{
cur_val = cur;
next_go = false;
document.getElementById(id_to).focus();
}
return true;
}
next_go = true;
}
/**
* 두 날짜의 차이를 일자로 구한다.(조회 종료일 - 조회 시작일)
*
* @param val1 - 조회 시작일(날짜 ex.2002-01-01)
* @param val2 - 조회 종료일(날짜 ex.2002-01-01)
* @return 기간에 해당하는 일자
*/
function calDateRange(val1, val2)
{
var FORMAT = "-";
// FORMAT을 포함한 길이 체크
if (val1.length != 10 || val2.length != 10)
return null;
// FORMAT이 있는지 체크
if (val1.indexOf(FORMAT) < 0 || val2.indexOf(FORMAT) < 0)
return null;
// 년도, 월, 일로 분리
var start_dt = val1.split(FORMAT);
var end_dt = val2.split(FORMAT);
// 월 - 1(자바스크립트는 월이 0부터 시작하기 때문에...)
// Number()를 이용하여 08, 09월을 10진수로 인식하게 함.
start_dt[1] = (Number(start_dt[1]) - 1) + "";
end_dt[1] = (Number(end_dt[1]) - 1) + "";
var from_dt = new Date(start_dt[0], start_dt[1], start_dt[2]);
var to_dt = new Date(end_dt[0], end_dt[1], end_dt[2]);
return (to_dt.getTime() - from_dt.getTime()) / 1000 / 60 / 60 / 24;
}
//사업자번호체크
function fnChkBNo(vencod) {
var sum = 0;
var getlist =new Array(10);
var chkvalue =new Array("1","3","7","1","3","7","1","3","5");
for(var i=0; i<10; i++) { getlist[i] = vencod.substring(i, i+1); }
for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; }
sum = sum + parseInt((getlist[8]*5)/10);
sidliy = sum % 10;
sidchk = 0;
if(sidliy != 0) { sidchk = 10 - sidliy; }
else { sidchk = 0; }
if(sidchk != getlist[9]) { return false; }
return true;
}
//외국인체크
function fnChkFNo(fgnno) {
var sum=0;
var odd=0;
buf = new Array(13);
for(i=0; i<13; i++) { buf[i]=parseInt(fgnno.charAt(i)); }
odd = buf[7]*10 + buf[8];
if(odd%2 != 0) { return false; }
if( (buf[11]!=6) && (buf[11]!=7) && (buf[11]!=8) && (buf[11]!=9) ) {
return false;
}
multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
for(i=0, sum=0; i<12; i++) { sum += (buf[i] *= multipliers[i]); }
sum = 11 - (sum%11);
if(sum >= 10) { sum -= 10; }
sum += 2;
if(sum >= 10) { sum -= 10; }
if(sum != buf[12]) { return false }
return true;
}
//동영상/스틸컷 팝업
function fnOpenPopup(type,seq){
var windowW = "855";
var windowH = "577";
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);
var urlPop1 = "/common/popup/pop_photo.asp"; //스틸컷
var urlPop2 = "/common/popup/pop_movie.asp"; //동영상
var cineSeq = "?seq="+seq
//var style = "width=845, height=505, scrollbars=no, left="+windowX+", top="+windowY;
var style = "width=880, height=606, scrollbars=no, left="+windowX+", top="+windowY;
if (type == "1"){ //1:스틸컷,2:동영상
window.open(urlPop1+cineSeq,"스틸컷",style);
}else{
window.open(urlPop2+cineSeq,"동영상",style);
}
}
//즐겨찾기추가
function favoritesite(){
window.external.AddFavorite(strWasURL, '엔초코');
}
//문자열길이 체크 함수
function CalByte3(tg,objMax, objNow){
var curText;
var strLen;
var byteIs;
var lastByte;
var thisChar;
var escChar;
var curTotalMsg;
var okMsg;
var _size = objMax.html();
curText = new String(tg.val());
strLen = curText.length;
byteIs = 0;
for(i=0; i 4) {
byteIs += 2; //특수문자 한글인 경우.
}else if(thisChar != '\r') { //개행을 제외한 이외의 경우
byteIs += 1;
}
if(byteIs > _size){ // 3페이지까지
alert(_size + '(문자)를 초과하실 수 없습니다.');
thisText = curText.substring(0, i);
tg.val(thisText);
byteIs = lastByte;
break;
}
lastByte = byteIs;
}
curTotalMsg = Math.ceil(byteIs / _size);
curEndByte = _size
objMax.html(curEndByte);
objNow.html(byteIs);
}
/* 정규 표현식을 사용하여 화이트스페이스를 빈문자로 전환 */
function trim(str){
str = str.replace(/^\s*/,'').replace(/\s*$/, '');
return str; //변환한 스트링을 리턴.
}
/*IFRMAE 리사이즈 공용*/
var IE = false ;
if (window.navigator.appName.indexOf("Explorer") !=-1){
IE = true;
}
function resizeIfr(obj, minHeight) {
minHeight = minHeight || 10;
try {
var getHeightByElement = function(body) {
var last = body.lastChild;
try {
while (last && last.nodeType != 1 || !last.offsetTop) last = last.previousSibling;
return last.offsetTop+last.offsetHeight;
} catch(e) {
return 0;
}
}
var doc = obj.contentDocument || obj.contentWindow.document;
if (doc.location.href == 'about:blank') {
obj.style.height = minHeight+'px';
return;
}
if (/MSIE/.test(navigator.userAgent)) {
var h = doc.body.scrollHeight;
} else {
var s = doc.body.appendChild(document.createElement('DIV'))
s.style.clear = 'both';
var h = s.offsetTop;
s.parentNode.removeChild(s);
}
if (h < minHeight) h = minHeight;
obj.style.height = h + 'px';
if (typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
if (typeof obj._check == 'undefined') obj._check = 0;
setTimeout(function(){ resizeIfr(obj,minHeight) }, 200); // check 5 times for IE bug
} catch (e) {
}
}
/*자바스크립트 Mid*/
function Mid(str, start, len) {
// Make sure start and len are within proper bounds
if ( start < 0 || len < 0 ) return "";
var iEnd, iLen = String(str).length;
if ( start + len > iLen ) iEnd = iLen;
else iEnd = start + len;
return String(str).substring(start,iEnd);
}
/*자바스크립트 INSTR*/
function InStr(strSearch, charSearchFor)
{
for (i=0; i < strSearch.length; i++)
{
if (charSearchFor == Mid(strSearch, i, 1)){
return i;
}
}
return -1;
}
/* 네이버MAP 호출 다중 OVERLAY형태 조정현 */
function fnSetAddMaker(obj,pos,iconURL){
var arrMaker = new NMark(pos, new NIcon(iconURL, new NSize(15, 15),new NSize(15, 15)));
/*NEvent.addListener(arrMaker, "mouseover", function(){
obj.setCenterAndZoom(pos,2);
});
NEvent.addListener(arrMaker, "mouseout", function(){
obj.setCenterAndZoom(pos,8)
});*/
obj.addOverlay(arrMaker);
}
var mapObj=null;;
function fnSetChangeCenterZoom(obj,mapX,mapY, iDepth){
if(iDepth == 'undefined' || iDepth == undefined) iDepth = 8;
var pos = new NPoint(mapX,mapY);
obj.setCenterAndZoom(pos,iDepth);
obj.enableWheelZoom(true);
}
function fnSetMapOverlayMulty(vId, vWidth, vHeight, vMapData, iDepth){
if(iDepth == 'undefined' || iDepth == undefined) iDepth = 8;
var strMapData = vMapData;
var arrMapData = strMapData.split("|");
var arrMapDtl = "";
mapObj = new NMap(document.getElementById(vId),{width:vWidth, height:vHeight, mapMode:0});
var infowin, arrMaker
for (var intX = 0;intX < arrMapData.length-1 ; intX++)
{
arrMapDtl = arrMapData[intX].split("^");
var mapX = arrMapDtl[0];
var mapY = arrMapDtl[1];
var iconUrl = "/images/date/i_mapnum"+arrMapDtl[2]+".gif";
var title = arrMapDtl[3];
var pos = new NPoint(mapX,mapY);
if (intX==0)
{
mapObj.setCenterAndZoom(pos, iDepth);
mapObj.enableWheelZoom(true);
/* 지도 좌표, 축적 수 준 초기화 */
}
//마커처리한다.
//마커처리후 이벤트 리스너 등록.
infowin = new NInfoWindow();
infowin.set(pos,"");
mapObj.addOverlay(infowin);
infowin.showWindow();
fnSetAddMaker(mapObj,pos,iconUrl);
}
/* 지도 컨트롤 생성 */
var zoom = new NZoomControl();
zoom.setAlign("right");
zoom.setValign("top");
mapObj.addControl(zoom);
/* 지도 모드 변경 버튼 생성 */
var mapBtns = new NMapBtns();
mapBtns.setAlign("right");
mapBtns.setValign("top");
mapObj.addControl(mapBtns);
/* 세이브 버튼 생성 */
var mapSave = new NSaveBtn()
mapSave.setAlign("right");
mapSave.setValign("bottom");
mapObj.addControl(mapSave);
}
//업로드 이미지 미리 보기
function fileUploadPreview(thisObj, preViewer) {
if(!/(\.gif|\.jpg|\.jpeg|\.png)$/i.test(thisObj.value)) {
alert("이미지 형식의 파일을 선택하십시오");
return;
}
preViewer = (typeof(preViewer) == "object") ? preViewer : document.getElementById(preViewer);
preViewer.innerHTML = "";
var ua = window.navigator.userAgent;
if (ua.indexOf("MSIE") > -1) {
var img_path = "";
if (thisObj.value.indexOf("\\fakepath\\") < 0) {
img_path = thisObj.value;
} else {
thisObj.select();
var selectionRange = document.selection.createRange();
img_path = selectionRange.text.toString();
thisObj.blur();
}
preViewer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fi" + "le://" + img_path + "', sizingMethod='scale')";
} else {
preViewer.innerHTML = "";
var W = preViewer.offsetWidth;
var H = preViewer.offsetHeight;
var tmpImage = document.createElement("img");
preViewer.appendChild(tmpImage);
tmpImage.onerror = function () {
return preViewer.innerHTML = "";
}
tmpImage.onload = function () {
if (this.width > W) {
this.height = this.height / (this.width / W);
this.width = W;
}
if (this.height > H) {
this.width = this.width / (this.height / H);
this.height = H;
}
}
if (ua.indexOf("Firefox/3") > -1) {
var picData = thisObj.files.item(0).getAsDataURL();
tmpImage.src = picData;
} else {
tmpImage.src = "file://" + thisObj.value;
}
}
}
//공통코드 AJAX 로 반환한다.
//파라미터 : obj(selectid), table("테이블명"), column (컬럼명) ,setcode(초기셋팅값), initval (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
//Jqtrantform 적용된 select box에서 사용 됨
function setCodeSelectJqTransForm(mode, obj, table, column, setcode, initval, pcode){
var url ="/common/lib/api.php?mode="+mode+"&nm_table="+table+"&nm_column="+column+"&pcode="+pcode;
$.getJSON(url,function(ajaxresult){
$("#"+obj).children().remove().end();
if(initval!=""){
$("#"+obj).append($('').val("").html(initval));
}
$.each(ajaxresult, function(i,item){
var cd_seq = item.seq;
var nm_code = item.code;
var nm_name = item.name;
var nm_pcode = item.pcode;
var nm_etc = item.etc;
// console.log(nm_code, nm_name);
if(setcode==nm_code){
$("#"+obj).append($('').val(nm_code).html(nm_name).attr('selected','selected').attr('etc',nm_etc));
}else{
$("#"+obj).append($('').val(nm_code).html(nm_name).attr('etc',nm_etc));
}
});
// jqtransformdone
$("#"+obj).jqTransSelectRefresh();
});
}
//공통코드 AJAX 로 반환한다.
//파라미터 : obj(selectid), table("테이블명"), column (컬럼명) ,setcode(초기셋팅값), initval (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
function setCodeSelect(mode, obj, table, column, setcode, initval, pcode){
var url ="/common/lib/api.php?mode="+mode+"&nm_table="+table+"&nm_column="+column+"&pcode="+pcode;
$.getJSON(url,function(ajaxresult){
$("#"+obj).children().remove().end();
if(initval!=""){
$("#"+obj).append($('').val("").html(initval));
}
$.each(ajaxresult, function(i,item){
var cd_seq = item.seq;
var nm_code = item.code;
var nm_name = item.name;
var nm_pcode = item.pcode;
var nm_etc = item.etc;
if(setcode==nm_code){
$("#"+obj).append($('').val(nm_code).html(nm_name).attr('selected','selected').attr('etc',nm_etc));
}else{
$("#"+obj).append($('').val(nm_code).html(nm_name).attr('etc',nm_etc));
}
});
});
}
function setCodeSelectLi(mode, obj, table, column, setcode, initval, pcode, callback){
var url ="/common/lib/api.php?mode="+mode+"&nm_table="+table+"&nm_column="+column+"&pcode="+pcode;
$.getJSON(url,function(ajaxresult){
$("#"+obj).children().remove().end();
if(initval!=""){
$("#"+obj).append($('').data("val", "").html(initval));
}
$.each(ajaxresult, function(i,item){
var cd_seq = item.seq;
var nm_code = item.code;
var nm_name = item.name;
var nm_pcode = item.pcode;
var nm_etc = item.etc;
if(setcode==nm_code){
$("#"+obj).append($('').data("val", nm_code).html(nm_name).addClass("select"));
}else{
$("#"+obj).append($('').data("val", nm_code).html(nm_name).removeClass("select"));
}
});
$("#"+obj+" > li").click(function(){
var _text = $(this).text();
var _code = $(this).data("val");
$(this).parent().siblings("span").text(_text);
$(this).parent().hide();
$(this).parents().parents().removeClass("open");
if(!$(this).hasClass("select")){
$(this).siblings().removeClass("select");
$(this).addClass("select");
if(callback){
callback(_code);
}
}
});
});
}
function setCodeRadio(mode, obj, table, column, setcode, initval, pcode){
var html = "";
$.ajax({
url: '/common/lib/api.php',
data : {'mode':mode,'nm_table':table,'nm_column':column,'pcode':pcode},
dataType : 'json',
method : 'POST',
success : function(data){
// $("#"+obj).empty();
$.each(data , function(idx, row){
html = "\n";
html+= " \n";
html+= " \n";
html+= " \n";
html+= "\n";
$("#"+obj).append(html);
});
}
});
}
function setCodeRadioLi(mode, obj, table, column, setcode, initval, pcode, callback){
var html = "";
$.ajax({
url: '/common/lib/api.php',
data : {'mode':mode,'nm_table':table,'nm_column':column,'pcode':pcode},
dataType : 'json',
method : 'POST',
success : function(data){
$("#"+obj).empty();
var i=1;
$.each(data , function(idx, row){
html = "\n";
html+= "\n";
html+= " \n";
html+= " \n";
html+= " \n";
html+= "\n";
html+= " \n";
$("#"+obj).append(html);
i++;
});
$('[name="'+obj+'"]').click(function(){
var _text = $(this).text();
var _code = $(this).val();
if(callback){
callback(_code);
}
});
}
});
}
// 2017.10.19
// objId 엘리먼트 자식 img num배 확대
function imgZoom(objId,num){
var obj = $("#"+objId);
$(obj).click(function(){
if($(this).hasClass("on")){
imgZoomInit(obj);
$(this).removeClass("on");
}else{
imgZoomPlus(obj,num);
$(this).addClass("on");
}
});
}
// 초기화
function imgZoomInit(obj){
$(obj).attr("style","").children("img").attr("style","");
}
// 이미지 확대
function imgZoomPlus(obj,num){
var objImg = obj.children("img");
var objImgW = objImg.width();
var objImgH = objImg.height();
$(obj).css({"width":objImgW,"height":objImgH,"overflow":"auto"}).children("img").css({"width":objImgW*num,"height":objImgH*num});
}
// end 2017.10.19
//Ajax페이징
function ListPgAjax(url,pageno,PageSize,BlockPage,totalrows)
{
var lastpgno=parseInt(Math.ceil(totalrows/PageSize)); //마지막 페이지
var now_num = parseInt(Math.ceil(pageno/BlockPage));
var start_num = parseInt((now_num - 1) * BlockPage);
var end_num = parseInt(now_num * BlockPage);
var next_num = parseInt(end_num + 1);//마지막 페이지 값 구함
var prev_num = parseInt(start_num);//시작 페이지 값 구함
var html = "";
//처음
if(pageno!=1) {
html += "맨 처음";
}
//이전
if(now_num > 1) {
html += "이전";
}
//블럭단위 페이징
for (i = start_num + 1; i <= end_num && i <= lastpgno; i++) {
if (i == pageno) {
html += " "+i+" ";
}
else {
html += ""+i+" ";
}
}
//다음
if(end_num < lastpgno) {
html += " 다음";
}
//마지막
if(pageno!=lastpgno && lastpgno>0 ) {
html += "맨 마지막";
}
return html;
}
//날짜 가져오기
function getSearchDate(type, num){
var searchDate = new Date();
if(type == "year"){
searchDate.setYear(searchDate.getFullYear()+num);
}else if(type == "month"){
searchDate.setMonth(searchDate.getMonth()+num);
}else if(type == "day"){
searchDate.setDate(searchDate.getDate()+num);
}
var y = searchDate.getFullYear();
var m = searchDate.getMonth() + 1;
var d = searchDate.getDate();
if(m < 10) { m = "0" + m; }
if(d < 10) { d = "0" + d; }
var resultDate = y + "-" + m + "-" + d;
return resultDate;
}
//차량정보 AJAX 로 반환한다.
//파라미터 : obj(selectid), table("테이블명"), column (컬럼명) ,setcode(초기셋팅값), initval (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
function getCarInfo(mode, obj, table, column, setcode, initval, pcode, callback){
var html = "";
$.ajax({
url: '/common/lib/api.php',
data : {'mode':mode,'nm_table':table,'nm_column':column,'pcode':pcode},
dataType : 'json',
method : 'POST',
success : function(data){
$("#"+obj).empty();
var i=1;
$.each(data , function(idx, row){
html = "\n";
html+= "\n";
html+= " \n";
html+= " \n";
html+= " \n";
html+= "\n";
html+= " \n";
$("#"+obj).append(html);
i++;
});
$('[name="'+obj+'"]').click(function(){
var _text = $(this).text();
var _code = $(this).val();
if(callback){
callback(_code);
}
});
}
});
}
function get_query(enc_str){
var url = '?'+enc_str;
var qs = url.substring(url.indexOf('?') + 1).split('&');
for(var i = 0, result = {}; i < qs.length; i++){
qs[i] = qs[i].split('=');
result[qs[i][0]] = decodeURIComponent(qs[i][1]);
}
return result;
}