var CHeader = new Class(
				{
					// declare any variables we need
					aLogin: 		null,
					bClosed:		null,
					bAnimating:		null,
					
					objTopWrapper: 	{login:{open:260, closed:170},
									 share:{open:310, closed:170}},
					
					objAux: 		{login:{open:150, closed:60},
									 share:{open:200, closed:60}},
									 
					objHeader: 		{login:{open:120, closed:30},
									 share:{open:170, closed:30}},
									 
					objSearch: 		{},
					 
					objLogin: 		{open:20, closed:-60},
					
					objShare: 		{open:20, closed:-120},
					
					disableLogin:	function(el)
					{
						if(el)
						{
							if(Browser.Engine.trident)
								el.onclick = function(){ return true; };
							else
								el.removeAttribute('onclick');
								
							el.removeEvents('click');
						}
					},
					
					getSiteClass:	function()
					{
						var divSite 		= $('site');
						var strSiteClass 	= null;
						if(divSite)
						{
							if(divSite.hasClass('home'))
								strSiteClass = "home";
						    if(divSite.hasClass('error'))
								strSiteClass = "error";
							if(divSite.hasClass('search'))
								strSiteClass = "search";
						}
						return strSiteClass;
					},
					
					hideHeader:		function(divTarget, divHolder)
					{
						// get the divs that we need to manipulate
						var divTopWrapper 	= $('topwrapper');
						var divHeader 		= $('header');
						var divAux 			= $('inneraux');
						var divSearch 		= $('frm_search');
						
						// if we found all the divs
						if(divTopWrapper && divTopWrapper && divTopWrapper && divTarget)
						{
							// if we are ok to animate and it's closed,
							// then open up the header
							if(!this.bAnimating)
							{
								// get the li that holds the anchor
								//var aLoginHolder	= $('lnk_login_holder');
								
								// hide the white arrow, remove the class
								if(divHolder && divHolder.hasClass('active'))
									divHolder.removeClass('active');
								
								// tween the elements
								if(divTarget == $('login'))
								{
									// LOGIN
									divTopWrapper.tween('height', 	[this.objTopWrapper.login.open,		this.objTopWrapper.login.closed]);
									divAux.tween('height', 			[this.objAux.login.open,			this.objAux.login.closed]);
									divHeader.tween('top', 			[this.objHeader.login.open,			this.objHeader.login.closed]);
									divTarget.tween('top', 			[this.objLogin.open,				this.objLogin.closed]);
									
									//if(this.getSiteClass())
										//divSearch.tween('top', 			[this.objSearch[this.getSiteClass()].login.open,			this.objSearch[this.getSiteClass()].login.closed]);
								}
								else
								{
									// SHARE & SUBSCRIBE
									divTopWrapper.tween('height', 	[this.objTopWrapper.share.open,		this.objTopWrapper.share.closed]);
									divAux.tween('height', 			[this.objAux.share.open,			this.objAux.share.closed]);
									divHeader.tween('top', 			[this.objHeader.share.open,			this.objHeader.share.closed]);
									divTarget.tween('top', 			[this.objShare.open,				this.objShare.closed]);
									
									//if(this.getSiteClass())
										//divSearch.tween('top', 			[this.objSearch[this.getSiteClass()].share.open,			this.objSearch[this.getSiteClass()].share.closed]);
								}
								
								divTarget.set('open', false);
									
								// invert the closed status
								this.bClosed = "Yes";
								
								// set a cookie
								Cookie.write('GCSEPOD_HEADER', this.bClosed, {duration:365, domain:document.domain, path:"/"});
							}
						}	
					},
					
					showHeader:		function(divTarget, divHolder)
					{
						// get the divs that we need to manipulate
						var divTopWrapper 	= $('topwrapper');
						var divHeader 		= $('header');
						var divAux 			= $('inneraux');
						var divSearch 		= $('frm_search');
						
						// if we found all the divs
						if(divTopWrapper && divHeader && divAux && divTarget)
						{
							// if we are ok to animate and it's closed,
							// then open up the header
							if(!this.bAnimating)
							{
								// get the li that holds the anchor
								//var aLoginHolder	= $('lnk_login_holder');
								
								// set the holder to be active,
								// showing the white arrow head
								if(divHolder && !divHolder.hasClass('active'))
									divHolder.addClass('active');
								
								// tween the elements
								if(divTarget == $('login'))
								{
									// LOGIN
									divTopWrapper.tween('height', 	[this.objTopWrapper.login.closed,	this.objTopWrapper.login.open]);
									divAux.tween('height', 			[this.objAux.login.closed,			this.objAux.login.open]);
									divHeader.tween('top', 			[this.objHeader.login.closed,		this.objHeader.login.open]);
									divTarget.tween('top', 			[this.objLogin.closed,				this.objLogin.open]);
									
									//if(this.getSiteClass())
										//divSearch.tween('top', 			[this.objSearch[this.getSiteClass()].login.closed,			this.objSearch[this.getSiteClass()].login.open]);
									
									Cookie.write('GCSEPOD_HEADER_STATE', "Login", {duration:365, domain:document.domain, path:"/"});
								}
								else
								{
									// SHARE & SUBSCRIBE
									divTopWrapper.tween('height', 	[this.objTopWrapper.share.closed,	this.objTopWrapper.share.open]);
									divAux.tween('height', 			[this.objAux.share.closed,			this.objAux.share.open]);
									divHeader.tween('top', 			[this.objHeader.share.closed,		this.objHeader.share.open]);
									divTarget.tween('top', 			[this.objShare.closed,				this.objShare.open]);
									
									//if(this.getSiteClass())
										//divSearch.tween('top', 			[this.objSearch[this.getSiteClass()].share.closed,			this.objSearch[this.getSiteClass()].share.open]);
									
									Cookie.write('GCSEPOD_HEADER_STATE', "Share", {duration:365, domain:document.domain, path:"/"});
								}
								
								divTarget.set('open', true);
								
								// invert the closed status
								this.bClosed = "No";
								
								// set a cookie
								Cookie.write('GCSEPOD_HEADER', this.bClosed, {duration:365, domain:document.domain, path:"/"});
							}
						}
					},
					
					switchHeader: 	function(divTarget, divHolder)
					{
						// get the divs that we need to manipulate
						var divTopWrapper 	= $('topwrapper');
						var divHeader 		= $('header');
						var divAux 			= $('inneraux');
						var divSearch 		= $('frm_search');
						
						// if we found all the divs
						if(divTopWrapper && divHeader && divAux && divTarget)
						{
							// if we are ok to animate and it's closed,
							// then open up the header
							if(!this.bAnimating)
							{
								// get the li that holds the anchor
								//var aLoginHolder	= $('lnk_login_holder');
								
								if($('lnk_login_holder'))
									$('lnk_login_holder').removeClass('active');
								
								if($('lnk_share_holder'))
									$('lnk_share_holder').removeClass('active');
								
								// set the holder to be active,
								// showing the white arrow head
								if(divHolder && !divHolder.hasClass('active'))
									divHolder.addClass('active');
								
								// tween the elements
								if(divTarget == $('login'))
								{
									// LOGIN
									divTopWrapper.tween('height', 	[this.objTopWrapper.share.open,	this.objTopWrapper.login.open]);
									divAux.tween('height', 			[this.objAux.share.open,		this.objAux.login.open]);
									divHeader.tween('top', 			[this.objHeader.share.open,		this.objHeader.login.open]);
									
									$('sharesubscribe').set('open', false);
									$('login').set('open', true);
									$('sharesubscribe').setStyle('top', this.objShare.closed+'px');
									$('login').setStyle('top', this.objLogin.open+'px');
									$('login').setStyle('opacity', 0);
									$('login').tween('opacity', [0,1]);
									
									Cookie.write('GCSEPOD_HEADER_STATE', "Login", {duration:365, domain:document.domain, path:"/"});
								}
								else
								{
									// SHARE & SUBSCRIBE
									divTopWrapper.tween('height', 	[this.objTopWrapper.login.open,	this.objTopWrapper.share.open]);
									divAux.tween('height', 			[this.objAux.login.open,		this.objAux.share.open]);
									divHeader.tween('top', 			[this.objHeader.login.open,		this.objHeader.share.open]);
									
									$('login').set('open', false);
									$('sharesubscribe').set('open', true);
									$('login').setStyle('top', this.objLogin.closed+'px');
									$('sharesubscribe').setStyle('top', this.objShare.open+'px');
									$('sharesubscribe').setStyle('opacity', 0.3);
									$('sharesubscribe').tween('opacity', [0,1]);
									
									Cookie.write('GCSEPOD_HEADER_STATE', "Share", {duration:365, domain:document.domain, path:"/"});
								}
								
								divTarget.set('open', true);
								
								// invert the closed status
								this.bClosed = "No";
								
							}
						}
					},
					
					enableLinks: 	function()
					{
						var aLogin				= $('lnk_login');
						var aShare				= $('lnk_share');
						
						// declare the header closed
						var strLoginOpen 		= "false";
						var strShareOpen 		= "false";
						
						if(Cookie.read('GCSEPOD_HEADER') && Cookie.read('GCSEPOD_HEADER') == "No")
						{
							if(Cookie.read('GCSEPOD_HEADER_STATE'))
							{
								if(Cookie.read('GCSEPOD_HEADER_STATE') == "Login")
									strLoginOpen	= "true";
								else if(Cookie.read('GCSEPOD_HEADER_STATE') == "Share")
									strShareOpen	= "true";
							}
						}
						
						// if we've found it
						if(aLogin)
						{
							// declare that it the header closed
							$('login').set('open', strLoginOpen);
							
							// hijack the anchor behaviour
							if(Browser.Engine.trident)
								aLogin.onclick = function(){ return false; };
							else
								aLogin.setAttribute('onclick', 'return false');
								
							// add an onclick handler to open / close
							// the header
							aLogin.addEvent('click', function()
							{
								if(objHeader)
								{
									if(objHeader.bClosed == "Yes")
										objHeader.showHeader($("login"), $('lnk_login_holder'));
									else
									{
										if($("sharesubscribe").get('open') == "true")
										{
											objHeader.switchHeader($("login"), $('lnk_login_holder'));
										}
										else
										{
											objHeader.hideHeader($("login"), $('lnk_login_holder'));
										}
									}
								}
							});
						}
						
						// if we've found it
						if(aShare)
						{
							// declare that it the header closed
							$('sharesubscribe').set('open', strShareOpen);
							
							// hijack the anchor behaviour
							if(Browser.Engine.trident)
								aShare.onclick = function(){ return false; };
							else
								aShare.setAttribute('onclick', 'return false');
								
							// add an onclick handler to open / close
							// the header
							aShare.addEvent('click', function()
							{
								if(objHeader)
								{
									if(objHeader.bClosed == "Yes")
										objHeader.showHeader($("sharesubscribe"), $('lnk_share_holder'));
									else
									{
										if($("login").get('open') == "true")
										{
											objHeader.switchHeader($("sharesubscribe"), $('lnk_share_holder'));
										}
										else
											objHeader.hideHeader($("sharesubscribe"), $('lnk_share_holder'));
									}
								}
							});
						}
					},
					
					// do a constructor
					initialize:		function()
					{
						// get the login anchor
						var aLogin			= $('lnk_login');
						var aShare			= $('lnk_share');
						
						// declare the header closed
						this.bClosed		= "Yes";
						this.bAnimating		= false;
						
						
						// search field manipulation
						this.objSearch["home"] = {
												login:{open:470, closed:380},
									 			share:{open:520, closed:380}
											};
											
						this.objSearch["error"] = {
													login:{open:500, closed:410},
													share:{open:550, closed:410}
												};
												
						this.objSearch["search"] = {
													login:{open:300, closed:210},
													share:{open:350, closed:210}
												};
						
						// get the divs that we need to manipulate
						var divTopWrapper 	= $('topwrapper');
						var divHeader 		= $('header');
						var divAux 			= $('inneraux');
						var divLogin 		= $('login');
						var divShare 		= $('sharesubscribe');
						var divSearch 		= $('frm_search');
						
						if(divTopWrapper && divTopWrapper && divTopWrapper && divLogin && divShare)
						{
							// set the animation variables
							divTopWrapper.set('tween', 	{	transition:Fx.Transitions.Expo.easeOut, duration:600	});
							divAux.set('tween', 		{	transition:Fx.Transitions.Expo.easeOut, duration:600	});
							divHeader.set('tween', 		{	transition:Fx.Transitions.Expo.easeOut, duration:600	});
							divSearch.set('tween', 		{	transition:Fx.Transitions.Expo.easeOut, duration:600	});
							divLogin.set('tween',		{	transition:	Fx.Transitions.Expo.easeOut, 
															duration:	600,
															onStart:	function()
															{
																objHeader.bAnimating = true;
																
															},
															
															onComplete:	function()
															{
																objHeader.bAnimating = false;
															}
														});
							divShare.set('tween',		{	transition:	Fx.Transitions.Expo.easeOut, 
															duration:	600,
															onStart:	function()
															{
																objHeader.bAnimating = true;
															},
															
															onComplete:	function()
															{
																objHeader.bAnimating = false;
															}
														});
						}
								
						// now we need to check if the cookie has been set
						// and if it has, we need to already maximise the header
						if(Cookie.read('GCSEPOD_HEADER') && Cookie.read('GCSEPOD_HEADER') == "No")
						{
							if(Cookie.read('GCSEPOD_HEADER_STATE') && Cookie.read('GCSEPOD_HEADER_STATE') == "Login")
							{
								// get the li that holds the anchor
								var aLoginHolder	= $('lnk_login_holder');
								
								// if we found it but it's not set to active, add the class
								if(aLoginHolder && !aLoginHolder.hasClass('active'))
									aLoginHolder.addClass('active');
												
								// declare the header open
								this.bClosed		= "No";
								
								// get the divs that we need to manipulate
								var divTopWrapper 	= $('topwrapper');
								var divHeader 		= $('header');
								var divAux 			= $('inneraux');
								var divLogin 		= $('login');
								var divSearch		= $('frm_search');
								
								// if we found all the divs
								if(divTopWrapper && divHeader && divAux && divLogin)
								{
									divTopWrapper.set('styles', {height: this.objTopWrapper.login.open+'px'});
									divAux.set('styles', {height: this.objAux.login.open+'px'});
									divHeader.set('styles', {top: this.objHeader.login.open+'px'});
									divLogin.set('styles', {top: this.objLogin.open+'px'});
									
									//if(this.getSiteClass())
										//divSearch.set('styles', {top: this.objSearch[this.getSiteClass()].login.open+'px'});
									
								}
							}
							else if(Cookie.read('GCSEPOD_HEADER_STATE') && Cookie.read('GCSEPOD_HEADER_STATE') == "Share")
							{
								// get the li that holds the anchor
								var aShareHolder	= $('lnk_share_holder');
								
								// if we found it but it's not set to active, add the class
								if(aShareHolder && !aShareHolder.hasClass('active'))
									aShareHolder.addClass('active');
												
								// declare the header open
								this.bClosed		= "No";
								
								// get the divs that we need to manipulate
								var divTopWrapper 	= $('topwrapper');
								var divHeader 		= $('header');
								var divAux 			= $('inneraux');
								var divShare 		= $('sharesubscribe');
								var divSearch		= $('frm_search');
								
								// if we found all the divs
								if(divTopWrapper && divHeader && divAux && divShare)
								{
									divTopWrapper.set('styles', {height: this.objTopWrapper.share.open+'px'});
									divAux.set('styles', {height: this.objAux.share.open+'px'});
									divHeader.set('styles', {top: this.objHeader.share.open+'px'});
									divShare.set('styles', {top: this.objShare.open+'px'});
									
									
									//if(this.getSiteClass())
										//divSearch.set('styles', {top: this.objSearch[this.getSiteClass()].share.open+'px'});
								}
							}
						}
						
						this.enableLinks();
					}
				});

var objHeader = null;

// once the browser is ready, create a new header
window.addEvent('domready', function()
							{
								objHeader = new CHeader();
							});

