	//xmlhttp.js
	
	//Function to create an XMLHttp Object.
	function getxmlhttp (){
		//Create a boolean variable to check for a valid microsoft active X instance.
		var xmlhttp = false;

		//Check if we are using internet explorer.
		try {
			//If the javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//If not, then use the older active x object.
			try {
				//If we are using internet explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-internet explorer browser.
				xmlhttp = false;
			}
		}
		
		//If we are using a non-internet explorer browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();

		}

		
		return xmlhttp;
	}
	
	//Function to process an XMLHttpRequest.
	function processajax (serverPage, obj, getOrPost, str){
		//Get an XMLHttpRequest object for use.
		
		xmlhttp = getxmlhttp ();
		if (getOrPost == "get")
		{
			xmlhttp.open("GET", serverPage, true);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
				{
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			
			xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
			xmlhttp.setRequestHeader("Cache-Control", "no-cache");
			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 displayCalendar() {
		onerror = handleErr;
		var objID = "calendar";
		var serverPage = "calendar.php";
		//Set the open close tracker variable.
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
		
	
	}
	
	function handleErr(msg,url,l)
	{
		txt="There was an error on this page.\n\n";
		txt+="Error: " + msg + "\n";
		txt+="URL: " + url + "\n";
		txt+="Line: " + l + "\n\n";
		txt+="Click OK to continue.\n\n";
		//alert(txt);
		return true;
	}
	
	function navigateCalendar(month,year,id) {
	
		switch (id)
		{
		
			case 1:
		
				var objID = "calendar";
				var serverPage = "calendar.php?month="+month+"&year="+year;
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");
				break;
			
			case 2:	
				
				var objID = "displayDateStart";
				var serverPage = "addDateStart.php?month="+month+"&year="+year;
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");
				break;					
	
			case 3:	
			
				var objID = "displayDateEnd";
				var serverPage = "addDateEnd.php?month="+month+"&year="+year;
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");
				break;
				
			default:
			
				alert("what?");	
			
		}
	}
	
	function setDates(id,date) {
	
		switch(id)
		{
		
			case "displayDateStart":
			
				document.addToDB.dateStart.value = date;
				closewindow("displayDateStart");

			break;
			
			case "displayDateEnd":

				document.addToDB.dateEnd.value = date;
				closewindow("displayDateEnd");
			
			break;
			
			default:
			
				alert("what?");
			
		}
		
	}
	
	function setBeforePicture(beforePictureLocation) {
	
		document.addProject.beforePictureLocation.value = beforePictureLocation;
		closewindow("displayBeforeBrowser");
	}
	
	function setAfterPicture(afterPictureLocation) {
	
		document.addProject.afterPictureLocation.value = afterPictureLocation;
		closewindow("displayAfterBrowser");
	}
	
function changeText3(id){
	var oldHTML = document.getElementById('id').innerHTML;
	var newHTML = "<span style='color:#ed2024'>" + oldHTML + "</span>";
	document.getElementById('id').innerHTML = newHTML;
}
	
	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";
		
		//The location we are loading the page into.
		var objID = "createtask";
		var serverPage = "theform.php?thedate=" + thedate;
		
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
		
	}
	
	function sortRec (id, direction){
	
		switch (id)
		{
		
			case "order":
			
			if(direction == "up")
			{
			
			var theObject = document.getElementById("viewAllProjects");
			//theObject.style.visibility = "visible";
			theObject.style.height = "auto";
			theObject.style.width = "auto";
			//theObject.style.left = document.body.scrollLeft + 20 + "px";
			//theObject.style.top = document.body.scrollTop + 120 + "px";				
			var objID = "viewAllProjects";
			var serverPage = "viewProjects.php?function=order&sortDir=up";				
			var obj = document.getElementById(objID);

			processajax (serverPage, obj, "get", "");
			
			} else {
			
			var theObject = document.getElementById("viewAllProjects");
			//theObject.style.visibility = "visible";
			theObject.style.height = "auto";
			theObject.style.width = "auto";
			//theObject.style.left = document.body.scrollLeft + 20 + "px";
			//theObject.style.top = document.body.scrollTop + 120 + "px";				
			var objID = "viewAllProjects";
			var serverPage = "viewProjects.php?function=order&sortDir=down";				
			var obj = document.getElementById(objID);

			processajax (serverPage, obj, "get", "");
			
			//alert("WTF?");
			
			}
			
			break;
			
			case "position":
			
			if(direction == "up")
			{
			
			var theObject = document.getElementById("viewAllProjects");
			//theObject.style.visibility = "visible";
			theObject.style.height = "auto";
			theObject.style.width = "auto";
			//theObject.style.left = document.body.scrollLeft + 20 + "px";
			//theObject.style.top = document.body.scrollTop + 120 + "px";				
			var objID = "viewAllProjects";
			var serverPage = "viewProjects.php?function=position&sortDir=up";				
			var obj = document.getElementById(objID);

			processajax (serverPage, obj, "get", "");
			
			} else {
			
			var theObject = document.getElementById("viewAllProjects");
			//theObject.style.visibility = "visible";
			theObject.style.height = "auto";
			theObject.style.width = "auto";
			//theObject.style.left = document.body.scrollLeft + 20 + "px";
			//theObject.style.top = document.body.scrollTop + 120 + "px";				
			var objID = "viewAllProjects";
			var serverPage = "viewProjects.php?function=position&sortDir=down";				
			var obj = document.getElementById(objID);

			processajax (serverPage, obj, "get", "");
			
			//alert("WTF?");
			
			}	
			
			break;
			
		}
		
	}
	
	function closewindow(id){
	
		
		
		switch (id)
		{
		
			case "addToDB":
			
				var theObject = document.getElementById("addToCalendarEvents");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;
				
			case "addProject":
			
				var theObject = document.getElementById("addToProject");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;				
				
			case "displayDateStart":

				var theObject = document.getElementById("displayDateStart");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;
				
			case "displayDateEnd":
			
				var theObject = document.getElementById("displayDateEnd");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;
				
				
			case "AllEvents":
			
				var theObject = document.getElementById("viewAllEvents");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;

			case "viewAllProjects":
			
				var theObject = document.getElementById("viewAllProjects");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;
				
			case "displayBeforeBrowser":
			
				var theObject = document.getElementById("displayBeforeBrowser");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;
				
			case "displayAfterBrowser":
			
				var theObject = document.getElementById("displayAfterBrowser");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;				
				
			case "page1":
			//this isn't true ajax, because we are omitting the processajax part
			
				var theObject = document.getElementById("page1");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;
				
			case "page2":
			//this isn't true ajax, because we are omitting the processajax part
				//showwindow("page1");
				var theObject = document.getElementById("page2");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";
				break;

			case "page3":
			//this isn't true ajax, because we are omitting the processajax part
				//showwindow("page2");
				var theObject = document.getElementById("page3");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";

				break;		
				
			case "page4":
			//this isn't true ajax, because we are omitting the processajax part
				//showwindow("page3");
				var theObject = document.getElementById("page4");
				theObject.style.visibility = "hidden";
				theObject.style.height = "0px";
				theObject.style.width = "0px";

				break;	
												
			default:
			
				alert("Error with function closewindow("+ id + ": This ID is not available in the switch.");
		}
		
	}
	function viewLocalEvent(date) {
	
		var topID = "wrapper";
		
		var newObj = document.getElementById(topID);
		var objID = "content";

		var serverPage = "viewLocalEvent.php?date=" + date;
		var obj = document.getElementById(objID);
		newObj.scrollIntoView(true);

		processajax (serverPage, obj, "get", "");
	
	}
	
	function displayDateWindow(id){
	
		switch (id)
		{
		
			case "eventStart":
			
				var theObject = document.getElementById("displayDateStart");
				theObject.style.visibility = "visible";
				theObject.style.height = "230px";
				theObject.style.width = "325px";
				theObject.style.left = document.body.scrollLeft + 500 + "px";
				theObject.style.top = document.body.scrollTop + 90 + "px";				
				var objID = "displayDateStart";
				var serverPage = "addDateStart.php";				
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");

			
			break;
			
			case "eventEnd":
			
				var theObject = document.getElementById("displayDateEnd");
				theObject.style.visibility = "visible";
				theObject.style.height = "230px";
				theObject.style.width = "325px";
				theObject.style.left = document.body.scrollLeft + 500 + "px";
				theObject.style.top = document.body.scrollTop + 325 + "px";				
				var objID = "displayDateEnd";
				var serverPage = "addDateEnd.php";				
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");
			
			break;
			
			default:
			
				alert("what?");
			
		}
	
	}
	
	function showwindow(id){
	
		
		
		switch (id)
		{
		
			case "addToDB":
			
				var theObject = document.getElementById("addToCalendarEvents");
				theObject.style.visibility = "visible";
				theObject.style.height = "335px";
				theObject.style.width = "325px";
				theObject.style.left = document.body.scrollLeft + 120 + "px";
				theObject.style.top = document.body.scrollTop + 90 + "px";				
				var objID = "addToCalendarEvents";
				var serverPage = "test.php";				
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");

				break;
				
			case "addProject":
			
				var theObject = document.getElementById("addToProject");
				theObject.style.visibility = "visible";
				theObject.style.height = "410px";
				theObject.style.width = "425px";
				theObject.style.left = document.body.scrollLeft + 580 + "px";
				theObject.style.top = document.body.scrollTop + 90 + "px";				
				var objID = "addToProject";
				var serverPage = "addProject.php";				
				var obj = document.getElementById(objID);
				processajax (serverPage, obj, "get", "");

				break;				

			case "viewProjects":
			
				var theObject = document.getElementById("viewAllProjects");
				theObject.style.visibility = "visible";
				theObject.style.height = "auto";
				theObject.style.width = "auto";
				//theObject.style.left = document.body.scrollLeft + 20 + "px";
				//theObject.style.top = document.body.scrollTop + 120 + "px";				
				var objID = "viewAllProjects";
				var serverPage = "viewProjects.php";				
				var obj = document.getElementById(objID);

				processajax (serverPage, obj, "get", "");

				break;
				
			case "viewEvents":
			
				var theObject = document.getElementById("viewAllEvents");
				theObject.style.visibility = "visible";
				theObject.style.height = "auto";
				theObject.style.width = "auto";
				//theObject.style.left = document.body.scrollLeft + 20 + "px";
				//theObject.style.top = document.body.scrollTop + 120 + "px";				
				var objID = "viewAllEvents";
				var serverPage = "viewEvents.php";				
				var obj = document.getElementById(objID);

				processajax (serverPage, obj, "get", "");

				break;
				
			case "page1":
			//this isn't true ajax, because we are omitting the processajax part
				closewindow("page2");
				closewindow("page3");
				closewindow("page4");
				var theObject = document.getElementById("page1");
				
				theObject.style.visibility = "visible";
				theObject.style.height = "300px";
				theObject.style.width = "750px";
				theObject.style.left = document.body.scrollLeft + 4 + "px";
				theObject.style.top = document.body.scrollTop + 235 + "px";				
				var objID = "page1";
				//var serverPage = "viewEvents.php";				
				var obj = document.getElementById(objID);

				//processajax (serverPage, obj, "get", "");

				break;
				
			case "page2":
			//this isn't true ajax, because we are omitting the processajax part
				closewindow("page1");
				closewindow("page3");
				closewindow("page4");
				var theObject = document.getElementById("page2");
				theObject.style.visibility = "visible";
				theObject.style.height = "430px";
				theObject.style.width = "750px";
				theObject.style.left = document.body.scrollLeft + 4 + "px";
				theObject.style.top = document.body.scrollTop + 235 + "px";				
				var objID = "page2";
				//var serverPage = "viewEvents.php";				
				var obj = document.getElementById(objID);

				//processajax (serverPage, obj, "get", "");

				break;

			case "page3":
			//this isn't true ajax, because we are omitting the processajax part
				closewindow("page2");
				closewindow("page1");
				closewindow("page4");
				var theObject = document.getElementById("page3");
				theObject.style.visibility = "visible";
				theObject.style.height = "930px";
				theObject.style.width = "750px";
				theObject.style.left = document.body.scrollLeft + 4 + "px";
				theObject.style.top = document.body.scrollTop + 235 + "px";				
				var objID = "page3";
				//var serverPage = "viewEvents.php";				
				var obj = document.getElementById(objID);

				//processajax (serverPage, obj, "get", "");

				break;		
				
			case "page4":
			//this isn't true ajax, because we are omitting the processajax part
				closewindow("page1");
				closewindow("page2");
				closewindow("page3");
				var theObject = document.getElementById("page4");
				theObject.style.visibility = "visible";
				theObject.style.height = "500px";
				theObject.style.width = "750px";
				theObject.style.left = document.body.scrollLeft + 4 + "px";
				theObject.style.top = document.body.scrollTop + 235 + "px";				
				var objID = "page4";
				//var serverPage = "viewEvents.php";				
				var obj = document.getElementById(objID);

				//processajax (serverPage, obj, "get", "");

				break;						
				
			default:
			
				alert("What?");
		}
		
	}
	//function displayPictureBrowser(ID)
	
	function displayBeforeBrowser(ID){
		var theObject = document.getElementById("displayBeforeBrowser");
		theObject.style.visibility = "visible";
		theObject.style.height = "525px";
		theObject.style.width = "525px";
		theObject.style.left = document.body.scrollLeft + 30 + "px";
		theObject.style.top = document.body.scrollTop + 90 + "px";				
		var objID = "displayBeforeBrowser";
		var serverPage = "browseBefore.php";				
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
	
	}
	
	function displayAfterBrowser(ID){
		var theObject = document.getElementById("displayAfterBrowser");
		theObject.style.visibility = "visible";
		theObject.style.height = "525px";
		theObject.style.width = "525px";
		theObject.style.left = document.body.scrollLeft + 30 + "px";
		theObject.style.top = document.body.scrollTop + 90 + "px";				
		var objID = "displayAfterBrowser";
		var serverPage = "browseAfter.php";				
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
	
	}
	
	function editCalendarEvent(calEventID){
	
		var theObject = document.getElementById("addToCalendarEvents");
		theObject.style.visibility = "visible";
		theObject.style.height = "200px";
		theObject.style.width = "325px";
		theObject.style.left = document.body.scrollLeft + 120 + "px";
		theObject.style.top = document.body.scrollTop + 90 + "px";				
		var objID = "addToCalendarEvents";
		var serverPage = "editEvents.php?event=" + calEventID;				
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
	
	}
	
	function editProject(projID){
	
		var theObject = document.getElementById("addToProject");
		theObject.style.visibility = "visible";
		theObject.style.height = "410px";
		theObject.style.width = "425px";
		theObject.style.left = document.body.scrollLeft + 580 + "px";
		theObject.style.top = document.body.scrollTop + 90 + "px";				
		var objID = "addToProject";
		var serverPage = "editProject.php?projectID=" + projID;				
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
	
	}	

	function deleteProject(id){

		var objID = "viewAllProjects";
		var serverPage = "deleteProject.php?projectID=" + id;
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
		closewindow("viewAllProjects");
		showwindow("viewProjects");
	}	

	function deleteEvent(id){

		var objID = "viewAllEvents";
		var serverPage = "deleteEvent.php?event=" + id;
		var obj = document.getElementById(objID);
		processajax (serverPage, obj, "get", "");
		closewindow("AllEvents");
		showwindow("viewEvents");
	}
	
	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) {
	   // Removes leading and trailing spaces from the passed string. Also removes
	   // consecutive spaces and replaces it with one space. If something besides
	   // a string is passed in (null, custom object, etc.) then return the input.
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Check for spaces at the beginning of the string
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }
	   return retValue; // Return the trimmed string back to the user
	} // Ends the "trim" function
	
	//Function to validate the addtask form.
	function validatetask (thevalue, thename){
		
		var nowcont = true;
		
		if (thename == "yourname"){
			if (trim (thevalue) == ""){
				document.getElementById("themessage").innerHTML = "You must enter your name.";
				document.getElementById("newtask").yourname.focus();
				nowcont = false;
			}
		}
		if (nowcont == true){
			if (thename == "yourtask"){
				if (trim (thevalue) == ""){
					document.getElementById("themessage").innerHTML = "You must enter a task.";
					document.getElementById("newtask").yourtask.focus();
					nowcont = false;
				}
			}
		}
		
		return nowcont;
	}
	
	function validateCalendar (thevalue, thename){
		
		var nowcont = true;
		
		if (thename == "name"){
			if (trim (thevalue) == ""){
				document.getElementById("themessage").innerHTML = "You must enter the Events Name.";
				document.getElementById("addToDB").name.focus();
				nowcont = false;
			}
		}
		if (nowcont == true){
			if (thename == "Location"){
				if (trim (thevalue) == ""){
					document.getElementById("themessage").innerHTML = "Enter a location.";
					document.getElementById("addToDB").Location.focus();
					nowcont = false;
				}
			}
		}
	
		return nowcont;
	}
	
	function validateProject (thevalue, thename){
		
		var nowcont = true;
		
		if (thename == "projectname"){
			if (trim (thevalue) == ""){
				document.getElementById("themessage").innerHTML = "You must enter the name for this project!";
				document.getElementById("addProject").projectname.focus();
				nowcont = false;
			}
		}

		if (nowcont == true){
			if (thename == "orderNum"){
				if (trim (thevalue) == ""){
					document.getElementById("themessage").innerHTML = "Order # cannot be empty.";
					document.getElementById("addProject").orderNum.focus();
					nowcont = false;
				}
			}
		}
		
		if (nowcont == true){
			if (thename == "projectDescription"){
				if (trim (thevalue) == ""){
					document.getElementById("themessage").innerHTML = "Please enter a description for this project!";
					document.getElementById("addProject").projectDescription.focus();
					nowcont = false;
				}
			}
		}
		
		if (nowcont == true){
			if (thename == "beforePictureLocation"){
				if (trim (thevalue) == ""){
					document.getElementById("themessage").innerHTML = "Please select a before picture.";
					document.getElementById("addProject").beforePictureLocation.focus();
					nowcont = false;
				}
			}
		}

		if (nowcont == true){
			if (thename == "afterPictureLocation"){
				if (trim (thevalue) == ""){
					document.getElementById("themessage").innerHTML = "Please select a after picture.";
					document.getElementById("addProject").afterPictureLocation.focus();
					nowcont = false;
				}
			}
		}

		
		return nowcont;
	}

	
	var aok;
	
	//Functions to submit a form.
	function getformvalues (fobj, valfunc){
		
		var str = "";
		aok = true;
		var val;
		
		//Run through a list of all objects contained within the form.
		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;
					}
				}
			}
			str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
		}
		//Then return the string values.
		return str;
	}
	
	function submitform (theform, serverPage, objID, valfunc){
		var file = serverPage;
		var str = getformvalues(theform,valfunc);
		//If the validation is ok.
		if (aok == true){
			obj = document.getElementById(objID);
			processajax (serverPage, obj, "post", str);
		}
	}
		
	function updateCalendarDB(theform, serverPage, objID, valfunc){
	
		var file = serverPage;
		var str = getformvalues(theform,valfunc);

		//If the validation is ok.
		if (aok == true){
			obj = document.getElementById(objID);
			processajax (serverPage, obj, "post", str);
			
			closewindow("AllEvents");
			showwindow("viewEvents");
			closewindow("addToDB");
			
		}

	}
	
	function updateProjectDB(theform, serverPage, objID, valfunc){
		
		var file = serverPage;
		var str = getformvalues(theform,valfunc);
		
		//If the validation is ok.
		if (aok == true){
			obj = document.getElementById(objID);
			processajax (serverPage, obj, "post", str);
			
			closewindow("addProject");
			showwindow("viewProjects");
			//closewindow("addToDB");
			
		}

	}
	
// adding in functions.js for the picture browser functions

	
	//functions.js	
	
	function runajax(objID, serverPage) {
		
		//Create a boolean variable to check for a valid Internet Explorer instance.
		var xmlhttp = false;
		
		//Check if we are using IE.
		try {
			//If the javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//If not, then use the older active x object.
			try {
				//If we are using Internet Explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-IE browser.
				xmlhttp = false;
			}
		}
		//If we are using a non-IE browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
			xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
			xmlhttp.setRequestHeader("Cache-Control", "no-cache");
			xmlhttp.send(null);
	}
	
	//Function to clear error messages.
	function clearmes(ID){
		//Clear any old error messages.
		switch(ID)
		{
		
			case "before":
	
			document.getElementById("errordiv").innerHTML = "";

			break;
			
			case "after":
			
			document.getElementById("errordiv2").innerHTML = "";
			
			break;
			
		}

	}
	
	//Function to show a loading message.
	function showload(ID){
		switch(ID)
		{
			case "before":
			
			document.getElementById("middiv").innerHTML = "<b>Loading...</b><br><img src='loading.gif'>";
			
			break;
			
			
			case "after":
			
			document.getElementById("middiv2").innerHTML = "<b>Loading...</b><br><img src='loading.gif'>";
			
			break;
			
			default:
			
			alert("what?");	
			
			
		}
			


	}
	
	//Variable dictating how long to wait to refresh the gallery.
	var refreshrate = 17500;
	var delrefreshrate = 100;
	
	function uploadimg(theform, ID){
		//Submit the form.
		theform.submit();
		//Clear any old error messages.
		clearmes(ID);
		//Show loading.
		showload(ID);
		//Re-load the full size image.
		
		switch(ID)
		{
		
			case "before":

			setTimeout ('runajax ("middiv","midpic.php")',refreshrate);
			//Re-load the navigation.
			setTimeout ('runajax ("picdiv","picnav.php")',refreshrate);

			break;
			
			case "after":

			setTimeout ('runajax ("middiv2","midpic2.php")',refreshrate);
			//Re-load the navigation.
			setTimeout ('runajax ("picdiv2","picnav2.php")',refreshrate);
			
			break;
			
		}

	}
	
	function removeimg(theimg, ID){
		clearmes(ID);
		showload(ID);
		
		
		switch(ID)
		{
		
			case "before":

			runajax ("errordiv","delpic.php?pic=" + theimg + "");
			//Re-load the full size image.
			setTimeout ('runajax ("middiv","midpic.php")',delrefreshrate);
			//Re-load the navigation.
			setTimeout ('runajax ("picdiv","picnav.php")',delrefreshrate);
			
			break;
			
			case "after":

			runajax ("errordiv2","delpic.php?pic=" + theimg + "");
			//Re-load the full size image.
			setTimeout ('runajax ("middiv2","midpic2.php")',delrefreshrate);
			//Re-load the navigation.
			setTimeout ('runajax ("picdiv2","picnav2.php")',delrefreshrate);			

			break;
			
		}

	}