function popup(url, name, properties, returnType) { var popup; var popupName = ''; var optionsObject = new Object(); var optionsString = ''; var validProperties = [ 'height', 'width', 'outerheight', 'outerwidth', 'innerheight', 'innderwidth', 'left', 'top', 'screenx', 'screeny', 'alwayslowered', 'alwaysraised', 'channelmode', 'copyhistory', 'dependent', 'directories', 'fullscreen', 'hotkeys', 'location', 'menubar', 'resizable', 'scrollbars', 'status', 'toolbar', 'z-lock']; var validPropertiesLength = validProperties.length; var checkproperties = (typeof properties != 'undefined'); for (var x = 0; x < validPropertiesLength; x++) { if (checkproperties && typeof properties[validProperties[x]] != 'undefined') { optionsObject[validProperties[x]] = properties[validProperties[x]]; } else if (typeof this.popup[validProperties[x]] != 'undefined') { optionsObject[validProperties[x]] = this.popup[validProperties[x]]; } }
var centerPopup; if (checkproperties && typeof properties['centered'] != 'undefined') { centerPopup = properties['centered']; } if (centerPopup == null && typeof this.popup.centered != 'undefined') { centerPopup = this.popup.centered; } if (centerPopup && typeof screen.width != 'undefined') { if (typeof optionsObject.height != 'undefined' && (!checkproperties || typeof properties['top'] == 'undefined')) { optionsObject.top = ((screen.height - optionsObject.height) / 2); } if (typeof optionsObject.width != 'undefined' && (!checkproperties || typeof properties['left'] == 'undefined')) { optionsObject.left = ((screen.width - optionsObject.width) / 2); } }
for (var y in optionsObject) { if (optionsString != '') { optionsString += ', '; } optionsString += y + '=' + optionsObject[y]; }
if (typeof name != 'undefined') { popupName = name; }
if (typeof this.popup.replace == 'undefined') { popup = window.open(url, popupName, optionsString); } else { popup = window.open(url, popupName, optionsString, this.popup.replace); }
if (checkproperties && typeof properties['focus'] != 'undefined' && properties['focus']) { popup.focus(); } else if (checkproperties && typeof properties['blur'] != 'undefined' && properties['blur']) { popup.blur(); } else if (typeof this.popup.focus != 'undefined' && this.popup.focus) { popup.focus(); } else if (typeof this.popup.blur != 'undefined' && this.popup.blur) { popup.blur(); }
if (returnType == 'popupobject') { return popup; } else { return false; } } popup.focus = 1; popup.resizable = 1; popup.scrollbars = 1;
