var A_Popups = []; var Popups_Level = 100; var referdiv = null var referdivheight = 0; var referdivwidth = 0; function Popup(name, style, width, height) { this.name = name; this.style = style; this.width = width; this.height = height; this.title = ""; this.content = ""; this.visible = false; this.window = null; this.scrollbar = null; this.persscrollbar = []; this.popupstyle = ""; this.popupstyle_border_width = 0; this.popupstyle_border_height = 0; this.filter = []; this.help_window = null this.help_title = ""; this.help_content = ""; this.help_popupstyle = ""; this.help_filter = []; this.popup_item = null; GetScreenSize(); if (! referdiv) { referdiv = document.createElement("div"); referdiv.style.position = 'absolute'; referdiv.style.top = '0'; referdiv.style.left = '0'; referdiv.style.padding = '0'; if (Get_Cookie("mywidth") > 0) { referdiv.style.width = Get_Cookie("mywidth") + 'px'; } else { referdiv.style.width = '100%'; } if (Get_Cookie("myheight") > 0) { referdiv.style.height = Get_Cookie("myheight") + 'px'; } else { referdiv.style.height = '100%'; } referdiv.style.visibility = 'hidden'; document.body.appendChild(referdiv); //document.body.insertBefore(referdiv, document.body.childNodes[0]); } if (referdiv.offset) { referdivheight = referdiv.offset.height; referdivwidth = referdiv.offset.width; } else { referdivheight = referdiv.offsetHeight; referdivwidth = referdiv.offsetWidth; } this.NewTitle = function(title) { this.title = title; } this.NewContent = function(content) { this.content = content; } this.NewContentHttp = function(address, params) { var Ajax_innerHTML = null; try { Ajax_innerHTML = new XMLHttpRequest(); } catch (e) { try { Ajax_innerHTML = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { Ajax_innerHTML = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } Ajax_innerHTML.open("POST", address, false); Ajax_innerHTML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); Ajax_innerHTML.send(params + "&popupname=" + this.name); if(Ajax_innerHTML.status == 200) { this.content = Ajax_innerHTML.responseText; } } this.UpdateContent = function(content) { tmp_content = document.getElementById(this.name + '_content'); tmp_content.style.marginLeft = '0'; tmp_content.style.marginRight = '0'; tmp_content.style.marginTop = '0'; tmp_content.style.marginBottom = '0'; tmp_content.style.padding = '0'; tmp_content.style.height = "auto"; tmp_content.style.width = "auto"; this.content = content; tmp_content.innerHTML = this.content; this.Center(); } this.UpdateContentHttp = function(address, params, title) { ShowPrepage(); var Ajax_innerHTML = null; try { Ajax_innerHTML = new XMLHttpRequest(); } catch (e) { try { Ajax_innerHTML = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { Ajax_innerHTML = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } for (var i = 0; i < this.persscrollbar.length; i++) { this.persscrollbar[i][1].Remove(); } Ajax_innerHTML.open("POST", address, false); Ajax_innerHTML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); Ajax_innerHTML.send(params + "&popupname=" + this.name); if(Ajax_innerHTML.status == 200) { this.content = Ajax_innerHTML.responseText; tmp_content = document.getElementById(this.name + '_content'); tmp_content.style.marginLeft = '0'; tmp_content.style.marginRight = '0'; tmp_content.style.marginTop = '0'; tmp_content.style.marginBottom = '0'; tmp_content.style.height = "auto"; tmp_content.style.width = "auto"; tmp_content.innerHTML = this.content; this.window.style.height = "auto"; this.window.style.width = "auto"; if (title && title.length > 0) { this.title = title; if (document.getElementById(this.name + '_title')) { document.getElementById(this.name + '_title').innerHTML = this.title; } } this.Center(); } HidePrepage(); } this.SetFilter = function (color, opacity) { this.filter.push(new Array(color, opacity, null)); } this.Show = function() { if (this.visible == false) { var Ajax_innerHTML = null; try { Ajax_innerHTML = new XMLHttpRequest(); } catch (e) { try { Ajax_innerHTML = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { Ajax_innerHTML = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } Ajax_innerHTML.open("POST", "popups/style" + style + ".php", false); Ajax_innerHTML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); Ajax_innerHTML.send("name=" + this.name); if(Ajax_innerHTML.status == 200) { this.popupstyle = Ajax_innerHTML.responseText; } if (navigator.appName == "Microsoft Internet Explorer") { //alert("iframe created"); var iFrame = document.createElement("IFRAME"); iFrame.setAttribute("src", "/blank.htm"); iFrame.style.position="absolute"; iFrame.style.top = '0'; iFrame.style.left = '0'; if (Get_Cookie("mywidth") > 0) { iFrame.style.width = Get_Cookie("mywidth") + 'px'; } else { iFrame.style.width = '100%'; } if (Get_Cookie("myheight") > 0) { iFrame.style.height = Get_Cookie("myheight") + 'px'; } else { iFrame.style.height = '100%'; } iFrame.style.zIndex = Popups_Level; iFrame.style.filter = 'mask()'; document.getElementById('prepage').insertAdjacentElement('beforeBegin', iFrame); //document.body.appendChild(iFrame); this.popup_item = iFrame; Popups_Level = parseInt(Popups_Level) + 1; } if (this.filter.length > 0) { for (var i = 0; i < this.filter.length; i++) { var newfilter = document.createElement("div"); newfilter.style.position = 'absolute'; newfilter.style.top = '0'; newfilter.style.left = '0'; if (Get_Cookie("mywidth") > 0) { newfilter.style.width = Get_Cookie("mywidth") + 'px'; } else { newfilter.style.width = '100%'; } if (Get_Cookie("myheight") > 0) { newfilter.style.height = Get_Cookie("myheight") + 'px'; } else { newfilter.style.height = '100%'; } newfilter.style.backgroundColor = this.filter[i][0]; newfilter.style.zIndex = Popups_Level; if (newfilter.style.MozOpacity) { newfilter.style.MozOpacity = this.filter[i][1] / 100; } else { newfilter.style.filter = 'alpha(opacity=' + this.filter[i][1] + ')'; newfilter.style.opacity = this.filter[i][1] / 100; } document.getElementById('prepage').insertAdjacentElement('beforeBegin', newfilter); this.filter[i][2] = newfilter; } Popups_Level = parseInt(Popups_Level) + 1; } var newpopup = document.createElement("div"); newpopup.id = this.name; newpopup.innerHTML = this.popupstyle; newpopup.style.position = 'absolute'; newpopup.style.top = '0'; newpopup.style.left = '0'; newpopup.style.marginLeft = '0'; newpopup.style.marginRight = '0'; newpopup.style.marginTop = '0'; newpopup.style.marginBottom = '0'; newpopup.style.padding = '0'; newpopup.style.zIndex = Popups_Level; Popups_Level = parseInt(Popups_Level) + 1 document.getElementById('prepage').insertAdjacentElement('beforeBegin', newpopup); document.getElementById(this.name + '_title').innerHTML = this.title; document.getElementById(this.name + '_content').innerHTML = this.content; var tmp_style_size = document.getElementById(this.name + '_params').innerHTML.split("/"); this.popupstyle_border_height = tmp_style_size[0]; this.popupstyle_border_width = tmp_style_size[1]; this.visible = true; this.window = newpopup; this.Center(); A_Popups.push(new Array(this.name, this)); } } this.Remove = function () { this.window.innerHTML = " "; if (document.body.removeChild) { removeChildSafe(this.window); for (var i = 0; i < this.filter.length; i++) { this.filter[i][2].style.display = 'none'; removeChildSafe(this.filter[i][2]); } } if (this.popup_item) { document.body.removeChild(this.popup_item); this.popup_item = null; } this.filter.splice(0, this.filter.length); if (this.scrollbar) { this.scrollbar.Remove(); } for (var i = 0; i < this.persscrollbar.length; i++) { this.persscrollbar[i][1].Remove(); } ReloadAllScrollbar(); for (var i = 0; i < A_Popups.length; i++) { if (A_Popups[i][0] == this.name) { A_Popups.splice(i, 1); break; } } } this.Center = function () { if (! document.getElementById(this.name + '_content')) { return; } SetButtonHover(document.getElementById(this.name + '_content')); GetScreenSize(); if (! referdiv) { referdiv = document.createElement("div"); referdiv.style.position = 'absolute'; referdiv.style.top = '0'; referdiv.style.left = '0'; referdiv.style.padding = '0'; if (Get_Cookie("mywidth") > 0) { referdiv.style.width = Get_Cookie("mywidth") + 'px'; } else { referdiv.style.width = '100%'; } if (Get_Cookie("myheight") > 0) { referdiv.style.height = Get_Cookie("myheight") + 'px'; } else { referdiv.style.height = '100%'; } referdiv.style.visibility = 'hidden'; document.body.appendChild(referdiv); } if (referdiv.offset) { referdivheight = referdiv.offset.height; referdivwidth = referdiv.offset.width; } else { referdivheight = referdiv.offsetHeight; referdivwidth = referdiv.offsetWidth; } var height = 0; var width = 0; if (this.window.offset) { height = this.window.offset.height; width = this.window.offset.width; } else { height = this.window.offsetHeight; width = this.window.offsetWidth; } this.window.style.marginTop = Math.ceil((referdivheight - height) / 2) + "px"; this.window.style.marginLeft = Math.ceil((referdivwidth - width) / 2) + "px"; if (document.getElementById(this.name + '_scroll_table')) { document.getElementById(this.name + '_scroll_table').display = 'none'; document.getElementById(this.name + '_content').style.overflow = 'hidden'; } while (height > (referdivheight - 30) || width > (referdivwidth - 5)) { if (document.getElementById(this.name + '_scroll_table')) { document.getElementById(this.name + '_scroll_table').style.display = 'inline'; document.getElementById(this.name + '_content').style.overflow = 'hidden'; } else { document.getElementById(this.name + '_content').style.overflow = 'auto'; } if (height > (referdivheight - 30)) { height = (referdivheight - 30); this.window.style.height = height + "px"; document.getElementById(this.name + '_content').style.height = (height - this.popupstyle_border_height) + "px"; } if (width > (referdivwidth - 5)) { width = (referdivwidth - 5); this.window.style.width = width + "px"; document.getElementById(this.name + '_content').style.width = (width - this.popupstyle_border_width) + "px"; } this.window.style.marginTop = Math.ceil((referdivheight - height) / 2) + "px"; this.window.style.marginLeft = Math.ceil((referdivwidth - width) / 2) + "px"; if (document.getElementById(this.name + '_scroll_table')) { document.getElementById(this.name + '_scroll_table').style.display = 'inline'; tmp_height = (height - this.popupstyle_border_height - 40); if (tmp_height < 25) tmp_height = 25; document.getElementById(this.name + '_scroll_table').style.height = (tmp_height + 36) + "px"; document.getElementById(this.name + '_tdbare').style.height = (tmp_height) + "px"; document.getElementById(this.name + '_bare').style.height = (tmp_height) + "px"; this.scrollbar = new TextScroll(this.name + '_scroll', this.name + '_content', this.name + '_scroll_table', this.name + '_scroll_up', this.name + '_scroll_down', this.name + '_bare'); } if (this.window.offset) { height = this.window.offset.height; width = this.window.offset.width; } else { height = this.window.offsetHeight; width = this.window.offsetWidth; } } for (i = 1; i <= 10; i++) { if (document.getElementById(this.name + '_pers' + i + '_div')) { var found = false; for (var j = 0; j < this.persscrollbar.length; j++) { if (this.persscrollbar[j][0] == name) { found = this.persscrollbar[j][1]; break; } } if (found) { found.Reload(); } else { if (document.getElementById(this.name + '_pers' + i + '_scroll_table')) { scrolldiv = document.getElementById(this.name + '_pers' + i + '_div'); document.getElementById(this.name + '_pers' + i + '_scroll_table').style.display = 'inline'; scrolldiv.style.overflow = 'hidden'; if (scrolldiv.offset) { tmpscrolldivheight = scrolldiv.offset.height; } else { tmpscrolldivheight = scrolldiv.offsetHeight; } var new_scroll = new TextScroll(this.name + '_scroll_' + i, this.name + '_pers' + i + '_div', this.name + '_pers' + i + '_scroll_table', this.name + '_pers' + i + '_scroll_up', this.name + '_pers' + i + '_scroll_down', this.name + '_pers' + i + '_bare'); this.persscrollbar.push(new Array(this.name + '_scroll_' + i, new_scroll)); } else { document.getElementById(this.name + '_pers' + i + '_div').style.overflow = 'auto'; } } } } } this.EnableHelp = function (help_title, help_content, filter_color, filter_opacity) { this.help_title = help_title; this.help_content = help_content; this.help_filter.push(new Array(filter_color, filter_opacity, null)); document.getElementById(this.name + '_moreinfo').style.display = 'inline'; } this.ShowHelp = function (style) { this.help_popupstyle = style; MustShowPrepage = true; ShowPrepage(); var obj = new Popup(this.name + '_help', this.help_popupstyle, 500, 500); obj.NewTitle(this.help_title); obj.NewContentHttp('ajax/help.php', 'content=' + this.help_content); obj.SetFilter(this.help_filter[0][0], this.help_filter[0][1]); obj.Show(); HidePrepage(); this.help_window = obj; } } function CenterAllPopups() { for (var i = 0; i < A_Popups.length; i++) { A_Popups[i][1].Center(); } } function GetPopupElement(name) { for (var i = 0; i < A_Popups.length; i++) { if (A_Popups[i][0] == name) { return A_Popups[i][1]; } } } function QuickNewPopupHttp (name, style, title, address, parameters, filter_color, filter_opacity) { MustShowPrepage = true; ShowPrepage(); var obj = new Popup(name, style, 500, 500); obj.NewTitle(title); obj.NewContentHttp(address, parameters); obj.SetFilter(filter_color, filter_opacity); obj.Show(); HidePrepage(); return obj; }