jQuery(document).ready(function($){
	// IE fix for submitting button-less forms
	$('input').keydown(function(e){
		if (e.keyCode == 13) {
			$(this).parents('form').submit();
			return false;
		}
	});
	
	$('label.overlabel').overlabel();
	$("div.accordion").accordion({ collapsible: true, autoHeight: false, event: 'mouseover', active: 100 });

	$('form#giving3').submit(function() {
		return confirm('Are you sure you want to continue?  Payment will be processed immediately.');
	});

	// put this flash stuff in
	if ($('#flash-logo'))
	swfobject.embedSWF("/wp-content/themes/vanguard/flash/logo.swf", "flash-logo", "232", "100", "9.0.0", null, { allowFullScreen: true }, { wmode: 'transparent', allowFullScreen: true } );
	if ($('#slides'))
	swfobject.embedSWF("/wp-content/themes/vanguard/flash/slides1.swf", "slides", "542", "202", "9.0.0", null, { allowFullScreen: true }, { wmode: 'transparent', allowFullScreen: true } );
	if ($('#video'))
	swfobject.embedSWF("/wp-content/themes/vanguard/flash/vid1.swf", "video", "300", "220", "9.0.0", null, { allowFullScreen: true }, { wmode: 'transparent', allowFullScreen: true } );
	if ($('#gallery1'))
	swfobject.embedSWF("/wp-content/themes/vanguard/flash/gallery1.swf", "gallery1", "542", "762", "9.0.0", null, { allowFullScreen: true }, { wmode: 'transparent', allowFullScreen: true } );
	if ($('#vid2'))
	swfobject.embedSWF("/wp-content/themes/vanguard/flash/vid2.swf", "vid2", "542", "600", "9.0.0", null, { allowFullScreen: true }, { wmode: 'transparent', allowFullScreen: true } );

	// make the menu work in IE6
	if($.browser.msie && $.browser.version < 7) {
		$('#navigation ul li').mouseenter(function() {
			$('> ul', this).show();
		}).mouseleave(function() {
			$('> ul', this).hide();
		});
	}
});

( function( $ ) {
 
    // plugin definition
    $.fn.overlabel = function( options ) {
 
        // build main options before element iteration
        var opts = $.extend( {}, $.fn.overlabel.defaults, options );
 
        var selection = this.filter( 'label[for]' ).map( function() {
 
            var label = $( this );
            var id = label.attr( 'for' );
            var field = document.getElementById( id );
 
            if ( !field ) return;
 
            // build element specific options
            var o = $.meta ? $.extend( {}, opts, label.data() ) : opts;
 
            label.addClass( o.label_class );
 
            var hide_label = function() { label.css( o.hide_css ); };
            var show_label = function() { this.value || label.css( o.show_css ); };
 
            $( field )
                 .parent().addClass( o.wrapper_class ).end()
                 .focus( hide_label ).blur( show_label ).each( hide_label ).each( show_label );
 
            return this;
 
        } );
 
        return opts.filter ? selection : selection.end();
    };
 
    // publicly accessible defaults
    $.fn.overlabel.defaults = {
 
        label_class:   'overlabel-apply',
        wrapper_class: 'overlabel-wrapper',
        hide_css:      { 'text-indent': '-10000px' },
        show_css:      { 'text-indent': '0px', 'cursor': 'text' },
        filter:        false
 
    };
 
} )( jQuery );