    (function($){
        $.fn.clearDefault = function(){
            return this.each(function(){
                var default_value = $(this).val();
                $(this).focus(function(){
                    if ($(this).val() == default_value) $(this).val("");
                });
                $(this).blur(function(){
                    if ($(this).val() == "") $(this).val(default_value);
                });
            });
        };
    })(jQuery);


$(document).ready(function() {
        
    /*  EXTERNAL LINKS
        -------------------------------------------------------------*/
                    
        
        $("a.external").click( function() {
            window.open( $(this).attr("href") );
            return false;
        });
        
        
         
     	$('a.external').qtip({
            content: '<p>You are now leaving the CSMI website.</p>',
            show: 'mouseover',
            hide: 'mouseout',
            position: {
                corner: {
                    target: 'topMiddle',
                    tooltip: 'bottomMiddle'
                    }
                },
            style: { 
                padding: 5,
                background: '#6f90b8',
                color: '#ffffff',
                textAlign: 'center',
                border: {
                    width: 2,
                    radius: 5,
                    color: '#5e80a7'
                    },
                width: 300
            }
        });
	            
            

    /*  DROP DOWN NAV
        ----------------------------------------------------------*/
        
/*
        $("ul.structure > li").each(function() {
        	$(this).attr("id", "n" + ($(this).index() + 1));
        });
*/
        
        $("ul.structure > li").has("ul").addClass("dropdown");
        
        $('li.dropdown').hover(function() {
            $(this).children('a:first-child').addClass('hovering');
            $(this).children('ul').show();
        }, function() {
            $(this).children('a:first-child').removeClass('hovering');
            $(this).children('ul').hide();          
        }); 
        
        
        
    /*  SUB NAV
        ----------------------------------------------------------*/
        
        
        
        
    /*  NEWS/EVENTS TABS
        ----------------------------------------------------------*/
        
        $('.tEvents').hide();
            
        $('.switches a').click(function() {
            if($(this).parent().hasClass('on')) return false;               
            var clickedTab = $(this).parent().attr('id');
            $('.switches li').removeClass('on');
            $(this).parent().addClass('on');
            $('.tab').fadeOut('fast');
            $('.'+clickedTab).fadeIn('fast');               
            return false;
        });
        
        
    
    /*  SHOW/HIDE
        ----------------------------------------------------------*/

        //$("ul.accordion ul").hide();
        //$("ul.accordion li a").click(function() {
        //  $(this).next("ul").toggle();
        //  $(this).toggleClass("open")
        //  return false;
        //});
        
        
        $("h2 a.accordion").parent().nextUntil("h2").hide();
        $("h2 a.accordion").click(function() {
            $(this).parent().nextUntil("h2").slideToggle("fast");
            $(this).toggleClass("open")
            return false;
        });
        
        
        $("h3 a.accordion").parent().nextUntil("h3").hide();
        $("h3 a.accordion").click(function() {
            $(this).parent().nextUntil("h3").slideToggle("fast");
            $(this).toggleClass("open")
            return false;
        });
                
        
        $("div.peoplelist li div").hide();
        $("div.peoplelist h3").click(function() {
            $(this).siblings("div").slideToggle("fast");
            return false;
        });
        
        


    /*  CLEAR INPUT FIELDS ONFOCUS
        -------------------------------------------------------------*/
        
        $('input.clearinput').clearDefault();
        
            
    
        
    /*  FLASH HEADER
        -------------------------------------------------------------
        
        $(".feature").flash(
            {
                swf: "",
                height: 245,
                width: 669,
                play: true,
                flashvars: {
                    var0: "/_function/banner_intro/",
                    var1: "/_function/banner/"
                }
            }
        );
        
       */ 
        
    /*  Footer jQuery popup
        -------------------------------------------------------------
        
        $('.employeeaccess > ul > li > ul').hide();
        $('.employeeaccess > ul > li').hover(function() {
            $(this).addClass('on');
            $('.employeeaccess > ul > li > ul').show();                 
        }, function() {
                $(this).removeClass('on');
                $('.employeeaccess > ul > li > ul').hide();
        });
        
    */  
    

    });
