﻿var objEditWin={};
var objEditWinDesc={};
Ext.ns("AV");
AV.ContentWindow = {

	//this section added just to get old/AV Lite calendar events working - should eventually definitely be removed
	formDirty: true,
	toggleSave: function(on) { this.btnSave.setDisabled(!on); },
	//end section

	getWindowHeight: function(config) {
		var bodydom = Ext.get(document.body);
		height = bodydom.dom.offsetHeight - 40;
		return height;
	},

	sizeEditorContainers: function(config) {
		var cts = this.formWindow.body.select('.form-items-container');
		var ctheight = this.formWindow.body.getHeight();
		var height = 0;
		cts.each(function(el, ct, index) {
			height += el.getHeight() + 6;
		});
		var offset = 80;
		var diff = ctheight - height - offset;
		if (diff < 220) {
			diff = 220; //200px high is minimum, but must set height of containing div to 220 to account for padding w/in the editor
		}
		var editor1, editor2;
		if (config && config.editors && config.editors["objEditWin"]) {
			editor1 = config.editors["objEditWin"];
		} else if (config && config.editors && config.editors["objEditWinDesc"]) {
			editor2 = config.editors["objEditWinDesc"];
		} else {
			editor1 = this.editors["objEditWin"];
			editor2 = this.editors["objEditWinDesc"];
		}
		if (editor1 && editor2 && document.getElementById('div_objEditWinTarget') && document.getElementById('div_objEditWinDescTarget')) {
			diff / 2 < 220 ? half = 220 : half = parseInt(diff / 2);
			document.getElementById('div_objEditWinTarget').style.height = half + "px";
			document.getElementById('div_objEditWinDescTarget').style.height = half + "px";
		} else if (editor1 && !editor2 && document.getElementById('div_objEditWinTarget')) {
			document.getElementById('div_objEditWinTarget').style.height = diff + "px";
		} else if (!editor1 && editor2 && document.getElementById('div_objEditWinDescTarget')) {
			document.getElementById('div_objEditWinDescTarget').style.height = diff + "px";
		}
	},

	showWindow: function(config) {//url,width,height,title,editor config,edit/add,target, oCssJsLoader

		Ext.QuickTips.init();

		//Ticket 72397 escape apostrophes for documents(the config.url is already escaped in the link that calls showWindow, but when
		//argument is evaluated the escaping has been removed.)
		if (config.url && (config.url.indexOf('/doc/Ext/documentviewer.asp') === 0 || config.url.indexOf('/doc/documentviewer.asp') === 0)) {
			config.url = config.url.split("'").join("\\'");
		}

		// Zach - Override for setting animation duration --- TS - this is bad, very bad, should be applied to the window instance created below
		Ext.override(Ext.Window, {
			defaultAnimShowCfg: {
				duration: .25,
				easing: 'easeNone',
				opacity: .5
			},
			defaultAnimHideCfg: {
				duration: .25,
				easing: 'easeNone',
				opacity: 0
			},
			animShow: function() {
				this.proxy.show();
				this.proxy.setBox(this.animateTarget.getBox());
				this.proxy.setOpacity(0);
				var b = this.getBox(false);
				b.callback = this.afterShow;
				b.scope = this;
				b.block = true;
				Ext.apply(b, this.animShowCfg, this.defaultAnimShowCfg);
				this.el.setStyle('display', 'none');
				this.proxy.shift(b);
			},
			animHide: function() {
				this.proxy.setOpacity(.5);
				this.proxy.show();
				var tb = this.getBox(false);
				this.proxy.setBox(tb);
				this.el.hide();
				var b = this.animateTarget.getBox();
				b.callback = this.afterHide;
				b.scope = this;
				b.block = true;
				Ext.apply(b, this.animHideCfg, this.defaultAnimHideCfg);
				this.proxy.shift(b);
			}
		});

		var height = config.height ? config.height : this.getWindowHeight(config);
		var width = config.width ? config.width : 705;

		if (config.helpUrl) { this.helpUrl = config.helpUrl; }

		//will animate from the "Publish" button
		if (!config.target) { config.target = Ext.get(Ext.get(document.body).select('.clsSignIn').elements[0]); }

		this.btnSave = new Ext.Button({
			id: "btnSaveContentWindow",
			text: "Save",
			iconCls: 'save-button',
			listeners: {
				click: { fn: function() { this.submitForm(); }, scope: this }
			}
		});

		this.btnCancel = new Ext.Button({
			text: "Cancel",
			iconCls: 'cancel-button',
			listeners: {
				click: { fn: function() { this.closeWindow(config.target); }, scope: this }
			}
		});

		this.btnDelete = new Ext.Button({
			text: "Delete",
			iconCls: 'delete-button',
			hidden: AV.site_type_id == '7' ? true : false,
			listeners: {
				click: { fn: function() { this.deletePost(); }, scope: this }
			}
		});

		this.btnSubmit = new Ext.Button({
			text: "Submit",
			iconCls: "submit-button",
			listeners: {
				click: { fn: function() { this.submitForm(); }, scope: this }
			}
		});

		this.btnSendDiscussion = new Ext.Button({
			text: "Send Message",
			iconCls: 'send-email-button',
			visible: false,
			listeners: {
				click: { fn: function() { this.submitForm(); }, scope: this }
			}
		});

		var toolbarhidden = true;
		if (config.view) { toolbarhidden = false; }
		this.adminToolbar = new Ext.Toolbar({ hidden: toolbarhidden });

		this.editors = [];

		this.formWindow = new Ext.Window({
			title: config.title,
			layout: 'fit',
			width: width,
			height: height,
			border: true,
			bodyBorder: true,
			bodyStyle: "overflow:auto;",
			shadow: true,
			modal: true,
			animateTarget: config.target,
			animShowCfg: { duration: .5 },
			animHideCfg: { duration: .5 },
			closable: false,
			closeAction: 'close',
			cls: 'editor-window',
			resizable: true,
			tbar: this.adminToolbar,
			fbar: this.getButtonArr(config),
			listeners: {
				render: function(obj) { //mask and add close and help buttons
					obj.el.mask();
					var text = this.formWindow.el.child(".x-window-header-text");
					text.wrap({
						tag: 'div',
						style: 'float:left;'
					});
					var header = this.formWindow.el.child(".x-window-header");
					var wrap = header.createChild({
						tag: 'div',
						id: 'buttonwrap' + this.formWindow.id,
						style: 'float:right;margin-top:-3px;width:110px;'
					});
					header.createChild({
						tag: 'div',
						style: 'clear:both;'
					});

					this.closeButton = new Ext.Component({
						renderTo: wrap,
						autoEl: {
							tag: 'div',
							style: 'float:right;width: 57px;height:18px;background-image:url(/images/icons/icons-close-help.png);cursor:pointer;background-position:0 0;'
						},
						listeners: {
							render: {
								fn: function(button) {
									button.el.on("click", function(e, dom, stuff) {
										this.closeWindow(config.target);
									}, this);
								},
								scope: this
							}
						}
					});

					this.helpButton = new Ext.Component({
						renderTo: wrap,
						autoEl: {
							tag: 'div',
							style: 'float:left;width: 53px;height:18px;background-image:url(/images/icons/icons-close-help.png);cursor:pointer;background-position:0 -18px;'
						},
						listeners: {
							render: {
								fn: function(button) {
									button.el.on("click", function(e, dom, stuff) {
										this.showHelp(dom);
									}, this);
								},
								scope: this
							}
						}
					});
					if (!config.helpUrl) {
						this.helpButton.el.setDisplayed(false);
					}

					var clear = new Ext.Component({
						renderTo: wrap,
						autoEl: {
							tag: 'div',
							style: 'clear:both;'
						}
					});
				},
				show: function(obj) {
					//resize listener can't be inited in the listners because it fires when window resizes during animation
					this.formWindow.on("resize", function() {
						var obj = {};
						if (document.getElementById("div_objEditWinTarget") && document.getElementById("div_objEditWinDescTarget")) {
							obj = { editors: { objEditWin: true, objEditWinDesc: true} };
						} else if (document.getElementById("div_objEditWinTarget")) {
							obj = { editors: { objEditWin: true} };
						} else if (document.getElementById("div_objEditWinDescTarget")) {
							obj = { editors: { objEditWinDesc: true} };
						} else {
							obj = { editors: {} }
						}
						this.sizeEditorContainers();
					}, this);
					this.formWindow.on("beforehide", function() {
						this.formWindow.un("resize", function() { }, this);
					}, this);

					//this is here because IE is lame and height:'auto' doesn't work like other browsers
					//Ext tries to account for this in the mask() function, but the timing is off in this case.
					if (Ext.isIE) {
						var mask = obj.el.child('.ext-el-mask');
						mask.setHeight(height);
					}
					var self = this;
					setTimeout(function() {
						Ext.Ajax.request({
							url: "/SessionCheck.asp",
							method: "POST",
							scope: self,
							callback: function(request, success, response) {
								if (success && response.responseText === "OK") {

									if (config.oCssJsLoader) {
										AV.Loader.loadMultiple(config.oCssJsLoader,
											function() {
												if (typeof config.loadFn == "function") {
													var objToInsert = config.loadFn();
													if (objToInsert) { this.formWindow.add(objToInsert); }
												}
												if (this.formWindow) { this.formWindow.el.unmask(); }
											}, self);
									}

									else {
										obj.load({
											url: config.url,
											method: "GET",
											scripts: true,
											text: "Loading...",
											callback: function(winbody, success, response, post) {
												if (typeof config.loadFn == "function") {
													config.loadFn();
												} else {
													this.formWindow.el.unmask();
												}
											},
											scope: self
										});
									}
								} else {
									if (AV.login_id_curr === "176") {
										//refresh the page if guest session "timed out" - attempt to add assn id into query string if it wasn't there before
										var newLoc = window.location.href;
										if (window.location.search.toLowerCase().indexOf('assn_id') < 0 && Ext.isString(AV.assn_id)) {
											newLoc = Ext.urlAppend(window.location.href, "assn_id=" + AV.assn_id);
										}
										window.location.href = newLoc;
									}
									else {
										Ext.Msg.show({
											title: 'Session Expired',
											msg: 'Your session has expired.  Please click OK and log in again.',
											buttons: Ext.Msg.OK,
											fn: function() {
												//get assn id
												var qsAssnId = '';
												if (AV.assn_id && AV.assn_id != '') { qsAssnId = AV.assn_id; }
												if (qsAssnId == '') { //attempt to grab from url/qs if above didn't work
													var pageParameters = Ext.urlDecode(window.location.search.substring(1));
													if (pageParameters.assn_id != '') { qsAssnId = pageParameters.assn_id; }
												}
												var qsLoc = '';
												if (qsAssnId != '') {
													//if you're on a webpublisher page, have to redirect w/link_id otherwise throws error
													var qsLinkId = '';
													if (location.href.indexOf('~') > -1) {
														if (location.href.split(/~/)[1]) {
															qsLinkId = location.href.split(/~/)[1];
															qsLoc = '/link/linkshow.asp?link_id=' + qsLinkId;
														}
													}
													else {
														qsLoc = location.href; //get current loc
													}
													qsLoc = escape(qsLoc);
												}
												//build query string and redirect
												var qsRedir = '';
												if (qsAssnId != '') {
													qsRedir = '?assn_id=' + qsAssnId + '&destination=' + qsLoc;
												}
												location.href = '/member/SignIn.asp' + qsRedir;
											}
										});
									}
								}
							}
						});
						return;

					}, obj.animShowCfg.duration);
				},
				add: function(obj) {
					obj.doLayout();
				},
				scope: this
			}
		});

		this.formWindow.show();
		HM_f_HideAll(); //hide menu
	},

	loadEditors: function(winbody, config) {
		if (config.editors) {
			var temp = [];
			if (config.editors.objEditWin) { temp.push("objEditWin") }
			if (config.editors.objEditWinDesc) { temp.push("objEditWinDesc") }
			//this.nhowEditors(temp,config);
		}
		winbody.setStyle('overflow', 'auto');
		this.formWindow.center();
		this.formWindow.syncShadow();
	},

	updateContent: function(config) {
		this.formWindow.el.mask();
		//since the edit grid must be added to the window instead of just rendered to it
		//I put the call in to removeAll or the edit grid appears when update() is called
		this.formWindow.removeAll();

		Ext.Ajax.request({
			url: "/SessionCheck.asp",
			method: "POST",
			scope: this,
			callback: function(request, success, response) {
				if (success && response.responseText === "OK") {

					if (config.oCssJsLoader) {
						AV.ContentWindow.formWindow.body.update('');
						AV.Loader.loadMultiple(config.oCssJsLoader,
							function() {
								if (typeof config.loadFn == "function") {
									var objToInsert = config.loadFn();
									if (objToInsert) { this.formWindow.add(objToInsert); }
								}
								if (this.formWindow) { this.formWindow.el.unmask(); }
							}, self);

						config.view ? this.adminToolbar.show() : this.adminToolbar.hide();
						this.updateButtons(this.getButtonArr(config));
						this.formWindow.setTitle(config.title);
						this.updateHelp(config);
					}

					else {
						this.formWindow.getUpdater().update({
							url: config.url,
							loadScripts: true,
							method: "GET",
							scripts: true,
							text: "Loading...",
							nocache: true,
							callback: function(obj, success, response, call) {
								if (success) {
									if (typeof config.loadFn == "function") {
										config.loadFn();
									}
									config.view ? this.adminToolbar.show() : this.adminToolbar.hide();
									var temp = [];
									if (config.editors.objEditWin) { temp.push("objEditWin") }
									if (config.editors.objEditWinDesc) { temp.push("objEditWinDesc") }
									//this.showEditors(temp,config);
									this.updateButtons(this.getButtonArr(config));
									this.formWindow.setTitle(config.title);
									this.updateHelp(config);
								}
							},
							scope: this
						});
					}
				}
			}
		});
	},

	updateButtons: function(buttonArr) {
		this.formWindow.fbar.removeAll(false);
		this.formWindow.fbar.add(buttonArr);
		this.formWindow.fbar.doLayout();
	},

	updateHelp: function(config) {
		if (config.helpUrl) {
			this.helpUrl = config.helpUrl;
			this.helpButton.el.setDisplayed(true);
		} else {
			this.helpButton.el.setDisplayed(false);
		}
	},

	getButtonArr: function(config) {
		var buttonArr = [];
		if (config.edit) {
			buttonArr = [this.btnSave, this.btnCancel, this.btnDelete];
		} else if (config.add) {
			buttonArr = [this.btnSave, this.btnCancel];
		} else if (config.form) {
			buttonArr = [this.btnSubmit]
		} else if (config.discussionemail) {
			buttonArr = [this.btnSendDiscussion, this.btnCancel]
		}
		return buttonArr;
	},

	closeWindow: function(target) {
		//Take this out asap.  Cheesy way of getting around the editor init.
		var reload = false;

		//colossal hack to keep discussion group and alert editting from reloading a previous item's data    
		if (document.getElementsByName('forum_desc') && document.getElementsByName('forum_desc')[0] && document.getElementsByName('forum_desc')[0].type === 'textarea') {
			reload = true;
		}

		if (document.getElementsByName('alert_text') && document.getElementsByName('alert_text')[0] && document.getElementsByName('alert_text')[0].type === 'textarea') {
			reload = true;
		}

		if (this.editors && (typeof (this.editors.objEditWin) === 'object' || typeof (this.editors.objEditWinDesc) === 'object' || reload)) {
			setTimeout(function() {
				location.href = location.href;
			}, 500)
		}
		else {

			this.formWindow.removeAll(false);
			//this.formWindow.hide(target);

			this.formWindow.hide(target, function(win) {
				delete (objEditWin);
				delete (objEditWinDesc);
				objEditWin = {};
				objEditWinDesc = {};
				this.formWindow.close(true);
				this.formWindow.destroy();
				delete (this.formWindow)
			}, this);

		}
	},

	resetVars: function() {
		this.radiosRendered = false;
		this.dailyRendered = false;
		this.weeklyRendered = false;
		this.monthlyRendered = false;
		this.yearlyRendered = false;
		this.rendered = false;
		for (var a = 0; a < this.editors.length; a++) {
			delete this.editors[a].onKeyPress;
		}
	},

	closeHelp: function() {
		this.helpWin.close(true);
		this.helpWin.destroy();
		delete (this.helpWin);
	},

	showHelp: function(domBtn) {
		this.helpWin = new Ext.Window({
			cls: 'editor-window',
			width: 500,
			animateTarget: domBtn,
			closable: true,
			floating: true,
			draggable: true,
			modal: false,
			title: "Help",
			border: true,
			bodyBorder: true,
			autoLoad: {
				url: this.helpUrl,
				loadScripts: true,
				scripts: true,
				callback: function() {
					var self = this;
					setTimeout(function() {
						self.helpWin.syncShadow();
					}, 5);
				},
				scope: this
			}
		});
		this.helpWin.on("deactivate", function(win) {
			var maskZ = parseInt(this.formWindow.mask.dom.style.zIndex);
			win.el.setStyle('z-index', maskZ + 1);
		}, this);
		this.helpWin.on("show", function(win) {
			win.center();
		}, this);
		this.helpWin.show();
	},

	showEditor: function(editor, html, options) { //takes a string.  Either "objEditWin" or "objEditWinDesc"
		if (!html) { html = ""; }
		if (!options) { options = {}; }

		/*  Took this out beause we don't need to re-init the editor anymore.
		if (this.editors[editor]) {
		delete this.editors[editor];
		if (editor === "objEditWin") { delete objEditWin; objEditWin = {}; Ext.getDom("div_"+editor+"Target").innerHTML = "";}
		if (editor === "objEditWinDesc") { delete objEditWinDesc; objEditWinDesc = {}; Ext.getDom("div_"+editor+"Target").innerHTML = ""; }
		}
		*/
		this.editors[editor] = new InnovaEditor(editor);
		if (editor === "objEditWin") { objEditWin = this.editors[editor]; }
		if (editor === "objEditWinDesc") { objEditWinDesc = this.editors[editor]; }
		this.editors[editor].name = editor;
		this.editors[editor].css = "/library/css/" + this.CSS_FILENAME;
		this.editors[editor].width = "90%";
		this.editors[editor].height = "100%";
		editorDoc_Init(this.editors[editor]);
		//custom settings
		if (AV.site_type_id == 2 || AV.site_type_id == 7) {
			//hide flash, media, documents, templates, bookmarks, and maps
			this.editors[editor].btnFlash = false;
			this.editors[editor].btnMedia = false;
			//this.editors[editor].useDocInsert=false;
			this.editors[editor].useTemplate = false;
			this.editors[editor].btnBookmark = false;
			this.editors[editor].useMap = false;
		}
		//messenger service doesn't get some buttons and has neat styles.
		if (options.helpUrl && options.helpUrl.indexOf("MessengerService") !== -1) {
			this.editors[editor].btnStyles = true;
			this.editors[editor].useTemplate = true;
			this.editors[editor].useMap = false;
			this.editors[editor].btnMedia = false;
			this.editors[editor].btnFlash = false;
			this.editors[editor].arrStyle = [
				[".clsMainPane", false, "", "line-height: normal; background-color: #ffffff !important; background-image: none !important; border: 1px inset #e0dfe3; height: 100%; margin: 0; padding: 0;"],
				[".ObjContainer", false, "", "border: dotted 1px #000000;"],
				[".clsBodyText", false, "", "background-color: #ffffff !important; background-image: none !important;"],
				[".clsSmallText", false, "", "background-color: #ffffff !important; background-image: none !important;"],
				[".clsCaption", false, "", "background-color: #ffffff !important; background-image: none !important;"],
				[".clsInstructions", false, "", "background-color: #ffffff !important; background-image: none !important;"],
				[".clsLabelMand", false, "", "background-color: #ffffff !important; background-image: none !important;"]
			];
		}
		//discussion topics
		if (typeof (AV.DiscussionTopicAdd) === 'object') {
			this.editors[editor].bareBones = true;
			var thisRoleSeq = 10;
			if (AV.discussionTopic.data && AV.discussionTopic.data.role_seq) {
				thisRoleSeq = AV.discussionTopic.data.role_seq;
			}
			this.editors[editor].role_seq = thisRoleSeq;
		}
		editorDoc_PostInit(this.editors[editor]);
		this.sizeEditorContainers();
		if (html !== "") {
			this.editors[editor].putHTML(html);
		}
	},

	showEmailWindow: function(type, link, address, title, summary, content, scope) {
		if (!scope) { scope = AV.ContentWindow; }

		var winid = scope.formWindow.id;

		scope.emailWindow = new Ext.Window({
			cls: 'editor-window',
			width: 500,
			animateTarget: this.btnEmail,
			closable: true,
			floating: true,
			draggable: true,
			modal: false,
			title: "Email " + type,
			border: true,
			bodyBorder: true,
			items: [
				new Ext.form.FormPanel({
					id: 'emailform' + winid,
					border: false,
					bodyBorder: false,
					items: [
						{
							xtype: 'hidden',
							name: 'link',
							value: link
						},
						{
							xtype: 'hidden',
							name: 'title',
							value: title
						},
						{
							xtype: 'hidden',
							name: 'summary',
							value: summary
						},
						{
							xtype: 'hidden',
							name: 'body',
							value: content
						},
						{
							xtype: 'textfield',
							fieldLabel: 'To',
							name: 'to',
							width: 300
						},
						{
							xtype: 'textfield',
							fieldLabel: 'From',
							name: 'from',
							width: 300,
							value: address
						},
						{
							xtype: 'textfield',
							fieldLabel: 'Subject',
							name: 'subject',
							width: 300
						},
						{
							xtype: 'textarea',
							fieldLabel: 'Note',
							name: 'note',
							width: 300
						}
					],
					buttons: [
						{
							text: "Send",
							handler: this.submitEmailForm.createDelegate(scope, [winid], true),
							iconCls: 'send-button',
							scope: this
						},
						{
							text: "Cancel",
							handler: function() {
								this.emailWindow.hide(this.btnEmail, function() {
									this.emailWindow.close(true);
									this.emailWindow.destroy();
									delete (this.emailWindow);
								}, this)
							},
							iconCls: 'cancel-button',
							scope: this
						}
					]
				})
			]
		});
		this.emailWindow.on("deactivate", function(win) {
			var maskZ = parseInt(this.formWindow.mask.dom.style.zIndex);
			win.el.setStyle('z-index', maskZ + 1);
		}, this);
		this.emailWindow.show();
	},

	submitEmailForm: function(button, e, winid) {
		function isEmail(addr) {
			var regex = /^((?:(?:(?:[a-zA-Z0-9][\.\-\+_]*)*)[a-zA-Z0-9])+)\@((?:(?:(?:[a-zA-Z0-9][\.\-]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})$/
			return regex.test(addr);
		}
		var form = Ext.getCmp('emailform' + winid).getForm();
		var values = form.getValues();
		var html = "";
		var index = 0;
		var go = true;
		for (var a in values) {
			if (a === "to" || a === "from") {
				if (!isEmail(values[a])) {
					form.items.items[index].markInvalid("This address is invalid.");
					go = false;
					break;
				}
			}
			form.el.dom[a].value = values[a];
			html += form.el.dom[a].name + ": " + form.el.dom[a].value + "<br/>";
			index++;
		}
		if (!go) { return false; }

		form.submit({
			url: '/Send_Email.asp',
			method: 'POST',
			success: function() {
				Ext.Msg.alert("Success!", "Your message has been sent.");
				var self = this;
				setTimeout(function() {
					self.emailWindow.close(true);
					self.emailWindow.destroy();
					delete (self.emailWindow);
				}, 1000)
			},
			failure: function() {
				Ext.Msg.alert("Message Failed", "Message could not be sent. Please check your values and try again.");
			},
			scope: this
		});
	},

	checkValue: function(value, message) {
		if (value === "") {
			Ext.MessageBox.alert("Error", message);
			return false;
		}
		return true;
	},

	floatElement: function(obj, which) {
		var n = obj.el.dom;
		while (n.className.indexOf("x-form-item") === -1 && n.className.indexOf("x-btn") === -1) {
			if (Ext.get(n).dom.type === "form") {
				return;
			} else {
				n = n.parentNode;
			}
		}
		Ext.get(n).setStyle("float", which);
		if (Ext.isIE) { //must set width of this container explicitly in IE.
			var width = obj.width;
			if (!width) { return; }
			var padding = obj.el.dom.parentNode.style.paddingLeft;
			padding = parseInt(padding.substring(0, padding.length - 2)) + 3;
			if (!isNaN(padding)) {
				width += padding;
			}
			n.style.width = width + "px";
		}
	},

	getErrorDiv: function(name) {
		var div = new Ext.Container({
			autoEl: {
				id: name + "_error" + this.formWindow.id,
				style: "float:left;display:none;",
				html: "<img src='/library/Ext/ext-3.1.0/resources/images/default/form/exclamation.gif' style='margin:2px 0px 0px 3px'/>"
			}
		});
		return div;
	},

	getClearDiv: function() {
		return new Ext.Component({
			autoEl: {
				tag: "div",
				style: "clear:both;",
				html: "<img src='/images/1ptrans.gif' style='height:0px;' />"
			}
		})
	},

	focusEditorAttempt: 5,

	focusEditor: function() {
		if (Ext.isIE) {
			--this.focusEditorAttempt;
			if (this.focusEditorAttempt > 0) {
				var temp = Ext.get('idContentobjEditWinDesc');  //adding a new doc used this instead
				var temp2 = Ext.get('idContentobjEditWin');
				if (temp) {
					//alert('temp1');
					temp.focus();                   //prevent inaccessibility of editor
					this.focusEditorAttempt = 5;    //reset 
					window.focus();                 //unfocusses the editor (mimic current behavior)
				}
				else if (temp2) {
					//alert('temp2');
					temp2.focus();
					this.focusEditorAttempt = 5;
					window.focus();
				}
				else {
					setTimeout(function() {
						AV.ContentWindow.focusEditor();
					}, 250);
				}
			}
			else {
				//reset in case editor does not exist (viewing docs, etc, etc)
				this.focusEditorAttempt = 5;
			}
		}
	}
};