var formHighlight =
{
	'input' : function(element)
	{
		switch(element.type)
		{
			case 'text':
			case 'password':
				element.onfocus = function() { this.style.backgroundColor = '#FFFFFF'; };
				element.onblur = function() { this.style.backgroundColor = ''; };
			break;
			case 'checkbox':
			case 'radio':
				element.style.width = 'auto';
				element.style.border = 'none';
				element.style.backgroundColor = 'transparent';
			break;
			case 'submit':
			case 'reset':
			case 'button':
				if (element.className == '') { element.className = 'button'; }
				element.onmouseover = function() { this.style.backgroundColor = (this.className == 'calendar_button')?'#ff99ff':'#FFFFFF'; }
				element.onmouseout = function() { this.style.backgroundColor = ''; }
				element.style.cursor = 'pointer';
			break;
			case 'hidden':
				element.style.display = 'none';
			break;
		}
	},
	'textarea' : function(element)
	{
		element.onfocus = function()
		{
			this.style.backgroundColor = '#FFFFFF';
		};

		element.onblur = function()
		{
			this.style.backgroundColor = '';
		};
	},
	'.highlight' : function(element)
	{
		element.onmouseover = function() { this.style.backgroundColor = '#e0e0e0'; };
		element.onmouseout = function() { this.style.backgroundColor = ''; };
	}
};

Behaviour.register(formHighlight);

function $T(text)
{
	return document.createTextNode(text);
}

function $C(tagname)
{
	return $(document.createElement(tagname.toUpperCase()));
}

function $translate(element, data)
{
	$(element).innerHTML = $(element).innerHTML.replace(/{\#([^}]+)\}/g, function(a, b)
	{
		return data[b];
	});
}

window.LinkTracking = function(element)
{
	if (readCookie('linktracking') == 'off') return false;

	// Ignore anchor links
	if (element.href.charAt(0) == '#') return false;

	// Link Tracking onClick event
	$(element).observe('click', function(event)
	{
		// parameters for the POST action
		var param =
		{
			'link' :	this.href,
			'referer' :	window.location,
			'source' :	this.getAttribute('href_source')
		};

		// Synchronous AJAX
		results = loadText(siteWSPATH + '_shared/dynamic/link.php?ajax', param);
	});
};
