
Event.observe(window ,'load', function()
{
	$$('a[rel="external"]').invoke('writeAttribute', 'target', '_blank');

	search_string = $$('#header input[name="s"]')[0]
		.observe('focus', function(){ if(this.value == search_string)	{ this.value = ''; } })
		.observe('blur', function() { if(!this.value)					{ this.value = search_string; } })
		.next().readAttribute('value');


	if($('sidebar'))
	{
		if($('content').getHeight() > $('sidebar').getHeight())
		{
			$$('#sidebar .bottom')[0].style.height = ($('content').getHeight() - $$('#sidebar .heading')[0].getHeight() - 20) + 'px';
		}
		else
		{
			$$('#content .top .right')[0].style.height = ($('sidebar').getHeight() - 20) + 'px';
		}
	}

	if($('search-input'))
	{
		default_search_string = $$('#cnt input[name="s"]')[0]
		.observe('focus', function(){ if(this.value == search_string)	{ this.value = ''; } })
		.observe('blur', function() { if(!this.value)					{ this.value = default_search_string; } })
		.next().readAttribute('value');
	}

	if($('username'))
	{
		$('username')
		.observe('focus', function(){ if(this.value == $F('username_default_val'))	{ this.value = ''; } })
		.observe('blur', function() { if(!this.value) { this.value = $F('username_default_val'); } })
	}

	if($('password'))
	{
		$('password')
		.observe('focus', function(){ if(this.value == $F('password_default_val'))	{ this.value = ''; } })
		.observe('blur', function() { if(!this.value) { this.value = $F('password_default_val'); } })
	}

	if($('options'))
	{
		Event.observe($$('#options .print')[0], 'click', function (e)
		{
			window.print();
			Event.stop(e);
		});

		// Font size
		font_size_step = 2;
		selectors = '#cnt h1, #cnt h2, #cnt h3, #cnt h4, #cnt h5, #cnt p, #cnt li, #cnt em, #cnt dd, #cnt dl, #daily';

		Event.observe($$('#options .decrease')[0], 'click', function (e)
		{
			if(font_size_step > 0)
			{
				font_size_step--
				$$(selectors).each(function(e){ changeFontSize(e, -3, -1); });
			}
			Event.stop(e);
		});
		Event.observe($$('#options .increase')[0], 'click', function (e)
		{
			if(font_size_step < 5)
			{
				font_size_step++
				$$(selectors).each(function(e){ changeFontSize(e, 3, 1); });
			}
			Event.stop(e);
		});
		function changeFontSize(e, p, l)
		{
			e.setStyle({ fontSize: (parseInt(e.getStyle('font-size'))+p)+'px', lineHeight: (parseInt(e.getStyle('line-height'))+l)+'px' });
		}
	}
});


function showmap(show, hide)
{
	$$('.' + show).invoke('show');
	$$('.' + hide).invoke('hide');
}
