jQuery.noConflict(); var $ = jQuery;
nav = false;
$(document).ready(function() {

// clear text input and reset to default value if nothing is entered
  $.fn.search = function() {
    return this.focus(function() {
      if( this.value == this.defaultValue ) {
        this.value = "";
      }
    }).blur(function() {
	  if( !this.value.length ) {
	    this.value = this.defaultValue;
      }
    });
  };
  $("#email_address").search();
  $("#filter").search();

// slide the join form down by hovering over the noted ID 
  $('#join_button a').mouseover(function() {
    $('#join_button').addClass('active');
    $('#join_form').slideDown('normal');
  });

// slide the join form up by clicking on the noted link 
  $('#join_form a').click(function() {
    $('#join_button').removeClass('active');
    $('#join_form').slideUp('normal');
    return false;
  });

// fades subnav in and out when correpsonding li is rolled over
  var navConfig = {
     interval: 300,
     over: showNav,
     timeout: 600,
     out: hideNav
  };
  function showNav() {
	$('ul', this).fadeIn('fast');
    $('> a', this).addClass('active');
  } 
  function hideNav() {
    $('ul', this).fadeOut('fast');
    $('> a', this).removeClass('active');
  }
  $('#nav ul li').hoverIntent(navConfig);

// slides drop down div when navbar is rolled over
  var dropdownConfig = {
     interval: 100,
     over: showDropdown,
     timeout: 600,
     out: hideDropdown
  };
  function showDropdown() {
    $('#drop_down').slideDown('fast');
  } 
  function hideDropdown() {
    $('#drop_down').slideUp('slow');
  }
  $('#nav').hoverIntent(dropdownConfig);

// load members, events into unordered list 
  jQuery(function($) {
    $("#contentLoading").show();
    $("#eventsList").load("/includes/events.php", null, function(){$("#contentLoading").fadeOut("normal");});
    $("#eventsListVisitors").load("/includes/events.php?visitors=true", null, function(){$("#contentLoading").fadeOut("normal");});
    $("#membersList").load("/includes/members.php", null, function(){$("#contentLoading").fadeOut("normal");});
  });

});
