	if(!com) var com = {};
	if(!com.qwidget) com.qwidget = {};

	com.qwidget.Dialog = com.qwidget.View.extend({
		dialogHtml: undefined,
		dialogQwid: undefined,
		init: function (node)
		{
			this._super(node);
		},
		refresh: function (qwidMap, node)
		{
			//com.qwidget.debug('Dialog.refresh...');
			this._super(qwidMap, node);
		},
		hide: function ()
		{
			com.qwidget.DialogGuts.hideModalPopup();
		},
		show: function ()
		{
			if (!this.dialogHtml || !this.dialogQwid) com.qwidget.error('Dialog.show - dialogHtml and/or dialogQwid undefined');
			
			var q = jQuery(_qwid(this.dialogQwid), this.dialogHtml);
			com.qwidget.debug('Dialog.show - class: ' + q.attr('class'));
			com.qwidget.adjustStaticImageFilepaths(q);
			com.qwidget.DialogGuts.showModalPopup(q.html(), q.attr('class'), this.dimensions.width, this.dimensions.height);
			jQuery(_qwid(this.cqq.dialog_close)).click(function () {com.qwidget.DialogGuts.hideModalPopup(); return false;});
		}
	});
	
	com.qwidget.AboutDialog = com.qwidget.Dialog.extend({
		init: function ()
		{
			this.dialogHtml = com.qwidget.html['qwidgetAbout'];
			this.dialogQwid = this.cqq.about;
			this.containerQwid = this.cqq.modal_popup;
			this.dimensions = {width: 455, height: 323}
			
			this.refreshLists = {
				functions: [],
				html: [],
				text: [
					this.cqq.about_version
				]
			};

			this._super();
		},
		show: function ()
		{
			this._super();

			var qwidMap = [];
			qwidMap[this.cqq.about_version] = com.qwidget.version;
			this.refresh(qwidMap);
			
			var that = this;
			var signUpFunction = function ()
			{
				signUp = function ()
				{
					that.hide();
					com.qwidget.AccountManager.showRegister();
					return false;
				}
				return signUp;
			}
			jQuery(_qwid(this.cqq.about_signUp)).len(1).click(signUpFunction());
			var tosFunction = function ()
			{
				var about = function ()
				{
					that.hide();
					var dialog = new com.qwidget.TOSDialog();
					dialog.show();
					return false;
				}
				return about;
			}
			jQuery(_qwid(this.cqq.about_tos)).len(1).click(tosFunction());
		}
	});
	com.qwidget.TOSDialog = com.qwidget.Dialog.extend({
		init: function ()
		{
			this.dialogHtml = com.qwidget.html['qwidgetTOS'];
			this.dialogQwid = this.cqq.tos;
			this.containerQwid = this.cqq.modal_popup;
			this.dimensions = {width: 580, height: 1020}
			
			this._super();
		}
	});


	// TODO - this should be split into MessagesDialog, ListMessagesDialog, DetailMessagesDialog...
	// ASAP - there should just be one instance of MessageDialog and one instance each of helpers for inbox/list/detail and outbox/list/detail...
	com.qwidget.MessagesDialog = com.qwidget.Dialog.extend({ 
		dialogHtml: undefined,
		dialogQwid: undefined,
		modeQwid: undefined,
		messageItemNode: undefined,
		messageItemQwid: undefined,
		menuLoaded: false,
		allModeQwids: [],
		init: function (messagesParent, modeQwid)
		{
			if (!messagesParent) {com.qwidget.error('MessageDialog - messagesParent undefined'); return;}
			
			this.messagesParent = messagesParent;
			this.dialogHtml = com.qwidget.html['qwidgetMessages'];
			this.dialogQwid = this.cqq.messages;
			this.containerQwid = this.cqq.modal_popup;
			// TODO - for test add all modeQwids now. later push as each subclass does its init...
			//this.allModeQwids.push(modeQwid);
			this.allModeQwids =
			[
				// this.cqq.messages_inboxOutbox,
				// this.cqq.messages_inboxOutboxDetail,
				this.cqq.messages_inbox,
				this.cqq.messages_inboxDetail,
				this.cqq.messages_outbox,
				this.cqq.messages_outboxDetail
			];
			this.refreshLists = {
				functions: [],
				html: [
					this.cqq.message_detail_body
				],
				text: [
					this.cqq.message_item_name,
					this.cqq.message_item_photo,
					this.cqq.message_item_location,
					this.cqq.message_item_subject,
					this.cqq.message_item_preview,
					this.cqq.message_item_date,
					this.cqq.message_item_read,
					this.cqq.message_item_archived,
					// ASAP - un-dual mode this code...
					this.cqq.message_detail_from,
					this.cqq.message_detail_photo,
					this.cqq.message_detail_to,
					this.cqq.message_detail_subject,
					this.cqq.message_detail_date
				]
			};
			this._super();
		},
		refresh: function (qwidMap)
		{
			var whoami = 'MessagesDialog.refresh - ';
			var error = function (msg) {com.qwidget.error(whoami + msg);}

			this.container = undefined;
			
			var q = jQuery(_qwid(this.containerQwid)).len(1, whoami+'q (qwid: '+this.containerQwid+')');

			
			
			// ASAP - split this dual mode code into list and detail objects...
			if (this.modeQwid == this.cqq.messages_inbox || this.modeQwid == this.cqq.messages_outbox)
			{
				this.container = jQuery(_qwid(this.cqq.messages_inboxOutbox), q).len(1, whoami+'container (qwid: '+this.messages_inboxOutbox+')');
				
				// TODO - modify base class handle multiples - e.g. responses...
				var messages = qwidMap[this.cqq.messages_data];

				var messagesList = jQuery(_qwid(this.cqq.messages_list), this.container).len(1, whoami+'messagesList (qwid: '+this.cqq.messages_list+')');
				//var messagesList = this.container;
				messagesList.empty();
				for (var i = 0; i < messages.length; i++)
				{
					var node = this.messageItemNode.clone();
					var qwidMap = messages[i];
					var messageId = qwidMap[this.cqq.message_item_id];
					this._super(qwidMap, node);
					if (this.modeQwid == this.cqq.messages_inbox && !qwidMap[this.cqq.message_item_read])
					{
						jQuery(_qwid(this.cqq.message_item_subject), node).len(1).addClass('qw_orange');
					}
					
					var that = this;
					var showDetailFunction = function (id, read)
					{
						if (that.modeQwid == that.cqq.messages_inbox)
							return function() { com.qwidget.MessagesManager.showInboxDetail(id, read); return false;} 
						else
							return function() { com.qwidget.MessagesManager.showOutboxDetail(id); return false;} 
					}
					var archiveMessageFunction = function (id)
					{
						var f = function ()
						{
							that.messagesParent.refresh();
						}
						return function() { 
							com.qwidget.MessagesManager.archiveMessage(id, that.modeQwid, f); 
							return false;
						} 
					}
					
					var showList = jQuery(_qwid(this.cqq.message_item_show), node).len(1, whoami+'showList (qwid: '+this.cqq.message_item_show+')');
					showList[0].onclick = showDetailFunction(messageId, qwidMap[this.cqq.message_item_read]);

					var archiveItem = jQuery(_qwid(this.cqq.message_item_archive), node).len(1, whoami+'archiveItem (qwid: '+this.cqq.message_item_archive+')');
					if (qwidMap[this.cqq.message_item_archived])
						archiveItem.text('');
					else
						archiveItem[0].onclick = archiveMessageFunction(messageId);
						
					if (!qwidMap[this.cqq.message_item_repliedTo])
					{
						var q = jQuery(_qwid(this.cqq.message_item_repliedTo), node).len(1);
						q.hide();
					}
					
					messagesList.append(node);
				}
			}
			else // view individual messages
			{
				this.container = jQuery(_qwid(this.cqq.messages_inboxOutboxDetail), q).len(1, whoami+'container (qwid: '+this.messages_inboxOutboxDetail+')');
				
				var inboxOutboxFunction = this.modeQwid == this.cqq.messages_inboxDetail ? com.qwidget.MessagesManager.showInboxFunction() : com.qwidget.MessagesManager.showOutboxFunction();
				var back = jQuery(_qwid(this.cqq.message_detail_back), q).len(1);
				var text = back.text();
				back.click(inboxOutboxFunction);
				back.text(this.modeQwid == this.cqq.messages_inboxDetail ? text.replace('sent', 'received') : text.replace('received', 'sent'));
				var that = this;
				var messageId = qwidMap[this.cqq.message_item_id];
				var archiveMessageFunction = function (id)
				{
					return function() { 
						com.qwidget.MessagesManager.archiveMessage(id, that.modeQwid, inboxOutboxFunction); 
						return false;
					} 
				}
				var archive = jQuery(_qwid(this.cqq.message_detail_archive), q).len(1);
				
				var messages = qwidMap[this.cqq.messages_data];
				for (var i = 0; i < messages.length; i++)
				{
					var qwidMap = messages[i];
					if (this.detailMessageId == qwidMap[this.cqq.message_detail_id])
					{
						this.messageId	= qwidMap[this.cqq.message_detail_id];
						this.responseId	= qwidMap[this.cqq.message_detail_responseId];
						this.threadId	= qwidMap[this.cqq.message_threadId];
						this.fromId		= qwidMap[this.cqq.message_detail_fromId];
						this.toId		= qwidMap[this.cqq.message_detail_toId];
						this.subject 	= qwidMap[this.cqq.message_item_subject];
						// TODO - move these HTML snippets to the qwidgetMessages.html...
						// format the message body text...
						var bodyHtml = '<tr><td width="450" class="qw_message_text">'+ qwidMap[this.cqq.message_detail_body] + '</td></tr>\n';
						// if there's a message history format it and replace the message body with it...
						if (qwidMap[this.cqq.message_detail_history])
						{
							var detailHistory = qwidMap[this.cqq.message_detail_history];
							for (var j = 0; j < detailHistory.length; j++)
							{
								var item = detailHistory[j];
								bodyHtml += '<tr><td class="qw_message_divider"><img src="'+com.qwidget.staticImagePath()+'spacer.gif"></td></tr>\n';
								bodyHtml += '<tr><td class="qw_message_text"><strong>' + item[this.cqq.message_detail_date] + ' - ' + item[this.cqq.message_detail_from] + ' wrote:</strong>\n';
								bodyHtml += '<p>' + item[this.cqq.message_detail_body] + '</p></td></tr>\n';
							} 
						}
						qwidMap[this.cqq.message_detail_body] = bodyHtml;
						this._super(qwidMap);
						archive.click(archiveMessageFunction(this.messageId));
						break; // there should only be one detail message..
					}
				}
			}
		},
		show: function ()
		{
			this._super();
			whoami = 'MessagesDialog.show - ';
			
			var showQwid = '';
			var hideQwid = '';
			switch (this.modeQwid)
			{
			 case this.cqq.messages_inbox:
			 case this.cqq.messages_outbox:
				var q = jQuery(_qwid(this.cqq.messages_list_item)).len(1, 'MessageDialog.show - ' + this.cqq.messages_list_item);
				this.messageItemNode = q.clone();
				q.remove();
				showQwid = this.cqq.messages_inboxOutbox;
				hideQwid = this.cqq.messages_inboxOutboxDetail;
				break;
			 case this.cqq.messages_inboxDetail:
			 case this.cqq.messages_outboxDetail:
				showQwid = this.cqq.messages_inboxOutboxDetail;
				hideQwid = this.cqq.messages_inboxOutbox;
				break;
			 default:
				com.qwidget.error(whoami+'unknown modeQwid: ' + this.modeQwid);
				return;
				break;
			}
			jQuery(_qwid(showQwid)).len(1, whoami+'showQwid: ' + showQwid).show();
			jQuery(_qwid(hideQwid)).len(1, whoami+'hideQwid: ' + hideQwid).hide();
			
			// TODO - involve the subclasses in this work...
			// DRY - ...
			var inbox = jQuery(_qwid(this.cqq.messages_menu_inbox)).len(1);
			inbox.click(com.qwidget.MessagesManager.showInboxFunction());
			inbox.removeClass();
			inbox.addClass((this.modeQwid == this.cqq.messages_inbox || this.modeQwid == this.cqq.messages_inboxDetail ? 'qw_tab_selected' : 'qw_tab'));
			var q = inbox.next();
			q.removeClass();
			q.addClass((this.modeQwid == this.cqq.messages_inbox || this.modeQwid == this.cqq.messages_inboxDetail ? 'qw_tab_right_selected' : 'qw_tab_right'));
			var q = inbox.prev();
			q.removeClass();
			q.addClass((this.modeQwid == this.cqq.messages_inbox || this.modeQwid == this.cqq.messages_inboxDetail ? 'qw_tab_left_selected' : 'qw_tab_left'));

			var outbox = jQuery(_qwid(this.cqq.messages_menu_outbox)).len(1);
			outbox.click(com.qwidget.MessagesManager.showOutboxFunction());
			outbox.removeClass();
			outbox.addClass((this.modeQwid == this.cqq.messages_outbox || this.modeQwid == this.cqq.messages_outboxDetail ? 'qw_tab_selected' : 'qw_tab'));
			var q = outbox.next();
			q.removeClass();
			q.addClass((this.modeQwid == this.cqq.messages_outbox || this.modeQwid == this.cqq.messages_outboxDetail ? 'qw_tab_right_selected' : 'qw_tab_right'));
			var q = outbox.prev();
			q.removeClass();
			q.addClass((this.modeQwid == this.cqq.messages_outbox || this.modeQwid == this.cqq.messages_outboxDetail ? 'qw_tab_left_selected' : 'qw_tab_left'));

			q = jQuery(_qwid(this.cqq.messages_inboxOutbox_direction)).len(1);
			q.text(this.modeQwid == this.cqq.messages_inbox ? 'From' : 'To');
			
			var that = this;

			q = jQuery(_qwid(this.cqq.messages_previous)).len(1);
			q.click(function (eventObject) {that.messagesParent.pageMessages('previous'); return false;});

			q = jQuery(_qwid(this.cqq.messages_next)).len(1);
			q.click(function (eventObject) {that.messagesParent.pageMessages('next'); return false;});

			var showArchived = jQuery(_qwid(this.cqq.messages_showArchived)).len(1);
			showArchived.click(function (eventObject) {showArchived.text(that.messagesParent.toggleShowArchived() ? 'Hide Archived' : 'Show Archived'); return false;});

			if (this.modeQwid == this.cqq.messages_outbox || this.modeQwid == this.cqq.messages_inbox)
				this.showList();
			else
				this.showDetail(this.modeQwid);
				
			com.qwidget.DialogGuts.viewport.init("#divPopupBox"); // re-center now that the extra content is removed...
		},
		showArchived: function ()
		{
		},
		showDetail: function (mode)
		{
			if (mode == this.cqq.messages_outboxDetail)
			{
				var q = jQuery(_qwid(this.cqq.message_replySection)).len(1);
				q.hide();
			}
		},
		showList: function ()
		{
			var q = jQuery(_qwid(this.containerQwid)).len(1, whoami + this.containerQwid);
			this.container = jQuery(_qwid(this.cqq.messages_inboxOutbox), q).len(1, whoami + this.cqq.messages_inboxOutbox);
		}
	});
	com.qwidget.InboxMessagesDialog = com.qwidget.MessagesDialog.extend({
		init: function (messagesParent)
		{
			this.dimensions = {width: 700, height: 480};
			this.modeQwid = this.cqq.messages_inbox;
			this._super(messagesParent, this.modeQwid);
		},
		show: function ()
		{
			this._super();
			var q = jQuery(_qwid(this.cqq.messages_messageCount)).len(1).text('Message ('+com.qwidget.AccountManager.unreadMessageCount()+' unread)');
		},
		qwidMap: function (qwidMap)
		{
		}
	});
	com.qwidget.InboxDetailMessagesDialog = com.qwidget.MessagesDialog.extend({
		init: function (messagesParent)
		{
			this.dimensions = {width: 700, height: 850};
			this.modeQwid = this.cqq.messages_inboxDetail;
			this._super(messagesParent, this.modeQwid);
		},
		show: function (messageId)
		{
			this.detailMessageId = messageId;
			this._super();
			// TODO? - really the event should go to the MessagesManager and then the MessagesManager asks the view for the required info...
			var that = this;
			var body = function () 
			{
				var q = jQuery(_qwid(that.cqq.message_replyBody));
				var t = q.val();
				return t;
			}
			var q = jQuery(_qwid(this.cqq.message_reply)).len(1);
			q.click(function () {com.qwidget.MessagesManager.replyToMessage(that.responseId, that.threadId, that.fromId, that.subject, body(), that.detailMessageId, com.qwidget.MessagesManager.showInbox); return false;});
			q = jQuery(_qwid(this.cqq.message_cancel)).len(1);
			q.click(com.qwidget.MessagesManager.showInboxFunction());
		},
		qwidMap: function (qwidMap)
		{
		}
	});
	com.qwidget.OutboxMessagesDialog = com.qwidget.MessagesDialog.extend({
		init: function (messagesParent)
		{
			this.dimensions = {width: 700, height: 480};
			this.modeQwid = this.cqq.messages_outbox;
			this._super(messagesParent, this.modeQwid);
		},
		show: function ()
		{
			this._super();
			var q = jQuery(_qwid(this.cqq.messages_messageCount)).len(1).text('Message');
		},
		qwidMap: function (qwidMap)
		{
		}
	});
	com.qwidget.OutboxDetailMessagesDialog = com.qwidget.MessagesDialog.extend({
		init: function (messagesParent)
		{
			this.dimensions = {width: 700, height: 850};
			this.modeQwid = this.cqq.messages_outboxDetail;
			this._super(messagesParent, this.modeQwid);
		},
		show: function (messageId)
		{
			this.detailMessageId = messageId;
			this._super();
			// TODO? - really the event should go to the MessagesManager and then the MessagesManager asks the view for the required info...
			// DRY - see same code in InboxDetailMessagesDialog...
			var that = this;
			var body = function () 
			{
				var q = jQuery(_qwid(that.cqq.message_replyBody));
				var t = q.val();
				return t;
			}
			var q = jQuery(_qwid(this.cqq.message_reply));
			q.click(function () {com.qwidget.MessagesManager.replyToMessage(that.responseId, that.threadId, that.toId, that.subject, body(), that.detailMessageId,com.qwidget.MessagesManager.showOutbox); return false;});
		},
		qwidMap: function (qwidMap)
		{
		}
	});
	
	
	com.qwidget.AccountDialog = com.qwidget.Dialog.extend({
		init: function (accountParent, htmlName)
		{
			if (accountParent === undefined) {com.qwidget.error('AccountDialog - accountParent undefined'); return;}
			
			this.accountParent = accountParent;
			this.dialogHtml = com.qwidget.html[htmlName];
			if (this.dialogHtml == undefined) {com.qwidget.error('AccountDialog - this.dialogHtml undefined');}
			this.containerQwid = this.cqq.modal_popup;
			this._super();
		},
		emailInUse: function ()
		{
			alert('Email already in use');
		},
		displayNameInUse: function ()
		{
			alert('Username already in use');
		},
		usernameTooShort: function ()
		{
			alert('Username must be at least four characters long');
		},
		usernameNonAlphanumeric: function ()
		{
			alert('Username may only contain letters and numbers');
		}
	});
	com.qwidget.LogInAccountDialog = com.qwidget.AccountDialog.extend({
		init: function (accountParent)
		{
			this.dialogQwid = this.cqq.account_logIn;
			//this.dimensions = {width: 580, height: 535}; // FireFox...
			this.dimensions = {width: 590, height: 555}; // IE
			this._super(accountParent, 'qwidgetAccountLogIn');
		},
		show: function ()
		{
			this._super();
			jQuery(_qwid(this.cqq.account_logIn)).len(1).click(this.onClickLogInFunction());
			jQuery(_qwid(this.cqq.account_signUp)).len(1).click(this.onClickSignInFunction());
			jQuery(_qwid(this.cqq.account_logIn_lostPassword)).len(1).click(this.onClickLostPasswordFunction());
		},
		qwidMap: function (qwidMap)
		{
			var qwids =
			[
				this.cqq.account_email,
				this.cqq.account_password,
				this.cqq.account_autoLogIn
			];
			this.qwidMapViaList(qwids, qwidMap, jQuery(document)); // TODO? - is this the correct node?
			//qwidMap[this.cqq.account_autoLogIn] = (qwidMap[this.cqq.account_autoLogIn] == 'on' ? true : false);
		},
		onClickLogInFunction: function ()
		{
			var that = this;
			return function (eventObject) {
				that.accountParent.submitLogIn(); 
				return false;
			}
		},
		onClickSignInFunction: function ()
		{
			var that = this;
			return function (eventObject) {that.hide(); com.qwidget.AccountManager.showRegister();return false;}
		},
		onClickLostPasswordFunction: function ()
		{
			var that = this;
			var lostPassword = function (eventObject) {
				that.hide();
				var lostPassword = new com.qwidget.LostPasswordAccountDialog();
				lostPassword.show();
				return false;
			}
			return lostPassword;
		}
	});
	com.qwidget.CreateAccountDialog = com.qwidget.AccountDialog.extend({
		init: function (accountParent)
		{
			this.dialogQwid = this.cqq.account_create;
			this.dimensions = {width: 700, height: 655};

			this.refreshLists = {
				functions: [],
				html: [],
				text: [
					this.cqq.account_firstName,
					this.cqq.account_lastName,
					this.cqq.account_displayName,
					this.cqq.account_email,
					this.cqq.account_city,
					this.cqq.account_countryId,
					this.cqq.account_stateId,
					this.cqq.account_postalCode,
					this.cqq.account_genderId,
					this.cqq.account_password,
					//this.cqq.account_lostPassword,
					this.cqq.account_passwordConfirm,
					this.cqq.account_tosAgree,
					//this.cqq.account_logIn,
					this.cqq.account_autoLogIn,
					//this.cqq.account_image,
					this.cqq.account_responseNotification
				]
			};

			this._super(accountParent, 'qwidgetAccountCreate');
		},
		refresh: function (qwidMap, container)
		{
			for (var i = 0; i < this.refreshLists.text.length; i++)
			{
				var qwid = this.refreshLists.text[i];
				switch (qwid)
				{
				 case this.cqq.account_countryId:
				 case this.cqq.account_stateId:
					qwidMap[qwid] = 0;
					break;
				 default:
					qwidMap[qwid] = '';
					break;
				}
			}
			this._super(qwidMap, container);
		},
		show: function ()
		{
			this._super();
			var whoami = 'CreateAccountDialog.show -';
			

			var states = jQuery(_qwid(this.cqq.account_stateId), com.qwidget.html['qwidgetLists']).len(1, whoami+'state list');
			jQuery(_qwid(this.cqq.account_stateId)).len(1, whoami+'state list target').replaceWith(states);

			var countries = jQuery(_qwid(this.cqq.account_countryId), com.qwidget.html['qwidgetLists']).len(1, whoami+'country list');
			jQuery(_qwid(this.cqq.account_countryId)).len(1, whoami+'country list target').replaceWith(countries);

			jQuery(_qwid(this.cqq.account_createSubmit)).len(1, whoami+'account_createSubmit').click(this.onClickCreateFunction());
			jQuery(_qwid(this.cqq.account_create_alreadyMember)).len(1).click(this.onClickAlreadyMemberFunction());
			jQuery(_qwid(this.cqq.account_create_TOS)).len(1).click(this.onClickTOSFunction());
			jQuery(_qwid(this.cqq.account_create_form)).len(1).click(this.onClickFormFunction());
			
			jQuery('#qw_accountTOS').hide();
			com.qwidget.DialogGuts.viewport.init("#divPopupBox"); // re-center now that the extra content is removed...
		},
		onClickCreateFunction: function ()
		{
			var that = this;
			return function (eventObject) {that.accountParent.createAccount(); return false;}
		},
		onClickAlreadyMemberFunction: function ()
		{
			var that = this;
			var showLogIn = function (eventObject) {
				that.hide();
				com.qwidget.AccountManager.showLogIn();				
				return false;
			}
			return showLogIn;
		},
		onClickTOSFunction: function ()
		{
			var that = this;
			var showTOS = function (eventObject)
			{
				jQuery('#qw_accountForm').hide();
				that.setTitle('Terms of Service');
				jQuery('#qw_accountTOS').show();
			}
			return showTOS;
		},
		onClickFormFunction: function ()
		{
			var that = this;
			var showForm = function (eventObject)
			{
				jQuery('#qw_accountTOS').hide();
				that.setTitle('Sign Up to Join the Discussion');
				jQuery('#qw_accountForm').show();
			}
			return showForm;
		},
		setTitle: function (title)
		{
			jQuery('#qw_account_title').text(title);
		},
		qwidMap: function (qwidMap)
		{
			this.qwidMapViaList(this.refreshLists.text, qwidMap, jQuery(_qwid(this.cqq.modal_popup)).len(1, 'UpdateAccountDialog.qwidMap'));
		},
		accountCreatedUpdated: function ()
		{
			this.accountParent.accountCreated();
		}
	});
	com.qwidget.PhotoCreateAccountDialog = com.qwidget.AccountDialog.extend({
		init: function (accountParent)
		{
			this.dialogQwid = this.cqq.account_createPhoto;
			this.dimensions = {width: 575, height: 245};
			this._super(accountParent, 'qwidgetAccountCreatePhoto');
		},
		show: function ()
		{
			this._super();
			// TODO? - is this the best place for this?
			// DRY - this is also in update account...
			var q = jQuery(_qwid(this.cqq.account_imageUpload));
			q[0].action = com.qwidget.servicesUrl + '/member/image/create.jsp';
			q = q.find('iframe');
			q[0].src = com.qwidget.imagesUrl + '/default_medium.jpeg';
			var credentials = com.qwidget.AccountManager.credentials();
			document.account_image_upload.email.value 		= credentials.memberEmail;
			document.account_image_upload.password.value 	= credentials.memberPassword;
			document.account_image_upload.memberId.value 	= credentials.memberId;
		}
	});
	com.qwidget.UpdateAccountDialog = com.qwidget.AccountDialog.extend({
		init: function (accountParent)
		{
			this.dialogQwid = this.cqq.account_update;
			this.dimensions = {width: 577, height: 625};

			this.refreshLists = {
				functions: [],
				html: [],
				text: [
					this.cqq.account_firstName,
					this.cqq.account_lastName,
					this.cqq.account_displayName,
					this.cqq.account_email,
					this.cqq.account_city,
					this.cqq.account_countryId,
					this.cqq.account_stateId,
					this.cqq.account_password,
					this.cqq.account_passwordConfirm,
					this.cqq.account_image,
					this.cqq.account_responseNotification,
					this.cqq.account_autoLogIn
				]
			},

			this._super(accountParent, 'qwidgetAccountUpdate');
		},
		refresh: function (qwidMap, container)
		{
			// don't start with the password field populated
			//qwidMap[this.cqq.account_password] = '';
			
			this._super(qwidMap, container)
		},
		show: function ()
		{
			var whoami = 'UpdateAccountDialog.show - ';
			
			this._super();
			jQuery(_qwid(this.cqq.account_updateSubmit)).click(this.onClickUpdateFunction());

			// DRY - say I've seen the next four lines somewhere before...
			var states = jQuery(_qwid(this.cqq.account_stateId), com.qwidget.html['qwidgetLists']).len(1, whoami+'state list');
			jQuery(_qwid(this.cqq.account_stateId)).len(1, whoami+'state list target').replaceWith(states);

			var countries = jQuery(_qwid(this.cqq.account_countryId), com.qwidget.html['qwidgetLists']).len(1, whoami+'country list');
			jQuery(_qwid(this.cqq.account_countryId)).len(1, whoami+'country list target').replaceWith(countries);
			
			var that = this;
			jQuery(_qwid(this.cqq.account_deleteImage)).len(1).click(function () {that.accountParent.deleteImage(); return false;})
			
			// TODO? - is this the best place for this?
			var q = jQuery(_qwid(this.cqq.account_imageUpload));
			q[0].action = com.qwidget.servicesUrl + '/member/image/create.jsp';
			q = q.find('iframe');
			q[0].src = com.qwidget.imagesUrl + '/default_medium.jpeg';
			var credentials = com.qwidget.AccountManager.credentials();
			document.account_image_upload.email.value 		= credentials.memberEmail;
			document.account_image_upload.password.value 	= credentials.memberPassword;
			document.account_image_upload.memberId.value 	= credentials.memberId;
		},
		onClickUpdateFunction: function ()
		{
			var that = this;
			return function (eventObject) {that.accountParent.updateAccount(); return false;}
		},
		qwidMap: function (qwidMap)
		{
			this.qwidMapViaList(this.refreshLists.text, qwidMap, jQuery(_qwid(this.cqq.modal_popup)).len(1, 'UpdateAccountDialog.qwidMap'));
		},
		accountCreatedUpdated: function ()
		{
			this.accountParent.accountUpdated();
		}
	});
	com.qwidget.LostPasswordAccountDialog = com.qwidget.AccountDialog.extend({
		// TODO - make a proper account class and move AccountManager awareness up there...
		init: function ()
		{
			this.dialogQwid = this.cqq.account_lostPassword;
			this.dimensions = {width: 580, height: 222};
	
			this.refreshLists = {
				functions: [],
				html: [],
				text: [
					this.cqq.account_email
				]
			};
	
			this._super(null, 'qwidgetAccountLostPassword');
		},
		show: function ()
		{
			this._super();

			jQuery(_qwid(this.cqq.account_lostPasswordSubmit)).len(1, 'LostPasswordAccountDialog.show - account_lostPasswordSubmit').click(this.onClickLostPasswordSubmitFunction());
		},
		onClickLostPasswordSubmitFunction: function ()
		{
			var that = this;
			var lostPasswordSubmit = function (eventObject)
			{
				var qwidMap = {};
				that.qwidMapViaList(that.refreshLists.text, qwidMap, jQuery(_qwid(that.cqq.modal_popup)).len(1, 'LostPasswordAccountDialog.lostPasswordSubmit - modal_popup'));				
				com.qwidget.AccountManager.resetPassword(qwidMap[that.cqq.account_email], that.hide);
			};
			return lostPasswordSubmit;
		}
	});

	com.qwidget.DialogGuts = {};

	// com.qwidget.DialogGuts.dialog = undefined;
	// com.qwidget.DialogGuts.showModalPopup = function (innerHtml, width, height)
	// {
	// 	com.qwidget.DialogGuts.hideModalPopup();
	// 	com.qwidget.DialogGuts.dialog = $(innerHtml).dialog();
	// }
	// com.qwidget.DialogGuts.hideModalPopup = function ()
	// {
	// 	if (com.qwidget.DialogGuts.dialog)
	// 	{
	// 		com.qwidget.DialogGuts.dialog.close();
	// 		com.qwidget.DialogGuts.dialog = undefined;
	// 	}
	// }


	// TODO - replace DialogGuts with jQuery UI dialog

	// Browser Window Size and Position
	// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
	// you may copy these functions but please keep the copyright notice as well
	com.qwidget.DialogGuts.viewport = { // thanks to http://reindel.com/five_javascript_tricks_jquery/
		o: function() {
			if (self.innerHeight) {
			this.pageYOffset = self.pageYOffset;
			this.pageXOffset = self.pageXOffset;
			this.innerHeight = self.innerHeight;
			this.innerWidth = self.innerWidth;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			this.pageYOffset = document.documentElement.scrollTop;
			this.pageXOffset = document.documentElement.scrollLeft;
			this.innerHeight = document.documentElement.clientHeight;
			this.innerWidth = document.documentElement.clientWidth;
		} else if (document.body) {
			this.pageYOffset = document.body.scrollTop;
			this.pageXOffset = document.body.scrollLeft;
			this.innerHeight = document.body.clientHeight;
			this.innerWidth = document.body.clientWidth;
		}
		return this;
		},
		init: function(el) {
			jQuery(el).css("left",Math.round(this.o().innerWidth/2) + this.o().pageXOffset - Math.round(jQuery(el).width()/2));
			jQuery(el).css("top",Math.round(this.o().innerHeight/2) + this.o().pageYOffset - Math.round(jQuery(el).height()/2));
		}
	};
	com.qwidget.DialogGuts.pageWidth = function () {
	    return window.innerWidth != null ? window.innerWidth 
	    : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth 
	    : document.body != null ? document.body.clientWidth 
	    : null;
	}	
	com.qwidget.DialogGuts.pageHeight = function () {
	    return  window.innerHeight != null ? window.innerHeight 
	    : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight 
	    : document.body != null? document.body.clientHeight 
	    : null;
	} 
	com.qwidget.DialogGuts.posLeft = function () {
	    return typeof window.pageXOffset != 'undefined' ? window.pageXOffset 
	    : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft 
	    : document.body.scrollLeft ? document.body.scrollLeft 
	    : 0;
	} 
	com.qwidget.DialogGuts.posTop = function () {
	    return typeof window.pageYOffset != 'undefined' ? window.pageYOffset 
	    : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop 
	    : document.body.scrollTop ? document.body.scrollTop 
	    : 0;
	} 
	com.qwidget.DialogGuts.posRight = function () { 
	    return posLeft()+pageWidth(); 
	} 
	com.qwidget.DialogGuts.posBottom = function () { 
	    return posTop()+pageHeight(); 
	}
	com.qwidget.DialogGuts.scrollbarWidth = function()
	{
	    var div = jQuery('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
	    // Append our div, do our calculation and then remove it
		var f = function (s)
		{
			if (s)
				alert(s);
	    	jQuery(div).remove();
			return 12;
		}
	    var q = jQuery('body').append(div);
		if (q.length == 0)
			return f('q.length == 0 for \'body\'...');
			
		q = jQuery('div', div);
		if (q.length == 0)
			return f('q.length == 0 for \'div\'... (1)');

		var w1 = 12;
		if (q.innerWidth)
	    	w1 = q.innerWidth();
		else
			return f('q.innerWidth == undefined... (1)');

	    div.css('overflow-y', 'scroll');

		q = jQuery('div', div);
		if (q.length == 0)
			return f('q.length == 0 for \'div\'... (2)');

	    var w2 = 0;
		if (q.innerWidth)
	    	w2 = q.innerWidth();
		else
			return f('q.innerWidth == undefined... (2)');
			
	    return (w1 - w2);
	}
	com.qwidget.DialogGuts.hideModalPopup = function()
	{
	    jQuery('#divPopupMask').remove();
	    jQuery('#divPopupBox').remove();
	}
	com.qwidget.DialogGuts.showModalPopup = function (innerHtml, popupClass, width, height)
	{
	    this.hideModalPopup();
	    var isMsIe = jQuery.browser['msie'];
	    var mask = isMsIe ? jQuery(this.ieModalMask) : jQuery(this.otherModalMask);
	    var pgWidth = isMsIe ? jQuery().width() - this.scrollbarWidth() - 4 : jQuery().width();
	    var pgHeight = isMsIe ? jQuery().height() - this.scrollbarWidth() - 4 : jQuery().height();
	    mask[0].style.width = pgWidth + "px";
	    mask[0].style.height = pgHeight + "px";
    
	    var dlg = jQuery(this.modalPopup);
	    dlg.html(innerHtml);
		dlg.addClass(popupClass);
	    var dlgWidth = Math.max(width, dlg.width());
	    var dlgHeight = Math.max(height, dlg.height());
	    var leftOffset = (pgWidth - dlgWidth) / 2;
	    var topOffset = (pgHeight - dlgHeight) / 2;
    
	    // Now make sure the dialog has these settings so it shows at default size
	    //dlg.width(dlgWidth);
	    //dlg.height(dlgHeight);
    
	    // Then align the popup wrapper and show it.
	    dlg[0].style.left = leftOffset + "px";
	    dlg[0].style.top = topOffset + "px"
    
	    jQuery('body').prepend(mask);
	    jQuery('body').prepend(dlg);

		this.viewport.init("#divPopupBox");
	}
	com.qwidget.DialogGuts.otherModalMask = '<div id="divPopupMask" style="position:absolute; left:0px; top:0px; width:0px; height:0px; z-index:1000; background-color:#111111; opacity:0.15;"></div>';
	com.qwidget.DialogGuts.ieModalMask = '<div id="divPopupMask" style="position:absolute; left:0px; top:0px; width:0px; height:0px; z-index:1000; background-color:#111111; filter:alpha(opacity=15)"></div>';
	com.qwidget.DialogGuts.modalPopup = '<div qwid="modal_popup" id="divPopupBox" style="position:absolute; height:auto; z-index:1200; overflow:auto; padding: 0; border: none; background-color:#FFFFFF"></div>';
