var ContentHider = new Class({
	initialize:function(flashObject)
	{
		this.mainObj = $('rightHold');
		this.flashObject = flashObject;
		
		this.logo = $('logoHold');
		
		if(this.logo)
		{
			this.logo.setStyles({
				'position':'absolute',
				'left':this.logo.getPosition().x
			})
			this.logoPosition = 3;
		}
		else if($('logoNormalIn') && this.mainObj)
		{
			this.logo = $('logoNormalIn');
			this.logo.setStyle('position','absolute');
			this.logo.fx = new Fx.Tween(this.logo,{link:'chain'});
			this.moveLogo(1);
		}
		
		if(this.logo)
			this.logo.fx = new Fx.Tween(this.logo,{link:'chain'});
		
		window.addEvent('resize',this.resizeEvt.bind(this))
		
		if(!this.mainObj)
			return;
		
		this.mainObj.fx = new Fx.Tween(this.mainObj,{link:'cancel'});
		this.toggler = this.mainObj.getElement('div#switchHold').getElement('div.holder').getElement('a');
		this.minimumWidth = 220;
		this.show = true;
		this.toggler.addEvent('mouseup',this.toggle.bind(this));
		this.run = false;
/*		
		$(document.body).addEvent('click',function(e)
		{
			if(!this.checkBody(e.target))
				this.hidePanel();
			else if(!this.show)
				this.showPanel();
		}.bind(this));
*/		
		this.mainObj.addEvents({
			'mouseenter':function()
			{
				if(this.show==false && this.run == false)
					this.fadeInObj()
			}.bind(this),
			'mouseleave':function()
			{
				if(this.show==false && this.run == false)
					this.fadeOutObj()
			}.bind(this)
		})
	},
	toggle:function(e)
	{
		e.stopPropagation();
		e.stop();
		if(this.show == true)
			return this.hidePanel()
		else
			return this.showPanel()
	},
/*	checkBody:function(el)
	{
		el = $(el)
		if (!el) return true;
		while(el.id !='rightHold')
		{
			if(el.id == 'Holder')
				return false
			el = el.parentNode;
		}
		return true
	}, */
	hidePanel:function()
	{
		if(this.show == false)
			return
		this.run = true;
		this.toggler.setStyle('background-position','right top');
		this.mainObj.setStyles({'min-width':220,'width':this.mainObj.getSize().x});
		this.mainObj.fx.start('width',220).chain(function(){this.show = false; this.fadeOutObj(); this.run=false; this.moveLogo(3)}.bind(this));
	},
	showPanel:function()
	{
		if(this.show == true)
			return
		this.run = true;
		this.toggler.setStyle('background-position','left top');
		var width = ((window.getSize().x * 6)/10).toInt();
		this.mainObj.fx.start('width',width).chain(function(){this.mainObj.setStyles({'width':'60%','min-width':600}); this.show = true; this.run=false; this.fadeInObj(); this.moveLogo(1) }.bind(this))
	},
	flashShowPanel:function()
	{
		if(this.show == false)
			this.moveLogo(1)
		else
			this.moveLogo(3)
	},
	flashHidePanel:function()
	{
		if(this.show == false)
			return
		this.run = true;
		if(this.toggler && this.mainObj)
		{
			this.toggler.setStyle('background-position','right top');	
			this.mainObj.setStyles({'min-width':220,'width':this.mainObj.getSize().x});
			this.mainObj.fx.start('width',220).chain(function(){this.show = false; this.fadeOutObj(); this.run=false; this.moveLogo(2)}.bind(this));
		}
		else
		{
			this.moveLogo(2)
		}
	},
	moveLogo:function(option)
	{
		if(!this.logo)
			return
		var newPos = this.logo.getPosition().x;
		switch(option)
		{
			case 1:
				newPos = (window.getSize().x - this.mainObj.getSize().x - 310)/2;
			break;
			case 2:
				newPos = (window.getSize().x - 630 - 310)/2;
			break;
			case 3:
				newPos = (window.getSize().x-310)/2
			break;
		}
		this.logoPosition = option;
		this.logo.fx.start('left',newPos);
	},
	resizeEvt:function()
	{
		this.moveLogo(this.logoPosition);
	},
	fadeOutObj:function()
	{
		this.mainObj.fx.start('opacity',0.6);
	},
	fadeInObj:function()
	{
		this.mainObj.fx.start('opacity',1);
	}
});
