/**
 * Dropdown
 * 
 * Version: 0.0.1
 *
 * Discription
 * Dropdown gemaakt voor erik lolkema, de each functie aanpassen voor andere sites
 *
 * Changes:
 * 0.0.1
 * - 
 */

(function($) {
	
	$.fn.dropdown = function(){
		
		this.each(function(k, v){
			
			$(v).hover(show, hide);
			
		});
		
		$('.dropdown').hover(showSub, hideSub);
		
		function show() {
			
			if($(this)[0].tagName.toLowerCase() == 'a') {
				
				var href = $(this)[0].getAttribute('href');
			} else {
			
				var href = $(this).find('a')[0].getAttribute('href');
			}
			
			var pieces = href.split('/');
			var id = pieces[ pieces.length - 2 ];
			
			var pos = $(this).offset();
			var height = $(this).height();
			
			$('#D' + id).css({left: pos.left + 'px', top: (pos.top + height) + 'px'}).stop(true, true).fadeIn('fast');
		};
		
		function hide() {
			
			if($(this)[0].tagName.toLowerCase() == 'a') {
				
				var href = $(this)[0].getAttribute('href');
			} else {
			
				var href = $(this).find('a')[0].getAttribute('href');
			}
			
			var pieces = href.split('/');
			var id = pieces[ pieces.length - 2 ];
			
			$('#D' + id).stop(true, true).fadeOut('slow');
		};
		
		function showSub() {
			
			$(this).stop(true).css('opacity', 1).show();
		};
		
		function hideSub() {
			
			$(this).fadeOut('slow');
		};
	};
	
	$.fn.dropdown.activeHover;
	$.fn.dropdown.timer;
})(jQuery);
