/** 
 * @projectDescription Simple Tab Down
 * @author 	Matt Hobbs (http://nooshu.com/)
 * @version 0.1
 * 
 * Plug-in that positions selected content above the page
 * to be called by the user when needed. Useful for contact
 * information etc.
 */
(function($){
	$.fn.tabDown = function(customOptions){
		//Merge default and user options
		var options = $.extend({}, $.fn.tabDown.defaultOptions, customOptions);
		return this.each(function(i){
			//Tab Content
			var $this = $(this);
			//Wrapper (usually body)
			var $container = $(options.container);
			
			//Current container padding
			var padding = parseInt($container.css("paddingTop"), 100);
			
			//Calculate the height of the content
			var height = $this.innerHeight();
			
			//Pull the content up
			$this.css({
				position: "absolute",
				marginTop: -height,
				zIndex: 99,
				marginLeft: 607,
			});
			
			//Generate our tab (requires jQuery 1.4+)
			$("<div/>",{
				id: "tab",
				css: {
					display: "block",
					cursor: "pointer",
					background: "url('http://3dhonlapkeszites.hu/tothbori/skin/frontend/default/tothbori/images/info_icon.png')",
					width: 21,
					height: 24,
					position: "relative",
					float: "right",
					marginTop: 7,
				},
				//html: options.downText
			}).toggle(function(){
				$this.animate({
					marginTop: 0
				}, options.time, options.easing);
				
				if(!options.floating){
					$container.animate({
						paddingTop: height + padding
					}, options.time, options.easing);
				}
				
				//Change text up
				//$(this).empty().text(options.upText);
			}, function(){
				$this.animate({
					marginTop: -height
				}, options.time, options.easing);
				
				if(!options.floating){
					$container.animate({
						paddingTop: padding
					}, options.time, options.easing);
				}
				
				//Change text down
				//$(this).empty().text(options.downText);
			}).appendTo($this);
		});
	};
	
	//Set our plugin defaults
	$.fn.tabDown.defaultOptions = {
		container: "body",
		time: 1000,
		downText: "Down",
		upText: "Up",
		easing: "swing",
		floating: true
	};
})(jQuery);
