
(function( pb, $)
{
	pb.footer = function()
	{
		this.footerObject = null;
		this.currentClassId = "";
	}
	
	pb.footer.prototype = 
	{
			register : function( footerObject )
			{
				if( typeof( footerObject ) != "object")
				{
					alert("FooterObject is not an object!");
					return;
				}
				
				this.footerObject = footerObject;
				
				delete footerObject;
					
				return;
			}
			
		,	registerPages : function( classIds )
			{
				var thisObject = this;
				
				if( typeof( classIds ) != "object")
				{
					alert("ClassIds is not an array!");
					return;
				}
				
				for(id in classIds)
				{
					this.footerObject.find("a."+classIds[id]).bind("mousedown", function(){ return false; } );
					this.footerObject.find("a."+classIds[id]).bind("click", function()
					{
						$("div.footer-page").css( { height:0 } );1
						thisObject.currentClassId = $(this).attr("id").toString().split("-")[2];
						thisObject.openPage( thisObject.currentClassId );
						
						return false;
					});
				}
				
				this.footerObject.find("a.footer-close").bind("mouseover", function(){ $(this).addClass("close-over"); });
				this.footerObject.find("a.footer-close").bind("mouseout", function(){ $(this).removeClass("close-over"); });
				this.footerObject.find("a.footer-close").bind("mousedown", function()
				{ 
					var	thisObject = this;
				
					$(thisObject).addClass("close-down").removeClass("close-over"); 
					
					$(document).bind("mouseup", function()
					{
						$(thisObject).removeClass("close-down"); 
						$(document).unbind("mousedown");
					});
					
					delete thisObject;
					
					return false; 
				});
				
				this.footerObject.find("a.footer-close").bind("click", function()
				{
					$(this).removeClass("close-down");
					
					if(thisObject.currentClassId)
						thisObject.closePage( thisObject.currentClassId );
					
					return false;
				});
				
				delete classIds, thisObject;
				
				return;
			}
			
		,	openPage : function( classId )
			{
				this.footerObject.find("div."+classId).animate( { height:this.footerObject.find("div."+classId).get(0).scrollHeight } );
			}
			
		,	closePage : function( classId )
			{
				if(document.documentElement.scrollTop && (window.pageYOffset + window.innerHeight) === document.documentElement.scrollHeight)
						window.scrollTo(0, (document.documentElement.scrollTop-2));
						
				this.footerObject.find("div."+classId).animate( { height:0 } );
			}
	}
})( Pluxbox, jQuery );
