
(function() {
	// Init
	//	Must initially collapse the banner. 
	(function(onload) {
		window.onload = function() {
			bannerCollapse();
			if (onload) {
				onload();
			}
		}
	})(window.onload);
	
	// Configuration
	var options = {
		collapseExpandedBannerOnMouseOut: false, 
		sizeExpanded: {width: 746, height: 436}, 
		sizeCollapsed: {width: 746, height: 231}
	}
	
	// Public interface. 
	//	Called from flash upon interaction
	bannerExpand = function() {
		expanded = true;
		expand();
	}
	bannerCollapse = function() {
		expanded = false;
		collapse();
	}

	// Event handlers. 
	// 	Attach mouseover and mouseout events to the element containing the flash.  
	// 	When expanded from flash, collapse and expande on mouseout / mouseover. 
	onBannerMouseOut = function() {
		if (options.collapseExpandedBannerOnMouseOut && expanded) {
			collapse();
		}
	}

	onBannerMouseOver = function() {
		if (options.collapseExpandedBannerOnMouseOut && expanded) {
			expand();
		}
	}	
	
	// Private interface. Expand and collapse the element containing the flash.
	function expand() {
	    if (document.getElementById("banner-expand") != null)
		document.getElementById("banner-expand").style.clip="rect(0px,"+options.sizeExpanded.width+"px,"+options.sizeExpanded.height+"px,0px)";
	}
	function collapse() {
	    if (document.getElementById("banner-expand") != null)
		document.getElementById("banner-expand").style.clip="rect(0px,"+options.sizeCollapsed.width+"px,"+options.sizeCollapsed.height+"px,0px)";
	}
	
	// Keeps track of the expand state. Only the flash-calls affect this state. 
	var expanded = false;
})();
