	var isIE = navigator.appName.indexOf("Microsoft") != -1
	
function addBookmark()
{
	if (isIE)
		window.external.AddFavorite(location.href, document.title);
	else
	{
		if (window.sidebar) {
			window.sidebar.addPanel(document.title, location.href, "");
		} else if( document.all ) {
			window.external.AddFavorite(location.href, document.title);
		} else if( window.opera && window.print ) {
			return true;
		}
	}
}
function Bookmark(level)
{
	var i, path="img/";
	for(i=0;i<level;i++)
		path="../" + path;
	document.write('<a href="." onClick="JavaScript:addBookmark()"><img src="' + path + 'fav.gif" border="0" height="20" width="20" alt="Bookmark" hspace="7"></a>');
}
function HomePage(level)
{
	var i, path="img/";
	for(i=0;i<level;i++)
		path="../" + path;
	document.write('<a href="." onClick="JavaScript:setIEHomePage(this);"><img src="' + path + 'home.gif" border="0" height="20" width="20" alt="HomePage" hspace="7"></a>');
}
function setHomePage(twt)
{
	if(isIE)
	{
		twt.style.behavior='url(#default#homepage)';
		twt.setHomePage(location.href);
	}
}
function ValidarFormulario(lng)
{
	var fields = new Array('nombre','asunto','mensaje');		
	for(var i=0; i<fields.length; i++)
	{
		if(IsEmpty(document.getElementById(fields[i]).value))
		{
			switch(lng)
			{
				case "es": alert("Por favor rellene todos los campos requeridos"); break;
				case "cat": alert("Si us plau, ompli tots els camps requerits"); break;
				case "en": alert("Please fill out all required fields");
			}
			document.getElementById(fields[i]).focus();
			return false;
		}
	}
	if(IsEmpty(document.getElementById('email').value)&&IsEmpty(document.getElementById('tlfno').value))
	{
		switch(lng)
		{
			case "es": alert("Por favor, indique un e-mail o un teléfono de contacto"); break;
			case "cat": alert("Si us plau, indiqui un e-mail o un telèfon de contacte"); break;
			case "en": alert("Please provide an e-mail or phone contact");
		}
		if(IsEmpty(document.getElementById('email').value))
			document.getElementById('email').focus();
		else
			document.getElementById('tlfno').focus();
		return false;
	}
	if(!IsEmpty(document.getElementById('email').value)&&!IsEmail(document.getElementById('email').value))
	{
		switch(lng)
		{
			case "es": alert("La dirección de correo no es válida"); break;
			case "cat": alert("L'adreça de correu no és vàlida"); break;
			case "en": alert("E-mail address is not valid");
		}
		return false;
	}	
	if(!IsEmpty(document.getElementById('tlfno').value)&&!IsPhone(document.getElementById('tlfno').value))
	{
		switch(lng)
		{
			case "es": alert("El teléfono no es válido, use sólo 0123456789()[]+- y espacios"); break;
			case "cat": alert("El telèfon no és vàlid, utilitzeu només 0123456789()[]+- i espais"); break;
			case "en": alert("Phone is not valid, use only 0123456789()[]+- and spaces");
		}
		return false;
	}	
	return true;
}
function IsEmpty(s)
{
	var whitespace = " \t\n\r";
	var i;
	if(s.length == 0) return true;
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}
function IsEmail(email)
{
     var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
     return emailReg.test(email);
}
function IsPhone(tlfno)
{
    var validChars = " 0123456789(+)[]-";
	var i;
	for (i = 0; i < tlfno.length; i++)
	{
		var c = tlfno.charAt(i);
		if (validChars.indexOf(c) == -1) return false;
	}
	return true;
}