// creating a container object to function as a "namespace"
var mockbee = new Object(); // This used to be an object literal ({}) but IE6&7 didn't like that syntax. 2010.02.16- tbb
mockbee.startHeightTop = null;

// open items in a new window
mockbee.openwindow = function(){
	var newwin = window.open(this.href,'external');
	return false;
}

/* Hide and Show navigation tree in top of page */
mockbee.toggleintop = function () {
	var parent = $(this).parent(); 	// this will be #navigation or #footer	
	mockbee.startHeightTop = $(parent).height(); // sets a faux global variable that's referenced later
	$(this).fadeOut(100);
	$(this).prev('.shutter-wrap').fadeOut(100);	
	parent.animate({height: 25}, 
		400, 
		"easeOutCubic", 
		function(){
			$(this).children('.switch').fadeIn().css({'background-position':'0% 0%'});
		});
}
mockbee.toggleouttop = function () {
	var parent = $(this).parent(); // this will be #navigation or .shutter-outter-wrap
	$(this).prev('.shutter-wrap').fadeIn(800);
	$(this).fadeOut(100);
	$(parent).animate({
		height: mockbee.startHeightTop
	   }, 
	   400, 
	   "easeOutCubic", 
		function(){
			$(this).children('.switch').fadeIn().css({'background-position':'100% 0%'});	
	    }
	);
}

/* functions to make IE 6 play nicely with hovers */ 
mockbee.itemhoverin = function(){
 	var itemlink = $(this).children('a');
	if(itemlink){
		itemlink.addClass('showHover');
	}
}

/* functions to make IE 6 play nicely with hovers */ 
mockbee.itemhoverout = function(){
	var itemlink = $(this).children('a');
	if(itemlink){
		itemlink.removeClass('showHover');
	}

}

$(document).ready(function(){
	/* triggers *BOTH* the navigation and footer show / hide. */
	$('.switch').toggle(mockbee.toggleintop, mockbee.toggleouttop);

	/* opens links with a class of 'ext' in a new window */
	$('.ext').click(mockbee.openwindow);

	// document.all is an IE only thing. to solve hover bug in ie 6+, but causes no problems in 7 or 8.
	if(document.all){
		$('.item').hover(mockbee.itemhoverin,mockbee.itemhoverout);
	} else {}
});


