function userboard() { this.cfg = { iframe_src:'http://funmap.userboard.co.kr/widget.php', imgurl:'http://www.userboard.co.kr/images/' }; this.flags = { nodoctype:false, loaded:0, ticktime1:150, ticktime2:15, expand:0, ltimer:0 }; this.wpos = { animated:false, visible:false, wwidth:450, wheight:160, wminwidth:290, target:0, ohash:'', stime:0, ttime:0 }; this.init = function () { if (this.gel(this.wname('userboard_wcont'))) return false; var lhash = document.location.hash; if (navigator.userAgent.indexOf('MSIE') >= 0) { if ((navigator.userAgent.indexOf('MSIE 6') >= 0) || (document.firstChild.nodeValue == null)) { this.flags['nodoctype'] = true; } } if (lhash.substring(1,5) == 'show') { this.flags['expand'] = 1; } this.icon_insert(); }; this.init_pos = function (obj, shift) { obj.style.left = '-'+(this.wpos['wwidth'] - shift)+'px'; }; this.init_content = function () { var d = document; if (!this.gel(this.wname('userboard_cont')) ) { var obj = d.createElement('iframe'); obj.id = this.wname('userboard_cont'); obj.name = this.wname('userboard_cont'); obj.className = 'userboard_content'; this.init_pos(obj, 0); obj.style.display = 'none'; obj.scrolling = 'no'; obj.frameBorder=0; obj.setAttribute("allowTransparency","true"); this.add_el(obj); obj.src = this.cfg['iframe_src']; return true; } return false; }; this.init_onload = function () { if (this.flags['loaded']) return; this.flags['loaded']++; if (!this.gel(this.wname('userboard_wcont'))) this.init(); this.init_content(); if (this.flags['expand']) { this.flags['expand'] = 0; this.icon_click(); } this.set_timer(1); }; this.remove_px = function (str) { var pos = str.indexOf('px'); if (pos > 0) return str.substring(0, pos); else return str; } this.slide_prop = function (el, setto) { if (typeof setto == 'undefined') { var t = this.remove_px(el.style.left); return parseInt(t); } else { el.style.left = setto; } }; this.check_timer = function () { var curtime = this.ctime(); this.cmd_dispatch(); if (this.wpos['animated']) { var ael = [this.wname('userboard_cont'), this.wname('userboard_over'), this.wname('userboard_wcont')]; var tdiff = curtime - this.wpos['stime']; var pshift = 1; if (tdiff >= this.wpos['ttime']) { this.set_timer(1); this.wpos['animated'] = false; if (!this.wpos['visible']) { this.change_class(this.wname('userboard_wcont'), 'userboard_open', false); } this.wswitch_state(this.wpos['visible']); if (!this.wpos['visible']) this.refresh(); document.location.hash = this.wpos['visible'] ? '#show' : '#hide'; } else { pshift = tdiff/this.wpos['ttime']; } pshift = ((-Math.cos(pshift * Math.PI)/2) + 0.5) * this.wpos['target']; for (var i=0;i= 0) { var cmd = document.location.hash.substring(cmdpos+4); document.location.hash = this.wpos['ohash'] ? this.wpos['ohash'] : '#'; this.cmd_get(cmd); } if (this.wpos['ohash'] != document.location.hash) this.wpos['ohash'] = document.location.hash; }; this.cmd_get = function(e) { if (e.data) e = e.data; var psplit = e.split('_'); var cmd = psplit[0]; if (cmd.indexOf('brd') == 0) cmd = cmd.substring(3); switch(cmd) { case 'ready': this.change_class(this.wname('userboard_wcont'), 'userboard_n_load', false); this.wswitch_state(true); this.gel(this.wname('userboard_cont')).style.display = ''; break; case 'close': this.wswitch_state(false); break; } }; this.refresh = function() { this.gel(this.wname('userboard_cont')).src = this.cfg['iframe_src']; }; this.gel = function (elid) { return document.getElementById(elid); }; this.wname = function (elid) { return elid+'_brd'; }; this.icon_insert = function () { var d = document; var cssText = ""; if (this.flags['nodoctype']) { cssText += " * { margin:0; }"; cssText += " html, body { height:100%; overflow:auto; }"; } cssText += " .userboard_passive_container { position:"+(this.flags['nodoctype'] ? "absolute" : "fixed")+"; top:35%; left:0px; padding:0px; margin:0px; height:101px; z-index:2000000000; background:none; line-height:normal; cursor:pointer; }"; cssText += " #userboard_passive_large { position:absolute; top:0px; left:0px; height:108px; width:35px; border: none; margin:0; padding:0; background:transparent url("+this.cfg['imgurl']+"userboard_tab.gif) 0px 0px no-repeat; opacity:.95; }"; cssText += " #userboard_passive_large.userboard_open { background-position: 0px -108px !important; }"; cssText += " .userboard_passive_container.userboard_open #userboard_passive_large { background-position: -5px -216px !important; }"; cssText += " .userboard_passive_container.userboard_open #userboard_passive_large.userboard_open { background-position: -5px -324px !important; }"; if (this.flags['nodoctype']) { cssText += " .userboard_overlay { width: 450px; min-width:289px; z-index: 2000000000; background-color:#231f20; border-right:#231f20 1px solid ; position: absolute; top: 0px; left:-450px; padding:0px; margin:0px; height: expression(document.body.clientHeight); }"; cssText += " .userboard_content { z-index: 2000000000; margin: 0px; padding: 0px; position: absolute; width: 400px; scrolling: no; min-width:269px; top: 0px; left:-440px; height: expression(document.body.clientHeight - 15); border:none; }"; } else { cssText += " .userboard_overlay { width: 450px; min-width:289px; z-index: 2000000000; background-color:#231f20; border-right:#231f20 1px solid ; position: fixed; top: 0px; left:-450px; padding:0px; margin:0px; height: 100%; }"; cssText += " .userboard_content { z-index: 2000000000; margin: 0px; padding: 0px; position: fixed; width: 400px; scrolling: no; min-width:269px; top: 0px; left:-440px; height: 98%; border:none; }"; } cssText += " #userboard_waitload { display:none; position:absolute; top:39px; left:11px; }"; cssText += " .userboard_n_load { opacity:0.6; filter2: alpha(opacity=60); }"; cssText += " .userboard_n_load #userboard_waitload { display:inline; }"; cssText += " a:focus { outline: none; }"; var styleText = d.createTextNode(cssText); var styleNode = d.createElement("style"); styleNode.type = 'text/css'; if (styleNode.styleSheet) styleNode.styleSheet.cssText = styleText.nodeValue; else styleNode.appendChild(styleText); d.getElementsByTagName("head")[0].appendChild(styleNode); if (!this.gel(this.wname('userboard_wcont'))) { var obj = d.createElement('div'); var html = ''; html += "
"; html += "
"; html += "
"; obj.innerHTML = html; obj.id = 'ITH_icon'; obj.style.display = 'none'; this.add_el(obj); d.body.replaceChild(this.gel(this.wname('userboard_wcont')), this.gel('ITH_icon')); } }; this.icon_click = function () { var d = document; this.set_widget_width(this.wpos['wwidth'], false); var cinit = this.init_content(); if (!this.gel(this.wname('userboard_over'))) { this.change_class(this.wname('userboard_wcont'), 'userboard_n_load', true); var obj = d.createElement('div'); obj.id = this.wname('userboard_over'); obj.className = 'userboard_overlay'; this.init_pos(obj, 0); this.add_el(obj); if (!cinit) { if (document.location.hash.indexOf('cmd_brdready') < 0) { document.location.hash = document.location.hash+"#cmd_brdready"; } } this.set_widget_width(this.wpos['wwidth'], false); } else { o_userboard.wswitch_state(!this.wpos['visible']); } return false; }; this.icon_over = function(tp) { this.change_class('userboard_passive_'+tp, 'userboard_open', true); }; this.icon_out = function(tp) { this.change_class('userboard_passive_'+tp, 'userboard_open', false); }; this.add_onload = function(fnc) { if (!this.add_event( 'load', fnc, true )) { if ( window.onload != null ) { var oldOnload = window.onload; window.onload = function ( e ) { oldOnload(e); window[fnc](); }; } else window.onload = fnc; } }; this.change_class = function (elid, cname, onoff) { var el = this.gel(elid); if (onoff && (onoff!=0)) { if (el.className.indexOf(cname)<0) el.className += ' '+cname; } else { for(var cn='';cn!=el.className;) { cn = el.className; el.className = el.className.replace(cname,''); } el.className = el.className.replace(/ +/g, ' '); } }; this.add_el = function (obj) { var b = document.body; try { if (b.childNodes.length > 0) b.insertBefore(obj, b.childNodes[0]); else b.appendChild(obj); }catch(e) { return false; } return true; }; this.set_timer = function (tp) { if (this.flags['ltimer']) window.clearInterval(this.flags['ltimer']); this.flags['ltimer'] = null; this.flags['ltimer'] = window.setInterval('o_userboard.check_timer()', this.flags['ticktime'+tp]); }; this.add_event = function(ev, func, wnd) { var scope = wnd ? window : document; if (typeof scope.addEventListener != 'undefined') { scope.addEventListener(ev, func, false); } else { if (typeof scope.attachEvent != 'undefined') scope.attachEvent('on'+ev, func); else return false; } return true; }; this.set_widget_width = function (wd, mv) { wd = Math.min(parseInt(document.body.clientWidth*0.9), wd); wd = Math.max(o_userboard.wpos['wminwidth'], wd); o_userboard.wpos['wwidth'] = wd; var e1 = o_userboard.gel(this.wname('userboard_over')); var e2 = o_userboard.gel(this.wname('userboard_cont')); if (e1 && e2) { e1.style.width = (wd - 1) + 'px'; e2.style.width = (wd - 20)+ 'px'; var l1 = this.remove_px(e1.style.left); var l2 = this.remove_px(e2.style.left); if (parseInt(l1)<0) e1.style.left = '-'+(wd)+'px'; if (parseInt(l2)<0) e2.style.left = '-'+(wd-10)+'px'; } }; this.ctime = function(){ return +new Date; } } if (typeof o_userboard == 'undefined') { var o_userboard = new userboard(); o_userboard.add_onload(function(){o_userboard.init_onload();}); }