
/*****************************************************************************************
*
*      _                                                    _____________     __
*    /\ \                                                  /\_____   ____\   /\ \
*    \ \ \                                                 \/____/\  \___/   \ \ \
*     \ \ \                                                      \ \  \      _\_\ \___
*    __\_\ \    __    __    __  __      ___      __  _   __       \ \  \    /\___   ___\
*   /  __   \  /\ \  /\ \  /\ `'   \   / __'\   /\ `'  `'  \       \ \  \   \/___/\ \__/
*  /\  \L\   \ \ \ \_\_\ \ \ \ \/'\ \ /\ \L\ \_ \ \ \'\ \'\ \   ____\_\  \____   \ \ \
*  \ \_____,__\ \ \______ \ \ \_\\ \_\\ \____,_\ \ \_\ \_\ \_\ /\_____________\   \ \_\
*   \/____ /__/	\/_____/\ \ \/_/ \/_/ \/____/_/  \/_/\/_/\/_/ \/_____________/    \/_/
*                       \ \ \
*                      __\_\ \
*                    /\______/
*                    \/_____/
*
* Copyright 2009 dynamIt Technologies, LLC.
*
* The following code is for the exclusive use of dynamIt Technologies, LLC.
* Any use of this code with written permission from dynamIt is prohibited.
*
* Report an abuse of this copyright to
*	dynamIt Technologies, LLC
*	300 Marconi Boulevard, Suite 203
*	Columbus, Ohio 43215 USA
*	+1.614.538.0095
*
*****************************************************************************************/
/*****************************************************************************************
*
* author: 	Bobby Whitman
* date: 		March 25, 2009
* verson: 	1.0
*
* The following jQuery plugin will turn any nested unordered list into JavaScript
* drop-down menus. Simply include this js file in the <head> of your page and run with it.
*
* Example:
*
* XHTML:
* <ul id="nav">
*	<li><a href="#">About Us</a>
*	<ul>
*		<li><a href="/about-us/about">About</a></li>
*		<li><a href="/about-us/our-history">Our History</a></li>
*		<li><a href="/about-us/our-process">Our Process</a></li>
*	</ul></li>
* 	...
* </ul>
*
* JavaScript:
* $(document).ready(function() {
*	$("#nav").dynamItDrop();
* });
*
*****************************************************************************************/

(function($) {

	$.fn.dynamItDrop = function() {

		return this.each(function() {

			$(this).find('ul').addClass('opened');

			var to;
			var $shutDown = null;
			$(this).children('li').children('a').mouseover(function() {
                
                hideheads();
				
                clearTimeout(to);
				$('ul.opened').hide();
                
                var curBGP = $(this).css('backgroundPosition');
                $(this).css( {'backgroundPosition': curBGP.slice(0, curBGP.length-3).concat('47px')});
                
				$shutDown = $(this).siblings('ul').show();
			}).mouseout(function() {
				$shutDown = $(this).siblings('ul');
				to = setTimeout(function() {
					closeme($shutDown);
				}, 1000);
			});

			$('ul.opened').mouseover(function() {
				clearTimeout(to);
			}).mouseout(function() {
				$shutDown = $(this);
				to = setTimeout(function() {
					closeme($shutDown);
				}, 1000);
			});
            
		});
	};

	function closeme(o) {
		hideheads();
        o.hide();
	}
    
    function hideheads() {
        var cssObjAbout = {'width' : '108px', 'background-position' : '0px 0px'}
        var cssObjFuture = {'width' : '163px', 'background-position' : '-108px 0px'}
        var cssObjCurrent = {'width' : '172px', 'background-position' : '-271px 0px'}
        var cssObjParents = {'width' : '132px', 'background-position' : '-443px 0px'}
        var cssObjAlumni = {'width' : '172px', 'background-position' : '-575px 0px'}
        var cssObjGive = {'width' : '161px', 'background-position' : '-747px 0px'}
        
        $("a#about,	a#about:link, a#about:visited").css(cssObjAbout);
        $("a#future, a#future:link, a#future:visited").css(cssObjFuture);
        $("a#current, a#current:link, a#current:visited").css(cssObjCurrent);
        $("a#parents, a#parents:link, a#parents:visited").css(cssObjParents);
        $("a#alumni, a#alumni:link, a#alumni:visited").css(cssObjAlumni);
        $("a#give, a#give:link, a#give:visited").css(cssObjGive);
    }

})(jQuery);
