var isOpen = false;
var flyout = [
{
	goIn:  function() {
		$('.flyout').each(function () {
			if($(this).css('width') != '0px') {
				$(this).stop().animate({ width: '331px' }, 250 ).animate({ width: '0' }, 500 );
			}
		 } );
		isOpen = false;
	},
	goOut: function(id) {
		if(isOpen) {
			this.goIn();
		}
		
		$(id).stop().animate({ width: '331px' },   500 ).animate({ width: '559px' },  250 );
		isOpen = true;
	}
}
];

jQuery.easing.def = 'easeInQuart';

$(function(){
	//Opens a flyout when you click a marker
	$('#home-stage .marker span').click( function( ) {
		flyout[0].goOut('#' + $(this).attr('class'));
	} );

	//Closes a the flyout when you click on the flyout it's self
	$('.flyout').click( function(e) {
		e.stopPropagation(); flyout[0].goIn();
	} );
	
	//Fades in the Marker
	$('#home-stage .marker').mouseenter( function( ) {
		$(this).children().fadeIn('slow');
		$(this).addClass('hover');
	} );

	//Fades the Marker out
	$('#home-stage .marker').mouseleave( function( ) {
		$(this).children().fadeOut('slow');
		$(this).removeClass('hover');
	} );
});
