/**
 * ruleset for site
 * works with behaviour.js
 */

rules =
{
	'a' : function (el)
	{
		el.onfocus = function ()
		{
			this.blur();
		}
	},

	'#navigation li.navitem a' : function (el)
	{
		el.onmouseover = function ()
		{
			$(this.parentNode).addClassName('hover');
		}

		el.onmouseout = function ()
		{
			$(this.parentNode).removeClassName('hover');
		}
	},

	'#teaser' : function (el)
	{
		el.onmouseover = function ()
		{
			$('contact').addClassName('open');
			dimBackground();
		}
	},

	'a.popup' : function (el)
	{
		el.onclick = function ()
		{
			window.open(this.href, this.target, 'width=800, height=725');
			return false;
		}
	}
}

Behaviour.register(rules);

/**
 * spamprotection for email links
 * works with prototype 1.5.1.1
 */

function unSpamProtect ()
{
	var arrLinks	= $$('a');
	var i;

	for (i = 0; i < arrLinks.length; ++i)
	{
		if (arrLinks[i].href.indexOf('mailto:') == 0)
		{
			arrLinks[i].href		= arrLinks[i].href.replace(/\.sprotector\./, '@');
			arrLinks[i].title		= arrLinks[i].title.replace(/\.sprotector\./, '@');
			arrLinks[i].innerHTML	= arrLinks[i].childNodes[0].nodeValue.replace(/\.sprotector\./, '@');
		}
	}
}

Event.observe(window, 'load', unSpamProtect);

function dimBackground ()
{
	var fade = document.createElement('div');

	fade.onmouseover = function ()
	{
		$('contact').removeClassName('open');
		this.parentNode.removeChild(this);
	}

	$(fade).addClassName('fader');

	document.body.appendChild(fade);
}