// 전역 변수
var errmsg = "";
var errfld;
/**
* 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();
}
/**
* , 를 없앤다.
* @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();
}
}
/**
* @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_tel(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);
}
//슬라이딩배너
//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("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!_.")
function fnCheckAlphaNumber(str) {
var rtn;
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');
}
// 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 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();
}
// 특정영역만 프린트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();
}
/***************************************************************
* 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 isStrongValidFormPassword(val) {
var check = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{6,16}$/;
if (!check.test(val)) {
alert("비밀번호는 문자, 숫자, 특수문자의 조합으로 입력해주세요.");
return false;
}
if (val.length < 6 || val.length > 16) {
alert("비밀번호는 6 ~ 16 자리로 입력해주세요.");
return false;
}
return true;
}
function isValidFormPassword(val) {
var check = /^(?=.*[a-zA-Z])(?=.*[0-9]).{6,16}$/;
if (!check.test(val)) {
alert("비밀번호는 문자, 숫자, 조합으로 입력해주세요.");
return false;
}
if (val.length < 6 || val.length > 16) {
alert("비밀번호는 6 ~ 16 자리로 입력해주세요.");
return false;
}
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 (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
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));
}
});
});
}
//호수내역 패이징으로 처리 한다
var g_preval = "이전";
var g_nextval = "다음";
function setCateDateSelect(cd_cate, page, obj,setcode,initval){
var selected = false;
cd_cate = (typeof cd_cate !== undefined) ? cd_cate : "ZZZZ"
page = (typeof page !== undefined) ? page : 1;
var url ="/common/lib/api.php?mode=listNewsDatePagging&cd_cate="+cd_cate+"&page="+page+"&code="+setcode;
$.getJSON(url,function(json){
var nowpage = Number(json.nowpage);
var lastpage = Number(json.lastpage);
$("#"+obj).children().remove().end();
if(nowpage <= lastpage){
if(nowpage > 1){
$("#"+obj).append($('').val(nowpage-1).html(g_preval));
}
}
if(initval!=""){
$("#"+obj).append($('').val("").html(initval).attr('selected','selected'));
}
$.each(json.data, function(i,item){
var seq = item.seq;
var code = item.code;
var fullname = item.fullname;
var name = item.title;
if(cd_cate=="ZZZZ"){
name = fullname;
}
if(setcode==code){
$("#"+obj).append($('').val(code).html(name).attr('selected','selected'));
}else{
$("#"+obj).append($('').val(code).html(name));
}
});
if(nowpage < lastpage){
$("#"+obj).append($('').val(nowpage+1).html(g_nextval));
}
});
}
function addbookmark(title,url) {
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title,url,'');
return false;
} else if(document.all) { // IE Favorite
e.preventDefault();
window.external.AddFavorite(url,title);
}else {
alert( (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D 를 클릭하시면 북마크 가능합니다.');
}
}
function fnPrintNews(seq){
opt = 'scrollbars=yes, width=800,height=500, top=10, left=20';
popup_window("/sub/newsprint.php?cd_news="+seq, 'newsPrint', opt);
};
function printPage(obj){
var initBody;
window.onbeforeprint = function(){
initBody = document.body.innerHTML;
document.body.innerHTML = document.getElementById(obj).innerHTML;
};
window.onafterprint = function(){
document.body.innerHTML = initBody;
};
window.print();
return false;
}
function fontPlus() {
$(".tit").css("font-size",parseFloat($(".tit").css("font-size"),10)+1+"px");
$(".subtit").css("font-size",parseFloat($(".subtit").css("font-size"),10)+1+"px");
$(".date").css("font-size",parseFloat($(".date").css("font-size"),10)+1+"px");
$(".name").css("font-size",parseFloat($(".name").css("font-size"),10)+1+"px");
$(".cont").css("font-size",parseFloat($(".cont").css("font-size"),10)+1+"px");
$(".cont p").css("font-size",parseFloat($(".cont p").css("font-size"),10)+1+"px");
$(".cont p span").css("font-size",parseFloat($(".cont p span").css("font-size"),10)+1+"px");
$(".cont span").css("font-size",parseFloat($(".cont span").css("font-size"),10)+1+"px");
$(".cop").css("font-size",parseFloat($(".cop").css("font-size"),10)+1+"px");
}
function fontMinus() {
$(".tit").css("font-size",parseFloat($(".tit").css("font-size"),10)-1+"px");
$(".subtit").css("font-size",parseFloat($(".subtit").css("font-size"),10)-1+"px");
$(".date").css("font-size",parseFloat($(".date").css("font-size"),10)-1+"px");
$(".name").css("font-size",parseFloat($(".name").css("font-size"),10)-1+"px");
$(".cont p").css("font-size",parseFloat($(".cont p").css("font-size"),10)-1+"px");
$(".cont p span").css("font-size",parseFloat($(".cont p span").css("font-size"),10)-1+"px");
$(".cont span").css("font-size",parseFloat($(".cont span").css("font-size"),10)-1+"px");
$(".cop").css("font-size",parseFloat($(".cop").css("font-size"),10)-1+"px");
}
function rawurlencode(str) {
str = (str + '').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A');
}
//다음 도로명 + 지번 우편번호 연동
function setZipcode(zipcode,addr1, addr2) {
new daum.Postcode({
oncomplete: function(data) {
// 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
// 각 주소의 노출 규칙에 따라 주소를 조합한다.
// 내려오는 변수가 값이 없는 경우엔 공백('')값을 가지므로, 이를 참고하여 분기 한다.
var fullAddr = ''; // 최종 주소 변수
var extraAddr = ''; // 조합형 주소 변수
// 사용자가 선택한 주소 타입에 따라 해당 주소 값을 가져온다.
if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
fullAddr = data.roadAddress;
} else { // 사용자가 지번 주소를 선택했을 경우(J)
fullAddr = data.jibunAddress;
}
// 사용자가 선택한 주소가 도로명 타입일때 조합한다.
if(data.userSelectedType === 'R'){
//법정동명이 있을 경우 추가한다.
if(data.bname !== ''){
extraAddr += data.bname;
}
// 건물명이 있을 경우 추가한다.
if(data.buildingName !== ''){
extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
}
// 조합형주소의 유무에 따라 양쪽에 괄호를 추가하여 최종 주소를 만든다.
fullAddr += (extraAddr !== '' ? ' ('+ extraAddr +')' : '');
}
// 우편번호와 주소 정보를 해당 필드에 넣는다.
document.getElementById(zipcode).value = data.zonecode;
document.getElementById(addr1).value = fullAddr;
// 커서를 상세주소 필드로 이동한다.
if(addr2!==""){
document.getElementById(addr2).focus();
}
}
}).open();
}