/* ********************************************************************************************
	You can change the first three functions fairly easy. They just change how the menus
	are drawn. The bottom functions will affect how the images are displayed, so it's not
	suggested to mess with those.

*********************************************************************************************** */




// ============================================================================================
// LEFT NAV BAR
//	This writes out the buttons on the left hand side of the page. The document.write line
//	just spits out some text which looks like the following:
//
//	<a href="utah.html?directory=utah&image=webBentonite_Landscape">
//	<img src="images/utah.gif" border=0></a><br>
//
//	It looks odd since I have to escape the double quotes or the javascript will mess up.
// ============================================================================================
function DrawLeftNav()
{
	document.write("<img src=\"images/gallerytop.gif\" border=0><br>");
	document.write("<a href=\"utah.html?directory=utah&image=webBentonite_Landscape\"><img src=\"images/utah.gif\" border=0></a><br>");
	document.write("<a href=\"trees.html?directory=trees&image=webEnd_Of_Season\"><img src=\"images/trees.gif\" border=0></a><br>");
	document.write("<a href=\"mountains.html?directory=mountains&image=webPink_Teton\"><img src=\"images/mountains.gif\" border=0></a><br>");
	document.write("<a href=\"water.html?directory=water&image=webGarabaldi\"><img src=\"images/water.gif\" border=0></a><br>");
	document.write("<a href=\"animals.html?directory=animals&image=webSix_Geese\"><img src=\"images/animals.gif\" border=0></a><br>");
	document.write("<a href=\"people.html?directory=people&image=webStacey_Bridal\"><img src=\"images/people.gif\" border=0></a><br>");
	document.write("<a href=\"travels.html?directory=travels&image=webNY_Sept_11\"><img src=\"images/travels.gif\" border=0></a><br>");
	document.write("<a href=\"flowers.html?directory=flowers&image=webTS_Red_Yellow\"><img src=\"images/flowers.gif\" border=0></a><br>");
	document.write("<a href=\"trains.html?directory=trains&image=webProm_Point\"><img src=\"images/trains.gif\" border=0></a><br>");
	document.write("<a href=\"nostalgia.html?directory=nostalgia&image=webImage\"><img src=\"images/nostalgia.gif\" border=0></a><br>");
	document.write("<img src=\"images/gallerybottom.gif\" border=0><br>");
}




// ============================================================================================
// MAIN MENU
//	This draws the main menu buttons for all the pages in the root directory (everything
//	but the gallery full-view pages). Like navbar, it just spits some HTML out:
//
//	<a href="utah.html?directory=utah&image=webBentonite_Landscape">
//	<img src="images/gallery.jpg" height=25 width=150 border=0></a>
//
// ============================================================================================
function DrawMainMenu()
{
	document.write("<td width=602 bgcolor=\"#dddddd\"><a href=\"index.html\"><img src=\"images/home.jpg\" height=25 width=150 border=0></a>");
	document.write("<a href=\"utah.html?directory=utah&image=webBentonite_Landscape\"><img src=\"images/gallery.jpg\" height=25 width=150 border=0></a>");
	document.write("<a href=\"ordering.html\"><img src=\"images/ordering.jpg\" height=25 width=150 border=0></a>");
	document.write("<a href=\"about.html\"><img src=\"images/about.jpg\" height=25 width=152 border=0></a></td>");
}





// ============================================================================================
// MAIN FULL-VIEW MENU
//	This draws the main menu buttons for the full-view pages. It varies due to the ../../
//	in the path (makes everything a relative path).
//	
//	<a href="../../utah.html?directory=utah&image=webBentonite_Landscape">
//	<img src="../../images/gallery.jpg" height=25 width=150 border=0></a>
//
// ============================================================================================
function DrawMainFullViewMenu()
{
	document.write("<td width=602 bgcolor=\"#dddddd\"><a href=\"../../index.html\"><img src=\"../../images/home.jpg\" height=25 width=150 border=0></a>");
	document.write("<a href=\"../../utah.html?directory=utah&image=webBentonite_Landscape\"><img src=\"../../images/gallery.jpg\" height=25 width=150 border=0></a>");
	document.write("<a href=\"../../ordering.html\"><img src=\"../../images/ordering.jpg\" height=25 width=150 border=0></a>");
	document.write("<a href=\"../../about.html\"><img src=\"../../images/about.jpg\" height=25 width=152 border=0></a></td>");
}










// =========================================  QUERYSTRING PARSING *DO NOT EDIT* ==========================

QueryString.keys = new Array();
QueryString.values = new Array();


//---- Returns the argument of a querystring
function QueryString(key)
{
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}

//---- Parse the querystring
function QueryString_Parse()
{
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;		
		}
	}

}

//---- Replace all underscores in file names with a space - used for the DrawImage() function
function ParseName(sString)
{
	rExp = /_/g; // Regular expression to replace underscores globally
	return sString.replace(rExp," ");
}

//---- Draw the image in the gallery pages -- parses the name first and removes the first three chars of the filename
function DrawImage()
{
	var sImage = QueryString("image");
	var sName = sImage.substr(3);
	var sDir = QueryString("directory");

	document.write("<table cellspacing=0 cellpadding=0><tr><td valign=bottom class=PicTitle align=left>" + ParseName(sName) + "</td>");
	//document.write("<td align=right><a href=\"galleryPics/"+ sDir + "/" + sName + ".html\"><img src=\"images/magnify.jpg\" border=0 alt=\"View Full Image\"></a></td></tr>");
	document.write("<tr><td colspan=2><img border=1 src=\"galleryPics/"+ sDir + "/" + sImage + ".jpg\" align=top border=0></td></tr>");
	document.write("<tr><td colspan=2 align=center><a href=\"galleryPics/"+ sDir + "/" + sName + ".html\"><img src=\"images/fullsize.gif\" border=0 alt=\"View Full Image\"></a></td></tr>");
	//document.write("<tr><td colspan=2 align=center><a href=\"ordering.html\" onclick=\"AddToCart('" + sName + "');\"><img src=\"images/cart.gif\" border=0></a></td></tr></table>");
	document.write("</table>")
}

QueryString_Parse();






// ======================================= LEGACY STUFF ===========================================================//
/*var daCookie = document.cookie;
var today = new Date();
var expiry = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000); 
var arrRecords = new Array();

function PrintCart()
{
  if(document.cookie!="")
  {
    arrRecords = document.cookie.split(",");
    if(arrRecords.length <=0)
    {
	document.write("<tr><td colspan=4>You have no orders</td></tr>");
    } 
    else 
    {
      for(var i=0; i<arrRecords.length; i++)
      {
	
	document.write("<tr><td>#" + (i+1) + "</td>");
	document.write("<td><input type=\"text\" value=\""+ ParseName(arrRecords[i]) + "\" name=\"Item_"+ i +"\"></td>");
	document.write("<td align=right><input type=\"text\" value=\"1\" name=\"Item_"+ i +"\" Qty:\" size=2></td>");
	document.write("<td><select name=\"Item_"+i+" Size: \">");
		document.write("<Option value=\"11x14\">11\"x14\"</option>");
		document.write("<Option value=\"16x20\">16\"x20\"</option>");
		document.write("<Option value=\"20x24\">20\"x24\"</option>");
		document.write("<Option value=\"24x30\">24\"x30\"</option>");
		document.write("<Option value=\"30x40\">30\"x40\"</option>");
	document.write("</select>");
	document.write("</td></tr>");
      }
   }
  }
  else
	document.write("<tr><td colspan=2>You have no orders</td></tr>");
}

function AddToCart(sName)
{
	var sTmp="";

	if(document.cookie!="")
	{
		sTmp = document.cookie + sName + ",";
	}
	else
		sTmp = sName + ",";

	document.cookie = sTmp +"; domain=localhost; expires=" + expiry.toGMTString();
	daCookie = document.cookie;
}*/


