// drown-down.js
// jkeyes
$.fn.dropDown = function(element) {	
	var timeoutId;
    var target = $(element);

    var hide = function() { 
        timeoutId = setTimeout(function(){ 
            target.fadeOut(250);
        }, 5); 
    };
    
    var show = function() { 
        target.slideDown(100); 
    };
    
    var hideOther = function() { 
        $('.jq_dropdown').not(target).fadeOut(250); 
    };
    
    var cancelHide = function() {   
        if (timeoutId != undefined) {
            clearTimeout(timeoutId);
        }
    };
    
    target.addClass('jq_dropdown');
    target.css({ 
        top: this.position().top + this.height(), 
        left: this.position().left,
        display: 'none'
    });

    this.hover(function() { 
        hideOther(); 
        cancelHide(); 
        show(); 
    }, hide);
    
    target.hover(cancelHide, hide);
}
