	
	//functions.js
function despejar(origen)
{
var todo = origen;
p = todo.search(/SCRIPT>/i);
todo = todo.slice(p+8);
todo = todo.replace(/<TABLE>/g, '');
todo = todo.replace(/<TBODY>/g, '');
todo = todo.replace(/<TR>/g, '');
todo = todo.replace(/<TD>/g, '');
todo = todo.replace(/<\/TR>/g, '');
todo = todo.replace(/<\/TD>/g, '(=333=)');
todo = todo.replace(/<\/TABLE>/g, '');
todo = todo.replace(/<\/TBODY>/g, '');
todo = todo.replace(/<STRONG>/g, '');
todo = todo.replace(/<\/STRONG>/g, '');
todo = todo.replace(/<B>/g, '');
todo = todo.replace(/<\/B>/g, '');
todo = todo.replace(/TABLE>/g, '');

todo = todo.replace(/<table>/g, '');
todo = todo.replace(/<tbody>/g, '');
todo = todo.replace(/<tr>/g, '');
todo = todo.replace(/<td>/g, '');
todo = todo.replace(/<\/tr>/g, '');
todo = todo.replace(/<\/td>/g, '(=333=)');
todo = todo.replace(/<\/table>/g, '');
todo = todo.replace(/<\/tbody>/g, '');
todo = todo.replace(/<strong>/g, '');
todo = todo.replace(/<\/strong>/g, '');
todo = todo.replace(/<b>/g, '');
todo = todo.replace(/<\/b>/g, '');
todo = todo.replace(/table>/g, '');

p = todo.search(/Powered by/i);
todo = todo.slice(0, p+0);
p1 = todo.search(/<IMG src=/i);
p2 = todo.search(/>/i);
todo1 = todo.slice(0, p1+0);
todo2 = todo.slice(p2+1);
todo3 = todo1 + todo2;

todo3 = todo3.replace("Hello, visitor from:", "");
todo3 = todo3.replace("Your Country Code:", "");
todo3 = todo3.replace("Your IP State:", "");
todo3 = todo3.replace("Your IP Address:", "");
todo3 = todo3.replace("Your Hostname:", "");
todo3 = todo3.replace("Your ISP:", "");
todo3 = todo3.replace("Your Organization:", "");

return todo3;
}
	
function limite(que, cuanto, etiqueta)
{
var actual = document.getElementById(etiqueta).innerHTML;
var n = actual.indexOf('[');
if (n == -1) { base = actual; } else { base = actual.substr(0, (n-1)); }
var v=que.value;
leyenda = base + ' [m&aacute;ximo ' + cuanto + ' car&aacute;cteres. Quedan: ' + (cuanto-v.length) + ']';
if(v.length>cuanto)
  que.value=v.substring(0,cuanto)
else
  document.getElementById(etiqueta).innerHTML = leyenda;
}
	
	//Crear una variable de Bool para comprobar si se está usando IE.
	var xmlhttp = false;
	
	//Comprobar si se está usando IE.
	try {
		//Si la versión de javascript es superior a la 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		//Si no, utilizar el tradicional objeto ActiveX.
		try {
			//Si se está usando IE.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			//En caso contrario no debe estarse usando IE.
			xmlhttp = false;
		}
	}
	
	//si no se está usando IE, crear una instancia javascript del objeto.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	//A variable used to distinguish whether to open or close the calendar.
	var showOrHide = true;
	
	function showHideCalendar() {
		
		//The location we are loading the page into.
		var objID = "calendar";
		
		//Change the current image of the minus or plus.
		if (showOrHide == true){
			//Show the calendar.
			document.getElementById("opencloseimg").src = "images/mins.gif";
			//The page we are loading.
			var serverPage = "calendar.php";
			//Set the open close tracker variable.
			showOrHide = false;
			
			var obj = document.getElementById(objID);
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		} else {
			//Hide the calendar.
			document.getElementById("opencloseimg").src = "images/plus.gif";
			//The page we are loading.
			var serverPage = "blank.php";
			showOrHide = true;
			
			document.getElementById(objID).innerHTML = "";
		}
		
		
	}
	
	function createform (e){
		
		theObject = document.getElementById("createtask");
		
		theObject.style.visibility = "visible";
		theObject.style.height = "200px";
		theObject.style.width = "200px";
		
		var posx = 0;
		var posy = 0;
		
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
		
		posx = 020;
		posy = 220;
		
		
		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";
		
		//The location we are loading the page into.
		var objID = "createtask";
		var serverPage = "theform.php";
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
		
	}
		
	function closetask (){
		
		theObject = document.getElementById("createtask");
		
		theObject.style.visibility = "hidden";
		theObject.style.height = "0px";
		theObject.style.width = "0px";
		
		acObject = document.getElementById("autocompletediv");
		
		acObject.style.visibility = "hidden";
		acObject.style.height = "0px";
		acObject.style.width = "0px";
	}
	
	function findPosX(obj){
		var curleft = 0;
		if (obj.offsetParent){
			while (obj.offsetParent){
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		} else if (obj.x){
			curleft += obj.x;
		}
		return curleft;
	}
	
	function findPosY(obj){
		var curtop = 0;
		if (obj.offsetParent){
			while (obj.offsetParent){
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		} else if (obj.y){
			curtop += obj.y;
		}
		return curtop;
	}
	
	function autocomplete (thevalue, e){
		
		theObject = document.getElementById("autocompletediv");
		
		theObject.style.visibility = "visible";
		theObject.style.width = "152px";
		
		var posx = 0;
		var posy = 0;
		
		posx = (findPosX (document.getElementById("yourname")) + 1);
		posy = (findPosY (document.getElementById("yourname")) + 23);
		
		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";
		
		var theextrachar = e.which;
		
		if (theextrachar == undefined){
			theextrachar = e.keyCode;
		}
		
		//The location we are loading the page into.
		var objID = "autocompletediv";

		//Take into account the backspace.
		if (theextrachar == 8){
			if (thevalue.length == 1){
				var serverPage = "autocomp.php";
			} else {
				var serverPage = "autocomp.php" + "?sstring=" + thevalue.substr (0, (thevalue.length -1));
			}
		} else {
			var serverPage = "autocomp.php" + "?sstring=" + thevalue + String.fromCharCode (theextrachar);
		}
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	function setvalue (thevalue){
		acObject = document.getElementById("autocompletediv");
		
		acObject.style.visibility = "hidden";
		acObject.style.height = "0px";
		acObject.style.width = "0px";
		
		document.getElementById("yourname").value = thevalue;
	}
	
	function validateform (thevalue){
		
		serverPage = "validator.php?sstring=" + thevalue;
		objID = "messagebox";
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	function checkfortasks (pais, e)
	{
		theObject = document.getElementById("ipcompleto");
		theObject.style.visibility = "visible";

		serverPage = "taskchecker.php?pais=" + pais;
		objID = "ciudad";
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() 
		{
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
				obj.outerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	function dame_ip_completo (ip)
	{
		theObject = document.getElementById("ipcompleto");
		serverPage = "www.iyp1.com/php/dame_ip_completo.php?ip=" + ip;
		objID = "ipcompleto";
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() 
		{
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
				obj.value = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}

	function hidetask (){
//		tObject = document.getElementById("taskbox");
		
//		tObject.style.visibility = "hidden";
//		tObject.style.height = "0px";
//		tObject.style.width = "0px";
	}
	
	//Función para obtener una palabra de la base de datos.
	function grabword (theelement){
		//Si no hay nada en el cuadro, utilizar Ajax para rellenarlo.
		if (document.getElementById(theelement).innerHTML.length == 0){
			//Cambiar el color de fondo.
			document.getElementById(theelement).style.background = "#CCCCCC";
			serverPage = "wordgrabber.php";
			var obj = document.getElementById(theelement);
			xmlhttp.open("POST", serverPage);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		} else {
			//Cambiar el color de fondo.
			document.getElementById(theelement).style.background = "#FFFFFF";
			//Si el cuadro ya está relleno, vaciarlo.
			document.getElementById(theelement).innerHTML = "";
		}
	}
