
var $j = jQuery.noConflict();


$j(document).ready(function() {
		
	$j('#headerNav li.navdrop').hover(function() {
		$j(this).children('div').show();
	}, function() {
		$j(this).children('div').hide();
	});

	$j('#sidePhotos').cycle({
		timeout:	4000
	});
	$j('#memberBanners').cycle({
		timeout:	6000
	});
	
	$j('#sidePhotosOverlay').pngFix();
	
	$j('.tform_focus input, .tform_focus select, .tform_focus textarea').focus(function() {
		$j(this).parents('li').not('.nohov').addClass('focused').animate({ 'backgroundColor': '#E5ECF0' }, 200).find('.hint').show();
	}).blur(function() {
		$j(this).parents('li').not('.nohov').removeClass('focused').animate({ 'backgroundColor': '#ffffff' }, 200).find('.hint').hide();
	});
	
	$j('.tform_hov li').not('.nohov').hover(function() {
  		$j(this).animate({ 'backgroundColor': '#E5ECF0' }, 200).find('.hint').fadeIn(200);
		$j(this).find('p.hint').fadeIn(200);
  	}, function() {
		if (!$j(this).hasClass('focused')) {
			$j(this).animate({ 'backgroundColor': '#ffffff' }, 200).find('.hint').fadeOut(200);
			$j(this).find('p.hint').fadeOut(200);
		}
		
 	});
	
});


(function($) {


$.fn.wad = function(settings) {
	
    // settings
    settings = $.extend({
		containerClass:	'dropdown_container',
        headClass: 		'drophead',
		openClass: 		'drop_open',
		closedClass: 	'drop_closed',
        dropClass: 		'dropdown',
		slideTime: 		250,
		inForm:			true,
		overlay:		false
    }, settings || {});

    return this.each(function() {
							  
		var $this = $(this);
		var $input = $this.children('input:hidden');
		var temp = "";
		
		$(document).ready(function() {
			$(this).children('.' + settings.dropClass).hide();
			if (settings.overlay) $('#dropoverlay').css('opacity', '0.5');
			else $('#dropoverlay').css('opacity', '0');
						
			if ( $input.val() != "" ) {
				temp = $this.find('li').children('a').filter('[title=' + $input.val() + ']').html();
				$this.children('.' + settings.headClass).html(temp).addClass('active');
			}
			
		});
		
		function open_drop() {
			close_drop;
			$this.find('.' + settings.headClass).removeClass(settings.closedClass).addClass(settings.openClass).siblings('.' + settings.dropClass).slideDown(settings.slideTime);
			$('.' + settings.containerClass).css('z-index','1');
			$this.css('z-index','420');
			if (settings.overlay) $('#dropoverlay').fadeIn(settings.slideTime);
			else $('#dropoverlay').show();
		};
		
		function close_drop() {
			$this.find('.' + settings.headClass).removeClass(settings.openClass).addClass(settings.closedClass).siblings('.' + settings.dropClass).slideUp(settings.slideTime);
			if (settings.overlay) $('#dropoverlay').fadeOut(settings.slideTime);
			else $('#dropoverlay').hide();
			
		};
		
		$(this).find('.' + settings.headClass).click(function() {
			if ($(this).hasClass(settings.closedClass)) {
				open_drop();
			} else {
				close_drop();
			}
		});		

		if (settings.inForm) {
			$this.find('li').children('a').click(function() {
				$input.val($(this).attr('href'));
				$this.children('.' + settings.headClass).html($(this).html()).addClass('active');
				close_drop();
				return false;
			});
		};
		
		$('#dropoverlay').live('click', function() {
			close_drop();
		});


	});

};

})(jQuery);

