var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

/*	FUNCTION JUNCTION	*/
function jsddm_open(){
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = jQuery(this).find('ul').eq(0).css({'visibility':'visible'});
}
function jsddm_close(){	if(ddmenuitem) ddmenuitem.css({'visibility':'hidden'});}
function jsddm_timer(){	closetimer = window.setTimeout(jsddm_close, timeout);}
function jsddm_canceltimer(){
	if(closetimer){
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
function popMe(e){
	e.preventDefault();	
	if(this.id != window.tgtID){
		jQuery('#div_' + window.tgtID).slideToggle(800);
		var tgtID = this.id;
		jQuery('#div_' + tgtID).slideToggle(400);
		
		window.tgtID = tgtID;
	}
}

/*	PLUG IN CENTRAL	*/
(function($){
    $.fn.extend({
        centerMe: function(){
            return this.each(function(){
//				console.log(this);
				parent_h = $(this).parent().height();
				this_h = $(this).height();
				new_Y = (parent_h - this_h) / 2;
				jQuery(this).css({'top':new_Y});
            });
        }
    });
})(jQuery);


jQuery(document).ready(function(){
	jQuery('#home_pg .blurb').centerMe();
	
	jQuery('#jsddm > li').bind('mouseover', jsddm_open);
	jQuery('#jsddm > li').bind('mouseout', jsddm_timer);
	jQuery('#jsddm #funds_sm').prepend(jQuery('#jsddm #funds_sm #overview'));

	
	jQuery('#management_pg .manager_name').bind('click',popMe);
});
document.onclick = jsddm_close;
