Ext.ns('Ext.ux');

Ext.ux.Global = Ext.extend(Ext.util.Observable, {

			constructor : function() {

				Ext.select('a').each(function(el) {
					el.on("focus", function(e) {
								Ext.get(e.target).blur();
							});
				});

				Ext.select('a.videoclick').each(function(el) {

							el.on("click", function(ev) {

										Ext.select('div.video').each(
												function(el) {

													Ext.get(el).setStyle({
																display : 'none'
															});
												});

										Ext.get(ev.target.id + '_v').setStyle({
													display : 'block'
												});

									});
						});

				var maxHi = 0;
				Ext.select('div.indexitemcontent').each(function(el) {
					maxHi = el.getHeight() > maxHi
							? maxHi = el.getHeight()
							: maxHi = maxHi;
				});

				Ext.select('div.indexitemcontent').each(function(el) {
							el.setStyle({
										height : (maxHi) + 'px'
									})
						});
						
					var maxHi = 0;
				Ext.select('div.listitemcontent').each(function(el) {
					maxHi = el.getHeight() > maxHi
							? maxHi = el.getHeight()
							: maxHi = maxHi;
				});

				Ext.select('div.listitemcontent').each(function(el) {
							el.setStyle({
										height : (maxHi) + 'px'
									})
						});		
						
			}
		});

Ext.ux.RemainingChars = Ext.extend(Ext.util.Observable, {

			constructor : function(el, elo, maxchars, text) {

				this.el = Ext.get(el);
				this.elo = Ext.get(elo);
				this.maxchars = parseInt(maxchars);
				this.text = text;

				this.el.update(String.format(this.text, this.maxchars
								- this.elo.getValue().length));

				Ext.get(elo).on("keyup", function(ev) {

					if (this.elo.getValue().length > this.maxchars) {
						this.elo.dom.value = this.elo.getValue().substring(0,
								this.maxchars);

					}
					this.el.update(String.format(this.text, this.maxchars
									- this.elo.getValue().length));

				}, this);
			}

		});

