function massage(txt, margin, width, height) {
var ok = '
' + txt
+ '
';
return ok;
}
function countChecked(eleName) {
var count, i;
var ele = document.getElementsByName(eleName);
count = 0;
if (ele == '[object]') {
if (ele[0] == '[object]') {
for (i = 0; ele[i]; i++) {
if (ele[i].checked) {
count++;
}
}
} else {
if (ele.checked) {
count++;
}
}
}
return count;
}
// 공통 : 공백문자 제거
function trimString(inString) {
var outString;
var startPos;
var endPos;
var ch;
// where do we start?
startPos = 0;
ch = inString.charAt(startPos);
while ((ch == " ") || (ch == "\b") || (ch == "\f") || (ch == "\n")
|| (ch == "\r") || (ch == "\n")) {
startPos++;
ch = inString.charAt(startPos);
}
// where do we end?
endPos = inString.length - 1;
ch = inString.charAt(endPos);
while ((ch == " ") || (ch == "\b") || (ch == "\f") || (ch == "\n")
|| (ch == "\r") || (ch == "\n")) {
endPos--;
ch = inString.charAt(endPos);
}
// get the string
outString = inString.substring(startPos, endPos + 1);
return outString;
}
// 다음 필드로 넘기기
function moveNext(varControl, varNext) {
if (varControl.value.length == varControl.maxLength) {
varNext.focus();
varNext.select();
}
}
// 오직 숫자만, '-' 포함!!!
function checkNumber() {
var objEv = event.srcElement;
var numPattern = /([^0-9, -])/;
numPattern = objEv.value.match(numPattern);
if (numPattern != null) {
alert("-기호와 숫자만 입력해 주세요!");
objEv.value = "";
objEv.focus();
return false;
}
}
// 오직 숫자만, '-' 빼고!!!
function checkNumber2() {
var objEv = event.srcElement;
var numPattern = /([^0-9])/;
numPattern = objEv.value.match(numPattern);
if (numPattern != null) {
alert("숫자만 입력해 주세요!");
objEv.value = "";
objEv.focus();
return false;
}
return true; // jinsus_20050910_orderSheet.tpl 에서 사용하기 위해 추가.
}
// 오직 숫자만, '.' 포함!!!
function checkNumber3() {
var objEv = event.srcElement;
var numPattern = /([^0-9, .])/;
numPattern = objEv.value.match(numPattern);
if (numPattern != null) {
// Dialog.alert({url: 'info_panel.html', options: {method: 'get'}},
// {className: 'alphacube', width:540, okLabel: 'Close'});
Dialog.alert("숫자만 입력해주세요.", {
windowParameters : {
className : "alphacube",
width : 300,
okLabel : 'Close'
}
});
objEv.value = "";
objEv.focus();
return false;
}
}
// ---------------------------------------
// RegExp Functions
// ---------------------------------------
function ereg(pattern, str) {
if (RegExp) {
pattern.ignoreCase = false;
return pattern.test(str);
} else {
return true;
}
}
function eregi(pattern, str) {
if (RegExp) {
pattern.ignoreCase = true;
return pattern.test(str);
} else {
return true;
}
}
function ereg_replace(pattern, replaceStr, str) {
if (RegExp) {
pattern.ignoreCase = false;
pattern.global = true;
return str.replace(pattern, replaceStr);
} else {
return str;
}
}
function eregi_replace(pattern, replaceStr, str) {
if (RegExp) {
pattern.ignoreCase = true;
pattern.global = true;
return str.replace(pattern, replaceStr);
} else {
return str;
}
}
// ---------------------------------------
// String Functions
// ---------------------------------------
function trim(str) {
return rtrim(ltrim(str));
}
function ltrim(str) {
return ereg_replace(/^[ \t]*/, "", str);
}
function rtrim(str) {
return ereg_replace(/[ \t]*$/, "", str);
}
function empty(str) {
return ((str == null) || (str.length == 0));
}
function hasWhiteSpace(str) {
return ereg(/\s/, str);
}
function is_numeric(str) {
return ereg(/^[0-9]*\.*[0-9]*$/, str);
}
// ---------------------------------------
// Form Functions
// ---------------------------------------
function notVaildFormValue(ele, msg) {
alert(msg);
ele.focus();
}
// eleName : String. 폼 요소 명
function countChecked(eleName) {
var count, i;
var ele = document.getElementsByName(eleName);
count = 0;
if (ele == '[object]') {
if (ele[0] == '[object]') {
for (i = 0; ele[i]; i++) {
if (ele[i].checked) {
count++;
}
}
} else {
if (ele.checked) {
count++;
}
}
}
return count;
}
function countChecked2(ele) {
var count, i;
count = 0;
if (ele == '[object]') {
if (ele[0] == '[object]') {
for (i = 0; ele[i]; i++) {
if (ele[i].checked) {
count++;
}
}
} else {
if (ele.checked) {
count++;
}
}
}
return count;
}
function selectedValue(ele) {
return ele.options[ele.selectedIndex].value;
}
function checkedValue(ele) {
for (i = 0; ele[i] == '[object]'; i++) {
if (ele[i].checked)
return ele[i].value;
}
}
function disableElement(obj) {
if (obj) {
obj.disabled = true;
}
}
function enableElement(obj) {
if (obj) {
obj.disabled = false;
}
}
// 체크박스명이 서로 다를때 체크된 갯수 체크
function checkedCnt() {
var cnt = 0;
for (i = 0; i <= form.length - 1; i++) {
if (document.form.elements[i].checked) {
cnt++;
}
}
return cnt;
}
function getMsgLen(strMsg) {
var msgLen = 0;
for (i = 0; i < strMsg.length; i++) {
if (strMsg.charCodeAt(i) == 13) {
} else if (strMsg.charCodeAt(i) <= 127) {
msgLen = msgLen + 1;
} else {
msgLen = msgLen + 2;
}
}
return msgLen;
}
// Dash 제거
function removeDash(sNo) {
var reNo = ""
for ( var i = 0; i < sNo.length; i++) {
if (sNo.charAt(i) != "-") {
reNo += sNo.charAt(i)
}
}
return reNo
}
// 레이어창 띄우기
function move_box(an, box) {
// 링크된 위치에서 부터의 설정값 지정
var cleft = 20; // 왼쪽마진
var ctop = -10; // 상단마진
var obj = an;
while (obj.offsetParent) {
cleft += obj.offsetLeft;
ctop += obj.offsetTop;
obj = obj.offsetParent;
}
box.style.left = cleft + 'px';
ctop += an.offsetHeight + 8;
if (document.body.currentStyle && document.body.currentStyle['marginTop']) {
ctop += parseInt(document.body.currentStyle['marginTop']);
}
box.style.top = ctop + 'px';
}
function show_hide_box(an, width, height, borderStyle, src) {
// var href = an.href;
var href = src;
// alert(href);
var boxdiv = document.getElementById(href);
if (boxdiv != null) {
if (boxdiv.style.display == 'none') {
move_box(an, boxdiv);
boxdiv.style.display = 'block';
} else
boxdiv.style.display = 'none';
return false;
}
boxdiv = document.createElement('div');
boxdiv.setAttribute('id', 'div1');
boxdiv.style.display = 'block';
boxdiv.style.position = 'absolute';
boxdiv.style.width = width + 'px';
boxdiv.style.height = height + 'px';
boxdiv.style.border = borderStyle;
boxdiv.style.backgroundColor = '#fff';
var contents = document.createElement('iframe');
contents.scrolling = 'yes';
contents.frameBorder = '0';
contents.style.width = width + 'px';
contents.style.height = height + 'px';
contents.src = href;
boxdiv.appendChild(contents);
document.body.appendChild(boxdiv);
move_box(an, boxdiv);
return false;
}
function Layerclose() {
if (parent.$('div1') != null) {
parent.$('div1').style.display = "none";
}
}
// confirm 창 함수화
function msgConfirm(msg, url, val) {
var val;
ans = confirm(msg)
if (ans == true) {
str = url + val
location.href = str;
}
}
// 입력글자 byte수 체크
function cm_get_byte(str) { // 문자열의 byte 길이를 알아냄(한글 2byte로 처리)
var i, m = str.length, re_count = 0, val = 0;
;
for (i = 0; i < m; i++) {
val = escape(str.charAt(i)).length;
if (val > 3)
re_count++;
re_count++;
}
return re_count;
}
// 입력 byte 제한을 체크하여 출력
function chkTextLength(str, limit, output) {
if (limit && txt_limit > limit) {
alert("입력제한 글자를 초과했습니다.");
return false;
}
output.value = txt_limit + " / " + limit + " Byte";
}
function dialogAlert(msg) {
Dialog.alert(msg, {
windowParameters : {
className : "alphacube",
width : 300,
okLabel : '닫기'
}
});
}
function dialogAjax(ajaxUrl, ajaxWidth, ajaxHeight) {
Dialog.alert( {
url : ajaxUrl,
options : {
method : 'get'
}
}, {
className : 'alphacube',
width : ajaxWidth,
height : ajaxHeight,
closable : true,
draggable : true,
okLabel : '닫기'
})
}
function dialogAjaxDefault(ajaxUrl, ajaxWidth, ajaxHeight) {
Dialog.alert( {
url : ajaxUrl,
options : {
method : 'get'
}
}, {
className : 'default',
width : ajaxWidth,
height : ajaxHeight,
closable : true,
draggable : true,
okLabel: 'none'
})
}
function changeMenu(main_mnu) {
alert(main_mnu.value);
// dialogAjax('order.php?main_mnu='+main_mnu, '600');
}
function comma(n) {
return Number(String(n).replace(/\..*|[^\d]/g, "")).toLocaleString().slice(
0, -3);
}
function openConfirm(msg) {
Dialog.confirm(msg, {
top : 10,
width : 250,
className : "alphacube",
okLabel : "Yes",
cancelLabel : "No"
})
}