	var maxComic, viewing;
	var comicList;
	var comicDate;

	function reposWin(){
		document.getElementById('middleSec').style.left = ((document.documentElement.scrollWidth/2) - (document.getElementById('middleSec').scrollWidth/2))+"px";
		if (((document.documentElement.scrollWidth/2) - (document.getElementById('middleSec').scrollWidth/2)) < 0)
			document.getElementById('middleSec').style.left = "0px";
	}
	function setTitleBar(){
		var thisComic = comicList[viewing-1];

		cMonth = thisComic.getElementsByTagName("month")[0].childNodes[0].nodeValue
		cDay = thisComic.getElementsByTagName("day")[0].childNodes[0].nodeValue
		cYear = thisComic.getElementsByTagName("year")[0].childNodes[0].nodeValue
		comicDate = cMonth + "/" + cDay + "/" + cYear;

		myTitle = "#" + viewing + " - " + thisComic.getElementsByTagName("title")[0].childNodes[0].nodeValue;
		myTitle += " (" + comicDate + ")";

		document.getElementById("comicTitle").innerHTML = myTitle;
	}
	function getCaption(){		// Returns a comic's caption
		return (comicList[viewing-1]).getElementsByTagName("subtitle")[0].childNodes[0].nodeValue;
	}
	function loadXML(fileName){
		xmlDoc = null;			// Defaults xmlDoc to null as a catcher later

		if (window.XMLHttpRequest){		// Firefox
			xmlDoc = new XMLHttpRequest();
		}
		else if (window.ActiveXObject){		// Other IE
			try{
				xmlDoc = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e1){			// IE5 & IE6
				try{
					xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e2){		// Unable to create an XMLHttpRequest with ActiveX

				}
			}
		}
		else{
			if (document.getElementById("myComic")){
				alert("Your browser cannot support this page. You are being forwarded to a simplified version.");
				location.href="simple.php";
			}
		}

		if (xmlDoc != null){
			xmlDoc.onreadystatechange = getXMLData;
			xmlDoc.open("GET",fileName,true);
			xmlDoc.send(null);
		}
		else
			alert("Your browser does not support XMLHttp - Try upgrading to a more recent version");
	}

	function getXMLData(){
		var navButtons = "";

		if (xmlDoc.readyState != 4) return;	// Have not received the data back yet

		if (xmlDoc.status != 200){
			alert("Problem loading XML data");
			return;
		}

		comicList = xmlDoc.responseXML.documentElement.getElementsByTagName("strip");
		maxComic = comicList.length;
		manageDate();

		if (!viewing)
			viewing = maxComic;
		if (viewing>maxComic || viewing<1){	// Prevents someone from viewing an unpublished comic
			changeComic(2);		// Sends a person back to the maxComic
		}
		if (viewing>1){	// Displays the first and back buttons
			navButtons += "<img src='bb_first.png' height='50' onclick='changeComic(0)' style='cursor:pointer;' title='First Comic'>";
			navButtons += "<img src='bb_back.png' height='50' onclick='changeComic(-1)' style='cursor:pointer;' title='Back'>";
		}
		if (viewing < maxComic){ // Displays the next and last buttons
			navButtons += "<img src='bb_next.png' height='50' onclick='changeComic(1)' style='cursor:pointer;' title='Next'>";
			navButtons += "<a href='index.php'><img src='bb_last.png' height='50' border=0 title='Latest Comic'></a>";
		}
		if (viewing == maxComic){
			navButtons += "<a target='new' href='http://z10.invisionfree.com/Five_O_Clock_Shadow/index.php?showforum=6'><img src='l_comment.png' height=50 border=0 title='Comment on this comic'></a>";
		}
		if (document.getElementById('topButtons'))
			document.getElementById('topButtons').innerHTML = navButtons;


		if (document.comicForm)				// Checks if the user is viewing a page with the comic form on it
			document.comicForm.comic.value = viewing;
		if (document.getElementById('comicTitle'))	// Checks if this web page has a comic title element
			setTitleBar();
		reposWin();
		otherStuff(comicList);		// Each page has its own 'otherStuff' function for specific duties

		if (document.getElementById('myComic')){	// Checks if this page has a comic to display
			if ((document.getElementById("myComic").src).indexOf("comic.jpg")<0) // loads the comic from the xml file if we are on the comicNav page
				document.getElementById("myComic").src = "comics/strip_"+viewing+".jpg";
			document.getElementById("myComic").alt = getCaption();
			document.getElementById("myComic").title = getCaption();
		}
	}

	function autoHide(topic){		// Auto expand / hide news articles
		/* A user clicks on a news article's title bar with id='news_#' then this checks if the actual news being held in 'news_#b' is
				currently visible or hidden and toggles it accordingly. This also updates the icon for the news article at 'news_#c' */

		/*
		if ((document.getElementById(topic+'b')).style.display == ''){
			(document.getElementById(topic+'b')).style.display = 'none';
			(document.getElementById(topic+'c')).innerHTML = '[+]';
		}
		else{
			(document.getElementById(topic+'b')).style.display = '';
			(document.getElementById(topic+'c')).innerHTML = '[-]';
		}
		*/
	}

	function hoverImg(myImg){
		switch(myImg){
			case "main": hoverPic = "_main.gif";
				break;
			case "about": hoverPic = "_about.gif";
				break;
			case "sketches": hoverPic = "_sketch.gif";
				break;
			case "forum": hoverPic = "_forum.gif";
				break;
			case "news": hoverPic = "_news.gif";
				break;
			case "contact": hoverPic = "_contact.gif";
				break;
		}
		document.getElementById('rotator').style.backgroundImage = "url("+hoverPic+")";
	}

	function setLegal(){
		document.getElementById("legalDis").innerHTML = "All images and characters here are copyrighted &copy; 2008-2010 Christopher Davis. Five O'clock Shadow is a product of <a href='http://www.rhizdii.com/'>Rhizdii Entertainment.</a><br>";
		document.getElementById("legalDis").innerHTML += "Images may not be reproduced for commercial use without express written consent. Individuals may reproduce images for personal use (ie: blogs, forums, and avatars), but we ask that you either give credit to the comic and/or link back to this site when you do so.<br>";
		document.getElementById("legalDis").innerHTML += "For questions or comments that cannot be answered on the forums, <a href='mailto:cdavis@focscomic.com'>email us</a> directly.";
	}