"use strict"; var popup_open_failed = null; function popup_open(url,ctrl) { if ( typeof($GLOBALS["popup"]) == "undefined" ) { $GLOBALS["popup"] = new Array(); } if ( typeof($GLOBALS["zmax"]) == "undefined" ) { $GLOBALS["zmax"] = 1; } var p = $GLOBALS["popup"].length; if ( typeof(url) == "undefined") { var erg = new _P_popup(p); $GLOBALS["popup"][p] = erg; erg.init(); return erg; } else if ( typeof(ctrl) == "undefined" ) { var erg = new _P_popup(p); $GLOBALS["popup"][p] = erg; if ( typeof(url) == "string" ) { erg.init({url:url}); } else if ( typeof(url) == "object" ) { erg.init(url); } return erg; } else { if ( ctrl == "fail" ) { var erg = $GLOBALS["popup"][url]; if ( erg ) { erg.display("fail"); popup_open_failed = null; } } } return erg; } function popup_close(obj,ctrl) { if ( typeof(obj) == "object" ) { if ( typeof(ctrl) != "undefined") { var nr = popup_control(obj,true); window.setTimeout("popup_close("+nr+")",ctrl); } else { var erg = popup_control(obj); erg.close(); } } else { if ( $GLOBALS["popup"][obj] ) { if ( typeof(ctrl) != "undefined") { window.setTimeout("popup_close("+obj+")",ctrl); } else { $GLOBALS["popup"][obj].close(); } } } } function popup_delete(e) { if ($GLOBALS["popup"].length > 0) { for ( var i=0; i < $GLOBALS["popup"].length; i++ ) { if ( $GLOBALS["popup"][i] == e ) { $GLOBALS["popup"][i] = null; $GLOBALS["popup"].splice(i,1); break; } } } } function popup_control(e,ctrl) { if ( typeof(e) == "object" ) { if ( e.name ) { var a = e.name.split("_"); if ( a[0] == "iframe" ) { var nr = a[1]; if ( $GLOBALS["popup"][nr] ) { $GLOBALS["popup"][nr].window(e); if ( typeof(ctrl) == "undefined" ) { return $GLOBALS["popup"][nr]; } else if ( typeof(ctrl) == "boolean" ) { return nr; } else if ( typeof(ctrl) == "object" ) { var val = ctrl; var obj = $GLOBALS["popup"][nr]; for ( var key in val ) { obj[key]( val[key] ); } return $GLOBALS["popup"][nr]; } } } return null; } else { var div = e; while ( div.tagName != "HTML" ) { if ( div.name && div.name.indexOf("_") > 0 ) { var a = div.name.split("_"); if ( a[0] == "popup" ) { return $GLOBALS["popup"][a[1]]; } } do { div = div.parentNode; if (typeof(div.tagName) != "undefined") { } } while ( typeof(div.tagName) == "undefined" ); if ( div.tagName == "HTML" ) break; } } } } var set_focus; function popup_message(obj) { if (typeof(obj.nr) == "function") { var n = obj.nr(); popup_close(n); return false; } var params = {}; var ctrl, txt, data; set_focus = false; var defaults = { exclusive:true, position:"fixed", boxClassName:"alertbox", titleClassName:false, contentsClassName:"alertcontents", resizable:false, inhibitClassName:null, info:null, ctrl:null, message:null, debug:null }; for ( var param in defaults ) { params[param] = (typeof(obj[param]) != "undefined") ? obj[param] : defaults[param]; } params["clip"] = false; var p_message = popup_open(params); p_message.debug(); var tr_ctrl = document.createElement("tr"); var cols = (params["ctrl"] instanceof Array) ? params["ctrl"].length:0; var nr = p_message.nr(); if (params["ctrl"] !== null) { if (cols == 0) { ctrl = new Array(obj.ctrl); cols = 1; } else { ctrl = obj.ctrl; } for (var i=0; i 0) { var cN = className.split(" "); for (var j=0; j= 0) { txt = params.message.split(" "); rows = txt.length; } else { txt = new Array(params.message); rows = 1; } } else { txt = params.message; } for (var i=0; i 1) { td.colSpan = cols; } if (typeof (txt[i]) == "object") { if (txt[i].text) { t = txt[i].text; if (txt[i].style) { var s = txt[i].style; for (var j in s) { td.style[j] = s[j]; } } } if (txt[i].id) { td.id = txt[i].id; } if (txt[i].className) { td.className = txt[i].className; } if (txt[i].onclick) { td.onclick = new Function(txt[i].onclick); } } else { t = (txt[i] != " ") ? txt[i] : "\u00a0"; } clip += t + "\n"; var text = document.createTextNode(t); td.appendChild(text); tr.appendChild(td); tbody.appendChild(tr); } var tr = document.createElement("tr"); var td = document.createElement("td"); td.style.height = "0.5em"; if (cols > 1) { td.colSpan = cols; } if (params["clip"]) { var cp_div = document.createElement("div"); cp_div.style.height = "1px"; cp_div.style.overflow = "hidden"; var cp_area = document.createElement("textarea"); cp_area.id = "p_message_"+nr; cp_area.value = clip; cp_area.style.width = "100px"; cp_area.style.height = "100px"; cp_div.appendChild(cp_area); td.appendChild(cp_div); } tr.appendChild(td); tbody.appendChild(tr); tbody.appendChild(tr_ctrl); p_message.display(); if (obj.timeout) { var nr = p_message.nr(); popup_close(nr,obj.timeout); } if (set_focus) { set_focus.addEventListener("keydown",function(e) { var evt = (e) ? e : window.event; if (evt.keyCode == 13 || evt.keyCode == 27) { var nr = p_message.nr(); popup_close(nr); } },false); set_focus.focus(); } return p_message; } function _P_popup(p) { var $ = {}; $.box = null; $.title = null; $.close = null; $.contents = null; $.overlay = null; $.rightBorder = null; $.bottomBorder = null; $.rbBorder = null; $.brBorder = null; $.iframe = false; $.window = null; $.inhibit = null; $.ddw = ddw; var _ = []; var my = null; var params = {}; var listener = {}; _.nr = p; _.resize = null; _.offsX = 0; _.offsY = 0; _.cursor = "default"; _.closed = null; _.barX = 0; _.scrollY = null; _.mousedown = false; var popup_open_failed = null; this._P_resize_X_callback = function(evt) { var my_event = ( evt ) ? evt : window.event; if (my_event.type == "scroll") { if (_.scrollX !== null) { var y = window.scrollY; window.scrollTo(_.xscrollX,y); if ( my_event.preventDefault ) my_event.preventDefault(); return; } } if ( params["left"] == "center" ) { my.left("center"); } if ( $.inhibit !== null ) { } }; this._P_resize_Y_callback = function(evt) { var my_event = ( evt ) ? evt : window.event; if (my_event.type == "scroll") { if (_.scrollY !== null) { var x = window.scrollX; window.scrollTo(x,_.scrollY); if ( my_event.preventDefault ) my_event.preventDefault(); return; } } if ( params["top"] == "middle" ) { my.top("middle"); } }; this._P_none = function(evt) { var my_event = ( evt ) ? evt : window.event; if ( my_event.preventDefault ) my_event.preventDefault(); my_event.stopPropagation(); }; this._P_identTarget = function(obj) { for (var divs in $) { if ($[divs] == obj) { return divs; } } if (obj.id) { return obj.id; } else if (obj.name) { return obj.name; } else { return "not identified"; } }; this._P_click_callback = function(evt) { var my_event = ( evt ) ? evt : window.event; if ( my_event.preventDefault ) my_event.preventDefault(); my_event.stopPropagation(); if ( my_event.type == "click" ) { my.close(); } }; this._P_mousemove_callback = function (evt) { var my_event = ( evt ) ? evt : window.event; var obj = my_event.target; var my_target = my._P_identTarget(obj); if (!_.mousedown) return false; var x = my_event.pageX - _.offsX; var y = my_event.pageY - _.offsY; if ( _.resize == 0 ) { $.box.style.left = x + "px"; params["left"] = x; if ( y > 0 ) { $.box.style.top = y + "px"; params["top"] = y; } if ( my_target == "overlay" ) { if ( _.cursor != "move" ) { _.cursor = "move"; obj.style.cursor = "move"; } } } else { if ( ( _.resize & 1 ) == 1 ) { var width = parseInt($.box.style.width,10) + x; if ( width > 100 ) { _.offsX += x; my.width(width,false); if ($.window == null) { $.overlay.style.width = (width+30) + "px"; } } } if ( ( _.resize & 2 ) == 2 ) { var height = parseInt($.box.style.height,10) + parseInt(y); if ( height > 100 ) { _.offsY += y; my.height(height,false); if ($.window === null) { $.overlay.style.height = (height+30) + "px"; } } } } if ( my_event.preventDefault ) my_event.preventDefault(); if ( my_event.stopPropagation ) my_event.stopPropagation(); my_event.returnValue = false; }; this._P_mouseout_callback = function (evt) { var my_event = ( evt ) ? evt : window.event; var obj = my_event.target; var my_target = my._P_identTarget(obj); if ( my_target == "overlay" ) { my._P_mouseup_callback(my_event); } }; this._P_mouseup_callback = function (evt) { var my_event = ( evt ) ? evt : window.event; var obj = my_event.target; var my_target = my._P_identTarget(obj); if ( my_event.preventDefault ) my_event.preventDefault(); my_event.returnValue = false; my_event.stopPropagation(); _.mousedown = false; if ( my_target == "overlay" ) { my._P_deleteEventListener($.overlay,"mousemove",my._P_mousemove_callback,"overlay"); my._P_deleteEventListener($.overlay,"mouseover",my.mouseover_callback,"overlay"); my._P_deleteEventListener($.overlay,"mouseup",my._P_mouseup_callback,"overlay"); if ($.window != null) { document.body.removeChild(obj); } else { $.box.removeChild(obj); } } }; this._P_mousedown_callback = function (evt) { var my_event = ( evt ) ? evt : window.event; var obj = my_event.target; var my_target = my._P_identTarget(obj); console.log("target: "+my_target ); if (my_target == "not identified") return false; $.overlay = document.createElement("div"); $.overlay.style.position = "absolute"; $.overlay.style.top = 0; $.overlay.style.left = 0; $.overlay.style.bottom = 0; $.overlay.style.right = 0; $.overlay.style.backgroundColor = "rgb(0,0,0)"; $.overlay.style.opacity = "0.1"; $.overlay.style.zIndex = (parseInt(params["zindex"]) +2+ (_.nr * 3)); $.overlay.id = "resizeoverlay"; _.mousedown = true; if ( $.window !== null ) { document.body.appendChild($.overlay); } else { $.overlay.style.left = "-20px"; $.overlay.style.width = (parseInt($.box.style.width) + 40) + "px"; $.overlay.style.top = "-20px"; $.overlay.style.height = (parseInt($.box.style.height) + 40) + "px"; $.box.appendChild($.overlay); } my._P_installEventListener($.overlay,"mousemove",my._P_mousemove_callback,"overlay"); my._P_installEventListener($.overlay,"mouseover",my.mouseover_callback,"overlay"); my._P_installEventListener($.overlay,"mouseup",my._P_mouseup_callback,"overlay"); my._P_installEventListener($.overlay,"mouseout",my._P_mouseout_callback,"overlay"); if ( my_event.preventDefault ) my_event.preventDefault(); if ( my_event.stopPropagation ) my_event.stopPropagation(); if (params["titleClassName"] !== false) { my_event.returnValue = false; if ( my_target == "title" ) { _.offsX = my_event.layerX; _.offsY = my_event.layerY; _.resize = 0; _.cursor = "move"; if (params["parent"] != document.body) { var e = params["parent"]; var X_add = e.offsetLeft; var Y_add = e.offsetTop; _.offsX += X_add; _.offsY += Y_add; } } else if ( my_target == "rightBorder" ) { _.offsX = my_event.pageX; _.resize = 1; _.cursor = "e-resize"; } else if ( my_target == "bottomBorder" ) { _.offsY = my_event.pageY; _.resize = 2; _.cursor = "n-resize"; } else if ( my_target == "rbBorder" || my_target == "brBorder" ) { _.offsX = my_event.pageX; _.offsY = my_event.pageY; _.resize = 3; _.cursor = "se-resize"; } else { _.cursor = "default"; } } else { return false; } $.overlay.style.cursor = _.cursor; }; this._P_onload = function() { if ( popup_open_failed != null ) { my.display("view"); } else { my.display(); } if (params["title"] == "") { var iframeId = "iframe_"+_.nr; try { if (window.frames && window.frames[iframeId]) { var t = window.frames[iframeId].document.title; my.title(t); } } catch(c) { } } }; this._P_installEventListener = function(obj,evt,fkt,nn) { var _id = ( obj.id ) ? obj.id + "[" + _.nr + "]" : nn + "[" + _.nr + "]"; if ( obj.addEventListener ) { obj.addEventListener (evt, fkt, false); } else if ( obj.attachEvent ) { obj.attachEvent( "on" + evt, fkt) } else { var ie4_evt = "on" + evt; obj[ie4_evt] = fkt; } if (typeof(listener[nn]) == "undefined") listener[nn] = {}; listener[nn][evt] = true; }; this._P_deleteEventListener = function(obj,evt,fkt,nn) { var _id = ( obj.id ) ? obj.id + "[" + _.nr + "]" : nn + "[" + _.nr + "]"; if ( obj.removeEventListener ) { obj.removeEventListener (evt, fkt, false); } else if (obj.detachEvent) { obj.detachEvent( "on"+evt, fkt) } try { listener[nn][evt] = false; } catch(e) { } }; this._P_compStyle = function(obj,ctrl) { if (window.getComputedStyle) { var s = window.getComputedStyle(obj); if (typeof(ctrl) != "undefined") { return (typeof(s[ctrl]) != "undefined") ? s[ctrl] : null; } else { return s; } } else if (obj.currentStyle) { var s = obj.currentStyle; return (typeof(s[ctrl]) != "undefined") ? s[ctrl] : null; } return false; }; this.debug = function(ctrl) { if (ctrl === true) { $.ddw = ddw; } else { $.ddw = false; } } this.nr = function() { return _.nr; }; this.getSize = function(obj,part) { var values = {top:0,left:0,bottom:0,right:0}; var size; if (obj.getBoundingClientRect) { size = obj.getBoundingClientRect(); } if (size) { for (var i in size) { values[i] = size[i]; } if (typeof(size.width) == "undefined") { values["width"] = values["right"] - values["left"]; values["height"] = values["bottom"] - values["top"]; } if (obj.scrollWidth) { values["scrollWidth"] = parseInt(obj.scrollWidth,10); values["scrollHeight"] = parseInt(obj.scrollHeight,10); } else { values["scrollWidth"] = values["width"]; values["scrollHeight"] = values["height"]; } if (values["width"] == 0) values["width"] = values["scrollWidth"]; if (values["height"] == 0) values["height"] = values["scrollHeight"]; if (typeof(part) == "undefined") { return values } else if (typeof(values[part]) != "undefined") { return values[part]; } } return false; }; this.position = function(ctrl) { if (typeof(ctrl) != "undefined" && ctrl == "fixed") { params["position"] = "fixed"; } else { params["position"] = "absolute"; } }; this.top = function(value) { var _shiftY = (params["parent"] == document.body) ? my.scroll_Y():0; if ( value == "middle" ) { var _top; if (params["parent"] == document.body) { _top = ( parseInt(window.innerHeight) - parseInt($.box.style.height,10) ) / 2; } else { _top = ( parseInt(params["parent"].clientHeight ) - parseInt($.box.style.height) ) / 2; } var real_top = Math.max( Math.floor(_top) + _shiftY, 0 ); $.box.style.top = ( real_top ) + "px"; if ( params["top"] != "middle" ) { my._P_installEventListener(window,"resize",my._P_resize_Y_callback,"window"); params["top"] = "middle"; } } else { if ( params["top"] == "middle" ) { my._P_deleteEventListener(window,"resize",my._P_resize_Y_callback,"window"); } var real_top = Math.max(value + _shiftY, 0); $.box.style.top = ( real_top ) + "px"; params["top"] = Math.max(value,0); } }; this.left = function(ctrl) { var _shiftX = (params["parent"] == document.body) ? my.scroll_X():0; if ( ctrl == "center" ) { var _left; if (params["parent"] == document.body) { _left = ( parseInt(window.innerWidth) - parseInt($.box.style.width) ) / 2; } else { _left = ( parseInt(params["parent"].clientWidth ) - parseInt($.box.style.width) ) / 2; } $.box.style.left = ( Math.floor(_left) + _shiftX ) + "px"; if ( params["left"] != "center" ) { my._P_installEventListener(window,"resize",my._P_resize_X_callback,"window"); params["left"] = "center"; } } else { if ( params["left"] == "center" ) { my._P_deleteEventListener(window,"resize",my._P_resize_X_callback,"window"); } $.box.style.left = ( ctrl + _shiftX ) + "px"; params["left"] = ctrl; } }; this.width = function(value,ctrl) { var needWidth = NaN; var maxWidth = window.innerWidth - 80; if ( value == "auto" ) { if ( $.window !== null ) { if ( typeof($.window.document.body.style) != "undefined" && typeof($.window.document.body.style.width) != "undefined" && $.window.document.body.style.width !== null ) { needWidth = parseInt($.window.document.body.style.width); } if (isNaN(needWidth)) { $.window.document.body.style.width="100px"; needWidth = $.window.document.body.scrollWidth; $.window.document.body.style.width = null; } var comp = my._P_compStyle($.window.document.body); if (comp) { var add = parseInt(comp.marginLeft) + parseInt(comp.marginRight) + 2; needWidth += add; } value = Math.min(needWidth,maxWidth); } else { var contents = $.contents.firstChild; if (contents) { var comp = my._P_compStyle(contents); needWidth = Math.round(parseFloat(comp.width)+0.5); value = Math.min(needWidth,maxWidth); } } } else if ( !isNaN(value) ) { value = Math.min(value,maxWidth); } if ( !isNaN(value) ) { if ( typeof(ctrl) == "undefined" || ctrl == true ) params["width"] = parseInt(value); $.box.style.width = value + "px"; $.title.style.width = value + "px"; $.contents.style.width = value + "px"; if ( $.iframe ) $.iframe.style.width = value + "px"; if ( params["left"] == "auto" ) { my.left("auto"); } if ( params["resizable"] === true ) { $.rightBorder.style.left = value + "px"; $.bottomBorder.style.width = ( value - 25 ) + "px"; $.rbBorder.style.left = value + "px"; $.brBorder.style.left = ( value - 25 ) + "px"; } else if (params["exit"] !== null) { $.title.style.width = (parseInt(params["exit"])+value) + "px"; } } else { } if ( $.window === null ) { this.overflowX(); this.overflowY(); } }; this.overflowX = function() { var box = this.getSize($.contents); if ($.iframe === false) { if ( box.scrollWidth > box.width ) { $.contents.style.overflowX = "scroll"; _.barX = 16; } else { $.contents.style.overflowX = "hidden"; _.barX = 0; } } else { $.contents.style.overflowX = "hidden"; } }; this.overflowY = function() { var box = this.getSize($.contents); var hh = box.height; if ($.iframe === false) { var h = box.scrollHeight + _.barX; if ((box.scrollHeight+_.barX) > box.height) { $.contents.style.overflowY = "scroll"; } else { $.contents.style.overflowY = "hidden"; } } else { $.contents.style.overflowY = "hidden"; var f = this.getSize($.iframe); var ih = f.height; } }; this.height = function(value,ctrl) { var maxHeight = window.innerHeight - 80; var needHeight; if ( value == "auto" ) { if ( $.window !== null ) { $.iframe.style.height = "100px"; needHeight = $.window.document.body.scrollHeight; var comp = my._P_compStyle($.window.document.body); if (comp) { var add = parseInt(comp.marginTop) + parseInt(comp.marginBottom) + 2; needHeight += add; } if ($GLOBALS["system_key"] == "pc") { value = Math.min(needHeight,maxHeight); } else { value = needHeight; } } else { var contents = $.contents.firstChild; if (contents) { var comp = my._P_compStyle(contents); /* anz=2 % 0 */ needHeight = Math.round(parseFloat(comp.height)+0.5) + params["titleHeight"]; value = Math.min(needHeight,maxHeight); } } } if ( !isNaN(value) ) { params["height"] = parseInt(value); var h_out, h_in; if ( typeof(ctrl) == "undefined" || ctrl === true ) { h_out = params["height"] + params["titleHeight"]; h_in = params["height"]; } else { h_out = params["height"]; h_in = params["height"] - params["titleHeight"]; } $.box.style.height = h_out + "px"; $.contents.style.height = h_in + "px"; if ( $.iframe ) $.iframe.style.height = h_in + "px"; if ( params["resizable"] == true ) { $.rightBorder.style.height = ( h_in - 25 ) + "px"; $.bottomBorder.style.top = h_out + "px"; $.rbBorder.style.top = h_in + "px"; $.brBorder.style.top = h_out + "px"; } } if ( $.window === null ) { this.overflowX(); this.overflowY(); } }; this.title = function(text) { while ( $.title.childNodes.length > 1 ) { $.title.removeChild($.title.lastChild); } if (params["title"] !== false) { var div = document.createElement("div"); div.style.display = "inline-block"; div.style.marginLeft = "3px"; $.title.appendChild(div); var $_text = document.createTextNode(String.fromCharCode(160,160)+text); div.appendChild($_text); } }; this.id = function(text) { $.box.id = text; }; this.opacity = function(value) { $.box.style.opacity = value; }; this.closed = function() { return _.closed; }; this.onclose = function(ctrl) { params['onclose'] = ctrl; }; this.close = function(ctrl) { if ( params['onclose'] !== null ) { if (typeof(params['onclose']) == "function") { var ok = params['onclose'](); if ( typeof(ok) == "boolean" ) { if ( ok == false ) return; params['onclose'] = null; } } else { alert("1433 : onclose()\n"+typeof(params['onclose'])+"\n"+params['onclose']); } } if (typeof(ctrl) == "integer") { if ( $GLOBALS["popup"][_.nr] ) { params['onclose'] = null; window.setTimeout("$GLOBALS[\"popup\"]["+_.nr+"].close();",ctrl); } } else { if ($.close !== null) { my._P_deleteEventListener($.close,"click",my._P_click_callback,"close"); my._P_deleteEventListener($.close,"mousedown",my._P_click_callback,"close"); } my._P_deleteEventListener($.title,"mousedown",my._P_mousedown_callback,"title"); my._P_deleteEventListener(window,"resize",my._P_resize_X_callback,"window"); my._P_deleteEventListener(window,"resize",my._P_resize_Y_callback,"window"); my._P_deleteEventListener(window,"scroll",my._P_resize_X_callback,"window"); my._P_deleteEventListener(window,"scroll",my._P_resize_Y_callback,"window"); if ( params["resizable"] == true ) { my._P_deleteEventListener($.rightBorder,"mousedown",my._P_mousedown_callback,"rightBorder"); my._P_deleteEventListener($.bottomBorder,"mousedown",my._P_mousedown_callback,"bottomBorder"); my._P_deleteEventListener($.rbBorder,"mousedown",my._P_mousedown_callback,"rbBorder"); my._P_deleteEventListener($.brBorder,"mousedown",my._P_mousedown_callback,"brBorder"); } try { params["parent"].removeChild($.box); _.closed = true; popup_delete(this); } catch(e) { } if (params["exclusive"]) { if ($.inhibit !== null) { var $pi = $.inhibit.parentNode; if ($pi) $pi.removeChild($.inhibit); } } } }; this.contents = function() { return $.contents; }; this.timeout = function(value) { if (popup_open_failed != null) { window.clearTimeout(popup_open_failed); popup_open_failed = window.setTimeout("popup_open("+_.nr+",'fail')",value); } }; this.display = function(ctrl) { _.barX = 0; if ( typeof(ctrl) != undefined ) { if ( ctrl == "fail" ) { $.box.style.visibility = "visible"; popup_open_failed = null; return; } } if ( popup_open_failed != null ) { window.clearTimeout(popup_open_failed); popup_open_failed = null; } if (params["url"] !== null && $.window === null) { var iframeId = "iframe_"+_.nr; try { if (window.frames && window.frames[iframeId]) { var b = window.frames[iframeId].document.body; var comp = my._P_compStyle(b); params["width"] = parseInt(comp.width)+10; params["height"]= parseInt(comp.height)+10; console.log("ctrl_popup.js [1539] display() size: "+params["width"]+" x "+params["height"]) var d = window.frames[iframeId].document my._P_installEventListener(d,"mousedown",my._P_mousedown_callback,"b"); } } catch(c) { } } my.width(params["width"]); my.height(params["height"]); if ($.window !== null) { if ( params["width"] == "auto" ) { var sw = $.window.document.body.scrollWidth; var cw = $.window.document.body.clientWidth; var bsw = $.window.document.body.scrollWidth; if ( 0 < ( sw - cw ) < 20 ) { my.width(sw + sw - cw); } else { } } } else { if ( params["width"] == "auto" ) { my.width(100); var outerbox = this.getSize(params["parent"]); var innerbox = this.getSize($.contents); var value = Math.min(outerbox.width,innerbox.scrollWidth); if ( innerbox.scrollWidth > outerbox.width ) { $.contents.style.overflowX = "scroll"; value -= 50; _.barX = 16; } else { _.barX = 0; } my.width(value); } else { this.overflowX(); } if ( params["height"] == "auto" ) { my.height(100); var outerbox = this.getSize(params["parent"]); var innerbox = this.getSize($.contents); var value = Math.min(outerbox.height,(innerbox.scrollHeight+_.barX)); if ((innerbox.scrollHeight+_.barX) > outerbox.height) { $.contents.style.overflowY = "scroll"; value -= 50; } else { value = innerbox.scrollHeight + _.barX; } my.height(value); } else { this.overflowY(); } } if (params["depend"] != null) { if (params["depend"].getBoundingClientRect) { var rect = params["depend"].getBoundingClientRect(); } } var v = params["top"]; params["top"] = "init"; my.top(v); v = params["left"]; params["left"] = "init"; my.left(v); $.box.style.visibility = "visible"; }; this.window = function(obj) { $.window = obj; }; this.zindex = function(ctrl) { params["zindex"] = ctrl; var z = parseInt(ctrl); if ($.inhibit) { $.inhibit.style.zIndex = z + (_.nr * 3); } if ($.box) { $.box.style.zIndex = z + 1 + (_.nr * 3); } if ($.overlay) { $.overlay.style.zIndex = z + 2 + (_.nr * 3); } }; this.scroll_Y = function() { if (params["position"] == "fixed") return 0; if (typeof(window.scrollY) != "undefined") { return window.scrollY; } else if (window.pageYOffset) { return window.pageYOffset; } else if (document.body.scrollTop) { return document.body.scrollTop; } else { return 0; } }; this.scroll_X = function() { if (params["position"] == "fixed") return 0; if (typeof(window.scrollX) != "undefined") { return window.scrollX; } else if (window.pageXOffset) { return window.pageXOffset; } else if (document.body.scrollLeft) { return document.body.scrollLeft; } else { return 0; } }; this._P_inhibit_height = function(h) { if (h == 0) $.inhibit.style.height = 0; var sh = document.body.scrollHeight; var ch = document.body.clientHeight; var ih = window.innerHeight; if (ih > sh) { $.inhibit.style.height = ih + "px"; } else if (sh > ch) { $.inhibit.style.height = document.body.scrollHeight + "px"; } else { $.inhibit.style.height = "100%"; } }; this._P_inhibit_width = function(w) { if (w == 0) $.inhibit.style.width = 0; var sw = document.body.scrollWidth; var cw = document.body.clientWidth; if (sw > cw) { $.inhibit.style.width = document.body.scrollWidth + "px"; } else { $.inhibit.style.width = "100%"; } }; this.info = function(data) { if (typeof(data) == "undefined") { return this.data; } else { this.data = data; } }; this.init = function(ctrl) { if ( typeof(ctrl) == "undefined" ) ctrl = {}; var defaults = { boxClassName:null, closeClassName:null, closeImage:null, contentsClassName:null, debug:null, depend:null, exclusive:true, exit:null, height:"auto", id:null, iframeClassName:null, info:null, inhibitClassName:null, left:"center", moveable:true, onclose:null, opacity:null, parent:document.body, position:"absolute", resizable:true, timeout:10000, title:"", titleClassName:null, top:"middle", url:null, width:"auto", zindex:(100+_.nr) }; for ( var param in defaults ) { params[param] = (typeof(ctrl[param]) != "undefined") ? ctrl[param] : defaults[param]; } if (params["debug"] === false) $.ddw = false; params["titleHeight"] = 25; my = $GLOBALS["popup"][_.nr]; if (params["exclusive"] === true) { $.inhibit = document.createElement("div"); $.inhibit.style.position = "fixed"; $.inhibit.style.top = "0px"; $.inhibit.style.left = "0px"; $.inhibit.style.bottom = "0px"; $.inhibit.style.right = "0px"; _.scrollY = window.scrollY; $.inhibit.style.zIndex = (parseInt(params["zindex"]) + (_.nr * 3)); if ( params["inhibitClassName"] != null ) { $.inhibit.className = params["inhibitClassName"]; } else { $.inhibit.style.backgroundColor = "rgb(255,255,255)"; $.inhibit.style.opacity = "0.8"; } document.body.appendChild($.inhibit); my._P_installEventListener($.inhibit,"wheel",my._P_none,"inhibit"); my._P_installEventListener(window,"resize",my._P_resize_Y_callback,"window"); my._P_installEventListener(window,"scroll",my._P_resize_Y_callback,"window"); my._P_installEventListener(window,"resize",my._P_resize_X_callback,"window"); my._P_installEventListener(window,"scroll",my._P_resize_X_callback,"window"); } var _shiftX = (params["parent"] == document.body) ? my.scroll_X():0; var _shiftY = (params["parent"] == document.body) ? my.scroll_Y():0; $.box = document.createElement("div"); if ($.ddw) $.box.id = "box_"+_.nr; if (params["id"] != null) $.box.id = params["id"]; $.box.name = "popup_"+_.nr; $.box.style.position = (params["position"]=="fixed") ? "fixed":"absolute"; $.box.style.display = "block"; $.box.style.width = "500px"; $.box.style.height = "400px"; $.box.style.top = (_shiftY + 50) + "px"; $.box.style.left = (_shiftX + 200) + "px"; $.box.style.zIndex = (parseInt(params["zindex"]) +1+ (_.nr * 3)); if ( params["boxClassName"] != null ) { $.box.className = params["boxClassName"]; } else { $.box.style.border = "outset 3px #AAAAAA"; } if ( params["opacity"] != null ) { $.box.style.opacity = params["opacity"]; } $.title = document.createElement("div"); if ($.ddw) $.title.id = "title_"+_.nr; $.title.style.display = "block"; $.title.style.width = "500px"; if (params["titleClassName"] === false) { params["titleHeight"] = 0; $.title.style.height = "0px"; } else { $.title.style.height = "25px"; $.title.style.overflow = "hidden"; $.title.style.lineHeight = "25px"; $.title.style.fontWeight = "bold"; } $.title.style.position = "relative"; if (params["titleClassName"] != null && params["titleClassName"] != false) { $.title.className = params["titleClassName"]; } else if (params["titleClassName"] !== false) { $.title.style.backgroundColor = "#888888"; $.title.style.color = "#FFFFFF"; $.title.style.cursor = "move"; } $.box.appendChild($.title); if (params["titleClassName"] !== false || params["closeClassName"] !== null) { $.close = document.createElement("div"); $.close.style.display = "block"; $.close.style.cssFloat = "right"; $.close.style.width = "25px"; $.close.style.height = "25px"; var defaultImage = new Object(); defaultImage["left"] = null; defaultImage["alt"] = "schließen"; defaultImage["title"] = "close"; defaultImage["style"] = {cursor:"pointer"}; /* anz=3 % 1 */ defaultImage["src"] = "data:image/gif;base64,R0lGODlhGQAZANc+AP///+BXNOA4AuFWLudvUt5SL+VMGeJNJORTJeQ+B+VDDd9VM+BQKd1MKOVpS/9QKOdnQeVIE+h0W+JYNuRiQttDHNg3DgAAAOh8YuNcOgAAAONMHOdkO99TMOuKceNbOgAAAOZEDQAAAOhiNQAAAOdyWeh6YOyReeJLIudwVAAAAOZsTepeLQAAAOVnSeZoRehwVeRfQelKEQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPbMwgAAAGaQ5gAAAPO6rAAAAAAAAAAAAOdVJgAAAAAAAN9FHkAAAIAAAKAAAMAAAOAAAP8AAABAAEBAAIBAAKBAAMBAAOBAAP9AAACAAECAAICAAKCAAMCAAOCAAP+AAACgAECgAICgAKCgAMCgAOCgAP+gAADAAEDAAIDAAKDAAMDAAODAAP/AAADgAEDgAIDgAKDgAMDgAODgAP/gAAD/AED/AID/AKD/AMD/AOD/AP//AAAAQEAAQIAAQKAAQMAAQOAAQP8AQABAQEBAQIBAQKBAQMBAQOBAQP9AQACAQECAQICAQKCAQMCAQOCAQP+AQACgQECgQICgQKCgQMCgQOCgQP+gQADAQEDAQIDAQKDAQMDAQODAQP/AQADgQEDgQIDgQKDgQMDgQODgQP/gQAD/QED/QID/QKD/QMD/QOD/QP//QAAAgEAAgIAAgKAAgMAAgOAAgP8AgABAgEBAgIBAgKBAgMBAgOBAgP9AgACAgECAgICAgKCAgMCAgOCAgP+AgACggECggICggKCggMCggOCggP+ggADAgEDAgIDAgKDAgMDAgODAgP/AgADggEDggIDggKDggMDggODggP/ggAD/gED/gID/gKD/gMD/gOD/gP//gAAAwEAAwIAAwKAAwMAAwOAAwP8AwABAwEBAwIBAwKBAwMBAwOBAwP9AwACAwECAwICAwKCAwMCAwOCAwP+AwACgwECgwICgwKCgwMCgwOCgwP+gwADAwEDAwIDAwKDAwMDAwODAwP/AwADgwCH5BAEAAPgALAAAAAAZABkAAAiZAPEJHEiwoMGDCBMqXMjQh8OHECNCNCixYkQqFH082Mixo0cqGAs69EiyI8iMG30AKAlAyMaTIjU+AEDTI82VD2ASHLnxJkefL0PulNmzJtCgKDverGlS6ECeSpk2Tfpz6UenAqHONCo1J1Z8UI8e1flU5tGiOMlmlamSpUuvVEtejSuXo1qwIPPq3avXIN+/fBkKHky4MMKAADs="; if ( params["closeClassName"] !== null ) { $.title.style.overflow = ""; var cdiv = document.createElement("div"); cdiv.style.position = "relative"; $.close.appendChild(cdiv); cdiv.className = params["closeClassName"]; if ( params["closeImage"] != null ) { var img = document.createElement("img"); var cip = params["closeImage"]; for ( var param in defaultImage ) { if ( param != "style" ) { defaultImage[param] = (cip[param]) ? cip[param] : defaultImage[param]; } if ( defaultImage[param] != null ) { if ( param == "left") { params["exit"] = (cip[param]) ? cip[param] : defaultImage[param]; } else if ( param != "style" ) { img[param] = defaultImage[param]; } else { if ( typeof(cip[param]) == "undefined" ) cip[param] = {}; for ( var styleParam in defaultImage[param] ) { defaultImage[param][styleParam] = (cip[param][styleParam]) ? cip[param][styleParam] : defaultImage[param][styleParam]; if ( defaultImage[param][styleParam] != null ) { img.style[styleParam] = defaultImage[param][styleParam]; } } } } } cdiv.appendChild(img); } } else { var img = document.createElement("img"); img.src = defaultImage["src"]; img.alt = defaultImage["alt"]; img.title = defaultImage["title"]; img.style.cursor = "pointer"; params["exit"] = null; $.close.appendChild(img); } $.title.appendChild($.close); } my.title(params["title"]); $.contents = document.createElement("div"); if ($.ddw) $.contents.id = "contents_"+_.nr; $.contents.style.display = "block"; $.contents.style.cssClear = "both"; $.contents.style.position = "relative"; $.contents.style.width = "500px"; $.contents.style.height = "375px"; if ( params["contentsClassName"] != null ) { $.contents.className = params["contentsClassName"]; } else { $.contents.style.backgroundColor = "#FFFFFF"; } $.box.appendChild($.contents); if ( params["resizable"] == true ) { $.rightBorder = document.createElement("div"); $.rightBorder.style.display = "block"; $.rightBorder.style.position = "absolute"; $.rightBorder.style.top = "25px"; $.rightBorder.style.left = "497px"; $.rightBorder.style.width = "3px"; $.rightBorder.style.height = "350px"; $.rightBorder.style.backgroundColor = "rgb(0,0,0)"; $.rightBorder.style.opacity = "0.01"; $.rightBorder.style.cursor = "e-resize"; $.box.appendChild($.rightBorder); $.bottomBorder = document.createElement("div"); $.bottomBorder.style.display = "block"; $.bottomBorder.style.position = "absolute"; $.bottomBorder.style.top = "397px"; $.bottomBorder.style.height = "3px"; $.bottomBorder.style.width = "475px"; $.bottomBorder.style.left = "0px"; $.bottomBorder.style.backgroundColor = "rgb(0,0,0)"; $.bottomBorder.style.opacity = "0.01"; $.bottomBorder.style.cursor = "n-resize"; $.box.appendChild($.bottomBorder); $.rbBorder = document.createElement("div"); $.rbBorder.style.position = "absolute"; $.rbBorder.style.display = "block"; $.rbBorder.style.left = "497px"; $.rbBorder.style.top = "375px"; $.rbBorder.style.width = "3px"; $.rbBorder.style.height = "26px"; $.rbBorder.style.backgroundColor = "rgb(0,0,0)"; $.rbBorder.style.opacity = "0.01"; $.rbBorder.style.cursor = "se-resize"; $.box.appendChild($.rbBorder); $.brBorder = document.createElement("div"); $.brBorder.style.position = "absolute"; $.brBorder.style.display = "block"; $.brBorder.style.left = "475px"; $.brBorder.style.top = "397px"; $.brBorder.style.width = "26px"; $.brBorder.style.height = "3px"; $.brBorder.style.backgroundColor = "rgb(0,0,0)"; $.brBorder.style.opacity = "0.01"; $.brBorder.style.cursor = "se-resize"; $.box.appendChild($.brBorder); } $.box.style.visibility = "hidden"; params["parent"].appendChild($.box); _.closed = false; if ($.close !== null) { my._P_installEventListener($.close,"click",my._P_click_callback,"close"); my._P_installEventListener($.close,"mousedown",my._P_click_callback,"close"); } if ( params["moveable"] == true && params["titleClassName"] != false) { my._P_installEventListener($.title,"mousedown",my._P_mousedown_callback,"title"); } if ( params["resizable"] == true ) { my._P_installEventListener($.rightBorder,"mousedown",my._P_mousedown_callback,"rightBorder"); my._P_installEventListener($.bottomBorder,"mousedown",my._P_mousedown_callback,"bottomBorder"); my._P_installEventListener($.rbBorder,"mousedown",my._P_mousedown_callback,"rbBorder"); my._P_installEventListener($.brBorder,"mousedown",my._P_mousedown_callback,"brBorder"); } my._P_installEventListener(document.body,"mousemove",my._P_mousemove_callback,"overlay"); if ( params["info"] != null ) { this.data = params["info"]; } if ( params["url"] != null ) { $.iframe = document.createElement("iframe"); $.iframe.onload = my._P_onload; if (params["iframeClassName"] != null) { $.iframe.className = params["iframeClassName"]; } else { $.iframe.style.width = "500px"; $.iframe.style.height = "375px"; } $.iframe.frameBorder = 0; $.iframe.name="iframe_"+_.nr; $.iframe.id="iframe_"+_.nr; $.iframe.src = params["url"]; $.contents.appendChild($.iframe); } $.box.style.visibility = "hidden"; popup_open_failed = window.setTimeout("popup_open("+_.nr+",'fail')",params["timeout"]); var z = _.nr + 103; $GLOBALS["zmax"] = ( z > $GLOBALS["zmax"] ) ? z : $GLOBALS["zmax"]; }; } if (parent != self) { if (typeof(parent.popup_control) == "function") { parent.popup_control(self); } }