jQuery(function($){
	// Activate SuperFish for main menubar
	// This adds drop-down support for IE6, an animation for drop downs, 
	// and causes menus to not disappear the second the the mouse goes outside a submenu 
	$('#menu-bar').superfish({
		delay:       1000,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'fast',                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows
	});
	
	// Example client-side filtering script for sidebar checkboxes
	// Only runs on pages with form ID = sessions-filter
	var checkboxes = $('input[type="checkbox"]', '#sessions-filter');
	// if ( checkboxes.filter(':checked').length  == 0 ) {
	// 	checkboxes.attr('checked', 'checked');
	// }
	checkboxes.bind( 'click', filter_sessions ).each(filter_sessions);
	
	/* Avoice @font-face flickr */
	setTimeout( function(){		
			$('#menu-top, #menu-bar').css('visibility', 'visible');
	}, 250 );
	
	if ( $.browser.webkit ) {
		$('body').addClass('webkit');
	}
	
});

function filter_sessions( e ) {
	var $ = jQuery;
	var filter = $(this).parents('fieldset').attr('rel');
	var search = $(this).parent().text();
	
	var subject = $('dd', '#content')
		.filter( '.'+filter )
		.filter(':contains("'+search+'")')
		.parent();
	
	if ( $(this).is(':checked') ) {
		if ( isInt( e ) ) {
			subject.show();
		}else {
			subject.slideDown();
		}
	}else {
		if ( isInt( e ) ) {
			subject.hide();
		}else {
			subject.slideUp();
		}
	}
}

function isInt(x) { 
   var y=parseInt(x); 
   if (isNaN(y)) return false; 
   return x==y && x.toString()==y.toString(); 
 }
