/**
 *Copyright (c) Daum Communications. All rights reserved. 
 * if you want to use this js file, you should keep this copy right.
 */
Array.prototype.objectType = 'Array';
Function.prototype.objectType = 'Function';
String.prototype.objectType = 'String';
Number.prototype.objectType = 'Number';
Boolean.prototype.objectType = 'Boolean';
Date.prototype.objectType = 'Date';
Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
Function.prototype.daumEventListener = function(object, obj) {
var __method = this;
return function(event) {
return __method.call(object, event || window.event, obj);
}
};
Function.prototype.bindContext = function() {
var __method = this;
var args = null;
if(arguments.length == 1){
var object = arguments[0];
}else{
console.log('b')
args = new Array();
for(var i=0; i<arguments.length; i++){
args.push(arguments[i]);
}
var object = args.shift();
}
return function() {
if(arguments && arguments.length >= 1){
if(args == null)
args = new Array();
for(var i=0; i<arguments.length; i++){
args.push(arguments[i]);
}
}
return __method.apply(object, args);
}
}
Function.prototype.before = function(fn, obj){
var me = this;
return function(){
if(obj){
if(typeof fn == 'function') fn.apply(obj, arguments);
return me.apply(obj, arguments);
}else{
if(typeof fn == 'function') fn(arguments);
return me(arguments);
}
}
}
Function.prototype.after = function(fn, obj){
var me = this;
return function(){
var r;
if(obj){
r = me.apply(obj, arguments);
if(typeof fn == 'function') fn.apply(obj, arguments);
}else{
r = me(arguments);
if(typeof fn == 'function') fn(arguments);
}
return r;
}
}
var daum = {
properties: {},
modules: {},
actions: {},
includings: {},
logLevel: {
DEBUG:0,
INFO:1,
ERROR:2
},
templates: {},
totalIncludingTime: 0,
create: function() {
return function() {
if(this.__super){
var temp = {};
for(var prop in this.__super){
if(typeof(this.__super[prop]) == "function"){
if(this.__super[prop].__org){
temp[prop] = this.__super[prop].__org.bindContext(this);
}
}else{
temp[prop] = this.__super[prop];
}
}
this.__super = temp;
}
this.initialize.apply(this, arguments);
if(this.finalize){
this.finalize = this.finalize.bindContext(this);
if(window.onunload){
window.onunload = window.onunload.after(this.finalize);
}else{
window.onunload = this.finalize;
}
}
}
},
extend: function(destination, source) {
if(destination == undefined || source == undefined ){
return null;
}
destination.__super = {};
for (var property in source) {
if(!destination[property]){
destination[property] = source[property];
}else{
if(typeof(source[property]) == "function"){
destination.__super[property] = source[property].bindContext(destination);
destination.__super[property].__org = source[property];
}else{
destination.__super[property] = source[property];
}
}
}
return destination;
},
getValueFromSuper: function(object, key){
if(object.__super){
var value = object.__super[key];
if(value){
return value;
}else{
daum.debug(object.__super);
return this.getValueFromSuper(object.__super, key);
}
}
return null;
},
isLoaded: function(moduleName){
return this.modules[moduleName] == 1;
},
include: function(name){
daum.load({name:name});
},
getRequest: function(){
var xmlhttp;
try{ //to get the mozilla httprequest object
xmlhttp = new XMLHttpRequest();
}catch(e){
try{ //to get MS HTTP request object
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{ //to get MS HTTP request object
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
throw "Unable to get an HTTP request object";
}
}
}
return xmlhttp;
},
getScript: function(url, isXml) {
var xmlhttp = this.getRequest();
try{
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200 || xmlhttp.status == 304){
if(isXml){
var response = xmlhttp.responseXML;
}else{
var response = xmlhttp.responseText;
if (navigator.appVersion.indexOf("Safari") >= 0) {
response = decodeURIComponent(escape(response));
}
}
return response;
}
}catch(e){
throw "Unable to load script, URL: "+url;
}
},
getTemplate: function(path){
if(!this.templates[path]){
var url = daum.properties.TEMPLATE_URL+path+"?dummy="+daum.getDummyParam();
this.templates[path] = this.getScript(url, false);
}
return this.templates[path];
},
load: function(params) {
var name = params.name;
var alias = params.alias || false;
var usingEval = !(params.usingEval == false);
var from = params.from || false;
var isAbsolute = false;
var moduleName = "";
if(name.charAt(0) == "^"){
isAbsolute = true;
moduleName = name.substr(1);
}else{
moduleName = name;
}
if(alias){
if(this.modules[alias] == 2){
return this.modules[alias];
}else if(this.modules[alias] == 1){
return this.modules[alias];
}else{
this.modules[alias] = 1;
}
}else{
if(this.modules[moduleName] == 2){
return this.modules[moduleName];
}else if(this.modules[moduleName] == 1){
return this.modules[moduleName];
}else{
this.modules[moduleName] = 1;
}
}
try{
this._importModules(moduleName, alias, usingEval, isAbsolute);
if(alias){
this.modules[alias] = 2;
return this.modules[alias];
}else{
this.modules[moduleName] = 2;
return this.modules[moduleName];
}
}catch(e){
daum.error("Error occured in daum.load('"+moduleName+"'), reason:"+e);
if(alias){
this.modules[alias] = false;
}else{
this.modules[moduleName] = false;
}
}finally{
}
},
_loadConfig: function() {
try{
var configUrl = daum.properties.BASEURL+"actions-config.xml?dummy="+daum.getDummyParam();
var configInfo = this.getScript(configUrl, true);
daum._loadActionConfig(configInfo);
var modules = configInfo.getElementsByTagName("module");
for(var i=0; i<modules.length; i++){
var _path = modules[i].getAttribute("path");
var _file = modules[i].getAttribute("file");
configUrl = daum.properties.BASEURL+_file+"?dummy="+daum.getDummyParam();
configInfo = this.getScript(configUrl, true);
daum._loadActionConfig(configInfo, _path);
}
}catch(e){
daum.error("ERROR occured in daum._loadConfig. reason: "+e);
}
},
_importModules: function(moduleName, alias, usingEval, isAbsolute){
try{
var module = moduleName.split(".");
var dummyParam = "?dummy="+daum.getDummyParam();
if(isAbsolute){
var moduleUrl = module.join("/")+".js"+dummyParam;
}else if(daum.properties.DAUM_PACKAGE_PROXY &&
daum.properties.DAUM_PACKAGE_PROXY != "" &&
module[0] == "daum" ){
var moduleUrl = daum.properties.DAUM_PACKAGE_PROXY+module.join("/")+".js"+dummyParam;
}else{
var moduleUrl = daum.properties.BASEURL+module.join("/")+".js"+dummyParam;
}
if(alias){
module = alias.split(".");
}
if(module){
var submodule = "";
for(var i=0; i<module.length-1; i++){
if(i==0){
submodule = module[i];
}else{
submodule = submodule + "." + module[i];
}
var script = "if(!window."+submodule+") window."+submodule+"=new Object();";
eval(script);
}
}
if(usingEval == false){
document.write('<script language="javascript" type="text/javascript" src="'+moduleUrl+'"></script>');
}else{
var scriptText = this.getScript(moduleUrl);
if(scriptText==undefined || scriptText == null || scriptText == ""){
return false;
}
var beforeTime = new Date();
eval(scriptText);
var lastTime = new Date();
this.totalIncludingTime = this.totalIncludingTime + (lastTime-beforeTime);
}
}catch(e){
daum.error("Error occured in daum._importModules('"+moduleName+"'), reason:"+e);
throw e;
}
},
$: function(element) {
if (arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if (typeof element == 'string')
element = document.getElementById(element);
return element;
},
pause: function(numberMillis){
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true){
now = new Date();
if (now.getTime() > exitTime)
return;
}
},
getDummyParam: function(){
if(daum.properties.DUMMY_PARAM == "time"){
var now = new Date();
var month = now.getMonth().toString();
var date = now.getDate().toString();
var hour = now.getHours().toString();
var min = now.getMinutes().toString();
var sec = now.getSeconds().toString();
return month+date+hour+min+sec;
}
return daum.properties.DUMMY_PARAM;
}
};
var _logging ={
showProps: function(obj){
var result="";
for (var propName in obj){
result = result + propName +", ";
}
daum.debug(result);
},
debug: function(msg){
if(!daum.properties.USING_LOGGER)
return;
if(this.logLevel[daum.properties.LOGGER_LEVEL] > this.logLevel.DEBUG)
return;
try{
console.log(msg);
} catch(e) {
try{ Logger.debug(msg); } catch(e) {}
}
return '';
},
info: function(msg) {
if(!daum.properties.USING_LOGGER)
return;
if(this.logLevel[daum.properties.LOGGER_LEVEL] > this.logLevel.INFO)
return;
try{
console.log(msg);
} catch(e) {
try{ Logger.info(msg); } catch(e) {}
}
return '';
},
error: function(msg) {
if(!daum.properties.USING_LOGGER)
return;
if(this.logLevel[daum.properties.LOGGER_LEVEL] > this.logLevel.ERROR)
return;
try{
console.log(msg);
} catch(e) {
try{Logger.error(msg);} catch(e) {}
}
return '';
},
time: function(name) {
if(this.logLevel[daum.properties.LOGGER_LEVEL] > this.logLevel.DEBUG)
return;
try{
console.time(name);
} catch(e) {
try{ Logger.time(name); } catch(e) {}
}
return '';
},
timeEnd: function(name) {
if(this.logLevel[daum.properties.LOGGER_LEVEL] > this.logLevel.DEBUG)
return;
try{
console.timeEnd(name);
} catch(e) {
try{ Logger.timeEnd(name); } catch(e) {}
}
return '';
}
}
Object.extend(daum , _logging);
var _action = {
_loadActionConfig: function(configInfo,module) {
if(configInfo == undefined || configInfo == null){
daum.error("ERROR occured in daum._loadConfig. reason: cannot load actions-config.xml");
return false;
}
var actionConfig = new Array();
var actions = configInfo.getElementsByTagName("action");
for(var i=0; i<actions.length; i++){
var _name = actions[i].getAttribute("name");
var _type = actions[i].getAttribute("type");
var _method = actions[i].getAttribute("method");
if(_method == "")
_method = "execute";
var _description = actions[i].getAttribute("description");
actionConfig.push({name:_name, type:_type, method:_method, description:_description});
}
daum.registerActions(actionConfig,module);
},
registerActions: function(actionConfigs, subModule){
if(actionConfigs){
for(var i=0; i<actionConfigs.length; i++){
daum.registerAction(actionConfigs[i], subModule);
}
}
},
registerAction: function(actionConfig, subModule){
try{
if(subModule)
var actionName = subModule+"/"+actionConfig.name;
else
var actionName = actionConfig.name;
if(this.actions[actionName]){
throw actionName+" has been already registered";
}
daum.load({name:actionConfig.type, usingEval:true});
var scriptText = "this.actions['"+actionName+"']=["+actionConfig.type+", "+actionConfig.type+"."+actionConfig.method+", '"+actionConfig.description+"']";
eval(scriptText);
}catch(e){
daum.error("Error occured in daum.registerAction, Check the config file, reason: "+e);
}
},
call: function(className, methodName, params){
try{
daum.include(className);
if(params == undefined || params == null)
params = {};
return function(event) {
var evt = event || window.event;
if(evt){
params.event = evt;
}
eval("var classObj = "+className);
eval("var methodObj = "+className+"."+methodName);
return methodObj.call(classObj, params);
}
}catch(e){
daum.error("ERROR occured during getAction, reason: "+e);
throw e;
}
},
getAction: function(name, params){
var action = this.actions[name];
if(!action)
throw "[ACTION:"+name+"] is not registered!";
try{
if(params == undefined || params == null)
params = {};
return function(event) {
var evt = event || window.event;
if(evt){
params.event = evt;
}
return action[1].call(action[0], params);
}
}catch(e){
daum.error("ERROR occured during getAction, reason: "+e);
throw e;
}
},
_checkLoaded: function(moduleName){
if(this.modules[moduleName]){
daum.debug("_checkLoaded ==> "+this.modules[moduleName]);
return this.modules[moduleName];
}else{
daum.debug("_checkLoaded LOOP");
this._checkLoaded(moduleName);
}
}
}
Object.extend(daum , _action);
if(!daumProperties){
daum.error("Check if daumProperties.js has been included");
throw "Check if daumProperties.js has been included";
}
daum.properties = daumProperties;
if(daum.properties.PROJECT_ROOT){
for(var i=0; i<daum.properties.PROJECT_ROOT.length; i++){
if(daum.properties.PROJECT_ROOT[i])
eval("var "+daum.properties.PROJECT_ROOT[i]+" = new Object();");
}
}
for(var i=0; i<daum.properties.LIBRARY.length; i++){
if(daum.properties.LIBRARY[i])
daum.load({name:daum.properties.LIBRARY[i], usingEval:false});
}
window.onload = function(){
var unload = function() {
daum.modules = null;
actions = null;
if(typeof(dispose) == "function"){
dispose();
}
if (window.removeEventListener) {
window.removeEventListener('unload', unload, false);
} else if (window.detachEvent) {
window.detachEvent('onunload', unload);
}
}
if (window.addEventListener) {
window.addEventListener('unload', unload, false);
} else if (window.attachEvent) {
window.attachEvent('onunload', unload);
}
if(daum.properties.USING_LOGGER){
Logger.initialize();
}
if(daum.properties.USING_ACTION_SYSTEM){
daum._loadConfig();
}
if(daum.properties.USING_HISTORY_SYSTEM){
historyDiv = document.createElement("div");
historyDiv.id="history-div";
document.body.appendChild(historyDiv);
window.historyStorage.init();
window.dhtmlHistory.create();
dhtmlHistory.initialize();
daum.debug("HISTORY SYSTEM is initialized....");
}
if(typeof(main) == "function"){
main();
}
daum.debug("daumInit.js is completed.. totalIncludingTime:"+daum.totalIncludingTime);
}

daum.include = function(name){};
if(!window.daum) window.daum = new Object();
if(!window.daum.dom) window.daum.dom = new Object();
daum.dom.Event = {
 KEY_BACKSPACE: 8,
  KEY_TAB:       9,
  KEY_RETURN:   13,
  KEY_ESC:      27,
  KEY_LEFT:     37,
  KEY_UP:       38,
  KEY_RIGHT:    39,
  KEY_DOWN:     40,
  KEY_DELETE:   46,
  KEY_HOME:     36,
  KEY_END:      35,
  KEY_PAGEUP:   33,
  KEY_PAGEDOWN: 34,
  KEY_CTRL:		17,
  KEY_ALT:		18,
element: function(event) {
return event.target || event.srcElement;
},
isLeftClick: function(event) {
var e = event || window.event;
var lc = (((e.which) && (e.which == 1)) || ((e.button) && (e.button == 1)));
lc = lc && !e.ctrlKey && !e.altKey && !e.shiftKey;
return lc;
},
isLeftClickWithCtrl: function(event) {
var e = event || window.event;
var lc = (((e.which) && (e.which == 1)) || ((e.button) && (e.button == 1)));
lc = lc && e.ctrlKey;
return lc;
},
pointerX: function(event) {
return event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft));
},
pointerY: function(event) {
return event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop));
},
stop: function(event) {
var event = event || window.event;
if (event.preventDefault) {
event.preventDefault();
event.stopPropagation();
} else {
event.returnValue = false;
event.cancelBubble = true;
}
},
findElement: function(event, tagName) {
var element = daum.dom.Event.element(event);
while (element.parentNode && (!element.tagName ||
(element.tagName.toUpperCase() != tagName.toUpperCase())))
element = element.parentNode;
return element;
},
observers: false,
_observeAndCache: function(element, name, observer, useCapture) {
if (!this.observers) this.observers = [];
if (element.addEventListener) {
this.observers.push([element, name, observer, useCapture]);
element.addEventListener(name, observer, useCapture);
} else if (element.attachEvent) {
this.observers.push([element, name, observer, useCapture]);
element.attachEvent('on' + name, observer);
}
},
unloadCache: function() {
var e = daum.dom.Event
var observers = e.observers;
if (!observers) return;
for (var i = 0, length = observers.length; i < length; i++) {
e.stopObserving.apply(this, observers[i]);
e.observers[i][0] = null;
}
e.observers = false;
},
observe: function(element, name, observer, useCapture) {
element = daum.$(element);
useCapture = useCapture || false;
if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.attachEvent))
name = 'keydown';
daum.dom.Event._observeAndCache(element, name, observer, useCapture);
},
stopObserving: function(element, name, observer, useCapture) {
element = daum.$(element);
useCapture = useCapture || false;
if (name == 'keypress' &&
(navigator.appVersion.match(/Konqueror|Safari|KHTML/)
|| element.detachEvent))
name = 'keydown';
if (element.removeEventListener) {
element.removeEventListener(name, observer, useCapture);
} else if (element.detachEvent) {
try {
element.detachEvent('on' + name, observer);
} catch (e) {}
}
},
shift_nums : {
"`":"~",
"1":"!",
"2":"@",
"3":"#",
"4":"$",
"5":"%",
"6":"^",
"7":"&",
"8":"*",
"9":"(",
"0":")",
"-":"_",
"=":"+",
";":":",
"'":"\"",
",":"<",
".":">",
"/":"?",
"\\":"|"
},
special_keys : {
'esc':27,
'escape':27,
'tab':9,
'space':32,
'return':13,
'enter':13,
'backspace':8,
'scrolllock':145,
'scroll_lock':145,
'scroll':145,
'capslock':20,
'caps_lock':20,
'caps':20,
'numlock':144,
'num_lock':144,
'num':144,
'pause':19,
'break':19,
'insert':45,
'home':36,
'delete':46,
'end':35,
'pageup':33,
'page_up':33,
'pu':33,
'pagedown':34,
'page_down':34,
'pd':34,
'left':37,
'up':38,
'right':39,
'down':40,
'f1':112,
'f2':113,
'f3':114,
'f4':115,
'f5':116,
'f6':117,
'f7':118,
'f8':119,
'f9':120,
'f10':121,
'f11':122,
'f12':123
},
observeKey: function(shortcut, callback, options){
var opt = {
'type':'keydown',
'propagate':false,
'target':document
}
Object.extend(opt, options || {});
var ele = typeof opt.target == 'string' ? document.getElementById(opt.target) : opt.target;
var func = function(e) {
e = e || window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code).toLowerCase();
var keys = shortcut.toLowerCase().split("+");
var kp = 0;
for(var i=0; k=keys[i],i<keys.length; i++) {
if(k == 'ctrl' || k == 'control') {
if(e.ctrlKey) kp++;
} else if(k ==  'shift') {
if(e.shiftKey) kp++;
} else if(k == 'alt') {
if(e.altKey) kp++;
} else if(k.length > 1) { //If it is a special key
if(daum.dom.Event.special_keys[k] == code) kp++;
} else { //The special keys did not match
if(character == k){
kp++;
}else {
if(daum.dom.Event.shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
character = daum.dom.Event.shift_nums[character];
if(character == k) kp++;
}
}
}
}
if(kp == keys.length) {
callback(e);
if(!opt['propagate']) { //Stop the event
daum.dom.Event.stop(e);
return false;
}
}
}
daum.dom.Event.observe(ele,  opt['type'], func, false);
}
};
if(!window.$sw)
window.$sw = new Object();
$sw.ev = daum.dom.Event;
if (navigator.appVersion.match(/\bMSIE\b/))
daum.dom.Event.observe(window, 'unload', daum.dom.Event.unloadCache, false);
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.Baloon = daum.create();
daum.widget.Baloon.prototype = {
pause: false, // 일시 중단이 필요 할 경우
initialize: function (element, options) {
this.options = {
content: null, // MouseOver Event 가 발생 할 때 화면에 뿌려 줄 내용
width: '100px', // Baloon 의 가로 길이 (기본은 100px)
height: '15px', // Baloon 의 세로 길이 (기본은 15px)
backgroundColor: 'white', // Baloon 의 background-color (기본은 white)
color: 'black' // Baloon 의 color (기본은 black)
};
Object.extend(this.options, options || {});
this.element = $(element);
this.eventMouseOver = this._mouseOver.bindAsEventListener(this);
this.eventMouseDown = this._mouseDown.bindAsEventListener(this);
Event.observe(this.element, "mouseover", this.eventMouseOver);
Event.observe(document, "mousedown", this.eventMouseDown);
},
_mouseOver: function (event) {
this._createBaloon();
},
_mouseDown: function (event) {
this._removeBaloon();
},
_createBaloon: function () {
if (this.pause) {
return ;
}
var baloon = $('baloon');
if (baloon != null) {
this._removeBaloon();
}
baloon = document.createElement('div');
baloon.id = 'baloon';
baloon.style.position = 'absolute';
baloon.style.width = this.options.width;
baloon.style.height = this.options.height;
baloon.style.backgroundColor = this.options.backgroundColor;
baloon.style.color = this.options.color;
baloon.style.border = '1px groove';
baloon.style.padding = '5px';
var position = Position.cumulativeOffset(this.element);
var dimension = Element.getDimensions(this.element);
baloon.style.left = (parseInt(position[0]) + parseInt(dimension.width)) + 'px';
baloon.style.top = parseInt(position[1]) + 'px';
baloon.innerHTML = this.options.content;
Event.observe(baloon, "mouseout", this.eventMouseDown);
document.body.appendChild(baloon);
new Effect.Opacity(baloon, { duration:1, from:1.0, to:0.6 });
new Effect.Opacity(baloon, { duration:1, from:0.6, to:1.0 });
},
_removeBaloon: function () {
var baloon = $('baloon');
if (baloon != null) {
Event.stopObserving(baloon, "mouseout", this.eventMouseDown);
Element.remove(baloon);
baloon = null;
}
},
disable: function () {
this.pause = true;
},
enable: function () {
this.pause = false;
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.dom) window.daum.dom = new Object();
daum.dom.Element = {
hasClass : function(el, c){
var exist = false;
if(!el.className){
return false;
}
var tmp = el.className.split(' ');
for(var i in tmp){
if(tmp[i] == c){
exist = true;
break;
}
}
return exist;
},
addClass : function(el, c){
if(!this.hasClass(el, c)) el.className += ' ' + c;
},
removeClass : function(el, c){
var tmp = el.className.split(' ');
for(var i in tmp){
if(tmp[i] == c){
tmp.splice(i,1);
break;
}
}
el.className = tmp.join(' ');
},
hide: function(element) {
element.style.display = 'none';
return element;
},
show: function(element) {
element.style.display = '';
return element;
},
remove: function(element) {
element.parentNode.removeChild(element);
return element;
},
getCssDimension: function(e){
var parsing  = function(str){
if(str == null){
return 0;
}else{
var x = str.substr(0,str.length-2);
return isNaN(x)? 0: parseInt(x);
}
}
var ml = parsing(Element.getStyle(e, 'margin-left'))
var mr = parsing(Element.getStyle(e, 'margin-right'))
var bl = parsing(Element.getStyle(e, 'border-left-width'))
var br = parsing(Element.getStyle(e, 'border-right-width'))
var pl = parsing(Element.getStyle(e, 'padding-left'))
var pr = parsing(Element.getStyle(e, 'padding-right'))
var w = e.offsetWidth - ml - mr - bl - br - pl - pr;
var mt = parsing(Element.getStyle(e, 'margin-top'))
var mb = parsing(Element.getStyle(e, 'margin-bottom'))
var bt = parsing(Element.getStyle(e, 'border-top-width'))
var bb = parsing(Element.getStyle(e, 'border-bottom-width'))
var pt = parsing(Element.getStyle(e, 'padding-top'))
var pb = parsing(Element.getStyle(e, 'padding-bottom'))
var h = e.offsetHeight - mt - mb - bt - bb - pt - pb;
return [w, h];
},
setCurrentDelta: function(element, x, y) {
element.style.top      = y+"px";
element.style.left     = x+"px";
},
getMouseOffset: function(element, event){
var mousePos = this.getMousePosition(event);
var elePos = this.getElementPosition(element);
return {x:mousePos.x - elePos.x, y:mousePos.y - elePos.y};
},
positionCenter: function(element, width, height, topOffset, heightOffset){
var winSize = this.getWindowSize();
var tOffset = topOffset;
if(!tOffset)
tOffset = 0;
var hOffset = heightOffset;
if(!hOffset)
hOffset = 0;
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
if(width && height){
element.style.left = ((winSize.x+tOffset)/2 - parseInt(width)/2) + scrollLeft  + "px";
element.style.top = ((winSize.y+hOffset)/2 - parseInt(height)/2)  + scrollTop + "px";
}else{
var dim = {x:element.clientWidth, y:element.clientHeight};
element.style.left = ((winSize.x+tOffset)/2 - dim.x/2) + scrollLeft + "px";
element.style.top = ((winSize.y+hOffset)/2 - dim.y/2)  + scrollTop + "px";
}
},
getWindowSize: function(includeScroll){
if(!includeScroll){
var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
}else{
var windowWidth = document.documentElement.scrollWidth || document.body.scrollWidth || document.documentElement.offsetWidth || document.body.offsetWidth ;
var windowHeight = document.documentElement.scrollHeight || document.body.scrollHeight || document.documentElement.offsetHeight  || document.body.offsetHeight ;
}
return {x:windowWidth-2, y:windowHeight-2};
},
getMousePosition: function(event){
var mousePosX = Event.pointerX(event);
var mousePosY = Event.pointerY(event);
return {x:mousePosX, y:mousePosY};
},
getScrollOffset: function(element){
if(element){
var offsetX = element.scrollLeft;
var offsetY = element.scrollTop;
}else{
var offsetX = document.documentElement.scrollLeft || document.body.scrollLeft;
var offsetY = document.documentElement.scrollTop || document.body.scrollTop;
}
return {x:offsetX, y:offsetY};
},
getElementPosition: function(element){
var elePos = this.cumulativeOffset(element);
return {x:elePos[0], y:elePos[1]};
},
cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop  || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return [valueL, valueT];
},
currentDelta: function(element) {
return {x:parseInt(Element.getStyle(element,'left') || '0'),
y:parseInt(Element.getStyle(element,'top') || '0')};
},
getDimension: function(element) {
return {x: element.offsetWidth, y: element.offsetHeight};
},
setDimension: function(element, x, y) {
element.style.width = x+"px";
element.style.height = y+"px";
},
getElementRectanglePosition: function(element) {
var elePos = Position.cumulativeOffset(element);
return {
tl : { x : elePos[0], y : elePos[1] },
tr : { x : elePos[0] + element.offsetWidth, y : elePos[1] },
bl : { x : elePos[0], y : elePos[1] + element.offsetHeight },
br : { x : elePos[0] + element.offsetWidth, y : elePos[1] + element.offsetHeight }
};
},
move: function(element, left, top){
Element.makePositioned(element);
element.style.left = left+"px";
element.style.top = top+"px";
},
getFirstNode: function(element){
for(var i=0; i<element.childNodes.length; i++){
if(element.childNodes[i].nodeName=='#text')
continue;
return element.childNodes[i];
}
return null;
},
getFirstValue: function(element, tagName){
var children = element.getElementsByTagName(tagName);
if(children == null || children.length == 0)
return '';
if(children[0].firstChild && children[0].firstChild.nodeValue)
return children[0].firstChild.nodeValue;
return '';
},
getNextNode: function(element){
var nextNode = element.nextSibling;
if(nextNode.nodeName == '#text')
return nextNode.nextSibling;
return nextNode;
},
getChildValueByAttr: function( xRoot , name , value){
if(xRoot == null ) return "";
var xChilds = xRoot.childNodes;
var result = "";
if ( xChilds == null ) return result;
for( var k = 0  ;k < xChilds.length ; k++ ){
if( xChilds[k].getAttribute( name ) == value){
result = result+ xChilds[k].firstChild.nodeValue;
break;
}
}
return result;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.dnd) window.daum.dnd = new Object();
daum.dnd.DragObj = daum.create();
daum.dnd.DragObj.prototype = {
_moveBack: function() {
this.element.style.left = (this.delta.x)+"px";
this.element.style.top = (this.delta.y)+"px";
},
initialize: function(element,options){
this.options = {
name: null,
handle: null,
copy: false,
direction: null,
zindex: 1000,
revert: false,
showmousepos: false,
bound: false,
starteffect: function(element) {
},
reverteffect: this._moveBack.bind(this),
endeffect: function(element) {
},
onMouseDown : null,
onMouseMove : null,
onFinish : null
};
Object.extend(this.options, options || {});
if(typeof(element) == "string")
this.element = document.getElementById(element);
else
this.element = element;
this.dragging = false;
if(this.options.handle && (typeof(this.options.handle) == 'string')) {
var h = document.getElementsByClassName(this.options.handle, this.element)[0];
this.handle = h;
}
if(!this.handle) this.handle = document.getElementById(this.options.handle);
if(!this.handle) this.handle = this.element;
Element.makePositioned(this.element);
this.delta = this.currentDelta();
this.eventMouseDown = this._mouseDown.bindAsEventListener(this);
daum.dom.Event.observe(this.handle, "mousedown", this.eventMouseDown);
daum.dnd.DragObjMgr.register(this);
},
destroy: function() {
daum.dom.Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
daum.dnd.DragObjMgr.unregister(this);
},
getName: function(){
return this.options.name;
},
_mouseDown: function(event) {
var src = daum.dom.Event.element(event);
if(src.tagName && (
src.tagName=='INPUT' ||
src.tagName=='SELECT' ||
src.tagName=='OPTION' ||
src.tagName=='BUTTON' ||
src.tagName=='TEXTAREA')) return false;
if(this.element._revert) {
this.element._revert.cancel();
this.element._revert = null;
}
this.offset = this.getMouseOffset(event);
daum.dnd.DragObjMgr.activate(this);
this.dirX = 0;
this.dirY = 0;
if(this.options.copy) {
this._clone = this.element.cloneNode(true);
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
if(this.options.onMouseDown) this.options.onMouseDown(this, event);
daum.dom.Event.stop(event);
document.body.focus();
return false;
},
_prepareToMove: function(event) {
this.dragging = true;
if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex;
}
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
if(this.options.starteffect) this.options.starteffect(this.element);
},
_mouseMove: function(event) {
if(!this.dragging) this._prepareToMove(event);
this._draw(event);
if(this.options.onMouseMove) this.options.onMouseMove(this, event);
daum.dom.Event.stop(event);
return false;
},
_draw: function(event){
var elePos = this.getElementPosition(event);
var curDelta = this.currentDelta();
elePos.x -= curDelta.x;
elePos.y -= curDelta.y;
var mousePos = this.getMousePosition(event);
var movePosX = mousePos.x - elePos.x - this.offset.x;
var movePosY = mousePos.y - elePos.y - this.offset.y;
this.dirX = movePosX - curDelta.x;
this.dirY = movePosY - curDelta.y;
if(this.options.bound){
var winSize = daum.dom.Element.getWindowSize();
if(mousePos.x < 0){
movePosX = 0 - elePos.x - this.offset.x ;
}else if(mousePos.x > winSize.x){
movePosX = winSize.x - elePos.x - this.offset.x;
}
if(movePosY < 0){
movePosY = 0 - elePos.y - this.offset.y;
}else if(mousePos.y > winSize.y - 10){
movePosY = winSize.y - elePos.y - this.offset.y;
}
}
if((!this.options.direction) || (this.options.direction=='horizontal'))
this.element.style.left = movePosX+"px";
if((!this.options.direction) || (this.options.direction=='vertical'))
this.element.style.top = movePosY+"px";
},
_mouseUp: function(event) {
this._finishMove(event, true);
this.dirX = 0;
this.dirY = 0;
daum.dom.Event.stop(event);
return false;
},
_finishMove: function(event, success) {
this.dragging = false;
if(this.options.copy) {
Element.remove(this._clone);
this._clone = null;
}
var revert = this.options.revert;
if(revert && typeof revert == 'function') revert = revert(this.element);
var d = this.currentDelta();
if(this.options.zindex && this.originalZ){
this.element.style.zIndex = this.originalZ;
}
if(this.options.endeffect)
this.options.endeffect(this.element);
daum.dnd.DragObjMgr.deactivate(this);
if(this.options.onFinish) this.options.onFinish(this,event);
if(revert && this.options.reverteffect) {
this.options.reverteffect();
} else {
this.delta = d;
}
},
draggingDirection: function() {
return {x:this.dirX, y:this.dirY};
},
setCurrentDelta: function(x, y) {
daum.dom.Element.setCurrentDelta(this.element,x,y);
},
getMouseOffset: function(event){
return daum.dom.Element.getMouseOffset(this.element,event);
},
getMousePosition: function(event){
return daum.dom.Element.getMousePosition(event);
},
getElementPosition: function(){
return daum.dom.Element.getElementPosition(this.element);
},
currentDelta: function() {
return daum.dom.Element.currentDelta(this.element);
},
getDimension: function() {
return daum.dom.Element.getDimension(this.element);
}
}
daum.dnd.DragObjMgr = {
drags: new Array(),
activeDraggable: null,
register: function(dragObj) {
if(this.drags.length == 0) {
this.eventMouseUp   = this._mouseUp.bindAsEventListener(this);
this.eventMouseMove = this._mouseMove.bindAsEventListener(this);
daum.dom.Event.observe(document, "mouseup", this.eventMouseUp);
daum.dom.Event.observe(document, "mousemove", this.eventMouseMove);
}
this.drags.push(dragObj);
},
createPositionElement: function(){
this.pointXElement = document.createElement('div')
this.pointXElement.style.position = "absolute"
this.pointXElement.style.left = '-10px'
this.pointXElement.style.top = '-10px'
this.pointXElement.style.width = '1px'
this.pointXElement.style.height = '1000px'
this.pointXElement.style.backgroundColor = 'red'
this.pointXElement.style.fontSize = '1px'
this.pointXElement.style.zIndex = 2000
document.body.appendChild(this.pointXElement)
this.pointYElement = document.createElement('div')
this.pointYElement.style.position = "absolute"
this.pointYElement.style.left = '-10px'
this.pointYElement.style.top = '-10px'
this.pointYElement.style.width = '100%'
this.pointYElement.style.height = '1px'
this.pointYElement.style.overflow = 'hidden'
this.pointYElement.style.margin = '0px'
this.pointYElement.style.border = '0px'
this.pointYElement.style.backgroundColor = 'red'
this.pointYElement.style.fontSize = '1px'
this.pointYElement.style.zIndex = 2000
document.body.appendChild(this.pointYElement)
this.displayElement = document.createElement('div')
this.displayElement.style.position = "absolute"
this.displayElement.style.left = '-10px'
this.displayElement.style.top = '-10px'
this.displayElement.style.color = 'white'
this.displayElement.style.backgroundColor = 'red'
this.displayElement.style.fontSize = 'small'
this.displayElement.style.zIndex = 2000
document.body.appendChild(this.displayElement)
},
showPosition: function(x, y, msg){
if(this.pointXElement && this.pointYElement){
this.pointXElement.style.left = x + "px";
this.pointXElement.style.height = (y + 1000) + "px";
this.pointYElement.style.top = y + "px";
this.displayElement.style.left = x + "px";
this.displayElement.style.top = (y - Element.getHeight(this.displayElement)) + "px";
if(msg){
this.displayElement.innerHTML = msg+" ("+x+","+y+")";
}else{
this.displayElement.innerHTML = "("+x+","+y+")";
}
}
},
hidePosition: function(){
if(this.pointXElement && this.pointYElement){
this.pointXElement.style.left = "-10px";
this.pointXElement.style.top = "-10px";
this.pointYElement.style.left = "-10px";
this.pointYElement.style.top = "-10px";
this.displayElement.style.left = "-100px";
this.displayElement.style.top = "-100px";
}
},
unregister: function(dragObj) {
this.drags = this.drags.reject(function(d) { return d==dragObj });
if(this.drags.length == 0) {
daum.dom.Event.stopObserving(document, "mouseup", this.eventMouseUp);
daum.dom.Event.stopObserving(document, "mousemove", this.eventMouseMove);
}
},
activate: function(draggable) {
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable;
},
deactivate: function() {
this.activeDraggable = null;
},
_mouseMove: function(event) {
if(!this.activeDraggable) return;
this.activeDraggable._mouseMove(event);
},
_mouseUp: function(event) {
if(!this.activeDraggable) return;
this.activeDraggable._mouseUp(event);
this.activeDraggable = null;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.browser) window.daum.browser = new Object();
new function() {
var b = navigator.userAgent.toLowerCase();
daum.browser.Browser = {
safari: /webkit/.test(b),
opera: /opera/.test(b),
msie: /msie/.test(b) && !/opera/.test(b),
mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b),
isIE: function(){
return this.msie;
},
isMozilla: function(){
return this.mozilla;
},
isOpera: function(){
return this.opera;
},
isSafari: function(){
return this.safari;
}
};
if(!window.$sw)
window.$sw = new Object();
$sw.browser = daum.browser.Browser;
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.split) window.daum.widget.split = new Object();
daum.widget.split.Split = daum.create();
daum.widget.split.Split.prototype = {
front : null,
 rear : null,
 split : null,
initialize : function (front, rear, options) {
this.options = {
className : 'split-bar',
direction : 'horizontal',
size : '4',
frontminsize : '0',
rearminsize : '0',
onmousedown : null,
onmousemove : null,
onmouseup : null
};
Object.extend(this.options, options || {});
if(typeof(front) == "string"){
this.front = document.getElementById(front);
}else{
this.front = front;
}
if(typeof(rear) == "string"){
this.rear = document.getElementById(rear);
}else{
this.rear = rear;
}
if (this.front.parentNode == this.rear.parentNode) {
this.parent = this.front.parentNode;
this._createSplit();
}else{
throw Exception('Diff');
}
this._mouseDown = this._mouseDown.after(this.options.onmousedown, this);
this._mouseUp = this._mouseUp.after(this.options.onmouseup, this);
this._mouseMove = this._mouseMove.after(this.options.onmousemove, this);
},
_createSplit : function () {
this.split = document.createElement('div');
this.split.className = this.options.className;
this.split.id = 'split_'+this.front.id + '_' + this.rear.id; // center_right_split 과 같은 형태로 ID 자동부여
if (this.options.direction == 'horizontal') {
if (daum.browser.Browser.isIE()) {
this.split.style.styleFloat = 'left';
} else {
this.split.style.cssFloat = 'left';
}
this.split.style.cursor = 'e-resize';
this.split.style.width = this.options.size+'px';
this.split.style.height = (this.front.offsetHeight >= this.rear.offsetHeight ? this.front.offsetHeight : this.rear.offsetHeight) + 'px';
} else {
this.split.style.cursor = 'n-resize';
this.split.style.width = (this.front.offsetWidth >= this.rear.offsetWidth ? this.front.offsetWidth : this.rear.offsetWidth) + 'px';
this.split.style.height = this.options.size+'px';
}
this.parent.insertBefore(this.split, this.rear);
this.eventMouseDown = this._mouseDown.bind(this);
this.eventMouseMove = this._mouseMove.bind(this);
this.eventMouseUp = this._mouseUp.bind(this);
new daum.dnd.DragObj(this.split,
{
direction : this.options.direction,
onMouseDown : this.eventMouseDown,
onMouseMove : this.eventMouseMove,
onFinish : this.eventMouseUp
}
);
},
_mouseDown : function () {
this.oldPos = daum.dom.Element.getElementPosition(this.split);
this.frontDim = daum.dom.Element.getCssDimension(this.front);
this.rearDim = daum.dom.Element.getCssDimension(this.rear);
},
_mouseMove : function (dragObj, event) {
var newPos = daum.dom.Element.getElementPosition(this.split);
if (this.options.direction == 'horizontal') {
var distance = newPos.x - this.oldPos.x;
var frontWidth = this.frontDim[0] + distance;
var rearWidth = this.rearDim[0] - distance;
if (frontWidth > this.options.frontminsize && rearWidth > this.options.rearminsize) { // 최소 사이즈 보장
this.front.style.width = frontWidth + 'px';
this.rear.style.width = rearWidth + 'px';
this.split.style.height = (this.front.offsetHeight >= this.rear.offsetHeight ? this.front.offsetHeight : this.rear.offsetHeight) + 'px';
}
this.split.style.left = '0px';
} else if(this.options.direction == 'vertical') {
var distance = newPos.y - this.oldPos.y;
var frontHeight = parseInt(this.frontDim[1]) + distance;
var rearHeight = parseInt(this.rearDim[1]) - distance;
if (frontHeight > this.options.frontminsize && rearHeight > this.options.rearminsize) {
this.front.style.height = frontHeight + 'px';
this.rear.style.height = rearHeight + 'px';
this.split.style.width = (this.front.offsetWidth >= this.rear.offsetWidth ? this.front.offsetWidth : this.rear.offsetWidth) + 'px';
}
this.split.style.top = '0px';
}
},
_mouseUp : function () {
this.oldPos = null;
this.frontDim = null;
this.rearDim = null;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.tree) window.daum.widget.tree = new Object();
daum.widget.tree.TreeNode = daum.create();
daum.widget.tree.TreeNode.prototype = {
textNode : null,
initialize: function (element, rootId, nodeText, nodeId, options, value) {
this.options = {
textCss : null,
listCss : null,
visible: true
}
Object.extend(this.options, options || {});
this.titleNode = document.createElement('div');
this.text = nodeText;
if(value){
this.titleNode.setAttribute('value', value);
this.value = value;
}else{
this.titleNode.setAttribute('value', '');
}
this.listNode = document.createElement('div');
this.titleNode.id = rootId + '_Text_' + nodeId;
this.listNode.id = rootId + '_List_' + nodeId;
this.textNode = document.createElement('span');
if ( this.options.iconUrl) {
this.iconNode = document.createElement('img');
this.iconNode.src = this.options.iconUrl;
this.iconNode.border = 0;
this.textNode.appendChild(this.iconNode);
}
this.textNode.appendChild(document.createTextNode(nodeText));
if (this.options.textCss) {
this.titleNode.className = this.options.textCss;
}
if (this.options.listCss) {
this.listNode.className = this.options.listCss;
}
this.openIconNode = document.createElement('img');
this.closeIconNode = document.createElement('img');
this.textNode.id = this.titleNode.id;
this.openIconNode.id = this.titleNode.id;
this.closeIconNode.id = this.titleNode.id;
if (this.options.openIconUrl) {
this.openIconNode.src = this.options.openIconUrl;
this.openIconNode.border = 0;
}
if (this.options.closeIconUrl) {
this.closeIconNode.src = this.options.closeIconUrl;
this.closeIconNode.border = 0;
}
if(!this.options.openIconUrl && !this.options.closeIconUrl ) {
this.textNode.style.marginLeft = '13px';
}
Element.hide(this.openIconNode);
Element.hide(this.closeIconNode);
if (this.options.visible == true) {
if (this.options.closeIconUrl) {
Element.show(this.closeIconNode);
if( this.options.iconUrl &&  typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['opened'];
}
Element.show(this.listNode);
} else { // 초기 로딩 시 하위 메뉴를 숨기는 경우
if (this.options.openIconUrl) {
Element.show(this.openIconNode);
if( this.options.iconUrl &&  typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['closed'];
}
Element.hide(this.listNode);
}
this.titleNode.appendChild(this.openIconNode);
this.titleNode.appendChild(this.closeIconNode);
this.titleNode.appendChild(this.textNode);
element.appendChild(this.titleNode);
element.appendChild(this.listNode);
if (this.options.mouseOverColor && this.options.mouseOverBackgroundColor) {
this.eventMouseOver = this._mouseOver.bindAsEventListener(this);
this.eventMouseOut = this._mouseOut.bindAsEventListener(this);
daum.dom.Event.observe(this.titleNode, "mouseover", this.eventMouseOver);
daum.dom.Event.observe(this.titleNode, "mouseout", this.eventMouseOut);
}
},
remove: function () {
daum.dom.Element.remove(this.titleNode);
daum.dom.Element.remove(this.listNode);
},
rename: function (name) {
this.textNode.lastChild.nodeValue = name;
return this;
},
toggle: function () {
if (this.options.openIconUrl && this.options.closeIconUrl) {
if (Element.visible(this.listNode)) { // 하위 메뉴가 펼쳐져 있는 경우
daum.dom.Element.hide(this.closeIconNode);
daum.dom.Element.show(this.openIconNode);
if( this.options.iconUrl && typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['closed'];
} else { // 하위 메뉴가 접혀 있는 경우
daum.dom.Element.hide(this.openIconNode);
daum.dom.Element.show(this.closeIconNode);
if( this.options.iconUrl && typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['opened'];
}
}
if (this.listNode.hasChildNodes() == true) {
Element.toggle(this.listNode);
}
return this;
},
_mouseOver: function (event) {
if (this.options.mouseOverColor && this.options.mouseOverBackgroundColor) {
this.titleNode.style.color = this.options.mouseOverColor;
this.titleNode.style.backgroundColor = this.options.mouseOverBackgroundColor;
}
},
_mouseOut: function (event) {
this.titleNode.style.color = '';
this.titleNode.style.backgroundColor = '';
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.TreeNode = daum.create();
daum.widget.TreeNode.prototype = {
initialize: function (element, rootId, nodeText, nodeId, options, value) {
this.options = {
textCss : null, // 텍스트 노드에 별도의 CSS 를 적용 할 경우
listCss : null, // 리스트 노드에 별도의 CSS 를 적용 할 경우
visible: '1' // '1' 이면 Tree 가 생성될 때 하위 노드가 보여진 상태가 됨
}
Object.extend(this.options, options || {});
this.titleNode = document.createElement('div');
if(value){
this.titleNode.setAttribute('value', value);
}else{
this.titleNode.setAttribute('value', '');
}
this.listNode = document.createElement('div');
this.titleNode.id = rootId + '_Text_' + nodeId; // 메뉴 텍스트를 표시하기 위한 노드의 ID, Tree._getTreeNodeById 에도 동일한 규칙이 정의되어 있으므로 수정시 주의
this.listNode.id = rootId + '_List_' + nodeId; // 하위 메뉴를 등록하기 위한 노드의 ID
this.textNode = document.createElement('span');
if ( this.options.iconUrl) {
this.iconNode = document.createElement('img');
this.iconNode.src = this.options.iconUrl;
this.iconNode.border = 0;
this.textNode.appendChild(this.iconNode);
}
this.textNode.appendChild(document.createTextNode(nodeText));
if (this.options.textCss) {
this.titleNode.className = this.options.textCss;
}
if (this.options.listCss) {
this.listNode.className = this.options.listCss;
}
this.openIconNode = document.createElement('img');
this.closeIconNode = document.createElement('img');
this.textNode.id = this.titleNode.id;
this.openIconNode.id = this.titleNode.id;
this.closeIconNode.id = this.titleNode.id;
if (this.options.openIconUrl) {
this.openIconNode.src = this.options.openIconUrl;
this.openIconNode.border = 0;
}
if (this.options.closeIconUrl) {
this.closeIconNode.src = this.options.closeIconUrl;
this.closeIconNode.border = 0;
}
if(!this.options.openIconUrl && !this.options.closeIconUrl ) {
this.textNode.style.marginLeft = '13px';
}
Element.hide(this.openIconNode);
Element.hide(this.closeIconNode);
if (this.options.visible == '1') { // 초기 로딩 시 하위 메뉴를 보여주는 경우
if (this.options.closeIconUrl) {
Element.show(this.closeIconNode);
if( this.options.iconUrl &&  typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['opened'];
}
Element.show(this.listNode);
} else { // 초기 로딩 시 하위 메뉴를 숨기는 경우
if (this.options.openIconUrl) {
Element.show(this.openIconNode);
if( this.options.iconUrl &&  typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['closed'];
}
Element.hide(this.listNode);
}
this.titleNode.appendChild(this.openIconNode);
this.titleNode.appendChild(this.closeIconNode);
this.titleNode.appendChild(this.textNode);
element.appendChild(this.titleNode);
element.appendChild(this.listNode);
if (this.options.mouseOverColor && this.options.mouseOverBackgroundColor) {
this.eventMouseOver = this._mouseOver.bindAsEventListener(this);
this.eventMouseOut = this._mouseOut.bindAsEventListener(this);
Event.observe(this.titleNode, "mouseover", this.eventMouseOver);
Event.observe(this.titleNode, "mouseout", this.eventMouseOut);
}
},
remove: function () {
Element.remove(this.titleNode);
Element.remove(this.listNode);
},
rename: function (name) {
this.textNode.lastChild.nodeValue = name;
},
toggle: function () {
if (this.options.openIconUrl && this.options.closeIconUrl) {
if (Element.visible(this.listNode)) { // 하위 메뉴가 펼쳐져 있는 경우
Element.hide(this.closeIconNode);
Element.show(this.openIconNode);
if( this.options.iconUrl && typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['closed'];
} else { // 하위 메뉴가 접혀 있는 경우
Element.hide(this.openIconNode);
Element.show(this.closeIconNode);
if( this.options.iconUrl && typeof this.options.iconUrl != 'string' )
this.iconNode.src = this.options.iconUrl['opened'];
}
}
if (this.listNode.hasChildNodes() == true) {
Element.toggle(this.listNode);
}
},
_mouseOver: function (event) {
if (this.options.mouseOverColor && this.options.mouseOverBackgroundColor) {
this.titleNode.style.color = this.options.mouseOverColor;
this.titleNode.style.backgroundColor = this.options.mouseOverBackgroundColor;
}
},
_mouseOut: function (event) {
this.titleNode.style.color = '';
this.titleNode.style.backgroundColor = '';
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.Tree = daum.create();
daum.widget.Tree.prototype = {
type: 'daum.widget.Tree',
treeNodes : null,
initialize: function (element, options) {
this.options = {
addTreeNodeEventHandler: null,
selectTreeNodeEventHandler: null,
openIconUrl: null,
closeIconUrl: null,
lineCss: null,
mouseOverColor: null,
mouseOverBackgroundColor: null
}
Object.extend(this.options, options || {});
this.root = $(element);
this.treeNodes = new Array();
this.eventMouseClick = this._mouseClick.bindAsEventListener(this);
Event.observe(this.root, 'click', this.eventMouseClick);
},
addTreeNode: function (parentTreeNode, nodeText, nodeId, options, value) {
var allOptions = {};
Object.extend(allOptions, this.options || {});
Object.extend(allOptions, options || {});
var parentListNode = (parentTreeNode == null) ? this.root : parentTreeNode.listNode;
var treeNode = new daum.widget.TreeNode(parentListNode, this.root.id, nodeText, nodeId, allOptions, value);
this.treeNodes.push(treeNode);
if (this.options.addTreeNodeEventHandler != null) {
this.options.addTreeNodeEventHandler(this);
}
return treeNode;
},
_removeTreeNode: function (targetTreeNode) {
if (targetTreeNode) {
this.treeNodes = this.treeNodes.reject(function (treeNode) {
return (treeNode.textNode.id == targetTreeNode.textNode.id);
});
targetTreeNode.remove();
}
},
removeTreeNodeByTextNodeId: function (id) {
this._removeTreeNode(this._getTreeNodeByTextNodeId(id));
},
removeTreeNodeById: function (id) {
this._removeTreeNode(this._getTreeNodeById(id));
},
_renameTreeNode: function (targetTreeNode, name) {
if (targetTreeNode) {
targetTreeNode.rename(name);
}
},
renameTreeNodeById: function (name, id) {
this._renameTreeNode(this._getTreeNodeById(id), name);
},
renameTreeNodeByTextNodeId: function (name, id) {
this._renameTreeNode(this._getTreeNodeByTextNodeId(id), name);
},
addLineNode: function () {
var line = document.createElement('div');
if (this.options.lineCss) {
line.className = this.options.lineCss;
} else {
line.style.backgroundColor = 'gray';
line.style.margin = '5px 0px 5px 0px';
line.style.height = '1px';
line.style.overflow = 'hidden';
}
this.root.appendChild(line);
},
_mouseClick: function (event) {
var treeNode = this._getTreeNodeByTextNodeId(Event.element(event).id);
if (treeNode) {
treeNode.toggle();
if (treeNode.listNode.hasChildNodes() == false && this.options.selectTreeNodeEventHandler != null) {
this.options.selectTreeNodeEventHandler(event);
}
}
},
_getTreeNodeById: function (id) {
return this._getTreeNodeByTextNodeId(this.root.id + '_Text_' + id);
},
getTreeNodeById: daum.widget.Tree.prototype._getTreeNodeById,
_getTreeNodeByTextNodeId: function (id) {
var treeNode = this.treeNodes.find(function (treeNode) {
return (treeNode.textNode.id == id);
});
return treeNode;
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.tab) window.daum.widget.tab = new Object();
daum.widget.tab.TabPane = daum.create();
daum.widget.tab.TabPane.prototype = {
type: 'daum.widget.tab.TabPane',
id: null,
container: null,
tabNode : null,
contentsNode : null,
imageNode : null,
textNode : null,
inputNode : null,
removeNode : null,
finalize: function(){
if(this.tabNode){
this.tabNode.jsObject = null;
}
for(var i in this){
var o = this[i];
if(o){
o = null;
}
}
},
initialize: function (id, options, container) {
this.options = {
html: '',
tabNodeClass : "b-tabselector-div",
tabNodeBodyLeft : "b-tabselector-left",
tabNodeBodyRight : "b-tabselector-right",
tabNodeBodyMid : "b-tabselector-mid",
tabNodeBody : "b-tabselector-text"
};
this.id = id;
Object.extend(this.options, options || {});
this.container = container;
this.tabNodeId = this.container.tabBox.id + '_' + id;
this.contentsNodeId = this.container.cp.id + '_' + id;
this._createTabNode();
this._createContentsNode();
this.tabNode.jsObject = this;
if(this.options.html){
if(typeof(this.options.html) == "string"){
this.contentsNode.innerHTML = this.options.html;
}else{
this.contentsNode.appendChild(this.options.html);
}
}
this.editMode = false;
},
getTitle: function(){
return this.options.name;
},
getId: function(){
return this.id;
},
contents: function(){
if(arguments.length == 1){
if(!arguments[0]) throw new Exception('arguments is null');
if(typeof arguments[0] == 'string'){
this.contentsNode.innerHTML = arguments[0];
}else{
this.contentsNode.appendChild(arguments[0])	;
}
}else{
return this.contentsNode;
}
},
_createTabNode: function () {
var tabNode = this.tabNode = document.createElement('div');
tabNode.id = this.tabNodeId;
tabNode.className = this.options['tabNodeClass'];
this.container.tabBox.appendChild(this.tabNode);
var tabNodeBodyId = this.tabNodeBodyId = this.tabNodeId+'_body';
var tpl = [];
tpl.push(' <DIV class="'+this.options['tabNodeBodyMid']+'">');
tpl.push('  <h2 class="'+this.options['tabNodeBodyLeft']+'">');
tpl.push('		<a class="'+this.options['tabNodeBodyRight']+'">');
tpl.push('			<span style="display:block;" class="'+this.options['tabNodeBody']+'" id="'+tabNodeBodyId+'">');
tpl.push('			</span>');
tpl.push('		</a>');
tpl.push('  </h2>');
tpl.push(' </DIV>');
tabNode.innerHTML = tpl.join('\n');
this.body = document.getElementById(tabNodeBodyId);
this._createImageNode(); // 아이콘용 노드
this._createTextNode(); // 탭이름용 노드
this._createInputNode(); // 탭이름 편집용 노드
this._createRemoveNode(); // 탭삭제용 노드
this.tabNode.style.width = (this.textNode.offsetWidth + 30) + 'px';
this.textNode.style.width = this.textNode.offsetWidth + 'px';
this.removeNode.style.left = (this.textNode.offsetWidth + 12) +'px';
if (daum.browser.Browser.isIE()) {
tabNode.style.styleFloat = 'left';
} else {
tabNode.style.cssFloat = 'left';
}
daum.dom.Event.observe(tabNode, "mouseover", this._onTabMouseOver.bindContext(this));
daum.dom.Event.observe(tabNode, "mouseout", this._onTabMouseOut.bindContext(this));
},
_createContentsNode: function () {
this.contentsNode = document.createElement('div');
this.contentsNode.id = this.contentsNodeId;
this.container.cp.appendChild(this.contentsNode);
daum.dom.Element.hide(this.contentsNode);
},
_createImageNode: function () {
if(this.options.iconUrl){
var imageNode = document.createElement('img');
imageNode.id = this.tabNodeBodyId+'_icon';
imageNode.src = this.options.iconUrl;
imageNode.border = '0';
this.imageNode = imageNode;
this.body.appendChild(imageNode);
}
},
_createTextNode: function () {
var textNode = this.textNode = document.createElement('span');
textNode.id = this.tabNodeBodyId+'_label';
if(!this.options.tabDimDownCss)
textNode.style.fontSize = '12px';
textNode.innerHTML = this.options['name'];
this.eventEditText = this._onEditText.bindContext(this);
this.body.appendChild(textNode);
},
_createInputNode: function () {
if(this.options.changeTitle){
var inputNode = this.inputNode = document.createElement('input');
inputNode.id = this.tabNodeBodyId+'_edit';
inputNode.type = 'text';
inputNode.style.height = "12px"; // TODO 외부로 빠져야 할 듯
inputNode.style.width = "60px";
inputNode.value = this.options['name'];
inputNode.style.display = 'none';
this.body.appendChild(inputNode);
}
},
_createRemoveNode: function () {
if(this.options.removeIconUrl){
var removeNode = document.createElement('img');
removeNode.id = this.tabNodeBodyId+'_remove';
removeNode.src = this.options.removeIconUrl;
removeNode.style.cursor = "pointer";
removeNode.border = '0';
this.removeNode = removeNode;
this.removeNode.style.visibility = 'hidden';
this.body.appendChild(removeNode);
}
},
_onEditText: function (event) {
daum.dom.Element.hide(this.textNode);
daum.dom.Element.hide(this.removeNode);
this.inputNode.style.display = '';
this.inputNode.focus();
this.inputNode.select();
this.eventSaveTextByClick = this._saveTextByClick.bindAsEventListener(this);
this.eventSaveTextByEnter = this._saveTextByEnter.bindAsEventListener(this);
Event.observe(document, "click", this.eventSaveTextByClick);
Event.observe(document, "keypress", this.eventSaveTextByEnter);
this.editMode = true;
},
_saveTextByClick: function (event) {
var node = Event.element(event);
var id = node.id.indexOf('_body') == -1 ? node.id : node.id.substring(0,node.id.indexOf('_body'));
if (node == null || id != this.tabNodeId) {
this._saveText();
}
},
_saveTextByEnter: function (event) {
var key = event.which || event.keyCode;
if (key == Event.KEY_RETURN) {
this._saveText();
}
},
_saveText: function () {
var textNode = this.textNode;
var inputNode = this.inputNode;
var removeNode = this.removeNode;
textNode.innerHTML = inputNode.value;
daum.dom.Element.show(textNode);
if(this.options.removable){
daum.dom.Element.show(removeNode);
}
this.tabNode.style.width = (this.textNode.offsetWidth + 30) + 'px';
daum.dom.Element.hide(inputNode);
if (this.options.saveTextEventHandler != null) {
this.options.saveTextEventHandler(this.tabNodeId, textNode.innerHTML);
}
Event.stopObserving(document, "click", this.eventSaveTextByClick);
Event.stopObserving(document, "keypress", this.eventSaveTextByEnter);
this.editMode = false;
},
_remove: function () {
if(this.options.changeTitle){
Event.stopObserving(this.textNode, 'click', this.eventEditText);
}
Event.stopObserving(this.tabNode, "mouseover", this._onTabMouseOver.bindContext(this));
Event.stopObserving(this.tabNode, "mouseout", this._onTabMouseOut.bindContext(this));
if(this.options.html){
if(typeof(this.options.html) != "string"){
Element.remove(this.options.html);
}
}
Element.remove(this.tabNode);
Element.remove(this.contentsNode);
this.finalize();
},
_onTabMouseOver: function(ev){
if(!daum.dom.Element.hasClass(this.tabNode, "b-tabselector-sel")){
daum.dom.Element.addClass(this.tabNode, "b-tabselector-hov");
}
if( this.options.removable && !this.editMode){
this.removeNode.style.visibility = 'visible';
}
},
_onTabMouseOut: function(ev){
if(!daum.dom.Element.hasClass(this.tabNode, "b-tabselector-sel")){
daum.dom.Element.removeClass(this.tabNode, "b-tabselector-hov");
if( this.options.removable && !this.editMode){
this.removeNode.style.visibility = 'hidden';
}
}
},
_onSelected: function () {
daum.dom.Element.removeClass(this.tabNode, "b-tabselector-hov");
daum.dom.Element.addClass(this.tabNode, "b-tabselector-sel");
daum.dom.Element.show(this.contentsNode);
if( this.options.removable && !this.editMode){
this.removeNode.style.visibility = 'visible';
}
if(this.options.changeTitle)
daum.dom.Event.observe(this.textNode, 'click', this.eventEditText);
if(this.options.onShow)
this.options.onShow();
},
_onDeselected: function () { // 탭이 선택되지 않은 효과
daum.dom.Element.removeClass(this.tabNode, "b-tabselector-sel");
daum.dom.Element.hide(this.contentsNode);
if( this.options.removable && !this.editMode){
this.removeNode.style.visibility = 'hidden';
}
if(this.options.changeTitle)
daum.dom.Event.stopObserving(this.textNode, 'click', this.eventEditText);
if(this.options.onHide)
this.options.onHide();
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.Modal = {
zIndex : 5000,
timer : null,
show: function (color) {
daum.debug("show is called");
this._createModalLayer();
if(color){
this.modalLayer.style.backgroundColor = color;
}
if (this.modalLayer) {
if (daum.browser.Browser.isIE()) {
$$('select').each(function(element) {element.style.visibility = "hidden"});
}
this.resizeEventHandler = this.onResize.bindAsEventListener(this);
Event.observe(window, "resize", this.resizeEventHandler);
Element.show(this.modalLayer);
}
},
hide: function () {
if (this.modalLayer && Element.visible(this.modalLayer) == true) {
if (daum.browser.Browser.isIE()) {
$$('select').each(function(element) {element.style.visibility = "visible"});
}
try {
if(this.resizeEventHandler)
Event.stopObserving(window, "resize", this.resizeEventHandler);
} catch (e) {}
this.timer = null;
Element.hide(this.modalLayer);
}
},
_createModalLayer: function () {
if (! this.modalLayer) {
this.modalLayer = document.createElement('div');
this.modalLayer.style.position = 'absolute';
this.modalLayer.style.top = '0px';
this.modalLayer.style.left = '0px';
this.modalLayer.style.width = "100%";
this.modalLayer.style.zIndex = this.zIndex;
this.modalLayer.style.backgroundColor = '#ffffff';
this.modalLayer.style.display = 'none';
Element.setOpacity(this.modalLayer, 0.5);
this.onResize();
document.body.appendChild(this.modalLayer);
}
},
onResize: function () {
var winSize = daum.dom.Element.getWindowSize(true);
this.modalLayer.style.display = 'block';
this.modalLayer.style.height = winSize.y + 'px';
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.Dialog = {
dialog: false,
timerId: false,
alert: function(message, options){
if(!this.dialog)
this._createDialog();
this._destroy();
daum.widget.Modal.show();
this.options = {
width: "300px",
height: "80px",
border: "1px solid black",
backgroundColor: "white",
fontSize: "small",
padding: "20px 10px 10px 10px",
color: "black",
fontFamily: "굴림,Verdana"
};
Object.extend(this.options, options || {});
this._setCss();
$('daum_widget_Dialog_message').innerHTML = message;
$('daum_widget_Dialog_OK_button').onclick = this._destroy.bind(this);
$('daum_widget_Dialog_Cancel_button').style.display = "none";
this._repositionWindow();
daum.dom.Event.observe(window,'resize', this._repositionWindow.bind(this));
daum.dom.Event.observe(window,'scroll', this._repositionWindow.bind(this));
},
confirm: function(message, options){
if(!this.dialog)
this._createDialog();
this._destroy();
this.options = {
width: "250px",
height: "80px",
border: "1px solid black",
backgroundColor: "white",
fontSize: "12px",
padding: "20px 10px 10px 10px",
color: "black",
fontFamily: "굴림,Verdana",
onConfirm: false,
onCancel: false
};
Object.extend(this.options, options || {});
if(this.options.modalBackgroundColor)
daum.widget.Modal.show(this.options.modalBackgroundColor);
else
daum.widget.Modal.show();
this._setCss();
$('daum_widget_Dialog_message').innerHTML = message;
$('daum_widget_Dialog_OK_button').onclick = this._confirm.bind(this);
$('daum_widget_Dialog_Cancel_button').onclick = this._cancel.bind(this);
this._repositionWindow();
daum.dom.Event.observe(window,'resize', this._repositionWindow.bind(this));
daum.dom.Event.observe(window,'scroll', this._repositionWindow.bind(this));
},
basic: function(element, message, options) {
if (!this.dialog) {
this._createDialog();
}
this._destroy();
daum.widget.Modal.show();
this.options = {
width: "250px",
height: "80px",
border: "1px solid black",
backgroundColor: "white",
fontSize: "12px",
padding: "20px 10px 10px 10px",
color: "black",
fontFamily: "굴림,Verdana",
onConfirm: false,
onCancel: false
}
Object.extend(this.options, options || {});
this._setCss();
$('daum_widget_Dialog_message').innerHTML = message;
$('daum_widget_Dialog_message').style.height = '10%';
element.id = 'daum_widget_Dialog_element';
element.style.height = '90%';
this.dialog.appendChild(element);
Element.hide('daum_widget_Dialog_OK_button');
Element.hide('daum_widget_Dialog_Cancel_button');
this._repositionWindow();
daum.dom.Event.observe(window,'resize', this._repositionWindow.bind(this));
daum.dom.Event.observe(window,'scroll', this._repositionWindow.bind(this));
},
_setCss: function(){
this.dialog.style.backgroundColor = this.options.backgroundColor;
this.dialog.style.fontSize = this.options.fontSize;
this.dialog.style.fontFamily = this.options.fontFamily;
this.dialog.style.padding = this.options.padding;
this.dialog.style.border = this.options.border;
this.dialog.style.color = this.options.color;
this.dialog.style.width = this.options.width;
this.dialog.style.height = this.options.height;
},
_createDialog: function(){
this.dialog = document.createElement('div');
this.dialog.style.position = "absolute";
this.dialog.style.zIndex = daum.widget.Modal.zIndex + 100;
this.dialog.style.display = "none";
this.dialog.innerHTML =
'<div id="daum_widget_Dialog_message" align="center" style="height:70%;width:100%"></div>'+
'<div align="center" style="height:30%;width:100%"><button id="daum_widget_Dialog_OK_button" style="font-size:12px">확인</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id="daum_widget_Dialog_Cancel_button" style="font-size:12px">취소</button></div>';
document.body.appendChild(this.dialog);
},
_repositionWindow: function(){
this.dialog.style.display = 'block';
daum.dom.Element.positionCenter(this.dialog);
},
_destroy: function(){
daum.widget.Modal.hide();
if(this.dialog)
this.dialog.style.display = 'none';
var element = $('daum_widget_Dialog_element');
if (element) {
Element.hide(element);
Element.remove(element);
$('daum_widget_Dialog_message').style.height = '70%';
Element.show('daum_widget_Dialog_OK_button');
Element.show('daum_widget_Dialog_Cancel_button');
}
if(this.timerId){
try{
window.clearInterval(this.timerId);
}catch(e){}
this.timerId = false;
}
},
_confirm: function(){
this._destroy();
(this.options.onConfirm || Prototype.emptyFunction).call(this);
},
_cancel: function(){
this._destroy();
(this.options.onCancel || Prototype.emptyFunction).call(this);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.panel) window.daum.widget.panel = new Object();
daum.widget.panel.Panel = daum.create();
daum.widget.panel.Panel.prototype = {
type : 'daum.widget.panel.Panel',
observers : {},
destroy: function(){
for(var i in this){
if(this[i]){
this[i] = null;
}
}
},
initialize: function (id, options) {
this.options = {
itemClass: 'item',
panelClass: 'panel',
borderClassA: 'panel-outer-border',
borderClassB: 'panel-inner-border',
bodyClass: 'panel-body',
onclick : null,
onmouseover : null,
onmouseout : null,
update: null
};
Object.extend(this.options, options || {});
this.border1Id = id+'_border1';
this.border2Id = id+'_border2';
this.border3Id = id+'_border3';
this.border4Id = id+'_border4';
this.bodyId = id+'_body';
this.domElement = document.getElementById(id);
this.domElement.className = this.options['panelClass'];
this.domElement.innerHTML = this._getTemplate();
this.border1 = document.getElementById(this.border1Id);
this.border2 = document.getElementById(this.border2Id);
this.border3 = document.getElementById(this.border3Id);
this.border4 = document.getElementById(this.border4Id);
this.body = document.getElementById(this.bodyId);
this.body.innerHTML = this._setBody();
var mouseover = this._onmouseover.before(this._onMouseoverStyle,this).after(this.options.onmouseover,this);
daum.dom.Event.observe(this.domElement, 'mouseover', mouseover);
var mouseout = this._onmouseout.before(this._onMouseoutStyle,this).after(this.options.onmouseout,this);
daum.dom.Event.observe(this.domElement, 'mouseout', mouseout);
var click = this._onclick.before(this._onChangeStyle,this).after(this.options.onclick,this);
daum.dom.Event.observe(this.domElement, 'click', click);
this.update = this.update.after(this.options.update,this);
this.unloadEvent = this.destroy.bindContext(this);
daum.dom.Event.observe(window, "unload", this.unloadEvent);
},
reset: function(){
this._onChangeStyle();
this._fireEvent();
},
addObserver: function(eventType, observer){
if(!this.observers[eventType])
this.observers[eventType] = [];
var cargo = this.observers[eventType];
cargo[cargo.length] = observer;
},
_fireEvent: function(){
var obs = this.observers;
if(obs){
for(var i = 0; i < obs.length; i++){
var event = new Object();
event.observable = this;
obs[i].update(event);
}
}
},
_setBody: function(){
var c = '';
return c;
},
_getTemplate: function(){
var tpl = [];
tpl.push('<DIV class="'+this.options['borderClassA']+'" id="'+this.border1Id+'">');
tpl.push('  <DIV class="'+this.options['borderClassB']+'" id="'+this.border2Id+'">');
tpl.push('		<DIV class="'+this.options['borderClassC']+'" id="'+this.border3Id+'">');
tpl.push('			<DIV class="'+this.options['borderClassD']+'" id="'+this.border4Id+'">');
tpl.push('				<DIV class="'+this.options['bodyClass']+'" id="'+this.bodyId+'">');
tpl.push('				</DIV>');
tpl.push('  		</DIV>');
tpl.push('  	</DIV>');
tpl.push('  </DIV>');
tpl.push('</DIV>');
return tpl.join('\n');
},
_onmouseover: function(e){
},
_onmouseout: function(e){
},
_onmousedown: function(e){
},
_onmouseup: function(e){
},
_onclick: function(e){
this._fireEvent();
},
_onChangeStyle: function(ev){
var ev = ev || window.event;
var element = daum.dom.Event.element(ev);
if(element.id.indexOf(this.domElement.id) != -1){
return;
}else if(element.id.indexOf('body') != -1){
element = element.parentNode;
}
var children = this.body.childNodes;
for(var i = 0; i < children.length; i++){
children[i].className = this.options['itemClass'];
}
if(element.className != this.options['itemClass'] + "-selected"){
element.className = this.options['itemClass'] + "-selected";
}else if(element.className != this.options['itemClass']){
element.className = this.options['itemClass'];
}
},
_onMouseoverStyle: function(ev){
var ev = ev || window.event;
var element = daum.dom.Event.element(ev);
if(element.id.indexOf(this.domElement.id) != -1){
return;
}else if(element.id.indexOf('body') != -1){
element = element.parentNode;
}
if(element.className != ( this.options['itemClass'] + "-selected")){
element.className = element.className + "-hovered";
}
},
_onMouseoutStyle: function(ev){
var ev = ev || window.event;
var element = daum.dom.Event.element(ev);
if(element.id.indexOf(this.domElement.id) != -1){
return;
}else if(element.id.indexOf('body') != -1){
element = element.parentNode;
}
if(element.className != ( this.options['itemClass'] + "-selected")){
element.className = this.options['itemClass'];
}
},
_onSelectedStyle: function () {
if(this.domElement.className != this.options['itemClass'] + "-selected")
this.domElement.className = this.options['itemClass'] + "-selected";
},
_onDeselectedStyle: function () {
if(this.domElement.className != this.options['itemClass']);
this.domElement.className = this.options['itemClass'];
},
show: function(position){
if(position){
this.domElement.style.position = 'absolute';
this.domElement.style.left = position.left+'px'
this.domElement.style.top = position.top+'px';
}
},
hide: function(){
this.domElement.style.position = 'absolute';
this.domElement.style.left = '-10000px'
this.domElement.style.top = '-100000px';
},
isVisible: function(){
if(this.domElement.style.left == '-10000px'){
return false;
}
return true;
},
toggle: function(position){
if(this.domElement.style.left == '-10000px'){
this.show(position);
}else{
this.hide();
}
},
update: function(ev){
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.button) window.daum.widget.button = new Object();
daum.widget.button.Button = daum.create();
daum.widget.button.Button.prototype = {
 TYPE : 'daum.widget.button.Button',
 state : null,
 observers : null,
destroy: function(){
for(var i in this){
if(this[i]){
this[i] = null;
}
}
},
initialize: function (id, options) {
this.options = {
name: ' Click ',
btnClass: 'sw-btn-div',
leftBorderClass: 'sw-btn-left',
rightBorderClass: 'sw-btn-right',
midBorderClass: 'sw-btn-mid',
bodyClass: 'sw-btn-text',
selectStateClass: 'sw-btn-sel',
hoverStateClass: 'sw-btn-hov',
onclick : function(e){},
onmousedown : function(e){},
onmouseup : function(e){},
onmouseover : function(){},
onmouseout : function(){}
};
Object.extend(this.options, options || {});
this.state = {
SELECTED : true
}
this.observers = {};
this.leftBorderId = id+'_left_border';
this.rightBorderId = id+'_right_border';
this.midBorderId = id+'_mid_border';
this.bodyId = id+'_body';
 this.domElement = document.getElementById(id);
this.domElement.className = this.options['btnClass'];
this.domElement.innerHTML = this._getTemplate();
 this.leftBorder = document.getElementById(this.leftBorderId);
 this.rightBorder = document.getElementById(this.rightBorderId);
 this.midBorder = document.getElementById(this.midBorderId);
 this.body = document.getElementById(this.bodyId);
this.body.innerHTML = this.setBody();
var onmouseover = this._onmouseover.before(this._onMouseoverStyle,this).after(this.options.onmouseover,this);
daum.dom.Event.observe(this.domElement,'mouseover',onmouseover);
var onmouseout = this._onmouseout.before(this._onMouseoutStyle,this).after(this.options.onmouseout,this);
daum.dom.Event.observe(this.domElement,'mouseout',onmouseout);
var onclick = this._onclick.before(this._onChangeState.after(this._onChangeStyle, this),this)
.after(this.options.onclick,this);
daum.dom.Event.observe(this.domElement,'click',onclick);
this.domElement.style.width = (this.body.firstChild.offsetWidth + 5) + 'px';
this.unloadEvent = this.destroy.bindContext(this);
daum.dom.Event.observe(window, "unload", this.unloadEvent);
},
setup: function(){
if(this.isSelected()){
daum.dom.Element.addClass(this.domElement, this.options.selectStateClass);
daum.dom.Element.removeClass(this.domElement, this.options.hoverStateClass);
}else{
daum.dom.Element.removeClass(this.domElement, this.options.selectStateClass);
daum.dom.Element.removeClass(this.domElement, this.options.hoverStateClass);
}
this._fireEvent();
},
click: function(){
this._onChangeStyle();
this._fireEvent();
},
show: function(){
this.domElement.style.display = '';
},
hide: function(){
this.domElement.style.display = 'none';
},
addObserver: function(eventType, observer){
if(!this.observers[eventType])
this.observers[eventType] = [];
var cargo = this.observers[eventType];
cargo[cargo.length] = observer;
},
isSelected: function(){
return this.state.SELECTED;
},
setBody: function(name){
var v = name? name : this.options.name;
return '<span>' + v + '</span>';
},
_fireEvent: function(){
var obs;
if(this.isSelected()){
obs = this.observers['SELECTED'];
}else {
obs = this.observers['DESELECTED'];
}
if(obs){
for(var i = 0; i < obs.length; i++){
var event = new Object();
event.observable = this;
obs[i].update(event);
}
}
},
_getTemplate: function(){
var tpl = [];
tpl.push('<DIV class="'+this.options['midBorderClass']+'" id="'+this.midBorderId+'">');
tpl.push('  <h2 class="'+this.options['leftBorderClass']+'" id="'+this.leftBorderId+'">');
tpl.push('		<a href="javascript:;" class="'+this.options['rightBorderClass']+'" id="'+this.rightBorderId+'">');
tpl.push('			<span class="'+this.options['bodyClass']+'" id="'+this.bodyId+'">');
tpl.push('			</span>');
tpl.push('  	</a>');
tpl.push('  </h2>');
tpl.push('</DIV>');
return tpl.join('\n');
},
_onmouseover: function(e){ },
_onmouseout: function(e){ },
_onmousedown: function(e){
var e = e || window.event;
this._fireEvent();
daum.dom.Event.stop(e);
},
_onmouseup: function(e){
var e = e || window.event;
this._fireEvent();
daum.dom.Event.stop(e);
},
_onclick: function(e){
var e = e || window.event;
this._fireEvent();
daum.dom.Event.stop(e);
},
_onChangeState: function(){
if(!this.isSelected()){
this.state.SELECTED = true;
}else{
this.state.SELECTED = false;
}
},
_onChangeStyle: function(){
if(!this.isSelected()){
this._onDeselectedStyle();
}else{
this._onSelectedStyle();
}
},
_onMouseoverStyle: function(ev){
if(!daum.dom.Element.hasClass(this.domElement, this.options.selectStateClass)){
daum.dom.Element.addClass(this.domElement, this.options.hoverStateClass);
}
},
_onMouseoutStyle: function(ev){
if(!daum.dom.Element.hasClass(this.domElement, this.options.selectStateClass)){
daum.dom.Element.removeClass(this.domElement, this.options.hoverStateClass);
}
},
_onSelectedStyle: function () {
if(!daum.dom.Element.hasClass(this.domElement, this.options.selectStateClass))
daum.dom.Element.removeClass(this.domElement, this.options.hoverStateClass);
daum.dom.Element.addClass(this.domElement, this.options.selectStateClass);
},
_onDeselectedStyle: function () { // 탭이 선택되지 않은 효과
daum.dom.Element.addClass(this.domElement, this.options.hoverStateClass);
daum.dom.Element.removeClass(this.domElement, this.options.selectStateClass);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.tab) window.daum.widget.tab = new Object();
daum.widget.tab.TabPaneContainer = daum.create();
daum.widget.tab.TabPaneContainer.prototype = {
TYPE : 'daum.widget.tab.TabPaneContainer',
tabContainer : null,
tabBox : null,
cp : null,
tabPanes : null,
dropDownBtn : null,
dropDownPanel : null,
addTabBtn : null,
initialize: function (element, options) {
this.options = {
addTabPaneEventHandler: false, // TabPane 을 추가 할 때 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
beforeRemoveTabPaneEventHandler: false, // TabPane 을 삭제 할 때 삭제 전 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
removeTabPaneEventHandler: null, // TabPane 을 삭제 할 때 삭제 후 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
saveTextEventHandler: null, // TabPane 의 이름을 바꿀 때 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
onSelect: null, //TapPane을 선책하면 불리는 함수..
tabContainerClass : 'b-tabcontainer',
tabBoxClass : 'tabNav',
tabPaneClass: 'contentsPanel', // contents pane 에 적용 할 CSS 를 지정
removeConfirm: false,
removable: false,//탭을 삭제할 수 있는지, 각 탭을 만들때, 따로 줄수도 있다.
changeTitle: false, // Title을 변경할 수 있는지
iconUrl: '/sparrow/images/tree/file.gif', // 탭의 아이콘 설정 가능
removeIconUrl : 'http://imgsrc.search.daum-img.net/search_all/show/btn_tab_close.gif', // TabPane 삭제에 사용 할 아이콘
removeConfirmMessage: '삭제하시겠습니까?', // TabPane 을 삭제 시 확인 메시지
removeFailureMessage: '삭제에 실패하였습니다.', // TabPane 삭제 실패 시 메시지
enableAddTabButton: false, // Ta/bPane 추가 버튼을 TITLE NODE 에 생성
enableDropDownMenu: false
};
Object.extend(this.options, options || {});
this.holder = document.getElementById(element);
this._createTabContainer();
this._createTabBox();
this._createControlTab();
this._createContentsPane();
this._createDropDownMenu();
this._createAddTab();
this.tabPanes = []; // 등록된 TabPane 들의 배열
this.eventMouseClick = this._mouseClick.bindContext(this);
daum.dom.Event.observe(this.tabBox, 'click', this.eventMouseClick); // 토글과 삭제 처리를 위한 이벤트 리스너 등록
},
_getHiddenTabs: function(){
var tabs = [];
for(var i = 0; i < this.tabPanes.length; i++){
var t = this.tabPanes[i];
if(t.tabNode.offsetTop > 0 ){ // If this has gap with TabBox, you have to change the value.
tabs.push(t);
}
}
return tabs;
},
_getLastTabOnBar: function(hiddenTabSize){
var total = this.tabPanes.length;
var tab = this.tabPanes[total - hiddenTabSize - 1];
if(tab){
return [tab, this.tabPanes[total - hiddenTabSize - 2]];
}else{
daum.debug(" In _getLastTabOnBar, tab isn't ");
}
},
_createTabContainer: function(){
this.tabContainer = document.createElement('div');
this.tabContainer.id = this.holder.id + '_tabcontainer_'+this.holder.childNodes.length;
this.tabContainer.className = this.options.tabContainerClass;
this.holder.appendChild(this.tabContainer);
},
_createTabBox: function(){
this.tabBox = document.createElement('div');
this.tabBox.id = this.tabContainer.id + '_tabbox';
if (this.options.tabBoxClass) {
this.tabBox.className = this.options.tabBoxClass;
}
this.tabContainer.appendChild(this.tabBox); // Title 과 Pane 이 세트로 관리되어짐
},
_createControlTab: function(){
this.controlTab = document.createElement('div');
this.controlTab.id = 'rightTabMenu';
if (daum.browser.Browser.isIE()) {
this.controlTab.style.styleFloat = 'right';
} else {
this.controlTab.style.cssFloat = 'right';
}
this.tabBox.appendChild(this.controlTab); // Title 과 Pane 이 세트로 관리되어짐
},
_createContentsPane: function(){
this.cp = document.createElement('div');
this.cp.id = this.tabContainer.id + '_contentsPane';
if(this.options.tabPaneClass){
this.cp.className = this.options.tabPaneClass;
}
this.tabContainer.appendChild(this.cp);
},
addTabPane: function (id, options) {
var allOptions = {};
Object.extend(allOptions, this.options || {});
Object.extend(allOptions, options || {});
var tab = new daum.widget.tab.TabPane(id, allOptions, this); // 새 TabPane 생성
this.tabPanes.push(tab); // TabPane 의 배열에 등록
this._select(tab.tabNode.id);
},
_createAddTab: function() {
if (this.options.enableAddTabButton) {
this.addTabBtn = document.createElement('div');
if (daum.browser.Browser.isIE()) {
this.addTabBtn.style.styleFloat = 'left';
} else {
this.addTabBtn.style.cssFloat = 'left';
}
this.addTabBtn.style.cursor = 'pointer';
this.addTabBtn.style.height = '19px';
this.addTabBtn.style.lineHeight = '19px';
this.addTabBtn.style.borderWidth = '0px';
this.addTabBtn.style.fontSize = '11px';
this.addTabBtn.style.color = 'gray';
this.addTabBtn.innerHTML = "New Tab";
document.body.appendChild(this.addTabBtn);
this.addTabBtn.onclick = function(ev){
this.addTabPane(this.tabPanes.length, {name : 'no name'});
if (this.options.addTabPaneEventHandler) {
this.options.addTabPaneEventHandler.bindContext(this)();
}
}.bindContext(this);
}
},
_createDropDownMenu: function(){
if(this.options.enableDropDownMenu){
this.tabBox.style.overflow = 'hidden';
var reposition =  function(o){
var loc = daum.dom.Element.cumulativeOffset(o.domElement);
var l = loc[0] - ( this.domElement.offsetWidth - o.domElement.offsetWidth) + 1;
var t = loc[1] + o.domElement.offsetHeight;
if(o.isSelected()){
this.show( {left: l, top: t} );
}else{
this.hide();
}
}
var  dropDownBtn = document.createElement('div');
dropDownBtn.id = this.tabBox.id + '_dropDownBtn';
this.controlTab.appendChild(dropDownBtn);
this.dropDownBtn = new daum.widget.button.Button(dropDownBtn.id , {	name: 'Ok!' });
if (daum.browser.Browser.isIE()) {
dropDownBtn.style.styleFloat = 'left';
} else {
dropDownBtn.style.cssFloat = 'left';
}
var dropDownPanel = document.createElement('div');
dropDownPanel.id = this.tabBox.id + '_dropDownPanel'
document.body.appendChild(dropDownPanel);
var pnlOption = {
onclick: function(ev){
var ev = ev || window.event;
var element = daum.dom.Event.element(ev);
if(element.id.indexOf('dropDownPanel') != -1){
return;
}
var el = this._select(element.id);
if(el){
this.tabBox.insertBefore(el.tabNode, this.tabBox.childNodes[2]);
updateDropDownMenu();
}
}.bindContext(this),
update: function(ev){
var o = ev.observable;
reposition.bindContext(this)(o);
}
}
var pnl = this.dropDownPanel = new daum.widget.panel.Panel(dropDownPanel.id, pnlOption);
pnl.hide();
this.dropDownBtn.addObserver('SELECTED', this.dropDownPanel);
this.dropDownBtn.addObserver('DESELECTED', this.dropDownPanel);
this.dropDownBtn.setup();
var updateDropDownMenu = function(){
var tabs = this._getHiddenTabs();
this.dropDownBtn.body.innerHTML ='<span>' + tabs.length + '</span>';
if(tabs.length == 0){
this.dropDownBtn.domElement.style.display = 'none';
this.dropDownPanel.domElement.style.display = 'none';
}else{
this.dropDownBtn.domElement.style.display = '';
this.dropDownPanel.domElement.style.display = '';
}
this.dropDownPanel.body.innerHTML='';
for(var i = 0; i < tabs.length; i++){
var b = document.createElement('div');
b.id = tabs[i].tabNodeId;
b.className = this.currentTabPaneId != tabs[i].tabNodeId ? 'item':'item-selected';
this.dropDownPanel.body.appendChild(b);
b.innerHTML = document.getElementById(tabs[i].tabNodeBodyId).innerHTML;
var c = b.childNodes;
for(var j = 0; j < c.length ; j++){
if(c[j].style && ( c[j].tagName == 'IMG' || c[j].tagName =='img') ){
c[j].removeAttribute('style');
}
}
}
var tab = this._getLastTabOnBar(tabs.length);
if(tab){
var lastTabOnBar = tab[0];
var old = tab[1];
if(!lastTabOnBar.tabNode.childNodes[0].className){
if(old)daum.dom.Element.removeClass(old.tabNode.childNodes[1], 'last-tab');
daum.dom.Element.addClass(lastTabOnBar.tabNode.childNodes[1], 'last-tab');
}else{
if(old)daum.dom.Element.removeClass(old.tabNode.childNodes[0], 'last-tab');
daum.dom.Element.addClass(lastTabOnBar.tabNode.childNodes[0], 'last-tab');
}
}
reposition.bindContext(this.dropDownPanel)(this.dropDownBtn);
}.bindContext(this);
window.onresize = updateDropDownMenu;
this._select = this._select.after(updateDropDownMenu, this);
this.addTabPane = this.addTabPane.after(updateDropDownMenu, this);
this.removeTabPane = this.removeTabPane.after(updateDropDownMenu, this);
}else{
this.tabBox.style.height = 'auto';
}
},
removeTabPaneByTitleId: function (id) {
this.removeTabPane(this.getTabPaneByTitleId(id));
},
removeTabPaneById: function (id) {
this.removeTabPane(this.getTabPaneById(id));
},
removeTabPane: function (targetTabPane) {
if (this.getTabPaneCount() == 1 || targetTabPane.editMode == true) { // 현재 탭의 개수가 1 이면 더이상 삭제 할 수 없음 || 탭명 변경 중에는 삭제 할 수 없다.
daum.widget.Dialog.alert(this.options.removeFailureMessage);
return ;
}
var tmp = targetTabPane;
var removeConfirm;
var removeConfirmMessage;
if(typeof tmp.options.removeConfirm == 'function'){
removeConfirm = tmp.options.removeConfirm();
}else if(typeof tmp.options.removeConfirm == 'boolean'){
removeConfirm = tmp.options.removeConfirm;
}
if(tmp.options.removeConfirmMessage != null) {
removeConfirmMessage = tmp.options.removeConfirmMessage;
} else {
removeConfirmMessage = this.options.removeConfirmMessage;
}
if(removeConfirm){
var answer = confirm(removeConfirmMessage)
if (answer){
this._removeProcess(tmp);
}
}else{
this._removeProcess(targetTabPane);
}
targetTabPane = null;
},
_removeProcess: function(targetTabPane){
if (this.options.beforeRemoveTabPaneEventHandler) {
this.options.beforeRemoveTabPaneEventHandler(targetTabPane); // 별도로 지정해준 EventHandler 실행
}
for(var i = 0; i < this.tabPanes.length ; i++){
if(this.tabPanes[i].tabNode.id == targetTabPane.tabNode.id){
this.tabPanes[i] = null;
this.tabPanes.splice(i,1);
break;
}
}
targetTabPane._onDeselected();
targetTabPane._remove(); // 실제 TabPane 을 제거
this._select(this.previousTabPaneId);
if (this.options.removeTabPaneEventHandler != null) {
this.options.removeTabPaneEventHandler(targetTabPane); // 별도로 지정해준 EventHandler 실행
}
},
_mouseClick: function (event) {
var id = daum.dom.Event.element(event).id;
if (id != null && id != "") {
this._select(id);
}
},
_isExist: function(id){
var ok = false;
for(var i = 0; i < this.tabPanes.length; i++){
if(this.tabPanes[i].tabNode.id == id){
ok = true;
break;
}
}
return ok;
},
_select: function(id){
if(id == this.tabBox.id){
return;
}
var lastFix = id.substr( id.lastIndexOf('_')+1);
id = id.indexOf('_body') == -1 ? id : id.substring(0,id.indexOf('_body'));
if(lastFix == 'remove'){
if(id != this.currentTabPaneId){
this.previousTabPaneId = this.currentTabPaneId;
}
this.removeTabPaneByTitleId(id);
return;
}
var currentTabPane = null;
if(id)
currentTabPane = this.getTabPaneByTitleId(id);
this.oldCurrentTabPaneId = this.currentTabPaneId;
if (currentTabPane == null) {
daum.debug("currentTabPane is null, id:"+id);
this.currentTabPaneId = this.tabPanes[0].tabNode.id;
this.previousTabPaneId = this.tabPanes[0].tabNode.id;
currentTabPane = this.getTabPaneByTitleId(this.currentTabPaneId);
if( this.oldCurrentTabPaneId == currentTabPane.tabNodeId) return; // don't execute current tabPane.
}else{
if( this.oldCurrentTabPaneId == currentTabPane.tabNodeId) return; // don't execute current tabPane.
if(this.currentTabPaneId){
this.previousTabPaneId = this.currentTabPaneId;
var previousTabPane = this.getTabPaneByTitleId(this.previousTabPaneId);
if(previousTabPane)
previousTabPane._onDeselected(); // 기존의 탭을 dim down 처리
}
this.currentTabPaneId = id; // 현재 선택된 탭의 ID 를 설정해
}
if(this.getTabPaneCount() == 1){
currentTabPane._onSelected(true);
}else{
currentTabPane._onSelected();
}
if(this.options.onSelect)
this.options.onSelect(currentTabPane, previousTabPane);
return 	currentTabPane;
},
select: function(id){
this._select(this.tabBox.id + '_' + id);
},
getTabPaneById: function (id) {
return this.getTabPaneByTitleId(this.tabBox.id + '_' + id);
},
getTabPaneByTitleId: function (id) {
var tabs = this.tabPanes;
for(var i = 0; i <tabs.length; i++){
var t = tabs[i];
if(t.tabNodeId == id){
return t;
}
}
},
getCurrentTabPane: function() {
return this.getTabPaneByTitleId(this.currentTabPaneId); // 현재 선택되어있는 TabPane 을 반환
},
getTabPaneCount: function () {
return this.tabPanes.length; // 현재 등록되어있는 TabPane 의 개수를 반환
},
selectFirst: function () {
this._select(this.tabPanes[0].tabNode.id);
},
tab: function(){
var p =  this;
if(arguments.length == 0){
return p.tabPanes;
}else if(arguments.length == 1 && typeof arguments[0] == 'number'){
return p.getTabPaneById(arguments[0]);
}else if(arguments.length == 1 && typeof arguments[0] == 'string'){
return p.getTabPaneById(arguments[0]);
}else {
var n = arguments[0];
var option;
if(arguments.length == 2){
option = arguments[1];
option.name = n[1];
option.value = n[2];
}else{
option = {
name : n[1],
value : n[2]
}
}
p.addTabPane(n[0], option);
return this;
}
},
show: function(){
this.tabContainer.style.display='';
},
hide: function(){
this.tabContainer.style.display='none';
},
finalize: function(){
if(!this.tabPanes) return;
for(var i=0; i<this.tabPanes.length; i++){
var tabPane = this.tabPanes[i];
tabPane.finalize();
}
this.tabPanes = null;
for(var i in this){
if(this[i]){
this[i] = null;
}
}
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.LayerPopup = daum.create();
daum.widget.LayerPopup.prototype = {
initialize: function(options){
this.options = {
width: "65px",
height: "65px",
border: "1px solid #4169E1",
backgroundColor: "#E6E6FA",
mouseOverBackgroundColor: "#4169E1",
mouseOverColor: "white",
margin: "4px",
fontSize: "11px",
color: "#191970",
fontFamily: "굴림,Verdana",
menu:["수정","삭제","미리보기"],
onmousedown:[function(){alert("수정");},function(){alert("삭제");},function(){alert("미리보기");}]
};
Object.extend(this.options, options || {});
this.border = document.createElement('div');
this.border.style.backgroundColor = "#C0C0C0";
this.border.style.padding = "1px";
this.border.style.position = "absolute";
this.layer = document.createElement('div');
this.layer.id = "__layer__";
this.layer.style.backgroundColor = this.options.backgroundColor;
this.layer.style.border = this.options.border;
this.layer.style.fontSize = this.options.fontSize;
this.layer.style.color = this.options.color;
this.layer.style.padding = '2px';
this.layer.style.fontFamily = this.options.fontFamily;
this.border.oncontextmenu = this.oncontextmenu.bind(this,this.border);
this.hide();
for(var i=0; i<this.options.menu.length; i++){
var menuDiv = document.createElement('div');
menuDiv.style.margin = this.options.margin;
menuDiv.id = "menu"+i;
menuDiv.style.width = this.options.width;
menuDiv.onmouseover = this.onmouseover.bind(this,menuDiv);
menuDiv.onmouseout = this.onmouseout.bind(this,menuDiv);
menuDiv.oncontextmenu = this.oncontextmenu.bind(this,menuDiv);
menuDiv.onmousedown = this.onmousedown.daumEventListener(this,this.options.onmousedown[i]);
menuDiv.innerHTML = this.options.menu[i];
this.layer.appendChild(menuDiv);
}
this.border.appendChild(this.layer);
document.body.appendChild(this.border);
this.eventElement = false;
},
onmousedown: function(event, callback){
callback(event);
Event.stop(event);
},
onmouseover: function(menuDiv){
menuDiv.style.backgroundColor = this.options.mouseOverBackgroundColor;
menuDiv.style.color = this.options.mouseOverColor;
},
onmouseout: function(menuDiv){
menuDiv.style.backgroundColor = this.options.backgroundColor;
menuDiv.style.color = this.options.color;
},
oncontextmenu: function(menuDiv){
return false;
},
position: function(x, y){
if(x && y){
this.x = x;
this.y = y;
}
if(this.x && this.y){
daum.dom.Element.setCurrentDelta(this.border,x,y);
}
},
show: function(event){
if(event){
this.eventElement = Event.element(event);
}
if(this.border){
this.border.style.display = 'block';
this.isShow = true;
}
},
hide: function(){
if(this.border){
this.border.style.display = 'none';
this.position(-300, -300);
this.isShow = false;
}
if(this.eventElement){
this.eventElement = false;
}
},
destroy: function(){
if(this.border){
Element.remove(this.border);
this.border = null;
this.isShow = false;
}
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
daum.util.NumberUtil = {
isNumber: function (num) {
return !isNaN(num);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
String.prototype.ltrim = function() { return this.replace(/^\s+|\s+$/, ''); };
function parseObjectCode(code){
var class_attr = "class='KwtMultimediaObject'";
tagName = code.ltrim().substr(1,6).toLowerCase();
div = document.createElement("div");
div.innerHTML = code;
obj = div.firstChild;
if(tagName == "object"){
classid = obj.getAttribute("classid");
if(classid == "" || classid == undefined || classid == null){
mime = obj.getAttribute("type");
width = obj.getAttribute("width");
height = obj.getAttribute("height");
codebase = obj.getAttribute("codebase");
data = obj.getAttribute("data");
}else if(classid != null && classidToMime(classid.toLowerCase()) == "UNSUPPORTED"){
return code;
}else{
mime = classidToMime(classid.toLowerCase());
width = obj.getAttribute("width");
if(width == null || width == ""){
width = "0px";
}
height = obj.getAttribute("height");
if(height == null || height == ""){
height = "0px";
}
codebase = obj.getAttribute("codebase");
var data;
params = obj.childNodes;
for(i = 0; i < params.length; i++){
if(params[i].name == 'movie'){
data = params[i].value;
}
}
}
return "<object "+class_attr+" type='"+mime+"' data='"+data+"' codebase='"+codebase+"' id='f4Mx3acRW7U$' name='f4Mx3acRW7U$' width='"+width+"' height='"+height+"' align='middle'><param name='movie' value='"+data+"' /><param name='swLiveConnect' value='true' /><param name='allowScriptAccess' value='always' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /></object>";
}else if(tagName == "embed "){
obj.setAttribute("class","KwtMultimediaObject");
return div.innerHTML;
}else{
return "ERROR";
}
}
function classidToMime(cid){
switch(cid){
case "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" :
return "application/x-shockwave-flash";
case "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" :
return "application/x-shockwave-flash";
case "classid:6BF52A52-394A-11D3-B153-00C04F79FAA6" :
return "application/x-mplayer2";
default :
return "UNSUPPORTED";
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.dnd) window.daum.dnd = new Object();
daum.dnd.DragHelper = {
dragHelper: null,
getDragHelper: function(element){
if(!this.dragHelper)
this._createDragHelper();
for(var i=0; i<this.dragHelper.childNodes.length; i++) {
this.dragHelper.removeChild(this.dragHelper.childNodes[i]);
}
if(element)
this.setElement(element);
return this;
},
getDiv: function(){
return this.dragHelper;
},
setElement: function(element){
this.element = element;
this.dragHelper.appendChild(this.element);
},
_createDragHelper: function(){
this.dragHelper = document.createElement('div');
this.dragHelper.id = "__dragHelper__";
this.dragHelper.style.position = "absolute";
this.dragHelper.style.display = "none";
this.dragHelper.style.margin = "0px";
document.body.appendChild(this.dragHelper);
},
show: function(){
this.dragHelper.style.display = 'block';
},
hide: function(){
this.dragHelper.style.display = 'none';
},
destroy: function(){
if(this.dragHelper){
this.dragHelper.style.display = 'none';
}
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
daum.util.ObjectUtil = {
showProps: function(obj){
var result="";
for (var propName in obj){
result = result + propName +", ";
}
return result;
},
isEmpty: function (obj){
if( obj == undefined || obj == null )
return true;
if( typeof(obj) == "string" && obj == "")
return true;
return false;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.net) window.daum.net = new Object();
daum.net.Ajax = daum.create();
daum.net.Ajax.prototype = {
initialize: function(){
this.xmlHttpReq = this.getXMLHttpRequest();
if(!this.xmlHttpReq)
this.onException("cannot load XMLHttpRequest");
},
getXMLHttpRequest: function(){
return Ajax.getTransport();
},
_setOptions: function(options){
this.options = {
method: "GET",
params: null,
async: true,
successFtn: null,
failureFtn: null,
exceptionFtn: null
};
Object.extend(this.options, options || {});
},
request: function(url, options){
var response = false;
this._setOptions(options);
try{
this.xmlHttpReq.open(this.options.method, url, this.options.async);
if(this.options.async){
this.xmlHttpReq.onreadystatechange = this._onReady.bind(this);
}
this.xmlHttpReq.send(this.options.params);
if(!this.options.async){
if(this.xmlHttpReq.status == 200 || this.xmlHttpReq.status == 304){
response = this.xmlHttpReq;
}
}else{
return false;
}
}catch(e){
daum.error(e);
this.onException();
}
return response;
},
_onReady: function(){
if (this.xmlHttpReq.readyState == 4) {
if(this.xmlHttpReq.status == 200 || this.xmlHttpReq.status == 304){
this.onSuccess();
}else{
this.onFailure();
}
}
},
onSuccess: function(){
this.options.successFtn(this.xmlHttpReq);
this.xmlHttpReq = null;
},
onFailure: function(){
daum.debug("onFailure is called");
if(this.options.async && this.options.failureFtn){
this.options.failureFtn(this.xmlHttpReq);
}
},
onException: function(msg){
daum.debug("onException is called");
if(this.options.async && this.options.exceptionFtn){
this.options.exceptionFtn(msg);
}
},
update: function(id, url, options){
options = (daum.util.ObjectUtil.isEmpty(options))?{}:options;
this.containerId = id;
options.successFtn = this._updateElement.bind(this);
this.request(url, options);
},
_updateElement: function(xmlHttpReq){
if(!daum.util.ObjectUtil.isEmpty(this.containerId)){
var response = xmlHttpReq.responseText;
if(response){
var ele = $(this.containerId);
if(ele)
ele.innerHTML = response;
}
}
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.net) window.daum.net = new Object();
daum.net.RssChannel = daum.create();
daum.net.RssChannel.prototype = {
initialize: function(title, link, description){
this.title = title;
this.link = link;
this.description = description;
this.items = [];
},
addItem: function(item){
this.items.push(item);
},
dispose: function(){
this.items = null;
this.title = null;
this.link = null;
this.description = null;
}
}
daum.net.RssItem = daum.create();
daum.net.RssItem.prototype = {
initialize: function(channel, title, link, description, category, pubdate, comments){
this.channel = channel;
this.title = title;
this.link = link;
this.description = description;
this.category = category;
this.pubdate = pubdate;
this.comments = comments;
}
}
daum.net.RssReader = daum.create();
daum.net.RssReader.prototype = {
initialize: function(url, options){
var ajax = new daum.net.Ajax();
this.url = url;
this.options = {
params: false,
onSuccess: false,
onFailure: false,
onException: false
};
Object.extend(this.options, options || {});
ajax.request(url,
{
successFtn: this.onSuccess.bind(this),
failureFtn: this.onFailure.bind(this),
exceptionFtn: this.onException.bind(this)
});
},
onSuccess: function(xmlHttpRequest){
var xmlDoc = xmlHttpRequest.responseXML;
if(xmlDoc){
var daumDomElement = daum.dom.Element;
try{
var chTitle = daumDomElement.getFirstValue(xmlDoc, "title");
var chLink = daumDomElement.getFirstValue(xmlDoc, "link");
var chDesc = daumDomElement.getFirstValue(xmlDoc, "description");
if(!chTitle){
throw "Not RSS format";
}
daum.debug("chTitle: "+chTitle);
daum.debug("chLink: "+chLink);
daum.debug("chDesc: "+chDesc);
var channel = new daum.net.RssChannel(chTitle, chLink, chDesc);
var rssItems = xmlDoc.getElementsByTagName("item");
for(var i=0; i<rssItems.length; i++){
var itemTitle = daumDomElement.getFirstValue(rssItems[i], "title");
var itemLink = daumDomElement.getFirstValue(rssItems[i], "link");
var itemDesc = daumDomElement.getFirstValue(rssItems[i], "description");
var itemCate = daumDomElement.getFirstValue(rssItems[i], "category");
var itemPdate = daumDomElement.getFirstValue(rssItems[i], "pubdate");
var comments = daumDomElement.getFirstValue(rssItems[i], "comments");
daum.debug("itemTitle: "+itemTitle);
daum.debug("itemLink: "+itemLink);
daum.debug("itemDesc: "+itemDesc);
daum.debug("itemCate: "+itemCate);
daum.debug("itemPdate: "+itemPdate);
channel.addItem(new daum.net.RssItem(channel, itemTitle, itemLink, itemDesc, itemCate, itemPdate, comments));
}
}catch(e){
daum.error("Error occured in onSuccess of RssReader, reason:"+e);
if(this.options.onSuccess){
this.options.onSuccess(false);
return;
}
}
(this.options.onSuccess || Prototype.emptyFunction).call(this, channel);
}else{
(this.options.onSuccess || Prototype.emptyFunction).call(this, false);
}
},
onFailure: function(xmlHttpRequest){
daum.debug("FAILURE");
(this.options.onFailure || Prototype.emptyFunction).call(this);
},
onException: function(){
daum.error("EXCEPTION");
(this.options.onException || Prototype.emptyFunction).call(this);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.browser) window.daum.browser = new Object();
daum.browser.Cookie = {
write: function(name, value, days){
if(days){
(time = new Date()).setTime(new Date().getTime()+days*24*60*60*1000);
var exp = '; expires='+time.toGMTString();
}else{
var exp='';
}
document.cookie=name+"="+value+exp+"; path=/";
},
read: function (name){
var cookies = document.cookie.split(';');
for(var i=0; i<cookies.length; i++){
var cookie=cookies[i].replace(/^\s+/, '');
if (cookie.indexOf(name+'=')==0) return cookie.substring(name.length+1);
}
return null;
},
erase: function (name){
write(name, "", -1);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.WindowPane = daum.create();
daum.widget.WindowPane.prototype = {
initialize: function(id, options){
this.paneDiv = $(id);
this.options = options || {};
this._resize();
this.timerId = window.setInterval(this._resize.bind(this), 500);
},
_resize: function(){
var winSize = daum.dom.Element.getWindowSize();
var height = null;
if(this.options.margin){
this.paneDiv.style.margin = this.options.margin;
var elePos = daum.dom.Element.getElementPosition(this.paneDiv);
var height = (winSize.y - elePos.y - parseInt(this.options.margin));
}else{
var elePos = daum.dom.Element.getElementPosition(this.paneDiv);
var height = (winSize.y - elePos.y);
}
if(this.options.heightOffset){
height = height - this.options.heightOffset;
}
this.paneDiv.style.height = height + 'px';
},
close: function(){
try {
window.clearInterval(this.timerId);
} catch (e) {}
this.timerId = null;
this.paneDiv = null;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.Split = daum.create();
daum.widget.Split.prototype = {
initialize : function (front, rear, options) {
this.options = {
direction : 'horizontal', // horizontal or vertical
color : 'gray',
size : '2px',
frontminsize : '0', // IE 에 min-width 와 min-height 버그가 있어 CSS 속성에서 파라미터로 변경
rearminsize : '0', // front 엘리먼트와 rear 엘리먼트의 최소 사이즈 지정
mousedown : false, // 이벤트 핸들러
mousemove : false, // mousedown 핸들러에서 클릭 당시 하위 엘리먼트들의 Dimension 을 기억하고
mouseup : false // mousemove 에서 이동한 거리 (distance) 를 파라미터로 전달받아 하위 엘리먼트에 적절한 핸들링 수행
};
Object.extend(this.options, options || {});
this.front = $(front);
this.rear = $(rear);
if (this.front.parentNode == this.rear.parentNode) {
this.parent = this.front.parentNode;
this._createSplit();
}
},
_createSplit : function () {
this.split = document.createElement('div');
this.split.id = this.front.id + '_' + this.rear.id + '_split'; // center_right_split 과 같은 형태로 ID 자동부여
this.split.style.backgroundColor = this.options.color;
if (this.options.direction == 'horizontal') {
if (daum.browser.Browser.isIE()) {
this.split.style.styleFloat = 'left';
} else {
this.split.style.cssFloat = 'left';
}
this.split.style.cursor = 'e-resize';
this.split.style.width = this.options.size;
this.split.style.height = (this.front.offsetHeight >= this.rear.offsetHeight ? this.front.offsetHeight : this.rear.offsetHeight) + 'px';
} else {
this.split.style.cursor = 'n-resize';
this.split.style.width = (this.front.offsetWidth >= this.rear.offsetWidth ? this.front.offsetWidth : this.rear.offsetWidth) + 'px';
this.split.style.height = this.options.size;
}
this.parent.insertBefore(this.split, this.rear);
this.eventMouseDown = this._mouseDown.bind(this);
this.eventMouseMove = this._mouseMove.bind(this);
this.eventMouseUp = this._mouseUp.bind(this);
new daum.dnd.DragObj(this.split, {
direction : this.options.direction,
onMouseDown : this.eventMouseDown,
onMouseMove : this.eventMouseMove,
onFinish : this.eventMouseUp
});
},
_mouseDown : function () {
this.oldPos = daum.dom.Element.getElementPosition(this.split);
this.frontDim = Element.getDimensions(this.front);
this.rearDim = Element.getDimensions(this.rear);
(this.options.mousedown || Prototype.K)();
},
_mouseMove : function (dragObj, event) {
var newPos = daum.dom.Element.getElementPosition(this.split);
if (this.options.direction == 'horizontal') {
var distance = newPos.x - this.oldPos.x;
var frontWidth = this.frontDim.width + distance;
var rearWidth = this.rearDim.width - distance;
if (frontWidth > this.options.frontminsize && rearWidth > this.options.rearminsize) { // 최소 사이즈 보장
this.front.style.width = frontWidth + 'px';
this.rear.style.width = rearWidth + 'px';
this.split.style.height = (this.front.offsetHeight >= this.rear.offsetHeight ? this.front.offsetHeight : this.rear.offsetHeight) + 'px';
if (this.options.mousemove) {
this.options.mousemove(distance);
}
}
this.split.style.left = '0px';
} else {
var distance = newPos.y - this.oldPos.y;
var frontHeight = this.frontDim.height + distance;
var rearHeight = this.rearDim.height - distance;
if (frontHeight > this.options.frontminsize && rearHeight > this.options.rearminsize) {
this.front.style.height = frontHeight + 'px';
this.rear.style.height = rearHeight + 'px';
this.split.style.width = (this.front.offsetWidth >= this.rear.offsetWidth ? this.front.offsetWidth : this.rear.offsetWidth) + 'px';
if (this.options.mousemove) {
this.options.mousemove(distance);
}
}
this.split.style.top = '0px';
}
},
_mouseUp : function () {
this.oldPos = null;
this.frontDim = null;
this.rearDim = null;
(this.options.mouseup || Prototype.K)();
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.template) window.daum.template = new Object();
daum.template.STML = {
cache: {},
getTemplate: function(templatePath, isAsync, callback){
if(isAsync && callback){
new daum.template.STML.AsyncCall(templatePath, callback);
}else{
return daum.getTemplate(templatePath);
}
},
process: function(templatePath, params){
try{
var template = this.getTemplate(templatePath);
var templateObj = TrimPath.parseTemplate(template);
return templateObj.process(params);
}catch(e){
daum.error("[daum.template.STML.process] Error occured, reason:"+e);
}
return null;
},
processAsync: function(templatePath, params, callback){
try{
if(this.cache[templatePath]){
var templateObj = TrimPath.parseTemplate(this.cache[templatePath]);
var html = templateObj.process(params);
callback(html);
}else{
this.getTemplate(templatePath, true, function(jst){
if(jst){
var templateObj = TrimPath.parseTemplate(jst);
var html = templateObj.process(params);
callback(html);
}else{
callback(false);
}
});
}
}catch(e){
daum.error("[daum.template.STML.process] Error occured, reason:"+e);
}
}
}
daum.template.STML.AsyncCall = daum.create();
daum.template.STML.AsyncCall.prototype = {
initialize: function(templatePath,callback){
this.templatePath = templatePath;
this.url = daum.properties.TEMPLATE_URL+templatePath+"?dummy="+daum.getDummyParam();
this.callback = callback;
this.ajax = new daum.net.Ajax();
this.ajax.request(this.url, {
successFtn: this.onSuccess.bind(this),
failureFtn: this.onFailure.bind(this),
exceptionFtn: this.onException.bind(this)
});
},
onSuccess: function(xmlHttpRequest){
var result = xmlHttpRequest.responseText;
daum.template.STML.cache[this.templatePath] = result;
this.callback(result);
},
onFailure: function(xmlHttpRequest){
this.callback(false);
},
onException: function(){
this.callback(false);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.TabPane = daum.create();
daum.widget.TabPane.prototype = {
initialize: function (titleNode, paneNode, id, options, defaultAddTabPaneButton) {
this.options = {
name: 'NONAME', // 탭이 생성 될 때 기본적인 이름
iconUrl: null // 탭의 아이콘 설정 가능
};
this.id = id;
Object.extend(this.options, options || {});
this.titleNode = $(titleNode);
this.paneNode = $(paneNode);
this.childTitleNodeId = this.titleNode.id + '_' + id;
this.childPaneNodeId = this.paneNode.id + '_' + id;
this.childTitleNode = this.createChildTitleNode(); // 탭 Title 노드 생성
this.childPaneNode = this.createChildPaneNode(); // 탭 Pane 노드 생성 - 실제로 컨텐츠가 삽입 될 영역
if (defaultAddTabPaneButton) {
this.titleNode.insertBefore(this.childTitleNode, defaultAddTabPaneButton); // 새로 생성된 탭이 탭 생성 버튼보다 앞쪽에 위치해야 하므로
} else {
this.titleNode.appendChild(this.childTitleNode);
}
if(this.options.round){
Nifty("div#"+this.childTitleNode.id, "small tl tr");
this._setWidth();
}
if(this.options.html){
if(typeof(this.options.html) == "string"){
this.childPaneNode.innerHTML = this.options.html;
}else{
this.childPaneNode.appendChild(this.options.html);
}
}
this.paneNode.appendChild(this.childPaneNode);
this.editMode = false; // 탭명변경 진행여부를 나타내는 플래그
},
getTitle: function(){
return this.options.name;
},
getId: function(){
return this.id;
},
createChildTitleNode: function () {
var childTitleNode = document.createElement('div');
childTitleNode.id = this.childTitleNodeId; // element_Title_0 과 같은 형태로 생성됨
childTitleNode.style.textAlign = "center";
if(this.options.tabDimDownCss){
childTitleNode.className = this.options.tabDimDownCss;
}else{
childTitleNode.style.backgroundColor = this.options.dimDownColor; // TODO 외부로 빠져야 할 듯
childTitleNode.style.cursor = 'pointer';
childTitleNode.style.height = '19px';
childTitleNode.style.borderTop = '1px solid #D3D3D3';
childTitleNode.style.borderRight = '1px solid #D3D3D3';
childTitleNode.style.borderLeft = '1px solid #D3D3D3';
childTitleNode.style.borderBottom = '0px';
}
childTitleNode.appendChild(this.createImageNode()); // 아이콘용 노드
childTitleNode.appendChild(this.createTextNode()); // 탭이름용 노드
if(this.options.changeTitle)
childTitleNode.appendChild(this.createInputNode()); // 탭이름 편집용 노드
childTitleNode.appendChild(this.createRemoveNode()); // 탭삭제용 노드
if (daum.browser.Browser.isIE()) {
childTitleNode.style.styleFloat = 'left';
} else {
childTitleNode.style.cssFloat = 'left';
}
return childTitleNode;
},
createRoundNode: function(){
var roundNode = document.createElement('div');
return roundNode;
},
createChildPaneNode: function () {
var childPaneNode = document.createElement('div');
childPaneNode.id = this.childPaneNodeId; // element_Pane_0 와 같은 형태로 생성됨
if(this.options.tabPaneCss){
childPaneNode.className = this.options.tabPaneCss;
}
Element.hide(childPaneNode);
return childPaneNode;
},
createImageNode: function () {
var imageNode = document.createElement('img');
imageNode.id = this.childTitleNodeId; // onClick Event 에서 동일한 처리가 가능하도록 id 를 element_Title_0 형태로 Title 노드와 동일하게 지정
if(this.options.iconUrl){
imageNode.src = this.options.iconUrl;
}else{
imageNode.style.display = 'none';
}
imageNode.border = '0';
this.imageNode = imageNode;
return imageNode;
},
createTextNode: function () {
var textNode = document.createElement('span');
textNode.id = this.childTitleNodeId; // onClick Event 에서 동일한 처리가 가능하도록 id 를 element_Title_0 형태로 Title 노드와 동일하게 지정
if(!this.options.tabDimDownCss)
textNode.style.fontSize = '12px';
textNode.innerHTML = this.options.name;
this.eventEditText = this.editText.bindAsEventListener(this); // 텍스트를 클릭 시 텍스트 편집이 가능하도록 이벤트 등록
this.textNode = textNode;
return textNode;
},
createInputNode: function () {
var inputNode = document.createElement('input'); // 탭명을 클릭 시 탭명 수정이 즉시 가능하도록 INPUT TEXT 노드를 숨겨둠
inputNode.id = this.childTitleNodeId;
inputNode.type = 'text';
inputNode.style.height = "12px"; // TODO 외부로 빠져야 할 듯
inputNode.style.width = "60px";
inputNode.value = this.options.name;
inputNode.style.display = 'none';
this.inputNode = inputNode;
return inputNode;
},
createRemoveNode: function () {
if(this.options.removeIconUrl){
var removeNode = document.createElement('img');
removeNode.id = 'Remove_' + this.childTitleNodeId; // 탭 삭제 클릭을 TabPaneContainer 에서 구분 할 수 있도록 'Remove_element_Title_0' 와 같이 ID 지정
removeNode.src = this.options.removeIconUrl;
removeNode.style.cursor = "pointer";
removeNode.border = '0';
}else{
var removeNode = document.createElement('span');
removeNode.id = 'Remove_' + this.childTitleNodeId;
removeNode.style.padding = "0px 2px 0px 5px";
removeNode.style.color = "#FFA500";
removeNode.style.fontWeight = "bold";
removeNode.style.fontFamily = "Arial";
removeNode.innerHTML = "x";
}
Element.hide(removeNode);
this.removeNode = removeNode;
return removeNode;
},
editText: function (event) {
var textNode = this.getTextNode();
var inputNode = this.getInputNode();
var removeNode = this.getRemoveNode();
Element.hide(textNode);
inputNode.style.display = ''; // 탭명 변경을 위해 TEXT NODE 를 숨기고 INPUT NODE 를 노출한 다음
Element.hide(removeNode);
inputNode.focus();
inputNode.select();
this.eventSaveTextByClick = this.saveTextByClick.bindAsEventListener(this);
this.eventSaveTextByEnter = this.saveTextByEnter.bindAsEventListener(this);
Event.observe(document, "click", this.eventSaveTextByClick); // 해당 탭 이외의 장소에서 클릭 이벤트가 발생하면 저장이 이루어지도록 이벤트 리스너 등록
Event.observe(document, "keypress", this.eventSaveTextByEnter);
this.editMode = true;
},
saveTextByClick: function (event) {
var node = Event.element(event);
if (node == null || node.id != this.childTitleNodeId) {
this.saveText();
}
},
saveTextByEnter: function (event) {
var key = event.which || event.keyCode;
if (key == Event.KEY_RETURN) {
this.saveText();
}
},
saveText: function () {
var textNode = this.getTextNode();
var inputNode = this.getInputNode();
var removeNode = this.getRemoveNode();
textNode.innerHTML = inputNode.value; // 변경된 탭명을 TEXT NODE 에 세팅해 줌
Element.show(textNode);
Element.hide(inputNode);
if (this.options.saveTextEventHandler != null) {
this.options.saveTextEventHandler(this.childTitleNodeId, textNode.innerHTML); // 별도로 지정해준 EventHandler 실행
}
Event.stopObserving(document, "click", this.eventSaveTextByClick); // editText 에서 클릭 이벤트 리스너 등록해 준 것을 해제
Event.stopObserving(document, "keypress", this.eventSaveTextByEnter);
this.editMode = false;
},
remove: function () {
if(this.options.changeTitle)
Event.stopObserving(this.getTextNode(), 'click', this.eventEditText);
Element.remove(this.childTitleNode);
Element.remove(this.childPaneNode);
},
_setWidth: function() {
var dim = daum.dom.Element.getDimension(this.getTextNode());
this.childTitleNode.style.width = (dim.x+35) + "px";
},
_setRoundBackgroundColor: function(color){
var rs1 = document.getElementsByClassName("rs1", this.childTitleNode)[0];
var rs2 = document.getElementsByClassName("rs2", this.childTitleNode)[0];
rs1.style.backgroundColor = color;
rs2.style.backgroundColor = color;
},
dimUp: function (hideRemoveNode) { // 탭이 선택되어진 효과
if(this.options.tabDimUpCss){
this.childTitleNode.className = this.options.tabDimUpCss;
}else{
this.childTitleNode.style.backgroundColor = this.options.dimUpColor;
this.childTitleNode.style.borderTop = '1px outset #D3D3D3';
this.childTitleNode.style.borderRight = '1px outset #D3D3D3';
this.childTitleNode.style.borderLeft = '1px outset #D3D3D3';
this.childTitleNode.style.borderBottom = '0px';
this.getTextNode().style.color = "#2F4F4F";
this.getTextNode().style.fontWeight = "bold";
}
if(this.options.round)
this._setRoundBackgroundColor(Element.getStyle(this.childTitleNode, "background-color"));
Element.show(this.childPaneNode);
if(!hideRemoveNode && this.options.removable){
Element.show(this.getRemoveNode());
if(this.options.round)
this._setWidth();
}
if(this.options.changeTitle)
Event.observe(this.getTextNode(), 'click', this.eventEditText);
if(this.options.onShow)
this.options.onShow();
},
dimDown: function () { // 탭이 선택되지 않은 효과
if(this.options.tabDimDownCss){
this.childTitleNode.className = this.options.tabDimDownCss;
}else{
this.childTitleNode.style.backgroundColor = this.options.dimDownColor;
this.childTitleNode.style.borderTop = '1px solid #D3D3D3';
this.childTitleNode.style.borderRight = '1px solid #D3D3D3';
this.childTitleNode.style.borderLeft = '1px solid #D3D3D3';
this.childTitleNode.style.borderBottom = '0px';
this.getTextNode().style.color = "#C0C0C0";
this.getTextNode().style.fontWeight = "normal";
}
if(this.options.round)
this._setRoundBackgroundColor(Element.getStyle(this.childTitleNode, "background-color"));
Element.hide(this.childPaneNode);
Element.hide(this.getRemoveNode());
if(this.options.changeTitle)
Event.stopObserving(this.getTextNode(), 'click', this.eventEditText);
if(this.options.onHide)
this.options.onHide();
},
getImageNode: function () {
return this.imageNode;
},
getTextNode: function () {
return this.textNode;
},
getInputNode: function () {
return this.inputNode;
},
getRemoveNode: function () {
return this.removeNode;
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
(function(){
if(!daum){
var daum = new Object();
daum.widget = new Object();
daum.extend = function(destination, source) {
if(destination == undefined || source == undefined )
return null;
for (var property in source) {
if(!destination[property])
destination[property] = source[property];
}
return destination;
};
}else{
}
})();
daum.widget.MovingList = function(parentNode, options){
this.parentNode = parentNode
this.options = {
direction: "down"
};
daum.extend(this.options, options || {});
}
daum.widget.MovingList.prototype.move = function(id){
if(typeof(id) == "string"){
var movingElement = document.getElementById(id);
}else{
var movingElement = id;
}
if(!movingElement)
return;
var divList = [];
var nodeNum = 0;
var index = false;
for(var i=0; i<this.parentNode.childNodes.length; i++){
var child = this.parentNode.childNodes[i];
if(child.nodeName == '#text')//Firefox의 dom파싱때문에..
continue;
else
nodeNum++;
if(child == movingElement){
index = nodeNum;
}
divList.push(child);
}
daum.debug("movingElement's index: "+index);
if(index){
if(index < divList.length){
movingElement.parentNode.insertBefore(divList[index], movingElement);
}else{
movingElement.parentNode.insertBefore(movingElement, divList[0]);
}
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.dnd) window.daum.dnd = new Object();
daum.dnd.shadow = {
shadow: false,
getInstance: function(){
if(!this.shadow){
this.shadow = document.createElement('div');
this.shadow.style.display = "none";
document.body.appendChild(this.shadow);
}
return this;
},
getDiv: function(){
return this.shadow;
},
show: function(){
this.shadow.style.display = "block";
},
destroy:function(){
if(this.shadow){
this.shadow.style.display = 'none';
this.shadow.className = '';
document.body.appendChild(this.shadow);
}
}
}
daum.dnd.DragContainer = Class.create();
daum.dnd.DragContainer.prototype = {
initialize: function(){
if(arguments.length < 1)
throw "Usage: new daum.dnd.DragContainer(container_id1,container_id2..,options)";
this.index = 1;
this.isDragging = false;
this.dragContainers = new Array();
this.options = {
handle: null,
shadowClass: null,
onChange: null
};
var index = arguments.length-1;
if(arguments[index] && (arguments[index].shadowClass || arguments[index].onChange || arguments[index].handle)  ){
var options = arguments[index];
Object.extend(this.options, options || {});
this._registerContainers(arguments.slice(0,index));
}else{
this._registerContainers(arguments);
}
},
_registerContainers: function(container){
for(var i= 0; i< container.length; i++){
this.dragContainers.push(container[i]);
this._registerDragElements(container[i]);
}
},
_registerDragElements: function(obj){
for(var j= 0; j< obj.childNodes.length; j++){
var ele = obj.childNodes[j];
if(ele.nodeName != '#text'){
ele.setAttribute("dragObj", this.index);
var handleObj = this._getHandleObj( this.options.handle, ele);
this._registerMouseEvent(ele);
}
}
},
registerDragElement: daum.dnd.DragContainer.prototype._registerDragElements,
addDragCont: daum.dnd.DragContainer.prototype._registerContainers,
_getHandleObj: function(handle, srcEle){
var handleObj = null;
if(handle && (typeof handle == 'string')) {
handleObj = document.getElementsByClassName(handle, srcEle)[0];
}
if(!handleObj) handleObj = document.getElementById(handle);
if(!handleObj) handleObj = srcEle;
srcEle.handle = handleObj;
return handleObj;
},
_registerMouseEvent: function(srcEle){
var dragObj = new daum.dnd.DragObj(srcEle,
{
handle: srcEle.handleObj,
onMouseDown: this._prepareToMove.bind(this),
onMouseMove: this._mouseMoveByDragObj.bind(this),
onFinish: this._mouseUpByDragObj.bind(this)
}
);
srcEle.dragObject = dragObj;
this.index++;
},
_prepareToMove: function(dragObj, event) {
var dragObjElement = dragObj.element;
var handleObj = dragObjElement.handle;
this.shadow = daum.dnd.shadow.getInstance();
this.shadow.getDiv().setAttribute("dragObj", dragObjElement.getAttribute("dragObj"));
var dragElePos = daum.dom.Element.getElementPosition(dragObjElement);
var dragEleDim = daum.dom.Element.getDimension(dragObjElement);
var margin = {
"margin-top": Element.getStyle(dragObjElement, "margin-top"),
"margin-right": Element.getStyle(dragObjElement, "margin-right"),
"margin-bottom": Element.getStyle(dragObjElement, "margin-bottom"),
"margin-left": Element.getStyle(dragObjElement, "margin-left")
};
daum.dom.Element.setDimension(this.shadow.getDiv(), dragEleDim.x-2, dragEleDim.y-2);
Element.setStyle(this.shadow.getDiv(), margin);
this.shadow.show();
if(this.options.shadowClass){
this.shadow.getDiv().className = this.options.shadowClass;
}
dragObjElement.parentNode.replaceChild(this.shadow.getDiv(), dragObjElement);
document.body.appendChild(dragObjElement);
var shadowDim = daum.dom.Element.getDimension(this.shadow.getDiv());
dragObjElement.style.position = 'absolute';
daum.dom.Element.setCurrentDelta(dragObjElement, dragElePos.x, dragElePos.y);
daum.dom.Element.setDimension(dragObjElement, (dragEleDim.x-2), (dragEleDim.y-2));
dragObj.dimension = daum.dom.Element.getDimension(dragObjElement);
},
_mouseMoveByDragObj: function(dragObj, event) {
var mousePos = dragObj.getMousePosition(event);
var mouseOffset = dragObj.offset;// 처음 mouse down했을 때 세팅된 넘을 가져와야 한다.
var dimension = dragObj.dimension;
if(!dimension)
return;
var dragObjPosX = mousePos.x - mouseOffset.x;
var dragObjPosY = mousePos.y - mouseOffset.y;
var xPos = dragObjPosX + (dimension.x/2);
var yPos = dragObjPosY + (dimension.y/2);
var activeDragContainer = null;
Position.prepare();
for(var i=0; i<this.dragContainers.length; i++){
var container = this.dragContainers[i];
if(Position.within(container, xPos, yPos)){
activeDragContainer = container;
break;
}
}
if(activeDragContainer){
var beforeNode = null;// clone 노드 이전 노드
for(var j=activeDragContainer.childNodes.length-1; j>=0; j--){
if(activeDragContainer.childNodes[j].nodeName=='#text')
continue;
if(this.shadow.getDiv().getAttribute("dragObj") !=
activeDragContainer.childNodes[j].getAttribute("dragObj")){
var cElePos = daum.dom.Element.getElementPosition(activeDragContainer.childNodes[j]);
var cEleDim = daum.dom.Element.getDimension(activeDragContainer.childNodes[j]);
if((cElePos.x+cEleDim.x) > xPos && (cElePos.y+(cEleDim.y/2)) > yPos){
beforeNode = activeDragContainer.childNodes[j];
}
}
}
if(beforeNode){
var sibling = this.shadow.getDiv().nextSibling;
if(beforeNode != sibling){
activeDragContainer.insertBefore(this.shadow.getDiv(), beforeNode);
}
} else {
if((this.shadow.getDiv().nextSibling) || (this.shadow.getDiv().parentNode!=activeDragContainer)){
activeDragContainer.appendChild(this.shadow.getDiv());
}
}
}
},
_mouseUpByDragObj: function(dragObj, event){
var dragElement = dragObj.element;
this.shadow.getDiv().parentNode.replaceChild(dragElement, this.shadow.getDiv());
if(this.shadow){
dragElement.style.position = '';
dragElement.style.width = '';
dragElement.style.height = '';
dragElement.style.left = '';
dragElement.style.top = '';
this.shadow.destroy();
}
if(this.options.onChange)
this.options.onChange(dragObj);
},
removeDragElement: function(srcEle){
srcEle.dragObject.destroy();
},
removeDragContainer: function(obj){
for(var j= 0; j< obj.childNodes.length; j++){
var ele = obj.childNodes[j];
if(ele.nodeName != '#text'){
this.removeDragElement(ele);
}
}
this.dragContainers = this.dragContainers.reject(function(dragCont) { return dragCont==Obj });
},
destroy: function(){
var size = this.dragContainers.length;
for(var i=0;i<size; i++){
this.removeDragContainer(this.dragContainers[0]);
}
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.thread) window.daum.thread = new Object();
daum.thread.Mutex = daum.create();
daum.thread.Mutex.prototype = {
initialize: function(cmdObject, methodName){
this.c        = cmdObject;
this.methodID = methodName;
daum.thread.MutexMap.add( this.c.id, this );
this.number   = (new Date()).getTime();
this.enter    = false;
this.attempt( daum.thread.MutexMap.first() );
},
attempt: function( start ) {
for (var j=start; j; j=daum.thread.MutexMap.next(j.c.id)) {
if (j.enter ||
(j.number &&
(j.number < this.number ||
(j.number == this.number && j.c.id < this.c.id) ) ) ){
return setTimeout("daum.thread.Slice.execute("+this.c.id+","+j.c.id+")",10);
}
}
this.c[ this.methodID ]();
this.number = 0;
daum.thread.MutexMap.remove( this.c.id );
}
}
daum.thread.Slice = {
execute: function( cmdID, startID ) {
daum.thread.MutexMap.get(cmdID).attempt( daum.thread.MutexMap.get(startID) );
}
}
daum.thread.MutexMap = {
map: {},
add: function( k,o ){
this.map[k] = o;
},
remove: function( k ){
delete this.map[k];
},
get: function( k ){
return k==null ? null : this.map[k];
},
first: function(){
return this.get( this.nextKey() );
},
next : function( k ){
return this.get( this.nextKey(k) );
},
nextKey : function( k ){
for (i in this.map) {
if ( !k ) return i;
if (k==i) k=null; /*tricky*/
}
return null;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.TabPaneContainer = daum.create();
daum.widget.TabPaneContainer.prototype = {
initialize: function (element, options) {
this.options = {
addTabPaneEventHandler: false, // TabPane 을 추가 할 때 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
beforeRemoveTabPaneEventHandler: false, // TabPane 을 삭제 할 때 삭제 전 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
removeTabPaneEventHandler: null, // TabPane 을 삭제 할 때 삭제 후 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
saveTextEventHandler: null, // TabPane 의 이름을 바꿀 때 외부에서 별도의 이벤트 핸들링이 필요한 경우 이벤트 핸들러를 지정
onSelect: false, //TapPane을 선책하면 불리는 함수..
dimUpColor: 'rgb(255, 255, 255)', // TabPane 이 선택되었을 때의 TITLE NODE 색상
dimDownColor: 'rgb(204, 204, 204)', // TabPane 이 선택되지 않았을 때의 TITLE NODE 색상
titleCss: false, // 전체 TITLE NODE 에 적용 할 CSS 를 지정
paneCss: false, // 전체 PANE NODE 에 적용 할 CSS 를 지정
tabTitleCss: false, // 각각의 TITLE NODE 에 적용 할 CSS 를 지정
tabPaneCss: false, // 각각의 PANE NODE 에 적용 할 CSS 를 지정
tabDimUpCss: false,
round: false, //탭을 round 처리 할지.. 하려면.. Nifty를 추가해야한다.
tabDimDownCss: false,
removeConfirm: true,
removable: true,//탭을 삭제할 수 있는지, 각 탭을 만들때, 따로 줄수도 있다.
changeTitle: true, // Title을 변경할 수 있는지
removeIconUrl: false, // TabPane 삭제에 사용 할 아이콘
removeConfirmMessage: '삭제하시겠습니까?', // TabPane 을 삭제 시 확인 메시지
removeFailureMessage: '삭제에 실패하였습니다.', // TabPane 삭제 실패 시 메시지
createDefaultAddTabPaneButton: null // TabPane 추가 버튼을 TITLE NODE 에 생성
};
Object.extend(this.options, options || {});
this.element = $(element);
this.titleNode = document.createElement('div');
this.titleNode.id = this.element.id + '_Title';
if (this.options.titleCss) {
this.titleNode.className = this.options.titleCss;
}
this.paneNode = document.createElement('div');
this.paneNode.id = this.element.id + '_Pane';
if (this.options.paneCss) {
this.paneNode.className = this.options.paneCss;
} else {
this.paneNode.style.borderWidth = '0';
this.paneNode.style.clear = 'both';
}
this.element.appendChild(this.titleNode); // Title 과 Pane 이 세트로 관리되어짐
this.element.appendChild(this.paneNode);
if (this.options.createDefaultAddTabPaneButton) {
this._createDefaultAddTabPaneButton();
}
this.tabPanes = new Array(); // 등록된 TabPane 들의 배열
this.eventMouseClick = this.mouseClick.bindAsEventListener(this);
Event.observe(this.titleNode, 'click', this.eventMouseClick); // 토글과 삭제 처리를 위한 이벤트 리스너 등록
},
addTabPane: function (id, options) {
var allOptions = {};
Object.extend(allOptions, this.options || {});
Object.extend(allOptions, options || {});
var tabPane = new daum.widget.TabPane(this.titleNode, this.paneNode, id, allOptions, this.defaultAddTabPaneButton); // 새 TabPane 생성
this.tabPanes.push(tabPane); // TabPane 의 배열에 등록
this._select(tabPane.childTitleNode.id);
},
_createDefaultAddTabPaneButton: function() {
this.defaultAddTabPaneButton = document.createElement('div');
if (daum.browser.Browser.isIE()) {
this.defaultAddTabPaneButton.style.styleFloat = 'left';
} else {
this.defaultAddTabPaneButton.style.cssFloat = 'left';
}
this.defaultAddTabPaneButton.style.cursor = 'pointer';
this.defaultAddTabPaneButton.style.height = '19px';
this.defaultAddTabPaneButton.style.lineHeight = '19px';
this.defaultAddTabPaneButton.style.borderWidth = '0px';
this.defaultAddTabPaneButton.style.fontSize = '11px';
this.defaultAddTabPaneButton.style.color = 'gray';
this.defaultAddTabPaneButton.innerHTML = "New Tab";
this.titleNode.appendChild(this.defaultAddTabPaneButton);
if (this.options.addTabPaneEventHandler) {
this.defaultAddTabPaneButton.onclick = this.options.addTabPaneEventHandler;
}
},
removeTabPaneByTitleId: function (id) {
this._removeTabPane(this.getTabPaneByTitleId(id));
},
removeTabPaneById: function (id) {
daum.debug("removeTabPaneById is called");
this._removeTabPane(this.getTabPaneById(id));
},
_removeTabPane: function (targetTabPane) {
if (this.getTabPaneCount() == 1 || targetTabPane.editMode == true) { // 현재 탭의 개수가 1 이면 더이상 삭제 할 수 없음 || 탭명 변경 중에는 삭제 할 수 없다.
daum.widget.Dialog.alert(this.options.removeFailureMessage);
return ;
}
if(this.options.removeConfirm){
daum.widget.Dialog.confirm(this.options.removeConfirmMessage,
{
onConfirm: function() {
this._removeProcess(targetTabPane);
}.bind(this)
});
}else{
this._removeProcess(targetTabPane);
}
},
_removeProcess: function(targetTabPane){
if (this.options.beforeRemoveTabPaneEventHandler) {
this.options.beforeRemoveTabPaneEventHandler(targetTabPane); // 별도로 지정해준 EventHandler 실행
}
this.tabPanes = this.tabPanes.reject(function (tabPane) {
return (tabPane.childTitleNode.id == targetTabPane.childTitleNode.id); // 선택된 탭을 배열에서 제거해 줌
});
targetTabPane.dimDown();
targetTabPane.remove(); // 실제 TabPane 을 제거
this._select(this.previousTabPaneId);
if (this.options.removeTabPaneEventHandler != null) {
this.options.removeTabPaneEventHandler(targetTabPane); // 별도로 지정해준 EventHandler 실행
}
},
mouseClick: function (event) {
var id = Event.element(event).id;
if (id != null && id != "") {
this._select(id);
}
},
_dimUp: function(tabPane){
if(this.getTabPaneCount() == 1){
tabPane.dimUp(true);
}else{
tabPane.dimUp();
}
},
_select: function(id){
if (id && id.substring(0, 7) == 'Remove_') { // 삭제
var tabId = id.substring(7);
this.removeTabPaneByTitleId(tabId); // Remove 노드의 ID 는 'Remove_element_Title_0' 와 같은 형태이므로 element_Title_0 과 같이 변경해 줌
return;
}
if(id && id == this.currentTabPaneId)
return;
var currentTabPane = null;
if(id)
currentTabPane = this.getTabPaneByTitleId(id); // 사용자의 클릭에 의해서 현재 선택된 탭을 배열에서 추출
if (currentTabPane == null) {
currentTabPane = this.tabPanes[this.tabPanes.length - 1];
this.currentTabPaneId = currentTabPane.childTitleNode.id;
this.previousTabPaneId = null;
}else{
if(this.currentTabPaneId){
this.previousTabPaneId = this.currentTabPaneId;
var previousTabPane = this.getTabPaneByTitleId(this.previousTabPaneId); // 기존에 선택되어져 있는 탭을 배열에서 추출
if(previousTabPane)
previousTabPane.dimDown(); // 기존의 탭을 dim down 처리
}
this.currentTabPaneId = id; // 현재 선택된 탭의 ID 를 설정해
}
this._dimUp(currentTabPane); // 현재 선택된 탭을 dim up 처리
if(this.options.onSelect)
this.options.onSelect(currentTabPane, previousTabPane);
},
select: function(id){
this._select(this.titleNode.id + '_' + id);
},
getTabPaneById: function (id) {
return this.getTabPaneByTitleId(this.titleNode.id + '_' + id);
},
getTabPaneByTitleId: function (id) {
return this.tabPanes.find(function (tabPane) {
return (tabPane.childTitleNode.id == id); // ID 에 해당하는 TabPane 을 배열에서 추출
});
},
getCurrentTabPane: function() {
return this.getTabPaneByTitleId(this.currentTabPaneId); // 현재 선택되어있는 TabPane 을 반환
},
getTabPaneCount: function () {
return this.tabPanes.length; // 현재 등록되어있는 TabPane 의 개수를 반환
},
selectFirst: function () {
this.tabPanes.each(function (tabPane) {
tabPane.dimDown();
});
this.tabPanes[0].dimUp();
this.currentTabPaneId = this.tabPanes[0].childTitleNode.id;
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.log) window.daum.log = new Object();
var b = navigator.userAgent.toLowerCase();
isMozilla = function(){
return /mozilla/.test(b) && !/(compatible|webkit)/.test(b);
};
Function.prototype.bindContext = function(object) {
var __method = this;
return function() {
return __method.apply(object, arguments);
}
}
getLogTime = function() {
var now = new Date();
var hour = now.getHours();
if (hour < 10) hour = "0" + hour;
var min = now.getMinutes();
if (min < 10) min = "0" + min;
var sec = now.getSeconds();
if (sec < 10) sec = "0" + sec;
return hour + ":" + min + ":" + sec;
}
Logger = {
type: 'Logger',
logConsole: null,
msgs: [],
timers: {},
initialize: function(){
if(this.logConsole)
return;
this.logConsole = new LogConsole();
this.flush();
},
log: function(msg, color){
if(arguments.length == 1){
color = 'blue';
}
if(!isMozilla()){
if (!this.logConsole) {
this.msgs.push({msg: msg, color: color});
} else {
this.logConsole.log({msg: msg, color: color});
}
}else{
throw new Exception();
}
return '';
},
_log_with_level: function(level, msg, color) {
this.log("[" + level + "][" + getLogTime() + "] " + msg, color);
return '';
},
debug: function(msg){
return this._log_with_level("DEBUG", msg, "black");
},
info: function(msg) {
return this._log_with_level("INFO", msg, "blue");
},
error: function(msg) {
return this._log_with_level("ERROR", msg, "red");
},
time: function(name) {
if (! this.timers[name]) {
this.timers[name] = new Date();
}
},
timeEnd: function(name) {
if (this.timers[name]) {
this.debug(name + ": " + (new Date().getTime() - this.timers[name].getTime()) + "ms");
delete this.timers[name];
}
},
flush: function(){
if(this.logConsole){
var msgLength = this.msgs.length;
for(var i=0; i<msgLength; i++){
this.logConsole.log(this.msgs.shift());
}
}else{
this.clear();
}
},
clear: function(){
this.msgs.splice(0, this.msgs.length);
this.logConsole.clear();
},
toggleConsole: function(){
this.logConsole.toggle();
}
}
if(!isMozilla()){
console = {
log : Logger.log.bindContext(Logger)
}
}
LogConsole = function(){
this.initialize.apply(this, arguments);
}
LogConsole.prototype = {
constructor: LogConsole,
type : 'LogConsole',
_createSplit: function(){
this.spliter = document.createElement('div')
this.spliter.id = "split"
this.spliter.style.position = "absolute"
this.spliter.style.left = '0px'
this.spliter.style.height = '5px'
this.spliter.style.fontSize = '1px'
this.spliter.style.width = '100%'
this.spliter.style.padding = '0px'
this.spliter.style.margin = '0px 0px 0px 0px'
this.spliter.style.backgroundColor = 'blue'
this.spliter.style.border = "1px solid black"
this.spliter.style.cursor = 'n-resize'
this.spliter.style.display = 'none'
this.spliter.style.zIndex = 100
document.body.appendChild(this.spliter);
var opt = {
direction: 'vertical',
onMouseDown: this.startDrag.bindContext(this),
onMouseMove: this.dragToolbar.bindContext(this),
onFinish:  this.finishDrag.bindContext(this)
}
try{
if(daum.dnd){
new daum.dnd.DragObj(this.spliter, opt);
}
}catch(e) {}
},
_createLogger: function(){
this.logger = document.createElement('div')
this.logger.id = "logger";
this.logger.style.position = "absolute"
this.logger.style.left = '0px'
this.logger.style.width = '100%'
this.logger.style.height = "250px"
this.logger.style.padding = "0px"
this.logger.style.margin = "0px 0px 0px 0px"
this.logger.style.display = 'none'
this.logger.style.textAlign = "left"
this.logger.style.fontFamily = "lucida console"
this.logger.style.backgroundColor = 'darkgray'
this.logger.style.zIndex = 100
this.logger.style.border = "1px solid black"
document.body.appendChild(this.logger)
},
_createToolbar: function(){
this.toolbar = document.createElement('div')
this.toolbar.id="toolbar";
this.toolbar.style.padding = "0px"
this.toolbar.style.border = "1px solid yellow"
this.toolbar.style.backgroundColor = 'red'
this.logger.appendChild(this.toolbar);
},
_addToolbarButton: function(){
this.btnContainer = document.createElement('span')
this.btnContainer.innerHTML += '<button onclick="Logger.toggleConsole()" style="color:black">close</button>'
this.btnContainer.innerHTML += '<button onclick="Logger.clear()" style="color:black">clear</button>'
this.toolbar.style.border = "1px solid black"
this.toolbar.appendChild(this.btnContainer);
this.btnContainer.style.border = "1px solid black"
},
_createConsole: function(){
this.console = document.createElement('div')
this.console.id = "console"
this.console.style.overflow = "auto"
this.console.style.height = "100%"
this.console.style.backgroundColor = 'white'
this.console.style.border = "1px solid black"
this.console.style.color = "black";
this.console.style.fontSize = '12px'
this.console.style.zIndex = 200
this.logger.appendChild(this.console)
},
_createCommandLine: function(){
this.commandLine = document.createElement('input')
this.commandLine.id = "commandLine"
this.commandLine.style.height = "12pt"
this.commandLine.style.backgroundColor = 'white'
this.commandLine.style.border = "1px solid black"
this.commandLine.style.color = "black";
this.commandLine.style.width = "100%";
this.commandLine.style.fontSize = '1em'
this.commandLine.style.zIndex = 200
this.logger.appendChild(this.commandLine);
function addEvent(object, name, handler){
if (object.attachEvent){
object.attachEvent("on"+name, handler);
}else{
object.addEventListener(name, handler, false);
}
}
var evalCommandLine =  function(){
var text = this.commandLine.value;
this.commandLine.value = "";
var value;
try{
Logger.log('>>>' + text, 'blue');
value = eval(text);
}catch (exc){
}
Logger.log(value, 'red');
}.bindContext(this);
var onCommandLineKeyDown = function (event){
if (event.keyCode == 13){
evalCommandLine();
}else if (event.keyCode == 27){
this.commandLine.value = "";
}
this.reposition();
}.bindContext(this);
addEvent(this.commandLine, "keydown", onCommandLineKeyDown);
},
initialize : function() {
try{
window.Cookie = {
write : daum.browser.Cookie.write,
read : daum.browser.Cookie.read,
erase : daum.browser.Cookie.erase
}
}catch(e){
window.Cookie = {
write: function(name, value, days){
if(days){
(time = new Date()).setTime(new Date().getTime()+days*24*60*60*1000);
var exp = '; expires='+time.toGMTString();
}else{
var exp='';
}
document.cookie=name+"="+value+exp+"; path=/";
},
read: function (name){
var cookies = document.cookie.split(';');
for(var i=0; i<cookies.length; i++){
var cookie=cookies[i].replace(/^\s+/, '');
if (cookie.indexOf(name+'=')==0) return cookie.substring(name.length+1);
}
return null;
},
erase: function (name){
write(name, "", -1);
}
}
}
if (document.getElementById('logger')) {
return;
}
this._createSplit();
this._createLogger();
this._createToolbar();
this._addToolbarButton();
this._createConsole();
this._createCommandLine();
window.setTimeout(this.repositionWindow.bindContext(this), 500);
this.dragging = false;
this.accessElement = document.createElement('span')
this.accessElement.innerHTML = '<button style="position:absolute;top:-100px" onclick="javascript:Logger.toggleConsole()" accesskey="d"></button>'
document.body.appendChild(this.accessElement)
if (window.Cookie.read('ConsoleVisible') == 'true') {
this.toggle();
}
window.onscroll = this.reposition.bindContext(this);
},
dragToolbar: function(DragObj){
this.dragging = true;
},
finishDrag: function(DragObj){
this.dragging = false;
var DragOffsetT = parseInt(DragObj.element.style.top) - this.DragObjOriginOffsetT;
this.console.style.height = (this.consoleHeight - DragOffsetT)+"px";
this.repositionWindow();
},
startDrag: function(DragObj){
this.consoleHeight = parseInt(this.console.style.height);
this.DragObjOriginOffsetT = parseInt(DragObj.element.style.top);
;
},
num: 0,
repositionWindow : function(isInit) {
if(this.logger.style.display == 'none') return;
var offset = document.documentElement.scrollTop || document.body.scrollTop
var pageHeight = document.documentElement.clientHeight || document.body.clientHeight
if(!this.dragging){
var logEleOffsetT = offset + pageHeight - this.logger.offsetHeight;
this.logger.style.top = logEleOffsetT + "px";
this.spliter.style.top = (logEleOffsetT - this.spliter.offsetHeight) + "px";
}
},
toggle : function() {
if (this.logger.style.display == 'none') {
this.show()
}
else {
this.hide()
}
},
reposition : function(){
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
var top = document.documentElement.scrollTop || document.body.scrollTop;
this.logger.style.top = top + (windowHeight - this.logger.offsetHeight );
var gap = this.console.scrollHeight - this.console.clientHeight;
if(gap > 0){
this.console.scrollTop = gap;
}
},
show : function() {
this.logger.style.display = '';
this.reposition();
window.Cookie.write('ConsoleVisible', 'true', 30);
},
hide : function() {
this.logger.style.display = 'none';
window.Cookie.write('ConsoleVisible', 'false', 30)
},
clear : function(e) {
this.console.innerHTML = "";
this.logger.style.height = '250px';
this.console.style.height = '100%';
},
log: function(logMsg) {
if(this.logger.offsetHeight > 350){
this.logger.style.height = '350px';
this.console.style.height = '350px';
}
if(this.console.innerHTML){
this.console.innerHTML = this.console.innerHTML +"<br /><font color='" + logMsg.color + "'><code>" + logMsg.msg + "</code></font>";
}else{
this.console.innerHTML = "<font color='" + logMsg.color + "'><code>" + logMsg.msg + "</code></font>";
}
}
}
if(!isMozilla()){
dir = function(obj){
var result= [];
result.push("<table>");
for (var propName in obj){
result.push("<tr>");
result.push("<td style='display:inline; font-size: 10pt'>");
var type = typeof(obj[propName]);
switch(type){
case 'function' :
case 'object' :
result.push("<a href='#' onClick='dir.bindContext("+ +")("+propName+")' >");
break;
default :
break;
}
result.push(propName);
result.push(" ("+typeof(obj[propName])+")");
switch(type){
case 'function' :
case 'object' :
result.push("</a>");
break;
case 'string' :
case 'number' :
case 'boolean' :
default :
break;
}
result.push(" </td> ");
result.push(" <td  style='font-size: 10pt'> ");
switch(type){
case 'function' :
case 'object' :
break;
case 'string' :
case 'number' :
case 'boolean' :
default :
result.push(": " + obj[propName]);
break;
}
result.push(" </td> ");
result.push(" </tr> ");
}
result.push('</ul>');
console.log(result.join(''));
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
daum.util.Random = {
generate: function(size){
var randSize = size ? 10*size : 100000000;
return Math.round(Math.random()*randSize);
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
daum.util.StringUtil = {
getTokens: function (string, delimiter) {
if(arguments.length == 1){
delimiter = '';
}
return string.split(delimiter);
},
getToken: function(string, delimiter, index) {
var tokens = this.getTokens(string, delimiter);
if (tokens && index < tokens.length) {
return tokens[index];
}
return null;
},
getFirstToken: function (string, delimiter) {
return this.getToken(string, delimiter, 0);
},
getLastToken: function (string, delimiter) {
var tokens = this.getTokens(string, delimiter);
if (tokens && tokens.length > 1) {
return tokens[tokens.length - 1];
}
return null;
},
trim: function(string){
if (string) {
return string.replace(/(^\s*)|(\s*$)/g, "");
}
return null;
},
ltrim: function (string) {
if (string) {
return string.replace(/^\s+/g, "");
}
return null;
},
rtrim: function (string) {
if (string) {
return string.replace(/\s+$/g, "");
}
return null;
},
strcut: function(str, len) {
var x=0;
for (var i=0; i<str.length; i++) {
x += (str.charCodeAt(i) > 128) ? 2 : 1;
if (x > len) return str.substring(0,i) + "...";
}
return str;
},
isValidLength: function(str, len) {
var x=0;
for (var i=0; i<str.length; i++) {
x += (str.charCodeAt(i) > 128) ? 2 : 1;
if (x > len) return false;
}
return true;
},
transFromKByte: function(quota) {
return this.transFromKByteWithPrecision(quota, 0);
},
transFromKByteWithPrecision: function(quota, precision) {
var result = "";
if(quota >= (1024 * 1024 * 1024)) {
var quotaDouble = parseFloat(quota / (1024 * 1024 * 1024));
result = quotaDouble.toFixed(precision) + "T";
}
else if(quota >= (1024 * 1024)) {
var quotaDouble = parseFloat(quota / (1024 * 1024));
result = quotaDouble.toFixed(precision) + "G";
}
else if(quota >= (1024)) {
var quotaDouble = parseFloat(quota / (1024));
result = quotaDouble.toFixed(precision) + "M";
}
else {
result = quota.toString() + "K";
}
return result;
},
IsValidObject: function(p_oVal)	{
if( p_oVal == null || typeof(p_oVal) == "undefined")
return false;
return true;
},
IsValidString:function (p_sVal){
if( this.IsValidObject(p_sVal) == false || p_sVal == "" )
return false;
return true;
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.DynaTable = daum.create();
daum.widget.DynaTable.prototype = {
initialize: function(tableId, visualRows, totalRows, options){
this.tableId = tableId;
this.table = $(tableId);
this.options = options || {};
this.metaData = new daum.widget.DynaTableData(this, visualRows, totalRows);
this._createTableRows();
this.scroll = new daum.widget.DynaTableScroll(this, this.tableId);
this.calculateLineHeight();
this.metaData.fetchBuffer();
},
_createTableRows: function(){
var tbody = document.createElement("tbody");
for(var i=0; i<this.metaData.getVisualRows(); i++){
var tr = document.createElement("tr");
var td1 = document.createElement("td");
var td2 = document.createElement("td");
tr.appendChild(td1);
tr.appendChild(td2);
tbody.appendChild(tr);
}
this.table.appendChild(tbody);
},
updateView: function(event){
daum.debug("[updateView] is called");
if(this.metaData.isFetching()){
daum.debug("[updateView] 데이타 fetching 중... 그냥 return");
return;
}
var mailList = this.metaData.getBuffer();
if(mailList){
daum.debug("[updateView] 테이블을 업데이트 한다..");
var pos = this.metaData.getDataPosition();
daum.debug("[updateView] pos ==> pos.start:"+pos.start+", pos.end:"+pos.end);
var mailIndex = pos.start;
var trList = this.table.getElementsByTagName("tr");
for(var i=0; i<trList.length; i++){
var mail = mailList[mailIndex];
if(mail){
trList[i].getElementsByTagName("td")[0].innerHTML = '<div style="padding-left:2px;width:100px;height:'+this.lineHeight+'px;line-height:'+this.lineHeight+'px;overflow:hidden;">'+mail.fromName+'</div>';
trList[i].getElementsByTagName("td")[1].innerHTML = '<div style="padding-left:2px;width:500px;height:'+this.lineHeight+'px;line-height:'+this.lineHeight+'px;overflow:hidden;">'+mail.subject+'</div>';
}else{
trList[i].getElementsByTagName("td")[0].innerHTML = '<div style="height:'+this.lineHeight+'px"></div>';
trList[i].getElementsByTagName("td")[1].innerHTML = '<div style="height:'+this.lineHeight+'px">.....</div>';
}
mailIndex++;
}
}
(this.options.onUpdate || Prototype.K)(this);
},
calculateLineHeight: function(){
var tableDim = daum.dom.Element.getDimension(this.table);
this.lineHeight = tableDim.y/this.metaData.visualRows - 1;
},
onScroll: function(event){
this.metaData.fetchBuffer();
}
}
daum.widget.DynaTableData = daum.create();
daum.widget.DynaTableData.prototype = {
initialize: function(dynaTable, visualRows, totalRows) {
this.dynaTable = dynaTable;
this.visualRows = visualRows;
this.totalRows = totalRows;
this.buffer = {};
this.startOffset = 0;// buffer의 start offset
this.dataOffset = 0;// currentDataOffset 테이블의 첫번째 row로 보여야 할 offset
this.lastDataOffset = -1;
this.fetching = false;
this.fetchRows = 0;
this.service = daum.net.DWRService.getService("sparrow.services.HanmailService");
},
isOverLimitPosition: function(){
var _curLastVisualRow = this.dataOffset + this.visualRows;
if(this.getLastOffset() == this.totalRows){
var _bottomLimit = this.getLastOffset();
}else{
var _bottomLimit = this.getLastOffset()-3;
}
if(this.getStartOffset() == 0){
var _upperLimit = this.getStartOffset();
}else{
var _upperLimit = this.getStartOffset()+3;
}
daum.debug("[isOverLimitPosition] _curLastVisualRow:"+_curLastVisualRow+
", _bottomLimit:"+_bottomLimit+", this.dataOffset:"+this.dataOffset+",  _upperLimit:"+_upperLimit);
if(_curLastVisualRow > _bottomLimit || this.dataOffset < _upperLimit){
return true;
}
return false;
},
fetchBuffer: function(){
daum.debug("[fetchBuffer] is called this.dataOffset:"+this.dataOffset+", this.fetchRows:"+this.fetchRows);
if(this.isOverLimitPosition()){
var spareOffset = this.getSpareOffset();
var startOffset = this.dataOffset - spareOffset;
if(startOffset < 0){
startOffset = 0;
}
var bufferSize = this.getBufferSize();
daum.debug("[fetchBuffer] 데이타를 가져온다, startOffset:"+startOffset+", bufferSize:"+bufferSize);
$('loading').style.display = "block";
this.service.getMailList("규돈편지함", startOffset, bufferSize, {
callback: function(mailList){
this.fetching = true;
daum.debug("[fetchBuffer] callback is called, mailList.length:"+mailList.length+", start:"+mailList[0].index+
", end:"+mailList[mailList.length-1].index);
this.startOffset = startOffset;
for(var i=0; i<mailList.length; i++){
this.buffer[mailList[i].index] = mailList[i];
}
this.fetchRows = mailList.length;
this.fetching = false;
daum.debug("[fetchBuffer] this.startOffset:"+this.startOffset+", getLastOffset():"+this.getLastOffset());
$('loading').style.display = "none";
this.dynaTable.updateView();
}.bind(this),
errorHandler: function(e) {
$('loading').style.display = "none";
alert("Error occured during getting mails");
}.bind(this)
});
}else{
this.dynaTable.updateView();
}
},
isFetching: function(){
return this.fetching;
},
getVisualRows: function(){
return this.visualRows;
},
getDirection: function(){
return this.dataOffset - this.lastDataOffset;
},
getFetchRows: function(){
return this.fetchRows;
},
getBufferSize: function(){
return this.visualRows + (this.getSpareOffset()*2);
},
getBuffer: function(){
return this.buffer;
},
getLastOffset: function(){
return this.startOffset+this.getFetchRows();
},
getStartOffset: function(){
return this.startOffset;
},
getSpareOffset: function(){
return this.visualRows;
},
getDataPosition: function(){
var start = this.dataOffset;
var end = this.dataOffset+this.visualRows;
return {start:start, end:end}
},
getDataOffset: function(){
return this.dataOffset;
},
setDataOffset: function(offset){
if(offset > this.totalRows - this.visualRows){
offset = this.totalRows - this.visualRows;
}
this.dataOffset = offset;
}
}
daum.widget.DynaTableScroll = daum.create();
daum.widget.DynaTableScroll.prototype = {
initialize: function(dynaTable, tableId){
this.dynaTable = dynaTable;
this._createScroll(tableId);
this.updateHeight();
this.lastScrollPos = 0;
this.lastDataOffset = 0;
},
updateHeight: function(){
var table = this.dynaTable.table;
var tableDim = daum.dom.Element.getDimension(table);
this.scrollerDiv.style.height = parseInt(tableDim.y*this.dynaTable.metaData.totalRows/this.dynaTable.metaData.visualRows) + "px";
},
_createScroll: function(tableId){
var table = this.dynaTable.table;
var tableDim = daum.dom.Element.getDimension(table);
this.scrollDiv = document.createElement('div');
this.scrollDiv.style.position    = "relative";
this.scrollDiv.style.left        = (daum.browser.Browser.isIE()) ? "-6px" : "-3px";
this.scrollDiv.style.border = '1px solid red';
this.scrollDiv.style.width = '19px';
this.scrollDiv.style.height = tableDim.y+'px';
this.scrollDiv.style.overflow = 'auto';
this.scrollerDiv = document.createElement('div');
this.scrollerDiv.style.width = '1px';
this.scrollDiv.appendChild(this.scrollerDiv);
if(daum.browser.Browser.isIE()){
table.onmousewheel =
function(evt) {
if (event.wheelDelta>=0){ //wheel-up
this.scrollDiv.scrollTop -= this.dynaTable.lineHeight;
}else{
this.scrollDiv.scrollTop += this.dynaTable.lineHeight;
}
this.onScroll(true);
}.bind(this);
} else {
table.addEventListener("DOMMouseScroll",
function(evt) {
if (evt.detail < 0){ //wheel-up
this.scrollDiv.scrollTop -= this.dynaTable.lineHeight;
}else{
this.scrollDiv.scrollTop += this.dynaTable.lineHeight;
}
this.onScroll(true);
}.bind(this),
true);
}
this.scrollDiv.onscroll = this.onScroll.bind(this);
table.parentNode.parentNode.insertBefore( this.scrollDiv, table.parentNode.nextSibling );
},
isUnPlugged: function() {
return this.scrollDiv.onscroll == null;
},
plugin: function() {
this.scrollDiv.onscroll = this.onScroll.bindAsEventListener(this);
},
unplug: function() {
this.scrollDiv.onscroll = null;
},
onScroll: function(skiptimeout){
daum.debug("skiptimeout:"+skiptimeout);
if ( this.scrollTimeout )
clearTimeout( this.scrollTimeout );
this.scrollTimeout = setTimeout( this.callScrollEvent.bind(this), 30 );
},
callScrollEvent: function(){
if ( this.scrollTimeout )
clearTimeout( this.scrollTimeout );
this.unplug();
daum.debug("[callScrollEvent] onScroll is called, this.lastScrollPos:"+this.lastScrollPos+", scrollHeight:"+this.scrollDiv.scrollHeight);
daum.debug("[callScrollEvent] this.scrollDiv.scrollTop:"+this.scrollDiv.scrollTop+
", this.dynaTable.metaData.totalRows:"+this.dynaTable.metaData.totalRows+", this.scrollerDiv.offsetHeight:"+this.scrollerDiv.offsetHeight);
var rem = this.scrollDiv.scrollTop % this.dynaTable.lineHeight;
daum.debug("rem: "+rem);
if (rem != 0) {
daum.debug("this.lastScrollPos: "+this.lastScrollPos+", this.scrollDiv.scrollTop: "+this.scrollDiv.scrollTop+
", this.dynaTable.lineHeight:"+this.dynaTable.lineHeight);
if (this.lastScrollPos < this.scrollDiv.scrollTop){
if(this.scrollDiv.scrollTop <= this.dynaTable.lineHeight){
this.scrollDiv.scrollTop = this.dynaTable.lineHeight*2;
}else{
if(this.lastScrollPos !=0 && ((this.lastScrollPos + 27) == this.scrollDiv.scrollTop) ){
this.scrollDiv.scrollTop = this.scrollDiv.scrollTop - rem;
}else{
this.scrollDiv.scrollTop = this.scrollDiv.scrollTop + this.dynaTable.lineHeight -rem;
}
}
}else{
this.scrollDiv.scrollTop = this.scrollDiv.scrollTop - rem;
}
}
this.lastScrollPos = this.scrollDiv.scrollTop;
this.plugin();
daum.debug("this.scrollDiv.scrollTop: "+this.scrollDiv.scrollTop);
var dataOffset = parseInt(this.scrollDiv.scrollTop*this.dynaTable.metaData.totalRows/this.scrollerDiv.offsetHeight);
if(dataOffset == this.dynaTable.metaData.dataOffset)
return;
daum.debug("[callScrollEvent] this.dynaTable.onScroll is calling, dataOffset:"+dataOffset);
this.dynaTable.metaData.setDataOffset(dataOffset);
this.dynaTable.onScroll();
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
daum.widget.WindowPopup = daum.create();
daum.widget.WindowPopup.prototype = {
jst: null,
initialize: function(options){
daum.debug("WindowPopup is called");
this.options = this.getDefaultOption();
Object.extend(this.options, options || {});
this.isShow = false;
this.html = "";//need to set the default html.....
if(this.jst){
try{
this.html = daum.template.STML.process(this.jst,this.jstParams);
}catch(e){
daum.error("[WindowPopup] Error:"+e);
}
}else if(this.options.html){
this.html = this.options.html;
}
this._createWindow();
},
getDefaultOption: function(){
return {
width: "400px",
height: "200px",
border: "4px solid black",
backgroundColor: "white",
fontSize: "small",
fontFamily: "돋움,Verdana",
html: null,
isDrag: true,
shadow: false
};
},
setEventHandler: function(){
},
removeEventHandler: function(){
},
_createWindow: function(){
this.winPopup = document.createElement('div');
this.winPopup.style.position = "absolute";
this.winPopup.style.zIndex = 10000;
this.winPopup.style.display = "none";
this.winPopup.style.width = this.options.width;
this.winPopup.style.height = this.options.height;
this.winPopup.style.backgroundColor = this.options.backgroundColor;
this.winPopup.style.border = this.options.border;
this.winPopup.style.fontFamily = this.options.fontFamily;
this.winPopup.style.overflow = "";
document.body.appendChild(this.winPopup);
},
hide: function(){
this._destroy();
if(this.resizeEventHandler)
Event.stopObserving(window, "resize", this.resizeEventHandler);
this.isShow = false;
},
show: function(html){
if(this.options.shadow)
daum.widget.Modal.show();
if(html)
this.html = html;
this.winPopup.innerHTML = this.html;
this.setEventHandler();
if(this.options.isDrag)
this.dragObj = new daum.dnd.DragObj(this.winPopup, {handle:"win-popup-header", bound:true});
this.resizeEventHandler = this.onResize.bindAsEventListener(this);
Event.observe(window, "resize", this.resizeEventHandler);
this._repositionWindow();
this.isShow = true;
},
_repositionWindow: function(){
daum.dom.Element.positionCenter(this.winPopup, this.options.width, this.options.height);
this.winPopup.style.display = 'block';
},
_destroy: function(){
if(this.options.shadow)
daum.widget.Modal.hide();
if(this.winPopup)
this.winPopup.style.display = 'none';
try{
this.removeEventHandler();
this.winPopup.innerHTML = "";
this.dragObj.destroy();
}catch(e){
}
},
onResize: function(){
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.dnd) window.daum.dnd = new Object();
Function.prototype.dragContEventListener = function(object, dragObjElement, handle) {
var __method = this;
return function(event) {
return __method.call(object, event || window.event, dragObjElement, handle);
}
}
daum.dnd.shadow = {
shadow: false,
getInstance: function(){
if(!this.shadow){
this.shadow = document.createElement('div');
this.shadow.style.display = "none";
document.body.appendChild(this.shadow);
}
return this;
},
getDiv: function(){
return this.shadow;
},
show: function(){
this.shadow.style.display = "block";
},
destroy:function(){
if(this.shadow){
this.shadow.style.display = 'none';
this.shadow.className = '';
document.body.appendChild(this.shadow);
}
}
}
daum.dnd.DragContainer = daum.create();
daum.dnd.DragContainer.prototype = {
initialize: function(){
if(arguments.length < 1)
throw "Usage: new daum.dnd.DragContainer(container_id1,container_id2..,options)";
this.isDragging = false;
this.dragConts = new Array();
this.mouseDownObservers = {};
this.mouseMoveObservers = {};
this.mouseUpObservers = {};
this.index = 1;
this.options = {};
var argsLength = arguments.length;
if(argsLength > 0){
var index = argsLength-1;
if(arguments[index] && (arguments[index].shadowClass || arguments[index].onChange) ){
var options = arguments[argsLength-1];
this.options = {
handle: false,
shadowClass: false,
onChange: false
};
Object.extend(this.options, options || {});
if(argsLength > 1)
this._registerDragCont(arguments);
}else{
this._registerDragCont(arguments);
}
}
},
setOptions: function(options){
Object.extend(this.options, options || {});
},
_isOptionsParam: function(param){
if(param && param.handle){
return true;
}
return false;
},
_setParams: function(args){
var handle = false;
var argsLength = args.length;
if(argsLength > 1){
if(this._isOptionsParam(args[argsLength-1])){
var options = args[argsLength-1];
handle = options.handle;
argsLength = argsLength - 1;
}
}
return {argsLength: argsLength, handle: handle};
},
_getHandleObj: function(handle, srcEle){
var handleObj = null;
if(handle && (typeof handle == 'string')) {
handleObj = document.getElementsByClassName(handle, srcEle)[0];
}
if(!handleObj) handleObj = $(handle);
if(!handleObj) handleObj = srcEle;
return handleObj;
},
_registerMouseDownEvent: function(handleObj, srcEle){
var eventMouseDown = this.mouseDown.dragContEventListener(this);
var eventMouseMove = this.mouseMove.dragContEventListener(this, srcEle, handleObj);
var eventMouseUp = this.mouseUp.dragContEventListener(this);
Event.observe(handleObj, "mousedown", eventMouseDown);
Event.observe(handleObj, "mousemove", eventMouseMove);
Event.observe(handleObj, "mouseup", eventMouseUp);
this.mouseDownObservers[this.index] = eventMouseDown;
this.mouseMoveObservers[this.index] = eventMouseMove;
this.mouseUpObservers[this.index] = eventMouseUp;
this.index++;
},
_removeMouseDownEvent: function(handleObj, srcEle){
var index = srcEle.getAttribute("dragObj");
if (index) {
Event.stopObserving(handleObj, "mousedown", this.mouseDownObservers[index]);
this.mouseDownObservers[index] = null;
Event.stopObserving(handleObj, "mousemove", this.mouseMoveObservers[index]);
this.mouseMoveObservers[index] = null;
Event.stopObserving(handleObj, "mouseup", this.mouseUpObservers[index]);
this.mouseUpObservers[index] = null;
}
},
_iteratorElements: function(array, logic, start, end){
if(!array)
return;
if(arguments.length == 2){
start = 0;
end = array.length;
}
for(var i=start; i<end; i++){
if(!array[i])
continue;
var obj = array[i];
try {
logic.call(this, obj);
} catch (e) {
if(e == $break) break;
if(e != $continue) throw e;
}
}
},
_registerDragCont: function(contArray){
var paramInfo = this._setParams(contArray);
var handle = paramInfo.handle;
var argsLength = paramInfo.argsLength;
this._iteratorElements(contArray, function(cObj){
this.dragConts.push(cObj);
this._iteratorElements(cObj.childNodes, function(ele){
if(ele.nodeName == '#text')//Firefox의 dom파싱때문에..
throw $continue;
ele.setAttribute("dragObj", this.index);
var handleObj = this._getHandleObj(handle, ele);
this._registerMouseDownEvent(handleObj, ele);
});
},0,argsLength);
},
addDragElement: function(){
var paramInfo = this._setParams(arguments);
var handle = paramInfo.handle;
var argsLength = paramInfo.argsLength;
var firstCont = this.dragConts[0];
if(!firstCont)
return;
this._iteratorElements(arguments, function(dragEle){
dragEle.setAttribute("dragObj", this.index);
var handleObj = this._getHandleObj(handle, dragEle);
this._registerMouseDownEvent(handleObj, dragEle);
this.index++;
if(!firstCont.childNodes || firstCont.childNodes.length == 0){
firstCont.appendChild(dragEle);
}else{
var firstNode = daum.dom.Element.getFirstNode(firstCont);
if(firstNode)
firstCont.insertBefore(dragEle, firstNode);
}
},0,argsLength);
},
registerDragElement: function(){
var paramInfo = this._setParams(arguments);
var handle = paramInfo.handle;
var argsLength = paramInfo.argsLength;
this._iteratorElements(arguments, function(dragEle){
dragEle.setAttribute("dragObj", this.index);
var handleObj = this._getHandleObj(handle, dragEle);
this._registerMouseDownEvent(handleObj, dragEle);
this.index++;
},0,argsLength);
},
removeDragElement: function(){
var paramInfo = this._setParams(arguments);
var handle = paramInfo.handle;
var argsLength = paramInfo.argsLength;
this._iteratorElements(arguments, function(dragEle){
var handleObj = this._getHandleObj(handle, dragEle);
this._removeMouseDownEvent(handleObj, dragEle);
},0,argsLength);
},
addDragCont: function(){
this._registerDragCont(arguments);
},
removeDragCont: function(dragContEle, options){
var removeEle = $(dragContEle);
if(!removeEle){
return;
}
var handle = false;
if(options){
handle = options.handle;
}
var Obj= null;
this._iteratorElements(this.dragConts, function(cObj){
if(cObj == removeEle){
Obj = cObj;
this._iteratorElements(cObj.childNodes, function(ele){
if(ele.nodeName == '#text')
throw $continue;
var index = ele.getAttribute("dragObj");
var handleObj = this._getHandleObj(handle, ele);
this._removeMouseDownEvent(handleObj, ele);
});
throw $break;
}
});
if(Obj){
this.dragConts = this.dragConts.reject(function(dragCont) { return dragCont==Obj });
}
},
mouseDown: function(event) {
if(!Event.isLeftClick(event))
return false;
this.isMouseDown = true;
return false;
},
prepareToMove: function(event, dragObjElement, handleObj) {
var src = Event.element(event);
this.isDragging = true;
this.dragElement = dragObjElement;
this.shadow = daum.dnd.shadow.getInstance();
this.shadow.getDiv().setAttribute("dragObj", this.dragElement.getAttribute("dragObj"));
var dragElePos = daum.dom.Element.getElementPosition(this.dragElement);
var dragEleDim = daum.dom.Element.getDimension(this.dragElement);
var margin = {
"margin-top": Element.getStyle(this.dragElement, "margin-top"),
"margin-right": Element.getStyle(this.dragElement, "margin-right"),
"margin-bottom": Element.getStyle(this.dragElement, "margin-bottom"),
"margin-left": Element.getStyle(this.dragElement, "margin-left")
};
daum.dom.Element.setDimension(this.shadow.getDiv(), dragEleDim.x-2, dragEleDim.y-2);
Element.setStyle(this.shadow.getDiv(), margin);
this.shadow.show();
if(this.options.shadowClass){
this.shadow.getDiv().className = this.options.shadowClass;
}
this.dragElement.parentNode.replaceChild(this.shadow.getDiv(), this.dragElement);
document.body.appendChild(this.dragElement);
var shadowDim = daum.dom.Element.getDimension(this.shadow.getDiv());
this.dragElement.style.position = 'absolute';
daum.dom.Element.setCurrentDelta(this.dragElement, dragElePos.x, dragElePos.y);
daum.dom.Element.setDimension(this.dragElement, (dragEleDim.x-2), (dragEleDim.y-2));
this.dragHelperObj = new daum.dnd.DragObj(this.dragElement,
{
handle: src,
onMouseMove: this.mouseMoveByDragObj.bind(this),
onFinish: this.mouseUpByDragObj.bind(this)
}
);
this.dragHelperObj._mouseDown(event);
this.dragHelperObj._mouseMove(event);
this.dragHelperObj.dimension = daum.dom.Element.getDimension(this.dragElement);
},
num: 0,
mouseMove: function(event, dragObjElement, handleObj) {
if(!this.isMouseDown)
return false;
if(!this.isDragging) this.prepareToMove(event, dragObjElement, handleObj);
return false;
},
mouseMoveByDragObj: function(dragHelper, event) {
var mousePos = dragHelper.getMousePosition(event);
var mouseOffset = dragHelper.offset;// 처음 mouse down했을 때 세팅된 넘을 가져와야 한다.
var dimension = this.dragHelperObj.dimension;
if(!dimension)
return;
var dragHelperPosX = mousePos.x - mouseOffset.x;
var dragHelperPosY = mousePos.y - mouseOffset.y;
var xPos = dragHelperPosX + (dimension.x/2);
var yPos = dragHelperPosY + (dimension.y/2);
var activeDragCont = null;
Position.prepare();
for(var i=0; i<this.dragConts.length; i++){
var dragCont = this.dragConts[i];
if(Position.within(dragCont, xPos, yPos)){
activeDragCont = dragCont;
break;
}
}
if(activeDragCont){
var beforeNode = null;// clone 노드 이전 노드
for(var j=activeDragCont.childNodes.length-1; j>=0; j--){
if(activeDragCont.childNodes[j].nodeName=='#text')
continue;
if(this.shadow.getDiv().getAttribute("dragObj") !=
activeDragCont.childNodes[j].getAttribute("dragObj")){
var cElePos = daum.dom.Element.getElementPosition(activeDragCont.childNodes[j]);
var cEleDim = daum.dom.Element.getDimension(activeDragCont.childNodes[j]);
if((cElePos.x+cEleDim.x) > xPos && (cElePos.y+(cEleDim.y/2)) > yPos){
beforeNode = activeDragCont.childNodes[j];
}
}
}
if(beforeNode){
var sibling = this.shadow.getDiv().nextSibling;
if(beforeNode != sibling){
activeDragCont.insertBefore(this.shadow.getDiv(), beforeNode);
}
} else {
if((this.shadow.getDiv().nextSibling) || (this.shadow.getDiv().parentNode!=activeDragCont)){
activeDragCont.appendChild(this.shadow.getDiv());
}
}
}
this.num++;
},
mouseUp: function(event) {
this.isDragging = false;
this.isMouseDown = false;
return false;
},
mouseUpByDragObj: function(dragHelper) {
this.isDragging = false;
this.isMouseDown = false;
if(this.dragHelperObj){
this.dragHelperObj.destroy();
this.shadow.getDiv().parentNode.replaceChild(this.dragElement, this.shadow.getDiv());
}
if(this.shadow){
this.dragElement.style.position = '';
this.dragElement.style.width = '';
this.dragElement.style.height = '';
this.dragElement.style.left = '';
this.dragElement.style.top = '';
this.shadow.destroy();
}
if(this.dragElement){
var _temp = this.dragElement;
this.dragElement = false;
if(this.options.onChange)
this.options.onChange(_temp);
}
},
destroy: function(){
var size = this.dragConts.length;
for(var i=0;i<size; i++){
this.removeDragCont(this.dragConts[0],{handle:this.options.handle});
}
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
daum.util.DateUtil = {
getCurrentTime: function(format){
if(!format)
format = "yyyy-MM-dd HH:mm:ss";
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
if(month < 10)
month = "0" + month;
var date = now.getDate();
if(date < 10)
date = "0" + date;
var hour = now.getHours();
if(hour < 10)
hour = "0" + hour;
var min = now.getMinutes();
if(min < 10)
min = "0" + min;
var sec = now.getSeconds();
if(sec < 10)
sec = "0" + sec;
return format.replace(/yyyy/g, year).replace(/MM/g, month).replace(/dd/g, date)
.replace(/HH/, hour).replace(/mm/, min).replace(/ss/, sec);
},
getLogTime: function() {
var now = new Date();
var hour = now.getHours();
if (hour < 10) hour = "0" + hour;
var min = now.getMinutes();
if (min < 10) min = "0" + min;
var sec = now.getSeconds();
if (sec < 10) sec = "0" + sec;
return hour + ":" + min + ":" + sec;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.net) window.daum.net = new Object();
daum.net.DWRService = {
SERVICE_PREFIX: daum.properties.DWR_SERVICE_PREFIX,
DTO_PREFIX: daum.properties.DWR_DTO_PREFIX,
getService: function(name){
var result = daum.load({name:"^"+this.SERVICE_PREFIX+name, alias:name});
eval("var service = new "+name+"();");
return service;
},
getDto: function(name){
daum.load({name:"^"+this.DTO_PREFIX+name, alias:name});
eval("var dto = new "+name+"();");
return dto;
},
setErrorHandler: function(errorHandler){
this.errorHandler = errorHandler;
DWREngine.setErrorHandler(errorHandler);
},
stopErrorHandler: function(){
DWREngine.setErrorHandler(null);
},
startErrorHandler: function(){
DWREngine.setErrorHandler(this.errorHandler);
},
getErrorHandler: function(){
return this.errorHandler;
},
setPreHook: function(ftn){
DWREngine.setPreHook(ftn);
},
setPostHook: function(ftn){
DWREngine.setPostHook(ftn);
},
stopWarningHandler: function(){
DWREngine.setWarningHandler(null);
},
startWarningHandler: function(){
DWREngine.setWarningHandler(this.warningHandler);
},
setWarningHandler: function(warningHandler){
this.warningHandler = warningHandler;
DWREngine.setWarningHandler(warningHandler);
},
getWarningHandler: function(){
return this.warningHandler;
},
setOrdered: function(isOrdered){
DWREngine.setOrdered(isOrdered);
},
stopLastRequest: function(){
DWREngine.stopLastRequest();
},
setAsync: function(isAsync){
DWREngine.setAsync(isAsync);
},
useLoadingMessage: function (message) {
var loadingMessage;
if (message) loadingMessage = message;
else loadingMessage = "Loading..";
DWREngine.setPreHook(function() {
var disabledZone = $('disabledZone');
if (!disabledZone) {
disabledZone = document.createElement('div');
disabledZone.setAttribute('id', 'disabledZone');
disabledZone.style.position = "absolute";
disabledZone.style.zIndex = "1000";
disabledZone.style.left = "0px";
disabledZone.style.top = "0px";
disabledZone.style.width = "100%";
disabledZone.style.height = "100%";
document.body.appendChild(disabledZone);
var messageZone = document.createElement('div');
messageZone.setAttribute('id', 'messageZone');
messageZone.style.position = "absolute";
messageZone.style.top = "0px";
messageZone.style.right = "0px";
messageZone.style.padding = "4px";
messageZone.innerHTML = '<img src="http://piece-dev.daum.net/swift-static/images/loading-w.gif" />';
disabledZone.appendChild(messageZone);
}
else {
disabledZone.style.visibility = 'visible';
}
});
DWREngine.setPostHook(function() {
$('disabledZone').style.visibility = 'hidden';
});
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.select) window.daum.widget.select = new Object();
daum.widget.Util = {
cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop  || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return [valueL, valueT];
},
foreach: function(obj, func) {
for (var i=0; i<obj.length; i++) {
func(i, obj[i]);
}
},
foreach_reverse: function(obj, func) {
var i=obj.length;
while (--i >= 0) {
func(i, obj[i]);
}
},
empty: function(node) {
while ( node.firstChild )
node.removeChild( node.firstChild );
return node;
}
};
daum.widget.select.SelectView = daum.create();
daum.widget.select.SelectView.prototype = {
type : 'daum.widget.select.SelectView',
initialize: function(handler) {
if(arguments.length == 0) return;
this.handler = handler;
this.optionContainer = document.getElementById(this.handler.model.id);
this.optionContainer.className = this.handler.settings["className"];
this.optionClassName = this.handler.settings["optionClassName"];
this.optionContainer.style.position= "relative";
},
draw: function(){
this.drawOptions();
},
createDiv: function(o){
var t = document.createElement("div");
t.style.position = 'relative';
var s = document.createElement("span");
t.appendChild(s);
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.width = "100%";
div.style.height = "100%";
div.style.top = "0px";
div.style.left = "0px";
div.style.border = '0px solid red';
div.style.filter = "alpha(opacity=0)";
div.style.opacity = "0.00";
div.style.backgroundColor = 'yellow';
t.appendChild(div);
o.div = t;
t.o = o;
this.optionContainer.insertBefore(t, this.handler.internalSelect);
},
drawOption: function(index, o){
var div = o.div;
div.setAttribute('value', o[1]);
div.className = this.optionClassName;
div.firstChild.innerHTML = o[0];
if(this.dropDownBox){
div.style.width = this.dropDownBox.clientWidth -2;
}
if (o[2]) {
if(this.handler.model.multiple) {
div.className = this.optionClassName+"-selected";
}else if (!this.handler.model.multiple && index != this.handler.selectedIndex()) {
div.className = this.optionClassName;
this.handler.__optionDeselected(div.o);
}else if (this.handler.selectedIndex() == index && !this.handler.model.multiple)	{
div.className = this.optionClassName+"-selected";
}
}
return div;
},
registEvent: function(div){
daum.dom.Event.observe(div, "mouseover", this.handler.mouseOver.bindContext(this.handler));
daum.dom.Event.observe(div, "mouseout", this.handler.mouseOut.bindContext(this.handler));
daum.dom.Event.observe(div, "mousedown", this.handler.mouseDown.bindContext(this.handler));
daum.dom.Event.observe(div, "mouseup", this.handler.mouseUp.bindContext(this.handler));
},
drawOptions: function(){
var options = this.handler.model["options"];
for(var i = 0; i < options.length; i++){
var o = options[i];
this.createDiv(o);
var d = this.drawOption(i, o);
this.registEvent(d);
}
},
__drawBlocker: function(){
var blocker = document.createElement("div");
blocker.className= this.handler.settings["blockerClassName"];
this.optionContainer.appendChild(blocker);
if(this.handler.model.disabled){
blocker.style.visibility = "visible";
}else{
blocker.style.visibility = "hidden";
}
},
empty: daum.widget.Util.empty
};
daum.widget.select.Select = daum.create();
daum.widget.select.Select.prototype = {
type : 'daum.widget.select.Select',
initialize: function(id, model, settings) {
if(arguments.length == 0) return;
this.model = this.createModel(id, model);
this.settings = {
className: "SpwSelect",
optionClassName: "SpwOption",
blockerClassName: "SpwSelectBlocker"
}
Object.extend(this.settings, settings || {});
this.optionClassName = this.settings["optionClassName"];
this.view = new daum.widget.select.SelectView(this);
this.__createInternalSelect(id);
this.view.draw();
},
createModel: function(id, model) {
var m = {
id: id,
name: undefined,
disabled:  false,
multiple: true,
options : [],
listeners: {}
}
Object.extend(m, model || {});
return m;
},
fireEvent: function(type) {
var f=this.model.listeners[type];
if(f)
f();
},
__optionDeselected: function(option){
option[2] = false;
},
__optionSelected: function(option){
option[2] = true;
},
selectOption: function(optionIndex){
var option = this.model.options[optionIndex];
if(!option[2])
this.__changeOptionClass(option.div);
},
deselectOption: function(optionIndex){
var option = this.model.options[optionIndex];
if(option[2])
this.__changeOptionClass(option.div);
},
__changeOptionClass: function(div){
if(this.model.multiple){
if (div.className == this.optionClassName+'-selected'){
div.className = this.optionClassName+"-activated";
this.__optionDeselected(div.o);
}else{
div.className = this.optionClassName+"-selected";
this.__optionSelected(div.o);
}
}else{
if (div.className == this.optionClassName+'-selected'){
div.className = this.optionClassName;
this.__optionDeselected(div.o);
}else{
var divs = this.view.optionContainer.childNodes;
for(var i = 0; i < divs.length; i++){
if(divs[i].o){
divs[i].className = this.optionClassName;
this.__optionDeselected(divs[i].o);
}
}
div.className = this.optionClassName+"-selected";
this.__optionSelected(div.o);
}
}
},
__createInternalSelect: function(id){
var sel = this.internalSelect = document.createElement("select");
sel.setAttribute('id', this.model.name+"_id");
sel.setAttribute('name', this.model.name);
sel.setAttribute('size', '10');
sel.setAttribute('multiple', 'multiple');
sel.multiple = true;
sel.style.position = "absolute";
sel.style.left = "-2000px";
sel.style.top = "-2000px";
document.getElementById(id).appendChild(sel);
},
getSelectedOptionCnt: function() {
var cnt = 0;
for (var i=0; i<this.model.options.length; i++) {
var o = this.model.options[i];
if(o[2]) {
cnt++;
}
}
return cnt;
},
selectedIndex: function() {
for (var i=0; i<this.model.options.length; i++) {
var o = this.model.options[i];
if(o[2]) {
return i;
}
}
return -1;
},
addOption: function(aOption) {
var length = this.model.options.push(aOption);
this.view.createDiv(aOption);
var d = this.view.drawOption(length-1, aOption);
this.view.registEvent(d);
this.__updateOptionInInternalSelect();
},
getOption: function(index) {
var o = this.model.options[index];
return [o[0], o[1], o[2], o.div];
},
getOptionSize: function() {
return this.model.options.length;
},
updateOption: function(index, option) {
var div = this.model.options[index].div;
this.model.options[index] = option;
div.o = this.model.options[index];
this.model.options[index].div = div;
this.view.drawOption(index, this.model.options[index]);
this.__updateOptionInInternalSelect();
},
multiple: function(flag){
return this.model.multiple = flag;
},
serialize: function() {
var length = this.model.options.length-1;
var str = '{ id: "'+this.model.id +'", \n';
str += 'name: "'+ this.model.name +'", \n';
str += 'disabled: '+ this.model.disabled +', \n';
str += 'multiple: '+ this.model.multiple +', \n';
str += 'options: [';
this.__foreach(this.model.options, function(i, o){
str += '[' + o[0] + ', ' + o[1] + ', '+ o[2] + ']';
if( i != length ) str +=',\n';
});
str += '] }'
return str;
},
__updateOptionInInternalSelect: function(){
var iSel = this.__empty(this.internalSelect);
this.__foreach(this.model.options, function(i, o) {
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(o[0]));
opt.setAttribute('value', o[1]);
if(o[2]) {
opt.setAttribute('selected', 'selected');
}
iSel.appendChild(opt);
});
},
copy: function(toBox){
this.__foreach(this.model.options, function(i, o) {
if (o[2]) {
toBox.addOption([o[0],o[1]] );
}
})
},
remove: function(index){
var o = this.model.options.splice(index, 1);
var div = o[0].div;
div.o = null;
o[0].div = null;
this.view.optionContainer.removeChild(div);
this.__updateOptionInInternalSelect();
},
moveSelectedOptionTo: function(toBox){
var self = this;
var to_be_removed = [];
this.__foreach_reverse(this.model.options, function(i, o) {
if (o[2]) {
self.remove(i);
toBox.addOption([o[0],o[1]]);
}
})
},
addEventListener: function(type, func, useCapture) {
this.model.listeners[type] = func.bindContext(this);
},
mouseOver: function(ev) {
var div = daum.dom.Event.element(ev).parentNode;
if(div.className.substr(0, this.optionClassName.length) == this.optionClassName){
if (div.className != this.optionClassName+'-selected'){
div.className = this.optionClassName+"-activated"
}
}
},
mouseOut: function(ev) {
var div = daum.dom.Event.element(ev).parentNode;
if(div.className.substr(0, this.optionClassName.length) == this.optionClassName){
if (div.className != this.optionClassName+'-selected'){
div.className = this.optionClassName;
}
}
},
mouseDown: function(ev) {
this.__execMouseDown(ev);
},
__onLeftClickWithCtrl: function(ev){
var div = daum.dom.Event.element(ev).parentNode;
if(this.model.multiple){
if (div.className == this.optionClassName+'-selected'){
div.className = this.optionClassName+"-activated";
this.__optionDeselected(div.o);
}else{
div.className = this.optionClassName+"-selected";
this.__optionSelected(div.o);
}
}else{
var divs = this.view.optionContainer.childNodes;
for(var i = 0; i < divs.length; i++){
if(divs[i].o){
divs[i].className = this.optionClassName;
this.__optionDeselected(divs[i].o);
}
}
div.className = this.optionClassName+"-selected";
this.__optionSelected(div.o);
}
},
__onLeftClick: function(ev){
var div = daum.dom.Event.element(ev).parentNode;
var divs = this.view.optionContainer.childNodes;
for(var i = 0; i < divs.length; i++){
if(divs[i].o){
divs[i].className = this.optionClassName;
this.__optionDeselected(divs[i].o);
}
}
div.className = this.optionClassName+"-selected";
this.__optionSelected(div.o);
},
__execMouseDown: function(ev){
var div = daum.dom.Event.element(ev).parentNode;
if(div.className.substr(0, this.optionClassName.length) == this.optionClassName){
if(daum.dom.Event.isLeftClick(ev)){
this.__onLeftClick(ev);
}else if(daum.dom.Event.isLeftClickWithCtrl(ev)){
this.__onLeftClickWithCtrl(ev);
}
this.__updateOptionInInternalSelect();
this.fireEvent('change');
}
},
mouseUp: function(ev) {
},
__foreach: daum.widget.Util.foreach,
__foreach_reverse: daum.widget.Util.foreach_reverse,
__empty: daum.widget.Util.empty
};
daum.widget.select.DropDownBoxView = daum.create();
daum.extend(daum.widget.select.DropDownBoxView.prototype = {
type : 'daum.widget.select.DropDownBoxView',
initialize: function(handler) {
this.handler = handler;
this.optionClassName = this.handler.settings["optionClassName"]
},
draw: function(){
this.drawOptions();
this.__setOption();
},
__setOption: function(){
if(this.handler.selectedIndex()==-1){
var div = this.optionContainer.firstChild;
if(div){
this.textField.innerHTML = div.o[1];
this.handler.__optionSelected(div.o);
}
}else{
var div = this.handler.model.options[this.handler.selectedIndex()].div;
this.textField.innerHTML = div.o[1];
this.handler.__optionSelected(div.o);
}
},
drawBox: function(){
this.dropDownBox = document.getElementById(this.handler.model.id);
this.dropDownBox.className = this.handler.settings["className"];
var dropDownArrow = document.createElement('div');
dropDownArrow.setAttribute('id', this.handler.model.id+'DropDownArrow');
dropDownArrow.className = this.handler.settings["arrowClassName"];
dropDownArrow.innerHTML = '>';
dropDownArrow.style.height = this.dropDownBox.clientHeight + 'px';
dropDownArrow.style.width = this.dropDownBox.clientHeight + 'px';
this.dropDownBox.appendChild(dropDownArrow);
this.textField = document.createElement('div');
this.textField.setAttribute('id', this.handler.model.id+'DropDownBoxTxt');
this.dropDownBox.appendChild(this.textField);
daum.dom.Event.observe(this.dropDownBox, "mousedown", this.togglePopup.bindContext(this));
},
drawPopup: function(){
var popup = this.optionContainer = document.createElement("div");
popup.id = this.handler.model.id+"_popup";
popup.className = this.handler.settings["popUpClassName"]
popup.style.left = '-1000px';
popup.style.top =  '-1000px';
popup.style.width = this.dropDownBox.clientWidth + 'px';
document.getElementById(this.handler.model.id).parentNode.appendChild(this.optionContainer);
},
togglePopup: function(){
if(this.optionContainer.style.display == "block"){
this.hidePopup();
}else{
this.showPopup();
}
},
showPopup: function(){
var pos = daum.widget.Util.cumulativeOffset(this.dropDownBox);
this.optionContainer.style.left = pos[0] + 'px';
this.optionContainer.style.top = pos[1] + this.dropDownBox.offsetHeight + 'px';
this.optionContainer.style.width = this.dropDownBox.clientWidth + 'px';
this.optionContainer.style.display = "block";
},
hidePopup: function(){
this.optionContainer.style.display = "none";
}
}, daum.widget.select.SelectView.prototype);
daum.widget.select.DropDownBox = daum.create();
daum.extend(daum.widget.select.DropDownBox.prototype = {
type : 'daum.widget.select.DropDownBox',
createModel: function(id, model) {
model['multiple'] = false;
var m = {
id: id,
name: undefined,
disabled:  false,
multiple: false,
options : [],
listeners: {}
}
Object.extend(m, model || {});
return m;
},
initialize: function(id, model, settings) {
this.model = this.createModel(id, model);
this.settings = {
className: "SpwDropDownBox",
popUpClassName: "SpwDropDownPopup",
arrowClassName: "SpwDrowDownArrow",
optionClassName: "SpwOption",
blockerClassName: "SpwSelectBlocker"
}
daum.extend(this.settings, settings || {});
this.optionClassName = this.settings["optionClassName"];
this.view = new daum.widget.select.DropDownBoxView(this);
this.view.drawBox();
this.view.drawPopup();
this.__createInternalSelect(id+'_popup');
this.view.draw();
},
addOption: function(aOption) {
this.__super.addOption(aOption);
this.view.__setOption();
},
mouseDown: function(ev) {
this.__execMouseDown(ev);
},
__execMouseDown: function(ev){
this.__onLeftClick(ev);
this.__updateOptionInInternalSelect();
this.fireEvent('change');
},
__onLeftClick: function(ev){
if(daum.dom.Event.isLeftClick(ev)){
var div = daum.dom.Event.element(ev).parentNode;
var divs = this.view.optionContainer.childNodes;
for(var i = 0; i < divs.length; i++){
if(divs[i].o){
divs[i].className = this.optionClassName;
this.__optionDeselected(divs[i].o);
}
}
div.className = this.optionClassName+"-selected";
this.__optionSelected(div.o);
this.view.textField.innerHTML = div.o[1];
}
},
mouseUp: function(ev) {
this.view.hidePopup();
}
}, daum.widget.select.Select.prototype);
if(!window.daum) window.daum = new Object();
if(!window.daum.thread) window.daum.thread = new Object();
daum.thread.COMMAND_ID = 1;
daum.thread.Command = daum.create();
daum.thread.Command.prototype = {
initialize: function(method){
this.id = daum.thread.COMMAND_ID++;
this.method = method;
daum.debug("initialize is called, id:"+this.id);
},
execute: function(){
this.method();
},
executeSync: function(){
new daum.thread.Mutex(this, "execute");
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.util) window.daum.util = new Object();
daum.util.StringBuffer = daum.create();
daum.util.StringBuffer.prototype = {
initialize: function(str){
this.box = [];
},
append: function(str){
this.box.push(str);
return this;
},
toString: function(){
return this.box.join('');
},
flush: function(){
var txt = this.toString();
this.box = null;
return txt;
}
}
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(!window.daum.widget.tree) window.daum.widget.tree = new Object();
daum.widget.tree.Tree = daum.create();
daum.widget.tree.Tree.prototype = {
type: 'daum.widget.tree.Tree',
treeNodes : null,
initialize: function (element, options) {
this.options = {
addTreeNodeEventHandler: null,
selectTreeNodeEventHandler: null,
mouseOverColor : 'white',
mouseOverBackgroundColor : 'mediumpurple' ,
iconUrl : '/sparrow/images/tree/file.gif' ,
textCss : 'channelText',
visible : true,
listCss : 'channelCategoryList'
}
Object.extend(this.options, options || {});
this.root = document.getElementById(element);
this.treeNodes = new Array();
this.eventMouseClick = this._mouseClick.bindContext(this);
Event.observe(this.root, 'click', this.eventMouseClick);
},
addTreeNode: function (parentTreeNode, nodeText, nodeId, options, value) {
var allOptions = {};
Object.extend(allOptions, this.options || {});
Object.extend(allOptions, options || {});
var parentListNode = (parentTreeNode == null) ? this.root : parentTreeNode.listNode;
var treeNode = new daum.widget.tree.TreeNode(parentListNode, this.root.id, nodeText, nodeId, allOptions, value);
this.treeNodes.push(treeNode);
if (this.options.addTreeNodeEventHandler != null) {
this.options.addTreeNodeEventHandler(this);
}
return treeNode;
},
_removeTreeNode: function (targetTreeNode) {
if (targetTreeNode) {
this.treeNodes = this.treeNodes.reject(function (treeNode) {
return (treeNode.textNode.id == targetTreeNode.textNode.id);
});
targetTreeNode.remove();
}
},
removeTreeNodeByTextNodeId: function (id) {
this._removeTreeNode(this._getTreeNodeByTextNodeId(id));
},
removeTreeNodeById: function (id) {
this._removeTreeNode(this._getTreeNodeById(id));
},
_renameTreeNode: function (targetTreeNode, name) {
if (targetTreeNode) {
targetTreeNode.rename(name);
}
},
renameTreeNodeById: function (name, id) {
this._renameTreeNode(this._getTreeNodeById(id), name);
},
renameTreeNodeByTextNodeId: function (name, id) {
this._renameTreeNode(this._getTreeNodeByTextNodeId(id), name);
},
addLineNode: function () {
var line = document.createElement('div');
if (this.options.lineCss) {
line.className = this.options.lineCss;
} else {
line.style.backgroundColor = 'gray';
line.style.margin = '5px 0px 5px 0px';
line.style.height = '1px';
line.style.overflow = 'hidden';
}
this.root.appendChild(line);
},
_mouseClick: function (event) {
var treeNode = this._getTreeNodeByTextNodeId(daum.dom.Event.element(event).id);
if (treeNode) {
treeNode.toggle();
if (treeNode.listNode.hasChildNodes() == false && this.options.selectTreeNodeEventHandler != null) {
this.options.selectTreeNodeEventHandler.bindContext(treeNode)(event);
}
}
},
_getTreeNodeById: function (id) {
return this._getTreeNodeByTextNodeId(this.root.id + '_Text_' + id);
},
getTreeNodeById: daum.widget.tree.Tree.prototype._getTreeNodeById,
_getTreeNodeByTextNodeId: function (id) {
var treeNode = this.treeNodes.find(function (treeNode) {
return (treeNode.textNode.id == id);
});
return treeNode;
}
};
if(!window.daum) window.daum = new Object();
if(!window.daum.widget) window.daum.widget = new Object();
if(daum == undefined)
daum = [];
daum.Widget = function(a, c){
if ( window == this || daum == this ){
return new daum.Widget(a,c);
}
a = a || document;
if(typeof a == 'string'){
return new daum.Widget(c).find(a);
}
return this.setArray([ a ]);
}
if ( typeof $sw != "undefined" ){
daum.Widget._$sw = $sw;
}
window.$sw = daum.Widget;
daum.Widget.fn = daum.Widget.prototype = {
constructor: daum.Widget,
setArray: function( a ) {
this.length = 0;
[].push.apply( this, a );
return this;
},
find: function(t){
var r;
if(t[0]=='#' || t.substr(0,1) =='#'){
t = t.substr(1,t.length-1);
r = document.getElementById(t);
}
return this.setArray([r]);
},
each: function( fn, args ) {
return daum.Widget.each( this, fn, args );
},
html: function(){
this.each(function(arg){
this.innerHTML = arg[0];
}, [arguments]);
return this;
},
children: function(){
var c = [];
this.each(function(arg){
var n = this.childNodes;
for(var i = 0; i  < n.length; i++){
if(n[i].tagName)
c.push(n[i]);
}
});
return this.setArray(c);
}
}
daum.Widget.extend = daum.Widget.fn.extend = function() {
var target = arguments[0], a = 1;
if ( arguments.length == 1 ) {
target = this;
a = 0;
}else{
target = arguments[0], a = 1;
}
var prop;
while (prop = arguments[a++]){
for ( var i in prop ) target[i] = prop[i];
}
return target;
};
daum.Widget.extend({
noConflict: function() {
if ( daum.Widget._$sw ){
$sw = daum.Widget._$sw;
}
return daum.Widget;
},
find: function(a,c){
if(a[0]=='#'){
a = a.substr(1,a.length-1);
}
},
each: function( obj, fn, args ) {
if ( obj.length == undefined ){
for ( var i in obj ){
fn.apply( obj[i], args || [i, obj[i]] );
}
}else{
for ( var i = 0, ol = obj.length; i < ol; i++ ){
if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
}
}
return obj;
}
});
daum.Widget._dnd = {
draggable: function(){
if(!daum.dnd || !daum.dnd.DragObj){
}
this.each( function(args){
var t = new daum.dnd.DragObj(this.id, args);
this.draggable = true;
this.dragObject = t;
t.domObject = this;
},
[arguments[0]]
)
return this;
}
}
daum.Widget.fn.extend(daum.Widget._dnd);
daum.Widget._split = {
splitPane: function(){
if(!daum.widget || !daum.widget.split){
}
this.splitBar = [];
var c = this.children();
if(c.length > 1){
for(var i = 0; i < c.length - 1; i++){
var front = c[i].id;
var rear = c[i+1].id;
this.splitBar[i] = new daum.widget.split.Split(front, rear,arguments[0]);
}
}
return this;
}
}
daum.Widget.fn.extend(daum.Widget._split);
daum.Widget.fn.extend({
tree: function(){
if(!daum.widget || !daum.widget.tree){
}
if(arguments.length = 1){
var t = new daum.widget.tree.Tree(this[0].id, arguments[0]);
this.treeObject = t;
return this;
}
},
branch: function(){
var treeObject = this.treeObject;
var _parent = this.parent ? this[0] : null;
if(arguments.length == 0){
return treeObject.treeNodes;
}else if(arguments.length == 1 && typeof arguments[0] == 'string'){
return treeObject._getTreeNodeById(arguments[0]);
}else if(arguments.length == 1){
var n = arguments[0];
var b = treeObject.addTreeNode(_parent, n[1], n[0],  n[3], n[2]);
var w = daum.Widget(b);
w.treeObject = this.treeObject;
w.parent = this[0];
return w;
}else if(arguments.length > 1){
for(var i = 0; i < arguments.length; i++){
var n = arguments[i];
var b = treeObject.addTreeNode(_parent, n[1], n[0],  n[3], n[2]);
var w = daum.Widget(b)
w.treeObject = this.treeObject;
w.parent = this[0];
}
}
}
});
daum.Widget.fn.extend({
tabContainer: function(){
if(!daum.widget || !daum.widget.tab)
daum.include( "daum.widget.tab.TabPaneContainer");
this.each(function(args){
var t = new daum.widget.tab.TabPaneContainer(this.id , args);
this.tabObject = t;
}, arguments );
if(this.length == 1){
return this[0].tabObject;
}else{
return this;
}
}
});
daum.Widget.fn.extend({
button: function(){
if(!daum.widget || !daum.widget.button) {
daum.include( "daum.widget.button.Button");
}
this.each(function(args){
var t = new daum.widget.button.Button(this.id , args);
this.btnObject = t;
}, [arguments[0]] );
if(this.length == 1){
return this[0].btnObject;
}else{
return this;
}
}
});
daum.Widget.fn.extend({
panel: function(){
if(!daum.widget || !daum.widget.panel){
daum.include( "daum.widget.panel.Panel");
}
this.each(function(args){
var t = new daum.widget.panel.Panel(this.id , args);
this.panelObject = t;
}, [arguments[0]] );
if(this.length == 1){
return this[0].panelObject;
}else{
return this;
}
}
});
daum.Widget.fn.extend({
comboBox: function(){
if(!daum.widget || !daum.widget.select){
daum.include( "daum.widget.select.Select");
}
this.each(function(args){
var t = new daum.widget.select.Select(this.id , args[0], args[1]);
this.selectorObject = t;
}, arguments );
if(this.length == 1){
return this[0].selectorObject;
}else{
return this;
}
}
});
daum.Widget.fn.extend({
dropdownBox: function(){
if(!daum.widget || !daum.widget.select){
daum.include( "daum.widget.select.Select");
}
this.each(function(args){
var t = new daum.widget.select.DropDownBox(this.id , args[0], args[1]);
this.dropdownBoxObject = t;
}, arguments );
if(this.length == 1){
return this[0].dropdownBoxObject;
}else{
return this;
}
}
});
