YUI().use('node', 'event-mouseenter', 'cookie', function(Y) {
var LOCATION = window.location,
	HREF = LOCATION.href,
	postId,

	_nodeBody,
	_nodeFind,
	_nodeOptions,
	_nodeOptionsWidth;

//	Y.one('#options').on('click', function() {alert('Options are unavailable at this time.\nCheck back in a few weeks.');});

	// logic to handle updating all the cached HTML files
	if (
		-1 < HREF.indexOf('runScript=T') &&
		-1 < HREF.indexOf('postId=')
	) {
		postId = HREF.replace(/.*?postId=(\d+).*/, '$1');

		if (525 > postId)
		{
			setTimeout(function() {
				LOCATION.href = HREF.replace(/\d+/, ++postId);
			}, 2000);
		}
	}
	else {
		_nodeBody = Y.one('#bd');
		_nodeFind = Y.one('#find');
		_nodeOptions = Y.one('#options');
		_nodeOptionsWidth = Y.one('#options-width');

		function handleMenuMouseEnter(e) {
			var submenu, region;
			submenu = this.one('div.submenu');
			region = this.get('region');
			this.addClass('hover');
			submenu.setXY([
				region.left - 10,
				region.bottom
			]);
		}

		function handleMenuMouseLeave(e) {
			this.removeClass('hover');
		}

		_nodeFind.on('mouseenter', handleMenuMouseEnter, _nodeFind);
		_nodeFind.on('mouseleave', handleMenuMouseLeave, _nodeFind);
		_nodeOptions.on('mouseenter', handleMenuMouseEnter, _nodeOptions);
		_nodeOptions.on('mouseleave', handleMenuMouseLeave, _nodeOptions);
		_nodeOptionsWidth.on('click', function() {
			var hasClass = _nodeBody.hasClass('width100');
			handleMenuMouseLeave.call(_nodeOptions);
			_nodeBody[hasClass ? 'removeClass' : 'addClass']('width100');
			_nodeOptionsWidth.set('innerHTML', hasClass ? 'Set Width 100%' : 'Restore Width Default');
			Y.Cookie.setSub("config", "width100", ! hasClass, { expires: new Date("January 12, 2025") });			
		});
	}

	if (window.dp && dp.sh) {
		dp.sh.BloggerMode();
		dp.sh.ClipboardSwf = 'scripts/clipboard.swf';
		dp.sh.HighlightAll();
	}

});