
/*
 * Superposition v0.1a - jQuery plugin
 * Copyright (c) 2010 Marcus Bieber
 * Special thanks to Matthias Enderes of me23.de
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 *
 * This plugin automatically adjusts submenu to the top pf parent container
 *
 */

;(function($){ // $ will refer to jQuery within this closure

	$.fn.superposition = function(options){	
		
		var opts = $.extend({}, $.fn.superposition.defaults, options);	
		
		return this.each(function() {								  
			var $parentLIs = $('.secondNav').parent();
			
			$parentLIs.each(function(i){
				var $ul = $parentLIs.eq(i);
				var $currentUL = $($ul.children('ul'));
				
				var $currentHeight = $($ul.children('ul')).outerHeight();
				var $currentTop = $($ul.children('ul')).position().top;
				
				var $topPosition = ($parentLIs.eq(i).position().top);
				var $leftPosition = ($parentLIs.eq(i).position().left);
				var $parentWidth = ($parentLIs.eq(i).outerWidth());
				var $newTop = $topPosition;
				
				$currentUL.css({		   						
					top:-$newTop+'px'
				});  
			});
			
			var $fourthsParent = $('.thirdNav').parent();			
			$fourthsParent.each(function(k){
				var $ulFourth = $fourthsParent.eq(k);
				var $currentULFourth = $($ulFourth.children('ul'));
				var $topPositionFourth = ($fourthsParent.eq(k).position().top);
				var $leftPosition = ($fourthsParent.eq(k).position().left);
				var $parentWidth = ($parentLIs.eq(k).outerWidth());
				$currentULFourth.css({		   						
					top:-$topPositionFourth+'px'
				});  
			});
		});
	};
	
	// expose defaults
	$.fn.superposition.defaults = {
		offSet		: 10
	};
})(jQuery); // plugin code ends

