// Utils
String.prototype.isAlpha = function()
{
	return /^[a-zA-Z]+$/.test(this);
}

String.prototype.isAlphaNum = function()
{
	return !/\W/.test(this);
}

String.prototype.isFloat = function()
{
	return /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/.test(this);
}

String.prototype.isEmail = function()
{
	return /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/.test(this);
}

String.prototype.isDate = function()
{
	return /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(this);
}

String.prototype.isUrl = function()
{
	return /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(this);
}

String.prototype.isNumeric = function()
{
	return (!isNaN(this) && !/^\s+$/.test(this));
}

/* SETUP PRINCIPAL ONLOAD */
document.observe('dom:loaded', function()
{
	$$('#languages a:not([class=selected])').invoke('observe', 'mouseover', function(event) {
		event.target.previous('img', 1).toggle();
		event.target.previous('img').toggle();
	});

	$$('#languages a:not([class=selected])').invoke('observe', 'mouseleave', function(event) {
		event.target.previous('img', 1).toggle();
		event.target.previous('img').toggle();
	});
});

/* ANALYTICS */
document.observe('dom:loaded', function()
{
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	var script = new Element('script', { 'src': gaJsHost + 'google-analytics.com/ga.js', type: 'text/javascript'});

	var gaTrack = function()
	{
		if (!script.readyState || /loaded|complete/.test(script.readyState))
		{
			var pageTracker = _gat._getTracker(ga_id);
			pageTracker._trackPageview();
		}
	};
	script.observe('load', gaTrack);
	script.observe('readystatechange', gaTrack);
	$(document.body).insert(script);
});