/************************************************************************
* Name: gallery.js														*
* Company: FuseWork Studios												*
* Author: Brandon Coppernoll											*
* Date Created: August 4, 2006											*
*																		*
* This file will allow the client to access functions and server actions*
* for the photo gallery module.											*
************************************************************************/
/*
* This function displays a gallery category's photos.
*/
function displayGallery()
{
	var url = "/gallery/?cid=";
	var oForm = document.forms[0];
	var sBody = getRequestBody(oForm);									// get the form
	var oXmlHttp = zXmlHttp.createRequest();
	url = url + document.getElementById("sltCategoryGallery").value;
	window.location = url;
  	// Open a connection to the server
/*  	oXmlHttp.open("GET", oForm.action + "?" + sBody, true);
  	// Setup a function for the server to run when it's done
  	oXmlHttp.onreadystatechange = function ()
	{
		if (oXmlHttp.readyState == 4) 
		{
			response = oXmlHttp.responseText;
			if (oXmlHttp.status == 200)
			{
				document.getElementById("divGallery").innerHTML = response;
				window.status = "Done";
				response = "";
			}
			else
				alert("Sorry, server error (" + oXmlHttp.status + ") has occurred when changing the photo gallery. If problems persist please contact your site administrator or hosting company. Thank you!");
		}
	};
  	// Send the request
  	oXmlHttp.send(null);
*/
}

/*
* This function displays a gallery category's photos after a user clicks on a link versus a select box.
*/
function showGalleryPage( vCategoryID, vstartCount )
{
	var url = "/gallery/?cid=" + vCategoryID + "&sc=" +vstartCount;
	window.location = url;
	/*
	var oXmlHttp = zXmlHttp.createRequest();
  	// Open a connection to the server
  	oXmlHttp.open("GET", "/gallery/scripts/srv_displayGallery.asp?sltCategoryGallery=" + vCategoryID + "&sc=" + vstartCount, true);
  	// Setup a function for the server to run when it's done
  	oXmlHttp.onreadystatechange = function ()
	{
		if (oXmlHttp.readyState == 4) 
		{
			response = oXmlHttp.responseText;
			if (oXmlHttp.status == 200)
			{
				document.getElementById("divGallery").innerHTML = response;
				window.status = "Done";
				response = "";
			}
			else
				alert("Sorry, server error (" + oXmlHttp.status + ") has occurred when changing the photo gallery. If problems persist please contact your site administrator or hosting company. Thank you!");
		}
	};
  	// Send the request
  	oXmlHttp.send(null);
	*/
}

/*
* This function displays the photo results.
*/
function switchPhoto( vPhotoID, vCategoryID )
{
var url = "/gallery/photo.asp?cid=" + vCategoryID + "&pid=" +vPhotoID;
	window.location = url;
/*
	var oXmlHttp = zXmlHttp.createRequest();
  	// Open a connection to the server
  	oXmlHttp.open("GET", "/gallery/scripts/srv_switchPhoto.asp?pid=" + vPhotoID + "&cid=" + vCategoryID, true);
  	// Setup a function for the server to run when it's done
  	oXmlHttp.onreadystatechange = function ()
	{
		if (oXmlHttp.readyState == 4) 
		{
			response = oXmlHttp.responseText;
			if (oXmlHttp.status == 200)
			{
				document.getElementById("divGallery").innerHTML = response;
				window.status = "Done";
				response = "";
			}
			else
				alert("Sorry, server error (" + oXmlHttp.status + ") has occurred when changing the photo gallery. If problems persist please contact your site administrator or hosting company. Thank you!");
		}
	};
  	// Send the request
  	oXmlHttp.send(null);
*/
}

/*
* This function submits a comment on a photo if everything checks out.
*/
function submitComment()
{
	if (document.frmComment.txtAuthor.value=="")
		document.frmComment.txtAuthor.value = "Anonymous";
		
		
	if	(document.frmComment.txtTitle.value=="")
		alert("Please enter a title to your comment.");
	else if (document.frmComment.txtComments.value=="")
		alert("Please enter your comments.");
	else
	{
		window.location = document.frmComment.action + "&txtAuthor=" + document.frmComment.txtAuthor.value + "&txtTitle=" + document.frmComment.txtTitle.value + "&txtComments=" + document.frmComment.txtComments.value;
	}
		
}
