$(document).ready(function(){
	var $left_container = $('#left_container'),
	$navigation_top = $('#left_navigation .expandable');
	
	if (!Modernizr.input.placeholder){ $('input').placeholder(); }

	function align_navigation(animate) {
		var window_height = $(window).height(),
		container_height = $left_container.height(),
		top_offset = Math.round(((window_height - $left_container.height()) / 2));

		if(top_offset < 0) top_offset = 0;
		if(animate){
			$left_container.stop().animate({'margin-top': top_offset}, 100);
		} else {
			$left_container.css('margin-top', top_offset);
		}

		if(window_height < container_height) $left_container.css('position', 'absolute');
		else $left_container.css('position', 'fixed');
	}
	
	$(window).resize(function(){ align_navigation(); });
	align_navigation();
	
	$navigation_top.live('click',function(){
		var old_element = $('#left_navigation').find('.expanded').attr('id'),
		new_element = $(this).attr('id');
		
		$navigation_top.removeClass('expanded').find('.submenu').slideUp('fast',function(){
			if(old_element === new_element) { align_navigation(true); }
		});
		
		if(old_element !== new_element) {
			$(this).addClass('expanded').find('.submenu').slideDown('fast',function(){ align_navigation(true); });
		}
	});
	
	$navigation_top.find('a').live('click',function(e){ e.stopPropagation(); });
});
























