var CommonPopup = {
	
	Object : {

		extend : function(
			oDestination,
			oSource,
			bReplace
			) {

			for(var i in oSource) {

				if((bReplace || typeof(oDestination[i]) == 'undefined') && typeof(oSource[i]) != 'undefined') {
					oDestination[i] = oSource[i];
				}
			}

			return oDestination;

		}

	},
	
	Utils: {
	
		oPopupDefaults: {
		
			iWidth: 540,
			iHeight: 600,
			sToolbar: 'no',
			sMenubar: 'no',
			sResizeable: 'yes',
			sScrollbars: 'yes',
			sStatus: 'yes'
		
		},
		
		popup: function(sUrl, sName, oOptions, bReplace){
		
			oOptions = CommonPopup.Object.extend(CommonPopup.Utils.oPopupDefaults, oOptions, true);
			
			var iLeftOffset = screen.availWidth / 2 - oOptions.iWidth / 2;
			var iTopOffset = screen.availHeight / 2 - oOptions.iHeight / 2;
			
			oNewWindow = window.open(sUrl, '', 'left=' + iLeftOffset + ', ' +
			'top = ' + iTopOffset +	', ' +
			'width=' + oOptions.iWidth + ', ' + 
			'height=' + oOptions.iHeight + ', ' +
			'menubar=' + oOptions.sMenubar + ', ' +
			'toolbar=' + oOptions.sToolbar + ', ' +
			'resizable=' + oOptions.sResizeable +
			', ' + 'scrollbars=' + oOptions.sScrollbars +
			', ' + 'status=' + oOptions.sStatus);
			
			if (sUrl.match(/\.(gif|jpe?g|png)$/i)) {
			
				oNewWindow.document.open();
				
				oNewWindow.document.write('<html><head>' + (sName != '' ? '<title>' + sName + '</title>' : '') + '</head><body style="background: #FFF; margin: 0; padding: 0;">' +
				'<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td align="center">' +
				'<img src="' +
				sUrl +
				'" />' +
				'</td></tr></table></body></html>');
				
				oNewWindow.document.close();
				
			}
			
			oNewWindow.focus();
			
			return false;
			
		}
	}
};