	
function crear(){	
	//Crear una variable de Bool para comprobar si existe Internet Explorer.
	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 Microsoft.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			//En caso contrario no debe estar usándose IE.
			xmlhttp = false;
		}
	}
	
	//Si no estamos usando IE, crear una versión javascript del objeto.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;

}
	
	function makerequest(serverPage, objID) {
		
		xmlhttp = crear();
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}else{
				obj.innerHTML ="<center><img src='loader.gif'></center>";
			}
		}
		xmlhttp.send(null);
	}
	
	function makerequest2(serverPage, objID) {
		
		xmlhttp2 = crear();
		
		var obj = document.getElementById(objID);
		xmlhttp2.open("GET", serverPage);
		xmlhttp2.onreadystatechange = function() {
			if (xmlhttp2.readyState == 4 && xmlhttp2.status == 200) {
				obj.innerHTML = xmlhttp2.responseText;
			}else{
				obj.innerHTML ="<br><br><img src='loader.gif'>";
			}
		}
		xmlhttp2.send(null);
	}
	

	function makerequest3(serverPage, objID) {
		
		xmlhttp3 = crear();
		
		var obj = document.getElementById(objID);
		xmlhttp3.open("GET", serverPage);
		xmlhttp3.onreadystatechange = function() {
			if (xmlhttp3.readyState == 4 && xmlhttp3.status == 200) {
				obj.innerHTML = xmlhttp3.responseText;
			}else{
				obj.innerHTML ="<br><br><img src='loader.gif'>";
			}
		}
		xmlhttp3.send(null);
	}
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		
	//xmlhttp.js
	
	//Función para crear un objeto XML-http
	function getxmlhttp (){
		//Crear una varialbe de ool para comprobar si se utiliza una instancia válida de ActiveX Microsoft.
		var xmlhttp = false;
		
		//Comprobar si se está utilizando Internet Explorer.
		try {
			//Si la versión de javascript es superior a la 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//En caso contrario, utilizar el tradicional objeto ActiveX.
			try {
				//Si se está utilizando Internet Explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//En caso contrarios, no se está utilizando Internet Explorer.
				xmlhttp = false;
			}
		}
		
		//Si no se está usando Internet Explorer, crear una instancia javascript del objeto.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		
		return xmlhttp;
	}
	
	//Función para procesar una petición XMLHttpRequest.
	function processajax (serverPage, obj, getOrPost, str){
		//Obtener el objeto XMLHttpRequest a utilizar.
		xmlhttp = getxmlhttp ();
		if (getOrPost == "get"){
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		} else {
			xmlhttp.open("POST", serverPage, true);
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(str);
		}
	}
	
	
	
////////////////////////////////////////////////////////////////////////////////////////////////


	
	//functions.js
			
	//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);
			processajax (serverPage, obj, "get", "");
		} else {
			//Hide the calendar.
			document.getElementById("opencloseimg").src = "images/plus.gif";
			showOrHide = true;
			//Reset the content.
			document.getElementById(objID).innerHTML = "";
		}
		
		
	}
	
	function createform (e, thedate){
		
		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;
		
		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";
		
		//La ubicación en la que estamos cargando la página.
		var objID = "createtask";
		var serverPage = "theform.php?thedate=" + thedate;
		
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
		
	}
		
	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);
		processajax (serverPage, obj, "get", "");
	}
	
	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);
		processajax (serverPage, obj, "get", "");
	}
	
	function checkfortasks (thedate, e){
		
		theObject = document.getElementById("taskbox");
		
		theObject.style.visibility = "visible";
		
		var posx = 0;
		var posy = 0;
		
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
		
		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";
		
		serverPage = "taskchecker.php?thedate=" + thedate;
		objID = "taskbox";
		
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "")
	}
	
	function hidetask (){
		tObject = document.getElementById("taskbox");
		
		tObject.style.visibility = "hidden";
		tObject.style.height = "0px";
		tObject.style.width = "0px";
	}
	
	function trim(inputString) {
	   // Elimina los espacios iniciales y finales de la cadena que recibe. También elimina
	   // espacios consecutivos y los sustituye por uno solo. Si se recibe algo que no sea una 
	   //cadena (null, objeto personalizado, ...), devuelve la entrada.
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Busca espacios al principio de la cadena
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Busca espacios al final de la cadena
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Comprueba si hay espacios consecutivos
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	   }
	   return retValue; // Devuelve la cadena sin espacios
	} // Final de la función "trim"
	
	//Función para validar el formulario addtask.
	function validatetask (thevalue, thename){
		
		var nowcont = true;
		
		if (thename == "correo"){
			if (trim (thevalue) == ""){
				alert("No ha ingresado su correo electronico");
				/*document.getElementById("themessage").innerHTML = "You must enter your name.";
				document.getElementById("newtask").yourname.focus();*/
				nowcont = false;
			}
		}

		if (nowcont == true){
			if (thename == "Nombre"){
				if (trim (thevalue) == ""){
					alert("No ha ingresado su nombre");
					nowcont = false;
				}
			}
		}
		
		if (nowcont == true){
			if (thename == "Correo"){
				if (trim (thevalue) == ""){
					alert("No ha ingresado su correo electronico");
					nowcont = false;
				}
			}
		}

		if (nowcont == true){
			if (thename == "Asunto"){
				if (trim (thevalue) == ""){
					alert("No ha ingresado el asunto");
					nowcont = false;
				}
			}
		}


		if (nowcont == true){
			if (thename == "Mensaje"){
				if (trim (thevalue) == ""){
					alert("No ha ingresado su mensaje");
					nowcont = false;
				}
			}
		}
		
		return nowcont;
	}
	
	var aok;
	
	//Funciones para enviar un formulario.
	function getformvalues (fobj, valfunc){
		
		var str = "";
		aok = true;
		var val;
		
		//Recorrer la lista de todos los objetos que contiene el formulario.
		for(var i = 0; i < fobj.elements.length; i++){
			if(valfunc) {
				if (aok == true){
					val = valfunc (fobj.elements[i].value,fobj.elements[i].name); 
					if (val == false){
						aok = false;
					}
				}
			}
			
			//Analiza radio button y solo envia el que este seleccionado
			if(fobj.elements[i].type == "radio") {
				if(fobj.elements[i].checked){
					str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
				}
			}else{
				str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
			}
		}
			
		//Devolver los valores de la cadena
		return str;
	}
	
	function submitform (theform, serverPage, objID, valfunc){
		var file = serverPage;
		var str = getformvalues(theform,valfunc);
		//Si la validación es correcta.
		if (aok == true){
			obj = document.getElementById(objID);
			processajax (serverPage, obj, "post", str);
		}
	}
	
	function submitformradio (theform, serverPage, objID, valfunc){
		var file = serverPage;

		var str = "";
		for(var i = 0; i < theform.elements.length; i++){
			if(theform.elements[i].type == "radio" && theform.elements[i].checked) {
					str += theform.elements[i].name + "=" + escape(theform.elements[i].value) + "&";
			}
		}
		if (str){
		obj = document.getElementById(objID);
		processajax (serverPage, obj, "post", str);
		}
	}