		var currentLocation = 0;
		var timer;
		var count = 0;

		function initialMoveLeft(item, amount)
		{
			var x = document.getElementById(item);
			var leftPos = -3750;
			x.style.left = leftPos + "px";
			currentLocation = x.style.left.replace(/px/, "").replace(/pt/, "");
		}

		function moveleftone(item)
		{
			count++;
			var x = document.getElementById(item);
			var leftPos = currentLocation - 3;
			x.style.left = leftPos + "px";
			currentLocation = x.style.left.replace(/px/, "").replace(/pt/, "");

			timer = setTimeout("moveleftone('" + item + "')", 1);
			if(count == 40)
			{
				clearTimeout(timer);
				count = 0;
			}
		}

		function moveleft(item)
		{
			var x = document.getElementById(item);

			for(var i = 0; i < 150; i++)
			{
				x.style.left = currentLocation - 1;
				currentLocation = x.style.left.replace(/px/, "").replace(/pt/, "");
			}
		}

		function moverightone(item)
		{
			count++;
			var x = document.getElementById(item);
			var leftPos = currentLocation - (-3);
			x.style.left = leftPos + "px";
			currentLocation = x.style.left.replace(/px/, "").replace(/pt/, "");

			timer = setTimeout("moverightone('" + item + "')", 1);
			if(count == 40)
			{
				clearTimeout(timer);
				count = 0;
			}
		}

		function moveright(item)
		{
			var x = document.getElementById(item);

			for(var i = 0; i < 150; i++)
			{
				x.style.left = currentLocation - (-1);
				currentLocation = x.style.left.replace(/px/, "").replace(/pt/, "");
			}
		}

		function select(item)
		{
			var x = document.getElementById(item);
			x.className = 'selected';
		}

		function hover(item, title)
		{
			var x = document.getElementById(item);
			x.className = 'hovered';
			document.getElementById('galleryname').innerHTML = title;
		}

		function reset(item)
		{
			var x = document.getElementById(item);
			x.className = '';
			document.getElementById('galleryname').innerHTML = '<span style="color:#CCC;">GALLERIES</span>';
		}

		function changeClass(item, theClass)
		{
			var x = document.getElementById(item);
			x.className = theClass;
		}

		function resetClass(item)
		{
			var x = document.getElementById(item);
			x.className = '';
		}

		var http = false;
		var xhttp = false;

		try 
		{
			http = new ActiveXObject("Msxml2.XMLHTTP");
			xhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			http = getHTTPObject();
			xhttp = getHTTPObject();
		}

		function handleHttpResponseGalleries()
		{
			if (http.readyState == 4)
			{
				results = http.responseText;
				//document.getElementById('mainimage').src = results;
				document.getElementById('thecenter').innerHTML = results;
			}
		}

		function handleXHttpResponseGalleries()
		{
			if (xhttp.readyState == 4)
			{
				results = xhttp.responseText;
				//document.getElementById('mainimage').src = results;
				document.getElementById('thecenter').innerHTML = results;
			}
		}

		function handleHttpResponseCategories()
		{
			if (http.readyState == 4)
			{
				results = http.responseText;
				//document.getElementById('mainimage').src = results;
				document.getElementById('center').innerHTML = results;
			}
		}

		function updateImage(galleryId)
		{
			//	//document.getElementById('mainimage').src = 'image2.jpg';
			//	var gallery = galleryId;
			//	//http.open("GET", url + gallery, true);
			//	http.open("GET", url, true);
			//	http.onreadystatechange = handleHttpResponse;
			//	http.send(null);
		}

		function loadImage(imageId, galleryId, type)
		{
			var url = 'changeImage.php?' + type + '=';
			var image = imageId;
			var gallery = galleryId;
			http.open("GET", url + image + '&imggal=' + gallery, true);
			http.onreadystatechange = handleHttpResponseGalleries;
			http.send(null);
		}

		function loadGallery(galleryId)
		{
			var url = 'changeGallery.php?gal=';
			var gallery = galleryId;
			http.open("GET", url + gallery, true);
			http.onreadystatechange = handleHttpResponseGalleries;
			http.send(null);
		}

		function loadCategory(categoryId, randomGalleryId)
		{
			var url = 'changeCategory.php?cat=';
			var category = categoryId;
			http.open("GET", url + category, true);
			http.onreadystatechange = handleHttpResponseCategories;

			loadCorrectImage(1, randomGalleryId, 'ord');

			http.send(null);
		}

		function loadCorrectImage(imageId, galleryId, type)
		{
			var url = 'changeImage.php?' + type + '=';
			var image = imageId;
			var gallery = galleryId;
			xhttp.open("GET", url + image + '&imggal=' + gallery, true);
			xhttp.onreadystatechange = handleXHttpResponseGalleries;
			xhttp.send(null);
		}

		function loadText(textId)
		{
			var url = 'changeImage.php?img=';
			var text = textId;
			http.open("GET", url + text, true);
			http.onreadystatechange = handleHttpResponseGalleries;
			http.send(null);
		}

		function getHTTPObject()
		{
			var xmlhttp;

			if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
			{
			    try { xmlhttp = new XMLHttpRequest(); }
				catch (e)
				{
					xmlhttp = false;
			    }
			}
			else
			{

			}

			return xmlhttp;
		}

		function open_win(width, height, image)
		{
			width = width + 120;
			window.open("fullimage.php?img=" + image + "&width=" + width + "&height=" + height,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=" + width + ", height=700");
		}

		function resetToHome(textToShow)
		{
			window.location = window.location + '?welcome=1&show=' + textToShow;
		}
