common.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498
  1. // 전역 변수
  2. var errmsg = "";
  3. var errfld;
  4. function _blank(url) {
  5. window.open(url, '_blank');
  6. }
  7. function new_popup(url, name) {
  8. window.open(url, name, 'height=' + screen.height + ',width=' + screen.width + 'fullscreen=yes');
  9. }
  10. function reload() {
  11. window.location.reload();
  12. }
  13. function link_replace(url) {
  14. window.location.replace(url);
  15. }
  16. function link(url) {
  17. window.location.href = url;
  18. }
  19. function popup_full(url, name) {
  20. window.open(url, name,'height=' + screen.height + ',width=' + screen.width + 'fullscreen=yes');
  21. }
  22. function popup_close() {
  23. self.close();
  24. }
  25. var custom_modal_alert_opts = {
  26. id : '',
  27. title : '',
  28. width : '400px',
  29. // height : '200px',
  30. height : 'auto',
  31. zIndex : '99999',
  32. btn_confirm_text : '확인',
  33. btn_close_show : true,
  34. event_esc_key : true,
  35. }
  36. var custom_modal_confirm_opts = {
  37. id : '',
  38. title : '',
  39. desc : '',
  40. width : '400px',
  41. // height : '200px',
  42. height : 'auto',
  43. zIndex : '99999',
  44. btn_cancel_text : '취소',
  45. btn_confirm_text : '확인',
  46. btn_close_show : true,
  47. event_esc_key : true,
  48. }
  49. // $(document).on("add_custom_modal_alert_keyup_event", "#custom_modal_alert", function(e){
  50. // // console.log($("#custom_modal_alert").css("display") == "flex");
  51. // // if (e.key === "Escape") {
  52. // // console.log(e.keyCode);
  53. // // }
  54. //
  55. // console.log('aaaa');
  56. // });
  57. $(document).on("add_custom_modal_alert_keyup_event", "#custom_modal_alert", function(e){
  58. custom_modal_alert_close();
  59. if(typeof custom_modal_alert_opts.id != "undefined" && $.trim(custom_modal_alert_opts.id) != "" && $("#"+custom_modal_alert_opts.id).attr("type") != "hidden") {
  60. $("#"+custom_modal_alert_opts.id).focus();
  61. }
  62. });
  63. $(document).on("add_custom_modal_confirm_keyup_event", "#custom_modal_confirm", function(e){
  64. custom_modal_confirm_close();
  65. if(typeof custom_modal_confirm_opts.id != "undefined" && $.trim(custom_modal_confirm_opts.id) != "" && $("#"+custom_modal_confirm_opts.id).attr("type") != "hidden") {
  66. $("#"+custom_modal_confirm_opts.id).focus();
  67. }
  68. });
  69. //alert 오픈
  70. function custom_modal_alert_open() {
  71. $("#custom_modal_alert").removeClass("hide");
  72. }
  73. //alert 닫음
  74. function custom_modal_alert_close() {
  75. $("#custom_modal_alert").addClass("hide");
  76. }
  77. //alert 창
  78. function custom_modal_alert(opts, callback) {
  79. //option setting
  80. for(var i in opts) {
  81. custom_modal_alert_opts[i] = opts[i];
  82. }
  83. //제목
  84. $("#custom_modal_alert_title").html(custom_modal_alert_opts.title.replace(/\n/g, "<br/>").replace(/\\n/g, "<br/>"));
  85. //확인 버튼
  86. $("#btn_custom_modal_alert_proc").text(custom_modal_alert_opts.btn_confirm_text);
  87. if(custom_modal_alert_opts.btn_close_show != true) {
  88. $("#custom_modal_alert #btn_custom_modal_alert_close").hide();
  89. }
  90. $("#custom_modal_alert").zIndex(custom_modal_alert_opts.zIndex);
  91. $("#custom_modal_alert .custom--pop--wrapper--inner").css({width: custom_modal_alert_opts.with, height: custom_modal_alert_opts.height});
  92. // console.log(custom_modal_alert_opts);
  93. custom_modal_alert_open();
  94. $(document).on("keyup", function(e){
  95. if(custom_modal_alert_opts.event_esc_key == true) {
  96. var custom_modal_alert_display = $("#custom_modal_alert").css("display");
  97. if ($.inArray(custom_modal_alert_display, ['block', 'flex']) != -1 && e.key === "Escape") {
  98. $("#custom_modal_alert").trigger("add_custom_modal_alert_keyup_event", []);
  99. }
  100. }
  101. });
  102. //확인
  103. $("#btn_custom_modal_alert_proc").on("click", function() {
  104. // console.log(1)
  105. $("#btn_custom_modal_alert_proc").unbind("click");
  106. $("#btn_custom_modal_alert_close").unbind("click");
  107. if(typeof callback === 'function') {
  108. callback(true);
  109. }else {
  110. custom_modal_alert_close();
  111. }
  112. });
  113. //닫기
  114. $("#btn_custom_modal_alert_close").on("click", function() {
  115. // console.log(2)
  116. $("#btn_custom_modal_alert_proc").unbind("click");
  117. $("#btn_custom_modal_alert_close").unbind("click");
  118. custom_modal_alert_close();
  119. });
  120. }
  121. //2023-03-28 팝업 신규 디자인 반영
  122. function custom_modal_alert_new(opts, callback) {
  123. //option setting
  124. for(var i in opts) {
  125. custom_modal_alert_opts[i] = opts[i];
  126. }
  127. $("#custom_modal_alert_title").html(custom_modal_alert_opts.title.replace(/\n/g, "<br/>").replace(/\\n/g, "<br/>"));
  128. $(document).on("keyup", function(e){
  129. if(custom_modal_alert_opts.event_esc_key == true) {
  130. var custom_modal_alert_display = $("#custom_modal_alert").css("display");
  131. if ($.inArray(custom_modal_alert_display, ['block', 'flex']) != -1 && e.key === "Escape") {
  132. $("#custom_modal_alert").trigger("add_custom_modal_alert_keyup_event", []);
  133. }
  134. }
  135. });
  136. //확인
  137. $("#btn_custom_modal_alert_proc").on("click", function() {
  138. // console.log(1)
  139. $("#btn_custom_modal_alert_proc").unbind("click");
  140. $("#btn_custom_modal_alert_close").unbind("click");
  141. if(typeof callback === 'function') {
  142. callback(true);
  143. }else {
  144. custom_modal_alert_close();
  145. }
  146. });
  147. //닫기
  148. $("#btn_custom_modal_alert_close").on("click", function() {
  149. // console.log(2)
  150. $("#btn_custom_modal_alert_proc").unbind("click");
  151. $("#btn_custom_modal_alert_close").unbind("click");
  152. custom_modal_alert_close();
  153. });
  154. }
  155. //modal open
  156. function custom_modal_confirm_open() {
  157. $("#custom_modal_confirm").removeClass("hide");
  158. }
  159. //modal close
  160. function custom_modal_confirm_close() {
  161. $("#custom_modal_confirm").addClass("hide");
  162. $(".dimLayer").remove();
  163. }
  164. //modal open
  165. function custom_modal_confirm(opts, callback) {
  166. //option setting
  167. for(var i in opts) {
  168. custom_modal_confirm_opts[i] = opts[i];
  169. }
  170. //제목
  171. //&lt;br/&gt;
  172. $("#custom_modal_confirm #custom_modal_confirm_title").html(custom_modal_confirm_opts.title.replace(/\n/g, "<br/>").replace(/\\n/g, "<br/>"));
  173. //내용
  174. $("#custom_modal_confirm #custom_modal_confirm_desc").text(custom_modal_confirm_opts.desc);
  175. //확인 버튼
  176. $("#custom_modal_confirm #btn_custom_modal_confirm_proc").text(custom_modal_confirm_opts.btn_confirm_text);
  177. //취소 버튼
  178. $("#custom_modal_confirm #btn_custom_modal_confirm_cancel").text(custom_modal_confirm_opts.btn_cancel_text);
  179. if(custom_modal_confirm_opts.btn_close_show != true) {
  180. $("#custom_modal_confirm #btn_custom_modal_confirm_close").hide();
  181. }
  182. $("#custom_modal_confirm").zIndex(custom_modal_confirm_opts.zIndex);
  183. $("#custom_modal_confirm .custom--pop--wrapper--inner").css({width: custom_modal_confirm_opts.width, height: custom_modal_confirm_opts.height});
  184. custom_modal_confirm_open();
  185. $(document).on("keyup", function(e){
  186. if(custom_modal_confirm_opts.event_esc_key == true) {
  187. var custom_modal_confirm_display = $("#custom_modal_confirm").css("display");
  188. if ($.inArray(custom_modal_confirm_display, ['block', 'flex']) != -1 && e.key === "Escape") {
  189. $("#custom_modal_confirm").trigger("add_custom_modal_confirm_keyup_event", []);
  190. }
  191. }
  192. });
  193. //modal confirm
  194. $("#btn_custom_modal_confirm_proc").on("click", function() {
  195. $("#btn_custom_modal_confirm_cancel").unbind("click");
  196. $("#btn_custom_modal_confirm_proc").unbind("click");
  197. $("#btn_custom_modal_confirm_close").unbind("click");
  198. // console.log(1)
  199. if(typeof callback === 'function') {
  200. callback(true);
  201. }else {
  202. custom_modal_confirm_close();
  203. }
  204. });
  205. //modal cancel
  206. $("#btn_custom_modal_confirm_cancel").on("click", function() {
  207. // console.log(2)
  208. $("#btn_custom_modal_confirm_cancel").unbind("click");
  209. $("#btn_custom_modal_confirm_proc").unbind("click");
  210. $("#btn_custom_modal_confirm_close").unbind("click");
  211. custom_modal_confirm_close();
  212. });
  213. //modal close
  214. $("#btn_custom_modal_confirm_close").on("click", function() {
  215. // console.log(3)
  216. $("#btn_custom_modal_confirm_cancel").unbind("click");
  217. $("#btn_custom_modal_confirm_proc").unbind("click");
  218. $("#btn_custom_modal_confirm_close").unbind("click");
  219. custom_modal_confirm_close();
  220. });
  221. }
  222. function custom_modal_confirm2(opts, callback) {
  223. custom_modal_confirm_open();
  224. if(typeof opts.title != "undefined") {
  225. $("#custom_modal_confirm #custom_modal_confirm_title").text(opts.title);
  226. }
  227. if(typeof opts.desc != "undefined") {
  228. $("#custom_modal_confirm #custom_modal_confirm_desc").text(opts.desc);
  229. }
  230. if(typeof opts.btn_cancel_text != "undefined") {
  231. $("#custom_modal_confirm #btn_custom_modal_confirm_cancel").text(opts.btn_cancel_text);
  232. }
  233. if(typeof opts.btn_confirm_text != "undefined") {
  234. $("#custom_modal_confirm #btn_custom_modal_confirm_proc").text(opts.btn_confirm_text);
  235. }
  236. // console.log("AAAAA", opts.btn_close_show);
  237. if(typeof opts.btn_close_show != "undefined" && opts.btn_close_show != true) {
  238. $("#custom_modal_confirm #btn_custom_modal_confirm_close").hide();
  239. }
  240. //modal confirm
  241. $("#btn_custom_modal_confirm_proc").on("click", function() {
  242. $("#btn_custom_modal_confirm_cancel").unbind("click");
  243. $("#btn_custom_modal_confirm_proc").unbind("click");
  244. $("#btn_custom_modal_confirm_close").unbind("click");
  245. // console.log(1)
  246. if(typeof callback === 'function') {
  247. callback(true);
  248. }else {
  249. custom_modal_confirm_close();
  250. }
  251. });
  252. //modal cancel
  253. $("#btn_custom_modal_confirm_cancel").hide();
  254. $("#btn_custom_modal_confirm_cancel").on("click", function() {
  255. // console.log(2)
  256. $("#btn_custom_modal_confirm_cancel").unbind("click");
  257. $("#btn_custom_modal_confirm_proc").unbind("click");
  258. $("#btn_custom_modal_confirm_close").unbind("click");
  259. custom_modal_confirm_close();
  260. });
  261. //modal close
  262. $("#btn_custom_modal_confirm_close").on("click", function() {
  263. // console.log(3)
  264. $("#btn_custom_modal_confirm_cancel").unbind("click");
  265. $("#btn_custom_modal_confirm_proc").unbind("click");
  266. $("#btn_custom_modal_confirm_close").unbind("click");
  267. custom_modal_confirm_close();
  268. });
  269. }
  270. function viewLayerPopup(obj){
  271. var _this = $("."+obj + "_popup");
  272. var _thisW = _this.width() / 2;
  273. var _thisH = _this.height() / 2;
  274. _this.css('margin-left',-_thisW);
  275. _this.css('margin-top',-_thisH);
  276. _this.show();
  277. $("body").append("<div class='dim'></div>");
  278. }
  279. function closeLayerPopup(obj){
  280. $("." + obj + "_popup").hide();
  281. $(".dim").remove();
  282. }
  283. /**
  284. * console.log() 대용(콘솔 사용불가시 자바스크립트 오류발생 방지)
  285. **/
  286. function debugPrint(msg) {
  287. if (typeof console == 'object' && typeof console.log == 'function') {
  288. console.log(msg);
  289. }
  290. }
  291. /**
  292. * 필드 검사
  293. **/
  294. function check_field(fld, msg) {
  295. if((fld.value = trim(fld.value)) == '') {
  296. error_field(fld, msg);
  297. } else {
  298. clear_field(fld);
  299. }
  300. return;
  301. }
  302. /**
  303. * 필드 오류 표시
  304. **/
  305. function error_field(fld, msg) {
  306. if(msg != "") errmsg += msg + "\n";
  307. if(!errfld) errfld = fld;
  308. fld.style.background = "#BDDEF7";
  309. }
  310. /**
  311. * 필드를 깨끗하게
  312. **/
  313. function clear_field(fld) {
  314. fld.style.background = "#FFFFFF";
  315. }
  316. /**
  317. * @TODO 함수 설명 필요
  318. **/
  319. function trim(s) {
  320. var t = '';
  321. var from_pos = to_pos = 0;
  322. for(i = 0; i < s.length; i++) {
  323. if(s.charAt(i) == ' ') {
  324. continue;
  325. } else {
  326. from_pos = i;
  327. break;
  328. }
  329. }
  330. for(i = s.length; i >= 0; i--) {
  331. if(s.charAt(i - 1) == ' ') {
  332. continue;
  333. } else {
  334. to_pos = i;
  335. break;
  336. }
  337. }
  338. t = s.substring(from_pos, to_pos);
  339. return t;
  340. }
  341. /**
  342. * 자바스크립트로 PHP의 number_format 흉내를 냄
  343. * 숫자에 , 를 출력
  344. **/
  345. function number_format(data) {
  346. var tmp = '';
  347. var number = '';
  348. var cutlen = 3;
  349. var comma = ',';
  350. var i;
  351. len = data.length;
  352. mod = (len % cutlen);
  353. k = cutlen - mod;
  354. for(i = 0; i < data.length; i++) {
  355. number = number + data.charAt(i);
  356. if(i < data.length - 1) {
  357. k++;
  358. if((k % cutlen) == 0) {
  359. number = number + comma;
  360. k = 0;
  361. }
  362. }
  363. }
  364. return number;
  365. }
  366. /**
  367. * 새 창
  368. **/
  369. function popup_window(url, winname, opt) {
  370. window.open(url, winname, opt);
  371. }
  372. /**
  373. * a 태그에서 onclick 이벤트를 사용하지 않기 위해
  374. * @TODO 설명문구 수정
  375. **/
  376. function win_open(url, name, option) {
  377. var popup = window.open(url, name, option);
  378. popup.focus();
  379. }
  380. /**
  381. * 폼메일 창
  382. **/
  383. function popup_formmail(url) {
  384. opt = 'scrollbars=yes, width=417, height=385, top=10, left=20';
  385. popup_window(url, 'wformmail', opt);
  386. }
  387. /**
  388. * , 를 없앤다.
  389. * @TODO 문자열 치환하는데 왜 loop를 돌지?
  390. **/
  391. function no_comma(data) {
  392. var tmp = '';
  393. var comma = ',';
  394. var i;
  395. for(i = 0; i < data.length; i++) {
  396. if(data.charAt(i) != comma) tmp += data.charAt(i);
  397. }
  398. return tmp;
  399. }
  400. /**
  401. * 삭제 검사 확인
  402. **/
  403. function del(href) {
  404. if(confirm("한번 삭제한 자료는 복구할 방법이 없습니다.\n\n정말 삭제하시겠습니까?")) {
  405. document.location.href = href;
  406. }
  407. }
  408. /**
  409. * 쿠키 입력
  410. * @TODO 쿠키 플러그인으로 대체
  411. **/
  412. function set_cookie(name, value, expirehours, domain) {
  413. var today = new Date();
  414. today.setTime(today.getTime() + (60 * 60 * 1000 * expirehours));
  415. document.cookie = name + '=' + escape( value ) + '; path=/; expires=' + today.toGMTString() + ';';
  416. if(domain) {
  417. document.cookie += 'domain=' + domain + ';';
  418. }
  419. }
  420. /**
  421. * 쿠키 얻음
  422. * @TODO 쿠키 플러그인으로 대체
  423. **/
  424. function get_cookie(name) {
  425. var find_sw = false;
  426. var start, end;
  427. var i = 0;
  428. for(i = 0; i <= document.cookie.length; i++) {
  429. start = i;
  430. end = start + name.length;
  431. if(document.cookie.substring(start, end) == name) {
  432. find_sw = true;
  433. break;
  434. }
  435. }
  436. if(find_sw == true) {
  437. start = end + 1;
  438. end = document.cookie.indexOf(';', start);
  439. if(end < start) end = document.cookie.length;
  440. return document.cookie.substring(start, end);
  441. }
  442. return '';
  443. }
  444. /**
  445. * 쿠키 지움
  446. * @TODO 쿠키 플러그인으로 대체
  447. **/
  448. function delete_cookie(name) {
  449. var today = new Date();
  450. today.setTime(today.getTime() - 1);
  451. var value = get_cookie(name);
  452. if(value != '') {
  453. document.cookie = name + '=' + value + '; path=/; expires=' + today.toGMTString();
  454. }
  455. }
  456. var last_id = null;
  457. /**
  458. * @TODO 함수설명 필요
  459. **/
  460. function menu(id) {
  461. if(id != last_id) {
  462. if(last_id != null) {
  463. jQuery('#' + last_id).hide();
  464. }
  465. jQuery('#' + id).show();
  466. last_id = id;
  467. } else {
  468. jQuery('#' + id).hide();
  469. last_id = null;
  470. }
  471. }
  472. /**
  473. * @TODO 함수설명 필요
  474. **/
  475. function textarea_decrease(id, row) {
  476. if(document.getElementById(id).rows - row > 0) {
  477. document.getElementById(id).rows -= row;
  478. }
  479. }
  480. /**
  481. * @TODO 함수설명 필요
  482. **/
  483. function textarea_original(id, row) {
  484. document.getElementById(id).rows = row;
  485. }
  486. /**
  487. * @TODO 함수설명 필요
  488. **/
  489. function textarea_increase(id, row) {
  490. document.getElementById(id).rows += row;
  491. }
  492. /**
  493. * 글숫자 검사
  494. * @TODO 함수설명 보완
  495. **/
  496. function check_byte(content, target) {
  497. var i = 0;
  498. var cnt = 0;
  499. var ch = '';
  500. var cont = document.getElementById(content).value;
  501. for(i = 0; i < cont.length; i++) {
  502. ch = cont.charAt(i);
  503. if(escape(ch).length > 4) {
  504. cnt += 2;
  505. } else {
  506. cnt += 1;
  507. }
  508. }
  509. // 숫자를 출력
  510. document.getElementById(target).innerHTML = cnt;
  511. return cnt;
  512. }
  513. /**
  514. * 브라우저에서 오브젝트의 왼쪽 좌표
  515. * @TODO jQuery 함수로 대체
  516. **/
  517. function get_left_pos(obj) {
  518. var parentObj = null;
  519. var clientObj = obj;
  520. var left = obj.offsetLeft;
  521. while((parentObj = clientObj.offsetParent) != null) {
  522. left = left + parentObj.offsetLeft;
  523. clientObj = parentObj;
  524. }
  525. return left;
  526. }
  527. /**
  528. * 브라우저에서 오브젝트의 상단 좌표
  529. * @TODO jQuery 함수로 대체
  530. **/
  531. function get_top_pos(obj) {
  532. var parentObj = null;
  533. var clientObj = obj;
  534. var top = obj.offsetTop;
  535. while((parentObj=clientObj.offsetParent) != null) {
  536. top = top + parentObj.offsetTop;
  537. clientObj = parentObj;
  538. }
  539. return top;
  540. }
  541. /**
  542. * @TODO 함수설명 필요
  543. **/
  544. function flash_movie(src, ids, width, height, wmode) {
  545. var wh = '';
  546. if(parseInt(width) && parseInt(height)) {
  547. wh = " width='"+width+"' height='"+height+"' ";
  548. }
  549. return "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' "+wh+" id="+ids+"><param name=wmode value="+wmode+"><param name=movie value="+src+"><param name=quality value=high><embed src="+src+" quality=high wmode="+wmode+" type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' "+wh+"></embed></object>";
  550. }
  551. /**
  552. * @TODO 함수설명 필요
  553. **/
  554. function obj_movie(src, ids, width, height, autostart) {
  555. var wh = "";
  556. if (parseInt(width) && parseInt(height))
  557. wh = " width='"+width+"' height='"+height+"' ";
  558. if (!autostart) autostart = false;
  559. return "<embed src='"+src+"' "+wh+" autostart='"+autostart+"'></embed>";
  560. }
  561. /**
  562. * @TODO 함수설명 필요
  563. **/
  564. function doc_write(cont) {
  565. document.write(cont);
  566. }
  567. String.prototype.trim = function() {
  568. return this.replace(/^\s+|\s+$/g, '');
  569. }
  570. String.prototype.ltrim = function() {
  571. return this.replace(/^\s+/, '');
  572. }
  573. String.prototype.rtrim = function() {
  574. return this.replace(/\s+$/, '');
  575. }
  576. /**
  577. * 한글, 영문, 숫자 검사
  578. **/
  579. function chk_hanalnum(s) {
  580. var pattern = /([^가-힣ㄱ-ㅎㅏ-ㅣ^a-z^0-9])/i;
  581. return pattern.test(s);
  582. }
  583. /**
  584. *도메인 체크
  585. */
  586. function chk_url(s) {
  587. var pattern =/^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/;
  588. return pattern.test(s);
  589. }
  590. /**
  591. * 이메일주소 검사
  592. **/
  593. function chk_email(s) {
  594. var pattern = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/;
  595. return pattern.test(s);
  596. }
  597. function chk_date(s){
  598. var pattern = /[0-9]{4}-[0-9]{2}-[0-9]{2}/;
  599. return pattern.test(s);
  600. }
  601. /**
  602. * 전화번호
  603. **/
  604. function chk_hp(s) {
  605. var pattern = /^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-?[0-9]{3,4}-?[0-9]{4}$/;
  606. return pattern.test(s);
  607. }
  608. function chk_tel(s) {
  609. var pattern = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
  610. return pattern.test(s);
  611. }
  612. /**
  613. * 포인트 창
  614. **/
  615. var win_point = function(href) {
  616. var new_win = window.open(href, 'win_point', 'left=100,top=100,width=600, height=600, scrollbars=1');
  617. new_win.focus();
  618. }
  619. /**
  620. * 쪽지 창
  621. **/
  622. var win_memo = function(href) {
  623. var new_win = window.open(href, 'win_memo', 'left=100,top=100,width=620,height=500,scrollbars=1');
  624. new_win.focus();
  625. }
  626. /**
  627. * 메일 창
  628. **/
  629. var win_email = function(href) {
  630. var new_win = window.open(href, 'win_email', 'left=100,top=100,width=600,height=580,scrollbars=0');
  631. new_win.focus();
  632. }
  633. /**
  634. * 우편번호 창
  635. **/
  636. var win_zip = function(href) {
  637. var new_win = window.open(href, 'win_zip', 'width=616, height=460, scrollbars=1');
  638. new_win.focus();
  639. }
  640. // 게시물 이름 클릭하면 나오는 레이어
  641. var div_sidebox = null;
  642. jQuery(function($) {
  643. $('.win_point').click(function() {
  644. win_point(this.href);
  645. return false;
  646. });
  647. $('.win_memo').click(function() {
  648. win_memo(this.href);
  649. return false;
  650. });
  651. $('.win_email').click(function() {
  652. win_email(this.ref);
  653. return false;
  654. });
  655. $('.win_scrap').click(function() {
  656. win_scrap(this.href);
  657. return false;
  658. });
  659. $('.win_profile').click(function() {
  660. win_profile(this.ref);
  661. return false;
  662. });
  663. $('.win_homepage').click(function() {
  664. win_homepage(this.ref);
  665. return false;
  666. });
  667. $('.win_zip_find').click(function() {
  668. win_zip(this.href);
  669. return false;
  670. });
  671. $('.win_password_lost').click(function() {
  672. win_password_lost(this.href);
  673. return false;
  674. });
  675. $('.win_poll').click(function() {
  676. win_poll(this.href);
  677. return false;
  678. });
  679. //==========================================================================
  680. // 게시물 이름 레이어
  681. //--------------------------------------------------------------------------
  682. div_sidebox = document.createElement('DIV');
  683. div_sidebox.id = 'sidebox';
  684. div_sidebox.style.display = 'none';
  685. div_sidebox.style.position = 'absolute';
  686. document.body.appendChild(div_sidebox);
  687. var click_document_area = false;
  688. document.onclick = function() {
  689. if(!click_document_area) {
  690. div_sidebox.style.display = 'none';
  691. } else {
  692. click_document_area = false;
  693. }
  694. }
  695. $('.sidebox').bind('click', function() {
  696. var $this = $(this);
  697. click_document_area = true;
  698. var top = $this.offset().top;
  699. var left = $this.offset().left;
  700. var width = $this.width();
  701. var height = $this.height();
  702. $('#sidebox').css({'top' : top + height / 3, 'left' : left + width - 5});
  703. var aflds = this.rel.split('&');
  704. var fld;
  705. for(var i = 0; i < aflds.length; i++) {
  706. fld = aflds[i].split('=');
  707. eval('var ' + fld[0] + ' = "' + fld[1] + '";');
  708. }
  709. var html = '';
  710. var first = ' class="first-child"';
  711. // 쪽지보내기
  712. if(mb_id) {
  713. html += "<li"+first+"><a href=\"javascript:win_memo('"+g4_bbs_path+"/memo_form.php?me_recv_mb_id="+mb_id+"');\" class='win_memo'>쪽지보내기</a></li>";
  714. first = '';
  715. }
  716. // 메일보내기
  717. if(email) {
  718. html += "<li"+first+"><a href=\"javascript:win_email('"+g4_bbs_path+"/formmail.php?email="+email+"');\" class='win_email'>메일보내기</a></li>";
  719. first = '';
  720. }
  721. // 홈페이지
  722. if(homepage) {
  723. html += "<li"+first+"><a href=\"javascript:win_homepage('"+homepage+"');\" class='win_homepage'>홈페이지</a></li>";
  724. first = '';
  725. }
  726. // 자기소개
  727. if(mb_id) {
  728. html += "<li"+first+"><a href=\"javascript:win_profile('"+g4_bbs_path+"/profile.php?mb_id="+mb_id+"');\" class='win_profile'>자기소개</a></li>";
  729. first = '';
  730. }
  731. // 아이디로 검색, 이름으로 검색
  732. if(g4_bo_table) {
  733. if(mb_id) {
  734. html += "<li"+first+"><a href=\""+g4_bbs_path+"/board.php?bo_table="+g4_bo_table+"&sca="+g4_sca+"&sfl=mb_id,1&stx="+mb_id+"\">아이디로 검색</a></li>";
  735. }
  736. html += "<li"+first+"><a href=\""+g4_bbs_path+"/board.php?bo_table="+g4_bo_table+"&sca="+g4_sca+"&sfl=wr_name,1&stx="+encodeURIComponent(name)+"\">이름으로 검색</a></li>";
  737. first = '';
  738. }
  739. // 전체게시물
  740. if(mb_id) {
  741. html += "<li"+first+"><a href=\""+g4_bbs_path+"/new.php?mb_id="+mb_id+"\">전체게시물</a></li>";
  742. first = '';
  743. }
  744. // 최고관리자일 경우
  745. if(g4_is_admin == 'super') {
  746. if(mb_id) {
  747. // 회원정보변경
  748. html += "<li"+first+"><a href=\""+g4_path+"/" + g4_admin + "/member_form.php?w=u&mb_id="+mb_id+"\">회원정보변경</a></li>";
  749. // 포인트내역
  750. html += "<li"+first+"><a href=\""+g4_path+"/" + g4_admin + "/point_list.php?sfl=mb_id&stx="+mb_id+"\">포인트내역</a></li>";
  751. first = "";
  752. }
  753. }
  754. if(html) {
  755. html = '<div class="sideview"><ul>' + html + '</ul></div>';
  756. $('#sidebox').html(html).show('fast');
  757. }
  758. });
  759. // 배경색상 변경
  760. $('.board_list tbody tr:odd, .table_list tbody tr:odd' ).addClass('list_odd');
  761. $('.board_list tbody tr:even, .table_list tbody tr:even').addClass('list_even');
  762. $('.board_list tbody tr, .table_list tbody tr').toggleClass('mouse_over');
  763. //==========================================================================
  764. // @FIXME 자동완성 기능을 왜 죄다 꺼버리는가?
  765. $('form').each(function(i) {
  766. $(this).attr('autocomplete', 'off');
  767. });
  768. });
  769. //메인메뉴 롤오버 이미지처리
  770. $(function() {
  771. $(".gnbSub").hide(); // 2뎁스 메뉴를 모두 숨김
  772. $(".gnbMain").hover(function(){
  773. var Img = $(this).contents().contents("img").attr("src").replace("_off.", "_on."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
  774. $(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
  775. $(this).contents("ul").slideDown("fast"); // 2뎁스 노출
  776. },
  777. function(){
  778. var Img = $(this).contents().contents("img").attr("src").replace("_on.", "_off."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
  779. $(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
  780. $(this).contents("ul").slideUp("fast");// 2뎁스 숨김
  781. });
  782. $(".gnbSub li").each(function(e){
  783. $(this).mouseenter(function(e){
  784. var subImg = $(this).contents().contents("img").attr("src").replace("_off.", "_on.");
  785. $(this).contents().contents("img").attr("src", subImg);
  786. });
  787. $(this).mouseleave(function(e){
  788. var subImg = $(this).contents().contents("img").attr("src").replace("_on.", "_off.");
  789. $(this).contents().contents("img").attr("src", subImg);
  790. });
  791. });
  792. });
  793. // 왼쪽사이드바 서브메뉴 롤오버 이미지처리
  794. $(function() {
  795. $(".snbSub").hide(); // 2뎁스 메뉴를 모두 숨김
  796. $(".snbMain").hover(function(){
  797. var Img = $(this).contents().contents("img").attr("src").replace("_off.", "_on."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
  798. $(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
  799. $(this).contents("ul").slideDown("fast"); // 2뎁스 노출
  800. },
  801. function(){
  802. var Img = $(this).contents().contents("img").attr("src").replace("_on.", "_off."); // 1뎁스 이미지명을 찾아서 변경하여 변수에 저장
  803. $(this).contents().contents("img").attr("src", Img); // 이미지명을 저장한 변수값으로 변경
  804. $(this).contents("ul").slideUp("fast");// 2뎁스 숨김
  805. });
  806. $(".snbSub li").each(function(e){
  807. $(this).mouseenter(function(e){
  808. var subImg = $(this).contents().contents("img").attr("src").replace("_off.", "_on.");
  809. $(this).contents().contents("img").attr("src", subImg);
  810. });
  811. $(this).mouseleave(function(e){
  812. var subImg = $(this).contents().contents("img").attr("src").replace("_on.", "_off.");
  813. $(this).contents().contents("img").attr("src", subImg);
  814. });
  815. });
  816. });
  817. // rollover이미지 처리 : right_sidebar
  818. $(function(){
  819. $("img.rollover").mouseover(function(){
  820. $(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
  821. }).mouseout(function(){
  822. $(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
  823. }).each(function(){
  824. $("<img>").attr("src",$(this).attr("src").replace("_off.", "_on."));
  825. });
  826. });
  827. //패밀리사이트
  828. $(function() {
  829. $("#family_site").hide();
  830. $(".family").click(function(){
  831. $("#family_site").slideDown();
  832. $("#family_site").mouseleave(function(){closeFamily();return false;})
  833. }
  834. );
  835. $("#family_site a.close").click(function(){closeFamily();return false;});
  836. $("#family_site").hover(
  837. function(){
  838. $("#family_site").slideDown();
  839. },function(){
  840. closeFamily();return false;
  841. }
  842. );
  843. });
  844. function closeFamily(){
  845. $("#family_site").slideUp();
  846. }
  847. //슬라이딩배너
  848. //new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);
  849. function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
  850. this.FloatingObj = FloatingObj;
  851. this.MarginX = (MarginX) ? MarginX : 0;
  852. this.MarginY = (MarginY) ? MarginY : 0;
  853. //this.MarginX = document.getElementById('body_cus').offsetLeft + 985;
  854. this.Percentage = (Percentage) ? Percentage : 15;
  855. this.setTime = (setTime) ? setTime : 10;
  856. this.FloatingObj.style.position = "absolute";
  857. this.Body = null;
  858. this.setTimeOut = null;
  859. this.Run();
  860. }
  861. Floating.prototype.Run = function () {
  862. if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
  863. this.Body = document.documentElement;
  864. } else {
  865. this.Body = document.body;
  866. }
  867. var This = this;
  868. var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
  869. var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
  870. var DocLeft = this.MarginX;
  871. var DocTop = this.Body.scrollTop + this.MarginY;
  872. var MoveX = Math.abs(FloatingObjLeft - DocLeft);
  873. MoveX = Math.ceil(MoveX / this.Percentage);
  874. var MoveY = Math.abs(FloatingObjTop - DocTop);
  875. MoveY = Math.ceil(MoveY / this.Percentage);
  876. if (FloatingObjLeft < DocLeft) {
  877. this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
  878. } else {
  879. this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
  880. }
  881. if (FloatingObjTop < DocTop) {
  882. this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
  883. } else {
  884. this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
  885. }
  886. window.clearTimeout(this.setTimeOut);
  887. this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
  888. }
  889. /* 공통 함수 */
  890. String.prototype.trim = function() {
  891. return this.replace(/\s/g, "");
  892. }
  893. String.prototype.IsNumber = function()
  894. {
  895. return (/^[0-9]+$/).test();
  896. }
  897. /* Byte계산 */
  898. String.prototype.bytes = function() {
  899. var str = this;
  900. var len = 0;
  901. for (var i = 0; i < str.length; i++) {
  902. len += (str.charCodeAt(i) > 128) ? 2 : 1;
  903. }
  904. return len;
  905. }
  906. //문자열자르기
  907. String.prototype.cut = function(len) {
  908. var str = this;
  909. var s = 0;
  910. for (var i = 0; i < str.length; i++) {
  911. s += (str.charCodeAt(i) > 128) ? 2 : 1;
  912. if (s > len) {
  913. return str.substring(0,i);
  914. }
  915. }
  916. return str;
  917. }
  918. //시간형태 체크 24시
  919. function timechk(value) {
  920. var input = String(value);
  921. var pattern = /([0-2][0-3])(h|:)([0-5][0-9])/g;
  922. return pattern.test(input);
  923. }
  924. function popupCenter(URL,w, h, s, r) {
  925. width=screen.width;
  926. height=screen.height;
  927. x=(width/2)-(w/2);
  928. y=(height/2)-(h/2);
  929. opt = "left=" + x + ", top=" + y + ", width=" + w + ", height=" + h;
  930. opt = opt + ", toolbar=no,location=no,directories=no,status=no,menubar=no";
  931. opt = opt + ",scrollbars=" + s;
  932. opt = opt + ",resizable=" + r;
  933. window.open(URL, "_blank", opt);
  934. }
  935. //<a href="javascript:popupCenter('URL','463','237','no','no');">가운데띄우기</a>
  936. // 숫자, 영문 체크
  937. var alpha_numeric = new String("0123456789abcdefghijklmnopqrstuvwxyz.")
  938. function fnCheckAlphaNumber(str) {
  939. var rtrn;
  940. for(j = 0 ; j < str.length; j++) {
  941. rtn = fnIsAlphaNumeric(str.charAt(j))
  942. if(rtn == false) {
  943. return rtn;
  944. }
  945. }
  946. return rtn;
  947. }
  948. function fnIsAlphaNumeric(cha1) {
  949. for(i=0;i<alpha_numeric.length;i++) {
  950. if(alpha_numeric.charAt(i) == cha1)
  951. return true;
  952. }
  953. return false;
  954. }
  955. function isStrongValidFormPassword(val) {
  956. var check = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{6,16}$/;
  957. if (!check.test(val)) {
  958. alert("비밀번호는 문자, 숫자, 특수문자의 조합으로 입력해주세요.");
  959. return false;
  960. }
  961. if (val.length < 6 || val.length > 16) {
  962. alert("비밀번호는 6 ~ 16 자리로 입력해주세요.");
  963. return false;
  964. }
  965. return true;
  966. }
  967. /*--------------------------------------------------------------
  968. form 문자열 입력 확인
  969. 사용법 : fnCheckForm(fieldlist)
  970. . fieldlist : 배열["form elements", "이름"]
  971. --------------------------------------------------------------*/
  972. function fnCheckForm(fieldlist, locale) {
  973. var add_check_elements = ["checkbox", "radio"];
  974. if(locale==null || locale==""){locale=="ko";}
  975. for (i = 0; i < fieldlist.length; i++) {
  976. var frm = document.getElementById(fieldlist[i][0]);
  977. //checkbox, radio 는 체크 하지 못해 수정
  978. if(frm != null) {
  979. if(frm.value == ""){
  980. if(locale=="en"){
  981. alert("Please Check " + fieldlist[i][1]);
  982. }else{
  983. // alert(fieldlist[i][1] + "을(를) 확인하세요.1");
  984. var custom_opts = {
  985. id : fieldlist[i][0],
  986. title : fieldlist[i][1] + "을(를) 확인하세요.",
  987. btn_close_show : false, //닫기 버튼 안보이게
  988. }
  989. custom_modal_alert(custom_opts, function() {
  990. custom_modal_alert_close();
  991. if(frm.type != "hidden"){
  992. frm.focus();
  993. }
  994. });
  995. }
  996. return false;
  997. }
  998. // console.log("null");
  999. }else {
  1000. var $el = $("input[name="+fieldlist[i][0]+"]");
  1001. if($el.length > 0 && $.inArray($el.prop("type"), add_check_elements)) {
  1002. var val = "";
  1003. switch ($el.prop("type")) {
  1004. case "radio":
  1005. case "checkbox":
  1006. val = $("input[name="+fieldlist[i][0]+"]:checked").val();
  1007. $("input[name="+fieldlist[i][0]+"]").eq(0).focus();
  1008. break;
  1009. default:
  1010. break;
  1011. }
  1012. if($.trim(val) == "") {
  1013. if(locale=="en"){
  1014. alert("Please Check " + fieldlist[i][1]);
  1015. }else{
  1016. // alert(fieldlist[i][1] + "을(를) 확인하세요.");
  1017. var custom_opts = {
  1018. id : fieldlist[i][0],
  1019. title : fieldlist[i][1] + "을(를) 확인하세요.",
  1020. btn_close_show : false, //닫기 버튼 안보이게
  1021. }
  1022. custom_modal_alert(custom_opts, function() {
  1023. custom_modal_alert_close();
  1024. if(frm.type != "hidden"){
  1025. frm.focus();
  1026. }
  1027. });
  1028. }
  1029. return false;
  1030. }
  1031. }
  1032. }
  1033. }
  1034. return true;
  1035. }
  1036. // 쿠키생성
  1037. function fnSetCookie(name, value, expiredays,domain ){
  1038. var today = new Date();
  1039. today.setDate( today.getDate() + expiredays );
  1040. var cook = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
  1041. if (domain) cook += "domain=" + domain + ";";
  1042. document.cookie = cook;
  1043. }
  1044. // 쿠키값 확인
  1045. function fnGetCookie( name ) {
  1046. var nameOfCookie = name + "=";
  1047. var x = 0;
  1048. while ( x <= document.cookie.length ) {
  1049. var y = (x+nameOfCookie.length);
  1050. if ( document.cookie.substring( x, y ) == nameOfCookie ) {
  1051. if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
  1052. endOfCookie = document.cookie.length;
  1053. return unescape( document.cookie.substring( y, endOfCookie ) );
  1054. }
  1055. x = document.cookie.indexOf( " ", x ) + 1;
  1056. if ( x == 0 )
  1057. break;
  1058. }
  1059. return "";
  1060. }
  1061. //쿠키삭제
  1062. function fnDeleteCookie(cookieName)
  1063. {
  1064. var expireDate = new Date();
  1065. //어제 날짜를 쿠키 소멸 날짜로 설정한다.
  1066. expireDate.setDate( expireDate.getDate() - 1 );
  1067. document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
  1068. }
  1069. function fnShowLoading(sEl) {
  1070. $('#'+ sEl).html('<img src="/images/common/loading.gif" />');
  1071. }
  1072. // ajax 가 처리되는 동안 진행되는 작업
  1073. var objLoadingHandlers = {
  1074. onCreate: function() {
  1075. if($(sDiv))
  1076. Element.show(sDiv);
  1077. }
  1078. , onComplete: function() {
  1079. if(Ajax.activeRequestCount == 0) {
  1080. if($(sDiv))
  1081. Element.hide(sDiv);
  1082. }
  1083. }
  1084. }
  1085. // ajax가 처리되는 동안 처리되는 작업을 등록
  1086. //Ajax.Responders.register(objLoadingHandlers);
  1087. // nodevalue 가져오기
  1088. function fnGetNodeValue(oXml, oNode){
  1089. var pNode = oXml.getElementsByTagName(oNode);
  1090. if(pNode[0]){
  1091. if(pNode[0].childNodes[0])
  1092. return pNode[0].childNodes[0].nodeValue;
  1093. else
  1094. return "";
  1095. }else{
  1096. return "";
  1097. }
  1098. }
  1099. // child nodevalue 가져오기
  1100. function fnGetChildNodeValue(oNode) {
  1101. if(oNode.childNodes[0])
  1102. return oNode.childNodes[0].nodeValue;
  1103. else
  1104. return "";
  1105. }
  1106. // select box 만들기
  1107. function fnSetXmlSelectList(oXML, oSelect, iStart) {
  1108. if(!iStart || iStart == "undefined") {
  1109. iStart = 1;
  1110. } else {
  1111. iStart = parseInt(iStart);
  1112. }
  1113. var pNode = oXML.getElementsByTagName("itemlist");
  1114. var id = null;
  1115. var desc = null;
  1116. var objSelect = document.getElementById(oSelect) ? document.getElementById(oSelect) : false;
  1117. if(objSelect) fnSetInitSelect(objSelect, iStart);
  1118. for(i = 0; i < pNode.length; i++) {
  1119. var cNode = pNode[i].childNodes;
  1120. for(j = 0; j < cNode.length; j++) {
  1121. if(cNode[j].nodeName == "id") id = fnGetChildNodeValue(cNode[j]);
  1122. if(cNode[j].nodeName == "desc") desc = fnGetChildNodeValue(cNode[j]);
  1123. }
  1124. if(objSelect) {
  1125. var option = new Option(desc, id);
  1126. objSelect.options[i + iStart] = option;
  1127. }
  1128. }
  1129. }
  1130. // select box 초기화
  1131. function fnSetInitSelect(obj, iStart) {
  1132. if(obj) {
  1133. if(obj.options) {
  1134. for(i = obj.options.length - 1; i >= iStart; i--) {
  1135. obj.options[i] = null;
  1136. }
  1137. }
  1138. }
  1139. }
  1140. // checkbox 선택
  1141. function fnSetCheckAll(objCheck, objTarget) {
  1142. var obj = document.getElementsByName(objTarget);
  1143. for(var i = 0; i < obj.length; i ++) {
  1144. if(document.getElementById(objCheck).checked) {
  1145. obj[i].checked = true;
  1146. } else {
  1147. obj[i].checked = false;
  1148. }
  1149. }
  1150. }
  1151. // 위 함수랑 이름이 같아서 오류 발생함
  1152. // function fnSetCheckAll(objTarget) {
  1153. // var obj = document.getElementsByName(objTarget);
  1154. // for(var i = 0; i < obj.length; i ++) {
  1155. // obj[i].checked = true;
  1156. // }
  1157. // }
  1158. // 체크박스 체크한 개수
  1159. function fnGetCheckCnt(obj) {
  1160. var iCnt = 0;
  1161. var o = document.getElementsByName(obj);
  1162. for(var i = 0; i < o.length; i ++) {
  1163. if(o[i].checked) iCnt ++;
  1164. }
  1165. return iCnt;
  1166. }
  1167. //체크박스 체크값 가져 온다,
  1168. function fnGetCheckVal(obj){
  1169. var strVal='';
  1170. var o = document.getElementsByName(obj);
  1171. for(var i = 0; i < o.length; i ++) {
  1172. if(o[i].checked) strVal= o[i].value;
  1173. }
  1174. return strVal;
  1175. }
  1176. // 올바른 날짜인지 확인
  1177. // 날짜는 yyyy-mm-dd 또는 yyyymmdd 형식으로 입력되어져야 함
  1178. function fnCheckDate(obj) {
  1179. var sValue = obj.value.replace(/-/g,"");
  1180. var iYear = sValue.substr(0, 4);
  1181. var iMonth = sValue.substr(4, 2) - 1;
  1182. var iDay = sValue.substr(6, 2);
  1183. var newDate = new Date(iYear, iMonth, iDay);
  1184. // 입력받은 값과 새로 생성된 날짜를 비교
  1185. if(iYear != newDate.getFullYear()
  1186. || iMonth != newDate.getMonth()
  1187. || iDay != newDate.getDate()) {
  1188. obj.value = "";
  1189. return false;
  1190. } else {
  1191. obj.value = iYear +"-"+ sValue.substr(4, 2) +"-"+ iDay;
  1192. return true;
  1193. }
  1194. }
  1195. //교사팝업 외부 인터페이스
  1196. //플래시 메뉴와 인터페이스시 이용한다.
  1197. function getCookie(name){
  1198. var nameOfCookie = name + "=";
  1199. var x = 0;
  1200. while( x <= document.cookie.length ){
  1201. var y = (x+nameOfCookie.length);
  1202. if ( document.cookie.substring( x, y ) == nameOfCookie ) {
  1203. if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) {
  1204. endOfCookie = document.cookie.length;
  1205. }
  1206. return unescape( document.cookie.substring( y, endOfCookie ) );
  1207. }
  1208. x = document.cookie.indexOf( " ", x ) + 1;
  1209. if ( x == 0 )
  1210. break;
  1211. }
  1212. return "";
  1213. }
  1214. function fnInstallquickLink(){
  1215. alert("퀵메뉴 설치 됩니다");
  1216. var WshShell = new ActiveXObject("WScript.Shell");
  1217. strDesktop = WshShell.SpecialFolders("Desktop");
  1218. var oURLLink = WshShell.CreateShortcut(strDesktop + "\\\\Dogfoot.URL");
  1219. oURLLink.TargetPath = "http://www.readingwell.com";
  1220. oURLLink.Save();
  1221. }
  1222. //DIV영역만 프린트
  1223. function printIt(printThis){
  1224. var win = window.open();
  1225. win.document.open();
  1226. win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
  1227. win.document.write('body, td { font-family: Verdana; font-size: 10pt;}');
  1228. win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');
  1229. win.document.write(printThis);
  1230. win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
  1231. win.document.close();
  1232. win.print();
  1233. win.close();
  1234. }
  1235. // 특정영역만 프린트2
  1236. function fnPrintDiv(sDiv){
  1237. var win = window.open('about:blank', '', 'width=670, height=500, scrollbars=yes');
  1238. win.document.open();
  1239. win.document.write('<html><head>');
  1240. win.document.write('<link rel="stylesheet" type="text/css" href="/inc/css/style.css" />');
  1241. win.document.write('<link rel="stylesheet" type="text/css" href="/inc/css/board.css" />');
  1242. win.document.write('</head><body>');
  1243. win.document.write($(sDiv).innerHTML);
  1244. win.document.write('<s'+'cript language="j'+'avascript" type="text/ja'+'vascript">document.getElementById("copy_btn").style.display = "none";</s'+'cript>');
  1245. //win.document.write('<s'+'cript language="j'+'avascript" type="text/ja'+'vascript"></s'+'cript>');
  1246. win.document.write('</body><html>');
  1247. win.document.close();
  1248. win.print();
  1249. win.close();
  1250. }
  1251. // 특정영역만 관리자
  1252. function fnPrintDivAdmin(sDiv){
  1253. var win = window.open('about:blank', '', 'width=670, height=500, scrollbars=yes');
  1254. win.document.open();
  1255. win.document.write('<html><head>');
  1256. win.document.write('<link rel="stylesheet" type="text/css" href="/admin/inc/css/style.css" />');
  1257. win.document.write('<link rel="stylesheet" type="text/css" href="/admin/inc/css/board.css" />');
  1258. win.document.write('</head><body>');
  1259. win.document.write($(sDiv).innerHTML);
  1260. win.document.write('</body><html>');
  1261. win.document.close();
  1262. win.print();
  1263. win.close();
  1264. }
  1265. /***************************************************************
  1266. * COMMON CHECK
  1267. **************************************************************/
  1268. // 공백체크
  1269. function chkSpace( str ){
  1270. if(str.search(/\s/) != -1){
  1271. return false;
  1272. } else {
  1273. return true;
  1274. }
  1275. }
  1276. // 특수문자 체크
  1277. function checkSpecialChar(expression) {
  1278. var strSpecial = ",`~#$%^&*()_+|\;\\/:=-<>.'\"";
  1279. for(i=0;i<expression.length;i++){
  1280. for(j=0;j<strSpecial.length;j++){
  1281. if(expression.charAt(i) == strSpecial.charAt(j)){
  1282. return false;
  1283. }
  1284. }
  1285. }
  1286. return true;
  1287. }
  1288. /***************************************************************
  1289. * 숫자만 체크 확인
  1290. ***************************************************************/
  1291. function ChkNum(x){
  1292. var var_normalize = /[^0-9]/gi;
  1293. //정규식
  1294. if(var_normalize.test(x) == true){
  1295. return false;
  1296. }else{
  1297. return true;
  1298. }
  1299. }
  1300. //아이디 입력시 한글, 특수문자 체크
  1301. function h_check(Objectname) {
  1302. var intErr;
  1303. var strValue = Objectname;
  1304. var retCode = 0;
  1305. var re = /[~!@\#$%<>^&*\()\-=+_\']/gi; //특수문자 정규식 변수 선언
  1306. for (i = 0; i < strValue.length; i++) {
  1307. var retCode = strValue.charCodeAt(i);
  1308. var retChar = strValue.substr(i,1).toUpperCase();
  1309. retCode = parseInt(retCode);
  1310. //입력받은 값중에 한글이 있으면 에러
  1311. if ((retChar < "0" || retChar > "9") && (retChar < "A" || retChar > "Z") && ((retCode > 255) || (retCode < 0)) ) {
  1312. intErr = -1;
  1313. break;
  1314. //입력받은 값중에 특수문자가 있으면 에러
  1315. } else if(re.test(strValue)) {
  1316. intErr = -1;
  1317. break;
  1318. }
  1319. }
  1320. return (intErr);
  1321. }
  1322. function han_check(Objectname) {
  1323. var intErr;
  1324. var strValue = Objectname;
  1325. var retCode = 0;
  1326. for (i = 0; i < strValue.length; i++) {
  1327. var retCode = strValue.charCodeAt(i);
  1328. var retChar = strValue.substr(i,1).toUpperCase();
  1329. retCode = parseInt(retCode);
  1330. //입력받은 값중에 한글이 있으면 에러
  1331. if ((retChar < "0" || retChar > "9") && (retChar < "A" || retChar > "Z") && ((retCode > 255) || (retCode < 0)) ) {
  1332. intErr = -1;
  1333. break;
  1334. }
  1335. }
  1336. return (intErr);
  1337. }
  1338. /*주민번호 체크 JS*/
  1339. function jumin_check(jumin1, jumin2) {
  1340. var er = 0;
  1341. var erm = "주민등록 번호가 잘못되었습니다.";
  1342. var rm = "주민등록번호를 확인하였습니다.";
  1343. var l1 = jumin1;
  1344. var l2 = jumin2;
  1345. if (l1 != 6 || l2 != 7) er=1;
  1346. if (Number(jumin1) == NaN || Number(jumin2) == NaN) er=1;
  1347. var dfdf = jumin1.split(".");
  1348. var fdfd = jumin2.split(".");
  1349. if (dfdf[1] || dfdf[1]){
  1350. er=1;
  1351. }
  1352. var array1 = jumin1.split("");
  1353. var array2 = jumin2.split("");
  1354. var y = array1[0]+array1[1];
  1355. if (Number(array1[2]) == 0) {
  1356. var m = array1[3];
  1357. }
  1358. else if (Number(array1[2])==1){
  1359. var m = array1[2]+array1[3];
  1360. }
  1361. else{
  1362. er=1;
  1363. }
  1364. if (Number(m)>12 || Number(m)<1){
  1365. er=1;
  1366. }
  1367. if (Number(array1[4]) == 0){
  1368. var d = array1[5];
  1369. }else{
  1370. var d = array1[4]+array1[5];
  1371. }
  1372. var f = 0;
  1373. if (Number(y)%4 == 0 && Number(y)%1000 != 0){
  1374. f = 1;
  1375. }
  1376. if (f == 0){
  1377. var ererr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1378. }else if(f == 1){
  1379. var ererr = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1380. }
  1381. else{
  1382. er=1;
  1383. }
  1384. if (ererr[m-1] < Number(d)) {
  1385. er=1;
  1386. }
  1387. var now = new Date();
  1388. var ny = now.getYear();
  1389. var nm = now.getMonth()+1;
  1390. var nd = now.getDate();
  1391. nc = Math.floor(ny/100)+1-20;
  1392. 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)){
  1393. er=1;
  1394. }
  1395. nc += 20;
  1396. y = changeC(nc, Number(array2[0]))+y;
  1397. if (ny < Number(y)){
  1398. er=1;
  1399. }
  1400. if (ny == Number(y) && nm < Number(m)){
  1401. er=1;
  1402. }
  1403. if (ny == Number(y) && nm == Number(m) && nd < Number(d)){
  1404. er=1;
  1405. }
  1406. 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);
  1407. num=11-(num%11)
  1408. var check=num%10
  1409. if (check != Number(array2[6])){
  1410. er=1;
  1411. }
  1412. if (er==1) {
  1413. alert(erm);
  1414. return false;
  1415. } else if (er==0) {
  1416. return true;
  1417. } else {
  1418. alert(erm);
  1419. return false;
  1420. }
  1421. }
  1422. function s_minus(a, b) {
  1423. var r = a-b;
  1424. while(1) {
  1425. if (r<0){
  1426. r+=10;
  1427. }
  1428. else if(r>=10) {
  1429. r-=10;
  1430. }
  1431. else{
  1432. break;
  1433. }
  1434. }
  1435. return r;
  1436. }
  1437. function s_plus(a, b) {
  1438. var r = a+b;
  1439. while(1) {
  1440. if (r<0){
  1441. r+=10;
  1442. }else if (r>=10) {
  1443. r-=10;
  1444. }else {
  1445. break;
  1446. }
  1447. }
  1448. return r;
  1449. }
  1450. function changeC(nc, s) {
  1451. while(1) {
  1452. if ((nc%5) != 4){
  1453. nc--;
  1454. }else {
  1455. break;
  1456. }
  1457. }
  1458. var ret = nc+s/2-1;
  1459. ret = ""+ret;
  1460. return ret;
  1461. }
  1462. function onlyNumber2(loc) {
  1463. if(/[^0123456789]/g.test(loc.value)) {
  1464. return false;
  1465. }else{
  1466. return true;
  1467. }
  1468. }
  1469. // 숫자만 입력 가능
  1470. function fnOnlyNumber(e) {
  1471. if (!e) var e = window.event;
  1472. // 숫자입력이 아닌 경우
  1473. if((e.keyCode < 48)||(e.keyCode > 57)) {
  1474. // key 패드에서 숫자입력이 아닌 경우
  1475. if((e.keyCode < 96) || (e.keyCode > 105)) {
  1476. // backspace, tab 허용
  1477. if(e.keyCode != 8 && e.keyCode != 9) {
  1478. if (e.preventDefault) {
  1479. e.preventDefault(); // firefox/모질라에서 event 발생시 자체 제공하는 특별기능 끄기.
  1480. } else {
  1481. e.returnValue = false; // IE에서 event 발생시 자체 제공하는 특별기능 끄기.
  1482. }
  1483. }
  1484. }
  1485. }
  1486. }
  1487. //기타벨리데이션 체크
  1488. //정규식타입 케이스별...
  1489. //사용법 isValid('amma76@test.com','regEmail');
  1490. function isValid(field, regExp){
  1491. var regNumber = /^[0-9]+$/; // 숫자
  1492. var regAlphabet = /^[a-zA-Z]+$/; // 알파벳(대문자,소문자)
  1493. var regAlphabetCapital = /^[A-Z]+$/; // 알파벳(대문자)
  1494. var regKorean = /^[가-힣]*$/; // 한글
  1495. var regPhone = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/; // 집전화
  1496. var regMobilePHone = /^[0-9]{3}-[0-9]{3,4}-[0-9]{4}$/; // 휴대폰
  1497. var regEmail =/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i; // 이메일
  1498. var regDomain = /^[.a-zA-Z0-9-]+.[a-zA-Z]+$/; // 도메인
  1499. var regIp = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; // IP
  1500. var result = false;
  1501. var fieldValue = field;
  1502. pattern = eval(regExp);
  1503. result = pattern.test(fieldValue);
  1504. return result;
  1505. }
  1506. /**
  1507. * 포커스 자동이동
  1508. *
  1509. * @param id_from - 현재 인풋박스 id
  1510. * @param id_to - 포커스 이동될 인풋 박스 id
  1511. * @param maxSize - 인풋박스에 입력될 글자수
  1512. * 사용예 <input type="text" id="a" onkeyup="moveNext('a','b',6);"> <input type="text" id="b"">
  1513. * 6글자 입력후 포커스가 id=b 인풋 박스로 이동된다.
  1514. ***/
  1515. var next_go = true;
  1516. var cur_val = null;
  1517. function moveNext(id_from,id_to,maxSize) {
  1518. var cur = document.getElementById(id_from).value;
  1519. curSize = cur.length;
  1520. if (curSize == maxSize) {
  1521. if(next_go || cur_val != cur)
  1522. {
  1523. cur_val = cur;
  1524. next_go = false;
  1525. document.getElementById(id_to).focus();
  1526. }
  1527. return true;
  1528. }
  1529. next_go = true;
  1530. }
  1531. /**
  1532. * 두 날짜의 차이를 일자로 구한다.(조회 종료일 - 조회 시작일)
  1533. *
  1534. * @param val1 - 조회 시작일(날짜 ex.2002-01-01)
  1535. * @param val2 - 조회 종료일(날짜 ex.2002-01-01)
  1536. * @return 기간에 해당하는 일자
  1537. */
  1538. function calDateRange(val1, val2)
  1539. {
  1540. var FORMAT = "-";
  1541. // FORMAT을 포함한 길이 체크
  1542. if (val1.length != 10 || val2.length != 10)
  1543. return null;
  1544. // FORMAT이 있는지 체크
  1545. if (val1.indexOf(FORMAT) < 0 || val2.indexOf(FORMAT) < 0)
  1546. return null;
  1547. // 년도, 월, 일로 분리
  1548. var start_dt = val1.split(FORMAT);
  1549. var end_dt = val2.split(FORMAT);
  1550. // 월 - 1(자바스크립트는 월이 0부터 시작하기 때문에...)
  1551. // Number()를 이용하여 08, 09월을 10진수로 인식하게 함.
  1552. start_dt[1] = (Number(start_dt[1]) - 1) + "";
  1553. end_dt[1] = (Number(end_dt[1]) - 1) + "";
  1554. var from_dt = new Date(start_dt[0], start_dt[1], start_dt[2]);
  1555. var to_dt = new Date(end_dt[0], end_dt[1], end_dt[2]);
  1556. return (to_dt.getTime() - from_dt.getTime()) / 1000 / 60 / 60 / 24;
  1557. }
  1558. //사업자번호체크
  1559. function fnChkBNo(vencod) {
  1560. var sum = 0;
  1561. var getlist =new Array(10);
  1562. var chkvalue =new Array("1","3","7","1","3","7","1","3","5");
  1563. for(var i=0; i<10; i++) { getlist[i] = vencod.substring(i, i+1); }
  1564. for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; }
  1565. sum = sum + parseInt((getlist[8]*5)/10);
  1566. sidliy = sum % 10;
  1567. sidchk = 0;
  1568. if(sidliy != 0) { sidchk = 10 - sidliy; }
  1569. else { sidchk = 0; }
  1570. if(sidchk != getlist[9]) { return false; }
  1571. return true;
  1572. }
  1573. //외국인체크
  1574. function fnChkFNo(fgnno) {
  1575. var sum=0;
  1576. var odd=0;
  1577. buf = new Array(13);
  1578. for(i=0; i<13; i++) { buf[i]=parseInt(fgnno.charAt(i)); }
  1579. odd = buf[7]*10 + buf[8];
  1580. if(odd%2 != 0) { return false; }
  1581. if( (buf[11]!=6) && (buf[11]!=7) && (buf[11]!=8) && (buf[11]!=9) ) {
  1582. return false;
  1583. }
  1584. multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
  1585. for(i=0, sum=0; i<12; i++) { sum += (buf[i] *= multipliers[i]); }
  1586. sum = 11 - (sum%11);
  1587. if(sum >= 10) { sum -= 10; }
  1588. sum += 2;
  1589. if(sum >= 10) { sum -= 10; }
  1590. if(sum != buf[12]) { return false }
  1591. return true;
  1592. }
  1593. //동영상/스틸컷 팝업
  1594. function fnOpenPopup(type,seq){
  1595. var windowW = "855";
  1596. var windowH = "577";
  1597. var windowX = (screen.width/2)-(windowW/2);
  1598. var windowY = (screen.height/2)-(windowH/2);
  1599. var urlPop1 = "/common/popup/pop_photo.asp"; //스틸컷
  1600. var urlPop2 = "/common/popup/pop_movie.asp"; //동영상
  1601. var cineSeq = "?seq="+seq
  1602. //var style = "width=845, height=505, scrollbars=no, left="+windowX+", top="+windowY;
  1603. var style = "width=880, height=606, scrollbars=no, left="+windowX+", top="+windowY;
  1604. if (type == "1"){ //1:스틸컷,2:동영상
  1605. window.open(urlPop1+cineSeq,"스틸컷",style);
  1606. }else{
  1607. window.open(urlPop2+cineSeq,"동영상",style);
  1608. }
  1609. }
  1610. //즐겨찾기추가
  1611. function favoritesite(){
  1612. window.external.AddFavorite(strWasURL, '엔초코');
  1613. }
  1614. //문자열길이 체크 함수
  1615. function CalByte3(tg,objMax, objNow){
  1616. var curText;
  1617. var strLen;
  1618. var byteIs;
  1619. var lastByte;
  1620. var thisChar;
  1621. var escChar;
  1622. var curTotalMsg;
  1623. var okMsg;
  1624. var _size = objMax.html();
  1625. curText = new String(tg.val());
  1626. strLen = curText.length;
  1627. byteIs = 0;
  1628. for(i=0; i<strLen; i++) {
  1629. thisChar = curText.charAt(i);
  1630. escChar = escape(thisChar);
  1631. // ´,¨, ¸ : 2byte 임에도 브라우져에서 1byte로 계산
  1632. if (thisChar == "´" || thisChar == "¨" || thisChar == "¸" || thisChar == "§" ){
  1633. byteIs++;
  1634. }
  1635. if (escChar.length > 4) {
  1636. byteIs += 2; //특수문자 한글인 경우.
  1637. }else if(thisChar != '\r') { //개행을 제외한 이외의 경우
  1638. byteIs += 1;
  1639. }
  1640. if(byteIs > _size){ // 3페이지까지
  1641. alert(_size + '(문자)를 초과하실 수 없습니다.');
  1642. thisText = curText.substring(0, i);
  1643. tg.val(thisText);
  1644. byteIs = lastByte;
  1645. break;
  1646. }
  1647. lastByte = byteIs;
  1648. }
  1649. curTotalMsg = Math.ceil(byteIs / _size);
  1650. curEndByte = _size
  1651. objMax.html(curEndByte);
  1652. objNow.html(byteIs);
  1653. }
  1654. /* 정규 표현식을 사용하여 화이트스페이스를 빈문자로 전환 */
  1655. function trim(str){
  1656. str = str.replace(/^\s*/,'').replace(/\s*$/, '');
  1657. return str; //변환한 스트링을 리턴.
  1658. }
  1659. /*IFRMAE 리사이즈 공용*/
  1660. var IE = false ;
  1661. if (window.navigator.appName.indexOf("Explorer") !=-1){
  1662. IE = true;
  1663. }
  1664. function resizeIfr(obj, minHeight) {
  1665. minHeight = minHeight || 10;
  1666. try {
  1667. var getHeightByElement = function(body) {
  1668. var last = body.lastChild;
  1669. try {
  1670. while (last && last.nodeType != 1 || !last.offsetTop) last = last.previousSibling;
  1671. return last.offsetTop+last.offsetHeight;
  1672. } catch(e) {
  1673. return 0;
  1674. }
  1675. }
  1676. var doc = obj.contentDocument || obj.contentWindow.document;
  1677. if (doc.location.href == 'about:blank') {
  1678. obj.style.height = minHeight+'px';
  1679. return;
  1680. }
  1681. if (/MSIE/.test(navigator.userAgent)) {
  1682. var h = doc.body.scrollHeight;
  1683. } else {
  1684. var s = doc.body.appendChild(document.createElement('DIV'))
  1685. s.style.clear = 'both';
  1686. var h = s.offsetTop;
  1687. s.parentNode.removeChild(s);
  1688. }
  1689. if (h < minHeight) h = minHeight;
  1690. obj.style.height = h + 'px';
  1691. if (typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
  1692. if (typeof obj._check == 'undefined') obj._check = 0;
  1693. setTimeout(function(){ resizeIfr(obj,minHeight) }, 200); // check 5 times for IE bug
  1694. } catch (e) {
  1695. }
  1696. }
  1697. /*자바스크립트 Mid*/
  1698. function Mid(str, start, len) {
  1699. // Make sure start and len are within proper bounds
  1700. if ( start < 0 || len < 0 ) return "";
  1701. var iEnd, iLen = String(str).length;
  1702. if ( start + len > iLen ) iEnd = iLen;
  1703. else iEnd = start + len;
  1704. return String(str).substring(start,iEnd);
  1705. }
  1706. /*자바스크립트 INSTR*/
  1707. function InStr(strSearch, charSearchFor)
  1708. {
  1709. for (i=0; i < strSearch.length; i++)
  1710. {
  1711. if (charSearchFor == Mid(strSearch, i, 1)){
  1712. return i;
  1713. }
  1714. }
  1715. return -1;
  1716. }
  1717. /* 네이버MAP 호출 다중 OVERLAY형태 조정현 */
  1718. function fnSetAddMaker(obj,pos,iconURL){
  1719. var arrMaker = new NMark(pos, new NIcon(iconURL, new NSize(15, 15),new NSize(15, 15)));
  1720. /*NEvent.addListener(arrMaker, "mouseover", function(){
  1721. obj.setCenterAndZoom(pos,2);
  1722. });
  1723. NEvent.addListener(arrMaker, "mouseout", function(){
  1724. obj.setCenterAndZoom(pos,8)
  1725. });*/
  1726. obj.addOverlay(arrMaker);
  1727. }
  1728. var mapObj=null;;
  1729. function fnSetChangeCenterZoom(obj,mapX,mapY, iDepth){
  1730. if(iDepth == 'undefined' || iDepth == undefined) iDepth = 8;
  1731. var pos = new NPoint(mapX,mapY);
  1732. obj.setCenterAndZoom(pos,iDepth);
  1733. obj.enableWheelZoom(true);
  1734. }
  1735. function fnSetMapOverlayMulty(vId, vWidth, vHeight, vMapData, iDepth){
  1736. if(iDepth == 'undefined' || iDepth == undefined) iDepth = 8;
  1737. var strMapData = vMapData;
  1738. var arrMapData = strMapData.split("|");
  1739. var arrMapDtl = "";
  1740. mapObj = new NMap(document.getElementById(vId),{width:vWidth, height:vHeight, mapMode:0});
  1741. var infowin, arrMaker
  1742. for (var intX = 0;intX < arrMapData.length-1 ; intX++)
  1743. {
  1744. arrMapDtl = arrMapData[intX].split("^");
  1745. var mapX = arrMapDtl[0];
  1746. var mapY = arrMapDtl[1];
  1747. var iconUrl = "/images/date/i_mapnum"+arrMapDtl[2]+".gif";
  1748. var title = arrMapDtl[3];
  1749. var pos = new NPoint(mapX,mapY);
  1750. if (intX==0)
  1751. {
  1752. mapObj.setCenterAndZoom(pos, iDepth);
  1753. mapObj.enableWheelZoom(true);
  1754. /* 지도 좌표, 축적 수 준 초기화 */
  1755. }
  1756. //마커처리한다.
  1757. //마커처리후 이벤트 리스너 등록.
  1758. infowin = new NInfoWindow();
  1759. infowin.set(pos,"<div style=\"color:red;font-weight:bold;\"></div>");
  1760. mapObj.addOverlay(infowin);
  1761. infowin.showWindow();
  1762. fnSetAddMaker(mapObj,pos,iconUrl);
  1763. }
  1764. /* 지도 컨트롤 생성 */
  1765. var zoom = new NZoomControl();
  1766. zoom.setAlign("right");
  1767. zoom.setValign("top");
  1768. mapObj.addControl(zoom);
  1769. /* 지도 모드 변경 버튼 생성 */
  1770. var mapBtns = new NMapBtns();
  1771. mapBtns.setAlign("right");
  1772. mapBtns.setValign("top");
  1773. mapObj.addControl(mapBtns);
  1774. /* 세이브 버튼 생성 */
  1775. var mapSave = new NSaveBtn()
  1776. mapSave.setAlign("right");
  1777. mapSave.setValign("bottom");
  1778. mapObj.addControl(mapSave);
  1779. }
  1780. //업로드 이미지 미리 보기
  1781. function fileUploadPreview(thisObj, preViewer) {
  1782. if(!/(\.gif|\.jpg|\.jpeg|\.png)$/i.test(thisObj.value)) {
  1783. alert("이미지 형식의 파일을 선택하십시오");
  1784. return;
  1785. }
  1786. preViewer = (typeof(preViewer) == "object") ? preViewer : document.getElementById(preViewer);
  1787. preViewer.innerHTML = "";
  1788. var ua = window.navigator.userAgent;
  1789. if (ua.indexOf("MSIE") > -1) {
  1790. var img_path = "";
  1791. if (thisObj.value.indexOf("\\fakepath\\") < 0) {
  1792. img_path = thisObj.value;
  1793. } else {
  1794. thisObj.select();
  1795. var selectionRange = document.selection.createRange();
  1796. img_path = selectionRange.text.toString();
  1797. thisObj.blur();
  1798. }
  1799. preViewer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fi" + "le://" + img_path + "', sizingMethod='scale')";
  1800. } else {
  1801. preViewer.innerHTML = "";
  1802. var W = preViewer.offsetWidth;
  1803. var H = preViewer.offsetHeight;
  1804. var tmpImage = document.createElement("img");
  1805. preViewer.appendChild(tmpImage);
  1806. tmpImage.onerror = function () {
  1807. return preViewer.innerHTML = "";
  1808. }
  1809. tmpImage.onload = function () {
  1810. if (this.width > W) {
  1811. this.height = this.height / (this.width / W);
  1812. this.width = W;
  1813. }
  1814. if (this.height > H) {
  1815. this.width = this.width / (this.height / H);
  1816. this.height = H;
  1817. }
  1818. }
  1819. if (ua.indexOf("Firefox/3") > -1) {
  1820. var picData = thisObj.files.item(0).getAsDataURL();
  1821. tmpImage.src = picData;
  1822. } else {
  1823. tmpImage.src = "file://" + thisObj.value;
  1824. }
  1825. }
  1826. }
  1827. //공통코드 AJAX 로 반환한다.
  1828. //파라미터 : obj(selectid), table("테이블명"), column (컬럼명) ,setcode(초기셋팅값), initval (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
  1829. //Jqtrantform 적용된 select box에서 사용 됨
  1830. function setCodeSelectJqTransForm(mode, obj, table, column, setcode, initval, pcode){
  1831. var url ="/common/lib/api.php?mode="+mode+"&nm_table="+table+"&nm_column="+column+"&pcode="+pcode;
  1832. $.getJSON(url,function(ajaxresult){
  1833. $("#"+obj).children().remove().end();
  1834. if(initval!=""){
  1835. $("#"+obj).append($('<option></option>').val("").html(initval));
  1836. }
  1837. $.each(ajaxresult, function(i,item){
  1838. var cd_seq = item.seq;
  1839. var nm_code = item.code;
  1840. var nm_name = item.name;
  1841. var nm_pcode = item.pcode;
  1842. var nm_etc = item.etc;
  1843. // console.log(nm_code, nm_name);
  1844. if(setcode==nm_code){
  1845. $("#"+obj).append($('<option></option>').val(nm_code).html(nm_name).attr('selected','selected').attr('etc',nm_etc));
  1846. }else{
  1847. $("#"+obj).append($('<option></option>').val(nm_code).html(nm_name).attr('etc',nm_etc));
  1848. }
  1849. });
  1850. // jqtransformdone
  1851. $("#"+obj).jqTransSelectRefresh();
  1852. });
  1853. }
  1854. //공통코드 AJAX 로 반환한다.
  1855. //파라미터 : obj(selectid), table("테이블명"), column (컬럼명) ,setcode(초기셋팅값), initval (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
  1856. function setCodeSelect(mode, obj, table, column, setcode, initval, pcode){
  1857. var url ="/common/lib/api.php?mode="+mode+"&nm_table="+table+"&nm_column="+column+"&pcode="+pcode;
  1858. $.getJSON(url,function(ajaxresult){
  1859. $("#"+obj).children().remove().end();
  1860. if(initval!=""){
  1861. $("#"+obj).append($('<option></option>').val("").html(initval));
  1862. }
  1863. $.each(ajaxresult, function(i,item){
  1864. var cd_seq = item.seq;
  1865. var nm_code = item.code;
  1866. var nm_name = item.name;
  1867. var nm_pcode = item.pcode;
  1868. var nm_etc = item.etc;
  1869. if(setcode==nm_code){
  1870. $("#"+obj).append($('<option></option>').val(nm_code).html(nm_name).attr('selected','selected').attr('etc',nm_etc));
  1871. }else{
  1872. $("#"+obj).append($('<option></option>').val(nm_code).html(nm_name).attr('etc',nm_etc));
  1873. }
  1874. });
  1875. });
  1876. }
  1877. function setCodeSelectLi(mode, obj, table, column, setcode, initval, pcode, callback){
  1878. var url ="/common/lib/api.php?mode="+mode+"&nm_table="+table+"&nm_column="+column+"&pcode="+pcode;
  1879. $.getJSON(url,function(ajaxresult){
  1880. $("#"+obj).children().remove().end();
  1881. if(initval!=""){
  1882. $("#"+obj).append($('<li></li>').data("val", "").html(initval));
  1883. }
  1884. $.each(ajaxresult, function(i,item){
  1885. var cd_seq = item.seq;
  1886. var nm_code = item.code;
  1887. var nm_name = item.name;
  1888. var nm_pcode = item.pcode;
  1889. var nm_etc = item.etc;
  1890. if(setcode==nm_code){
  1891. $("#"+obj).append($('<li></li>').data("val", nm_code).html(nm_name).addClass("select"));
  1892. }else{
  1893. $("#"+obj).append($('<li></li>').data("val", nm_code).html(nm_name).removeClass("select"));
  1894. }
  1895. });
  1896. $("#"+obj+" > li").click(function(){
  1897. var _text = $(this).text();
  1898. var _code = $(this).data("val");
  1899. $(this).parent().siblings("span").text(_text);
  1900. $(this).parent().hide();
  1901. $(this).parents().parents().removeClass("open");
  1902. if(!$(this).hasClass("select")){
  1903. $(this).siblings().removeClass("select");
  1904. $(this).addClass("select");
  1905. if(callback){
  1906. callback(_code);
  1907. }
  1908. }
  1909. });
  1910. });
  1911. }
  1912. function setCodeRadio(mode, obj, table, column, setcode, initval, pcode){
  1913. var html = "";
  1914. $.ajax({
  1915. url: '/common/lib/api.php',
  1916. data : {'mode':mode,'nm_table':table,'nm_column':column,'pcode':pcode},
  1917. dataType : 'json',
  1918. method : 'POST',
  1919. success : function(data){
  1920. // $("#"+obj).empty();
  1921. $.each(data , function(idx, row){
  1922. html = "<span class=\"radio_wrap\">\n";
  1923. html+= " <input type=\"radio\" name=\""+obj+"\" id=\""+obj+"\" value=\""+row.code+"\">\n";
  1924. html+= " <i></i>\n";
  1925. html+= " <label for=\""+obj+"\">"+row.name+"</label>\n";
  1926. html+= "</span>\n";
  1927. $("#"+obj).append(html);
  1928. });
  1929. }
  1930. });
  1931. }
  1932. function setCodeRadioLi(mode, obj, table, column, setcode, initval, pcode, callback){
  1933. var html = "";
  1934. $.ajax({
  1935. url: '/common/lib/api.php',
  1936. data : {'mode':mode,'nm_table':table,'nm_column':column,'pcode':pcode},
  1937. dataType : 'json',
  1938. method : 'POST',
  1939. success : function(data){
  1940. $("#"+obj).empty();
  1941. var i=1;
  1942. $.each(data , function(idx, row){
  1943. html = "<li>\n";
  1944. html+= "<span class=\"radio_wrap\">\n";
  1945. html+= " <input type=\"radio\" name=\""+obj+"\" id=\""+obj+i+"\" value=\""+row.code+"\">\n";
  1946. html+= " <i></i>\n";
  1947. html+= " <label for=\""+obj+i+"\">"+row.name+"</label>\n";
  1948. html+= "</span>\n";
  1949. html+= "</li> \n";
  1950. $("#"+obj).append(html);
  1951. i++;
  1952. });
  1953. $('[name="'+obj+'"]').click(function(){
  1954. var _text = $(this).text();
  1955. var _code = $(this).val();
  1956. if(callback){
  1957. callback(_code);
  1958. }
  1959. });
  1960. }
  1961. });
  1962. }
  1963. // 2017.10.19
  1964. // objId 엘리먼트 자식 img num배 확대
  1965. function imgZoom(objId,num){
  1966. var obj = $("#"+objId);
  1967. $(obj).click(function(){
  1968. if($(this).hasClass("on")){
  1969. imgZoomInit(obj);
  1970. $(this).removeClass("on");
  1971. }else{
  1972. imgZoomPlus(obj,num);
  1973. $(this).addClass("on");
  1974. }
  1975. });
  1976. }
  1977. // 초기화
  1978. function imgZoomInit(obj){
  1979. $(obj).attr("style","").children("img").attr("style","");
  1980. }
  1981. // 이미지 확대
  1982. function imgZoomPlus(obj,num){
  1983. var objImg = obj.children("img");
  1984. var objImgW = objImg.width();
  1985. var objImgH = objImg.height();
  1986. $(obj).css({"width":objImgW,"height":objImgH,"overflow":"auto"}).children("img").css({"width":objImgW*num,"height":objImgH*num});
  1987. }
  1988. // end 2017.10.19
  1989. //Ajax페이징
  1990. function ListPgAjax(url,pageno,PageSize,BlockPage,totalrows)
  1991. {
  1992. var lastpgno=parseInt(Math.ceil(totalrows/PageSize)); //마지막 페이지
  1993. var now_num = parseInt(Math.ceil(pageno/BlockPage));
  1994. var start_num = parseInt((now_num - 1) * BlockPage);
  1995. var end_num = parseInt(now_num * BlockPage);
  1996. var next_num = parseInt(end_num + 1);//마지막 페이지 값 구함
  1997. var prev_num = parseInt(start_num);//시작 페이지 값 구함
  1998. var html = "";
  1999. //처음
  2000. if(pageno!=1) {
  2001. html += "<a href=\"javascript:"+url+"(1,"+PageSize+",'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr first\">맨 처음</a>";
  2002. }
  2003. //이전
  2004. if(now_num > 1) {
  2005. html += "<a href=\"javascript:"+url+"("+prev_num+","+PageSize+",'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr prev\">이전</a>";
  2006. }
  2007. //블럭단위 페이징
  2008. for (i = start_num + 1; i <= end_num && i <= lastpgno; i++) {
  2009. if (i == pageno) {
  2010. html += " <strong>"+i+"</strong> ";
  2011. }
  2012. else {
  2013. html += "<a href=\"javascript:"+url+"("+i+","+PageSize+",'1','#car_list1')\" onFocus=\"this.blur();\">"+i+"</a> ";
  2014. }
  2015. }
  2016. //다음
  2017. if(end_num < lastpgno) {
  2018. html += " <a href=\"javascript:"+url+"("+next_num+","+PageSize+",'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr next\">다음</a>";
  2019. }
  2020. //마지막
  2021. if(pageno!=lastpgno && lastpgno>0 ) {
  2022. html += "<a href=\"javascript:"+url+"("+lastpgno+","+PageSize+",'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr last\">맨 마지막</a>";
  2023. }
  2024. return html;
  2025. }
  2026. //날짜 가져오기
  2027. function getSearchDate(type, num){
  2028. var searchDate = new Date();
  2029. if(type == "year"){
  2030. searchDate.setYear(searchDate.getFullYear()+num);
  2031. }else if(type == "month"){
  2032. searchDate.setMonth(searchDate.getMonth()+num);
  2033. }else if(type == "day"){
  2034. searchDate.setDate(searchDate.getDate()+num);
  2035. }
  2036. var y = searchDate.getFullYear();
  2037. var m = searchDate.getMonth() + 1;
  2038. var d = searchDate.getDate();
  2039. if(m < 10) { m = "0" + m; }
  2040. if(d < 10) { d = "0" + d; }
  2041. var resultDate = y + "-" + m + "-" + d;
  2042. return resultDate;
  2043. }
  2044. //차량정보 AJAX 로 반환한다.
  2045. //파라미터 : obj(selectid), table("테이블명"), column (컬럼명) ,setcode(초기셋팅값), initval (선택하세요표시), 만약 상위 코드를 가져와야 하면 상위 코드를 입력한다.
  2046. function getCarInfo(mode, obj, table, column, setcode, initval, pcode, callback){
  2047. var html = "";
  2048. $.ajax({
  2049. url: '/common/lib/api.php',
  2050. data : {'mode':mode,'nm_table':table,'nm_column':column,'pcode':pcode},
  2051. dataType : 'json',
  2052. method : 'POST',
  2053. success : function(data){
  2054. $("#"+obj).empty();
  2055. var i=1;
  2056. $.each(data , function(idx, row){
  2057. html = "<li>\n";
  2058. html+= "<span class=\"radio_wrap\">\n";
  2059. html+= " <input type=\"radio\" name=\""+obj+"\" id=\""+obj+i+"\" value=\""+row.code+"\">\n";
  2060. html+= " <i></i>\n";
  2061. html+= " <label for=\""+obj+i+"\">"+row.name+"</label>\n";
  2062. html+= "</span>\n";
  2063. html+= "</li> \n";
  2064. $("#"+obj).append(html);
  2065. i++;
  2066. });
  2067. $('[name="'+obj+'"]').click(function(){
  2068. var _text = $(this).text();
  2069. var _code = $(this).val();
  2070. if(callback){
  2071. callback(_code);
  2072. }
  2073. });
  2074. }
  2075. });
  2076. }
  2077. function get_query(enc_str){
  2078. var url = '?'+enc_str;
  2079. var qs = url.substring(url.indexOf('?') + 1).split('&');
  2080. for(var i = 0, result = {}; i < qs.length; i++){
  2081. qs[i] = qs[i].split('=');
  2082. result[qs[i][0]] = decodeURIComponent(qs[i][1]);
  2083. }
  2084. return result;
  2085. }