U.UI.Social = new Class({
	Extends : U.Element,
	Implements : Events,
	_closed : true,
	_sizes : {opened: 392, closed: 32},
	initialize : function() {
		this.parent('u-social');
		if (!this.element) return;
		if (Browser.Engine.trident4) {
			this.element.setStyle('position','absolute');
			window.addEvents({
				scroll : this._setPosition.bind(this),
				resize : this._setPosition.bind(this),
				load : this._setPosition.bind(this)
			});
			this.ie6Fx = new Fx.Tween(this.element, {duration: 200});
		} else {
			this.element.setStyles({
				position:'fixed',
				bottom:'0'
			})
		};
		this.content = $('u-social-content');
		//this.element.setStyle('position', Browser.Engine.trident4)?'absolute':'fixed';
		this.show();
		//this.element.fade('hide');
		//this.element.fade('in');
		this.fx = new Fx.Tween(this.element, {duration:200});
//still having issues here on IE6+7
//this.element.setStyles({visibility:'visible',height:0});
		this.element.setStyles({visibility:'visible', height:this._sizes.closed});
		//this.element.setStyle('visibility','visible')
//this._closed = false;
//this.minimize();
		this.toggleBtn = $('u-social-toggle');
		if (this.toggleBtn != null) this.toggleBtn.addEvent('click', this.toggle.bind(this));
	},
	toggle : function() {
		if (this._closed) this.maximize();
		else this.minimize();
		return this;
	},
	minimize : function() {
		if (this._closed) return;
		$log('minimize');
		this.fx.start('height', this._sizes.closed);
		if (Browser.Engine.trident4) this.ie6Fx.start('top', (document.documentElement.clientHeight+document.documentElement.scrollTop-this._sizes.closed)+'px');
		this._closed = true;
		$log('minimize _closed set');
		return this;
	},
	maximize : function() {
		if (!this._closed) return;
		$log('maximize');
		this.fx.start('height', this._sizes.opened);
		if (Browser.Engine.trident4) this.ie6Fx.start('top', (document.documentElement.clientHeight+document.documentElement.scrollTop-this._sizes.opened)+'px');
		this._closed = false;
		return this;
	},
	hide : function () {
		this.element.style.visibility = 'hidden';
		return this;
	},
	unHide : function () {
		this.element.style.visibility = "visible";
		return this;
	},
	_setPosition : function() {
		var y = this._closed?this._sizes.closed:this._sizes.opened;
		this.element.setStyle('top', (document.documentElement.clientHeight+document.documentElement.scrollTop-y)+'px');
	},
	adopt : function(element, replace) {
		if (replace) this.content.empty();
		this.content.adopt(element);
		return this;
	},
	loadHtml : function(text) {
		this.content.set('html', text);
		return this;
	},
	loadUrl : function(url, replace) {
		if (replace) this.content.empty();
		new IFrame({
			id : $newid(),
			src : url,
			styles : {width:'100%',height:'100%',border:'0 solid #fff'}
		}).inject(this.content);
		return this;
	},
	loadImage : function(url, replace) {
		if (replace) this.content.empty();
		new Element('img', {src:url}).inject(this.content);
		return this;
	}
	
});
var $usocial;
window.addEvent('domready', function() { $usocial = new U.UI.Social()});