
// Flag to make sure this fires only once.
var home_dom_loaded = 0;
document.observe('dom:loaded', function (evt) {
	if (home_dom_loaded) {
		return;
	} else {
		home_dom_loaded++;
	}
	if ( $('sidebar') && Cookie.get('DASH_SEEN') == null ) {
		loadHomeDashboard.delay(7);
	}
	
});

var loadHomeDashboard = function() {
	var sidebar_timeout;
	var cleared_timeout = 0;
	onObject( 'bottomAccordion', function () {
		//console.log('hit me');
		var sidebar_ = $('sidebar').findDefinition('Sidebar');
		if ( sidebar_ && typeof(sidebar_) == 'object' ) {
			sidebar_.toggle();
			sidebar_timeout = sidebar_.settimeout(8000);
			Cookie.set( 'DASH_SEEN', '1' );
		}
	});
	
	$('sidebar').observe( 'mouseover', function ( evt ) {
		if (!cleared_timeout) {
			clearTimeout(sidebar_timeout);
			cleared_timeout++;
		}
	});
}
