(function() {
	var loadCb = function() {
		var username = $('login_username'),
			password = $('login_password'),
			search_what = $('search_what'),
			name = $('name');

		[username, password, search_what, name].each(function(element) {
			if (element) {
				element._value = element.value;

				element.observe('focus', (function() { if (this.value == this._value) {
					this.value = '';
				}}).bind(element));
				element.observe('blur', (function() { if (this.value == '') {
					this.value = this._value;
				}}).bind(element));
			}
		});

		resizeCb();
	}, resizeCb = function() {
		function getPageDimensions() {
			return window.innerWidth ? {
				width: window.innerWidth,
				height: window.innerHeight
			} : {
				width: document.documentElement.clientWidth,
				height: document.documentElement.clientHeight
			};
		}

		$('outer_wrapper').setStyle({
			height: $('wrapper').getDimensions().height <= getPageDimensions().height ? '100%' : 'auto'
		});
	};

	document.observe('dom:loaded', loadCb);
	Event.observe(window, 'resize', resizeCb);
})();

function do_calendar() {
	new Ajax.Request($('root').href + 'calendar/', {
		method: 'post',
		parameters: {
			month: $F('calendar_month'),
			year: $F('calendar_year')
		},
		onComplete: function(response) {
			$('calendar_container').update(response.responseText);
			Tooltip.init($('calendar_container'));
		}
	});
}

