if(!deft){
	var deft = {};
}

var expanded = false;
	jQuery.fn.dropNav = function(){
		//cache nav
		var nav = $(this);
		//add indicators and hovers to submenu parents
		nav.find("li").each(function() {
			if ($(this).find("ul").length > 0) {
				//show subnav on hover
				$(this).mouseenter(function() {			
					$(this).find("ul").stop(true, true).show().animate({paddingTop: 15,height: 75,paddingBottom: 10},250);
					$(this).find('a').addClass('active-hover');
				});

				//hide submenus on exit
				$(this).mouseleave(function() {
					jsddm_close($(this).find("ul"))
					$(this).find('a').removeClass('active-hover');
				});
			}
		});
	}
	
	jQuery.fn.accordian = function() {
		
		var accordian = $(this);			
		var expandLink = accordian.prev();
		accordian.delegate('dt','click',function(e){
			$(this).addClass('no-border');	
			$(this).next().slideToggle('fast',function(ee){
				$(this).prev().toggleClass('expand');
				$(this).prev().removeClass('no-border');
				if((accordian.find("dt.expand").length) <= 0){
					 expanded = false;
					 expandLink.html('Expand All Panels');
				}else if(accordian.find("dt.expand").length >= accordian.find("dt").length){
					 expanded = true;
					 expandLink.html('Collapse All Panels');
				}
			});
		});	
		
		expandLink.click(function(e){
			var el = e.target;
			if($(el).hasClass('expanded')){	
			//if(expanded){
				//$(this).html('Collapse All Panels');
				$(this).removeClass('expanded');
				$(this).html('Expand All Panels');
				expanded = false;
				deft.collapsePanels($(this).next());
			}else{
				$(this).addClass('expanded');
				$(this).html('Collapse All Panels');
				expanded = true;
				deft.expandPanels($(this).next());
			}
			
		});
	}
	
	jQuery.fn.blockquote = function() {

		var quote = $(this);
		var source = $(quote).find('em').html();
		$(quote).find('em').remove();
		var quoteTxt = $(quote).html();
		$(quote).html('<div class=\"quoteLeft\"></div><div class=\"quoteRight\"></div><div class=\"content\"></div>')
		$('.content').html('<span>' + quoteTxt + '</span><em>' + source + '</em>')
		var width = $('blockquote span').width();
		var bgTop = $('.content').height() - 10;
		var bgLeft = parseInt(width) + parseInt(58);
		$('.content').width(width);
		$('.quoteRight').css('left', bgLeft + 'px').css('top', + bgTop + 'px');
}

	jQuery.fn.contactCompass = function() {

		_expand = function() {
			$('.contact-compass-bg').animate({height: 186},500)
			$('#contact-compass-link').addClass('no-hover');			
		}
		
		_collapse = function(){
			$('.contact-compass-bg').animate({height: 38},500)
			$('#contact-compass-link').removeClass('no-hover');
		}
		
		_setInterface = function() {
			$('#contact-compass-link').click(_expand);
			$('#contact-compass-collapse').click(_collapse);
		}	
		
		_setInterface();
	}

deft.expand = function(){
	$(this).toggleClass('expand');
}

deft.expandAll = function(){
	if(expanded){
		//$(this).html('Collapse All Panels');
		$(this).removeClass('expanded');
		$(this).html('Expand All Panels');
		expanded = false;
		deft.collapsePanels();
	}else{
		$(this).addClass('expanded');
		$(this).html('Collapse All Panels');
		expanded = true;
		deft.expandPanels();
	}
}

deft.expandPanels = function(e) {
	var def = $(e);
	
	def.find("dt").each(function(){
		var dt = $(this);
		var dd = $(this).next();
		
		dt.addClass('no-border');
		dd.slideDown('slow',function(ee){
			$(this).prev().addClass('expand');
		});
	});
}

deft.collapsePanels = function(e) {
	var def = $(e);
	
	def.find("dt").each(function(){
		$(this).next().slideUp('slow',function(ee){
			$(this).prev().removeClass('expand');
			$(this).prev().removeClass('no-border');
		});
	});
}

function jsddm_close(e){  
	e.stop(true, true).animate({paddingBottom: 0,height: 0,paddingTop: 0},250, function() {
	e.hide();
	});
}



