var minimized = true;
var mouseleft = false;
var width;

boxOpen = function() {
	
	// main container
	jQuery('#introText').animate({
	
		width: '620px'
		
	}, 500, function() {
		
		minimized = false;
	});
	
	jQuery('#introText div.footer').animate({
	
    	width: '480px'
    	
	}, 500, function() {
	
		if (mouseleft) boxClose();
	
	});    
	  
	jQuery('#introText div.footer span').animate({
		
		height: '164px'
		
	}, 500, function() {
	
	});      

	jQuery('#introText a.more-link').animate({
	    
	    opacity: '0'
	    
	}, 50, function() {
	
	});
}

boxClose = function() {

	mouseleft = false;
	
	jQuery('#introText').animate({
	    
        width: '305px'
        
    }, 500, function() {
      
    	// Animation complete.
    	minimized = true;
    });
      
    jQuery('#introText div.footer').animate({
    
        width: '170px'
        
    }, 500, function() {
    
    });    
      
    jQuery('#introText div.footer span').animate({
    
        height: '154px'
        
    }, 500, function() {
    	
		jQuery('#introText a.more-link').animate({
    
    		opacity: '1'
    	
    	}, 200, function() {
    
		}); 
    	
    });
}

jQuery(document).ready(function($) {

	jQuery('div#introText').mouseover(function() {

		if (minimized) {
			
			boxOpen();
		}
	});


	jQuery('div#introText').mouseleave(function() {
	
		mouseleft = true;
	
		if (minimized) return;
	
		boxClose();
	});
	
	jQuery('div#introText').click(function() {
	
		if (minimized) boxOpen;
		else boxClose();
	});	

});


