function MailLink (usuario, dominio, tld, textourl) {
	var arroba = '@';
	var punto = '.';
	var etiqueta = 'ma' + '' + 'il';
	var dospuntos = 'to:';
	var localizador = usuario;
	localizador = localizador + arroba + dominio;
	localizador = localizador + punto + tld;
	if(textourl=='') {
		document.write('<a href="' + etiqueta + dospuntos + localizador + '">' + localizador + '</a>');
	} else {
		document.write('<a href="' + etiqueta + dospuntos + localizador + '">' + textourl + '</a>');
	}
}

function trim(cadena) {
	for(i=0; i<cadena.length;) {
		if(cadena.charAt(i)==" ") {
			cadena=cadena.substring(i+1, cadena.length);
		} else {
			break;
		}
	}
	for(i=cadena.length-1; i>=0; i=cadena.length-1) {
		if(cadena.charAt(i)==" ") {
			cadena=cadena.substring(0,i);
		} else {
			break;
		}
	}
	return cadena;
}

function checkforblanks() {
	for (var i=0; i<arguments.length; i+=2) {
		if (!arguments[i]) {
			alert("El campo " + arguments[i+1] + " es obligatorio.");
			return false;
		}
	}
	return true;
}

function validate() {
	var isFull = checkforblanks(trim(document.getElementById("Nombre").value), "[Nombre]",
	trim(document.getElementById("Email").value), "[Email]",
	trim(document.getElementById("Telefono").value), "[Telefono]",
	trim(document.getElementById("Comentarios").value), "[Comentarios]");
	if (!isFull) {
		return false;
	}
	var dirmail = document.getElementById("email").value;
	var filter = /^.+@.+\..{2,4}$/;
	if (!filter.test(dirmail)) {
		alert("La dirección de correo electrónico no es correcta.");
		return false;
	}
	if(document.getElementById("Conocido1").checked==false && document.getElementById("Conocido2").checked==false && document.getElementById("Conocido3").checked==false) {
		alert("Por favor, indique cómo nos ha conocido.");
		return false;
	}
}

var xmlHttp;

function getNews() { 
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url = "noticias.php";
	//url = url+"?q="+str;
	//url = url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("ajaxNews").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function showrank(dato) {
	for(var i=1;i<5;i++) {
		if(dato==i) {
			document.getElementById("rank_"+i).style.display = 'inline';
			document.getElementById("rank_p"+i).className = 'rankactivo';
		} else {
			document.getElementById("rank_"+i).style.display = 'none';
			document.getElementById("rank_p"+i).className = 'rankgris';
		}
	}
}

function CreateControlFlash(divid, objectid, width, height, url, mode) {
	var d = document.getElementById(divid);
	var strHTML = '<object id="' + objectid + '" type="application/x-shockwave-flash" data="' + url + '" width="' + width + '" height="' + height + '">';
	strHTML = strHTML + '<param name="movie" value="' + url + '" />';
	if(mode=='1') { strHTML = strHTML + '<param name="wmode" value="transparent" />'; }
	strHTML = strHTML + '<a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;Lang=Spanish&amp;P5_Language=Spanish"><img src="flash/noflash.gif" border="0" alt="no tiene flash" /></a>';
	strHTML = strHTML + '</object>';
	d.innerHTML = strHTML;
}

function fCapa(id) {
	if (document.getElementById(id).style.display=='block') {
		document.getElementById(id).style.display='none';
	} else {
		document.getElementById(id).style.display='block';
	}
}

/* youtube */
/*
function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("ytactividades");
}

function play() {
	if (ytplayer) {
		ytplayer.playVideo();
	}
}
*/