<!--
  HM_DOM = (document.getElementById) ? true : false;
  var nua = navigator.userAgent.toLowerCase();
  HM_NS = (nua.indexOf("gecko")!=-1 && nua.indexOf("firefox")==-1);
  HM_Opera = (nua.indexOf("opera")!=-1);
  HM_IE     = ((nua.indexOf("msie") != -1) && !HM_Opera);
  HM_NS4 = (document.layers) ? true : false;
//  HM_IE = (document.all) ? true : false;
  HM_IE4 = HM_IE && !HM_DOM;
  HM_Mac = (navigator.appVersion.indexOf("Mac") != -1);
  HM_IE4M = HM_IE4 && HM_Mac;
  HM_Opera = (navigator.userAgent.indexOf("Opera")!=-1);
  HM_Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

  var seethumb = "seeThumb.aspx?Size=137&Image=";
	var ttip = "Click to view the full picture:\n";
	var curThumb = 0;
	var curPic = 0;
	var totalPic = 0;
	var xmlStr = "";
	var parentNode;
	var pics;
	var theMainPic;
	var picName, picBuy, picBuySet, picCat;
	var prevThumb, nextThumb;
	var picDelay = 500;	// delay to avoid pic distortion when
	if (!HM_IE)					// changing portrait-landscape mode
	  picDelay = 1000;  // mozilla needs longer delay

	var bslideshow = 0;
	var slideDelay = 6000;

function onSlideshow()
{
	if (bslideshow == 0) {
	  bslideshow = 1;
	  setTimeout("doSlideshow()", slideDelay);
	}
	else {
	  bslideshow = 0;
	}  
}

function doSlideshow()
{
	if (bslideshow) {
		onNextPic();
	  setTimeout("doSlideshow()", slideDelay);
	 }
	else {
		curThumb = curPic;
		prepThumbnails();
	}
}

//.............................................................................picSearchAll()
function picSearchAll()
{
var stxt;
	if (HM_IE) 
		stxt = document.all.item("searchTxt");
	else 
		stxt = document.getElementById("searchTxt");
		
	if (stxt.value.length > 0)
		return true;
	else
		return false;
}


//.............................................................................picSearch()
function picSearch()
{
var stxt;
var bfound = false;
	if (HM_IE) 
		stxt = document.all.item("searchTxt");
	else 
		stxt = document.getElementById("searchTxt");
	
//alert(stxt.value);	
	if (stxt.value.length > 0 && totalPic >= 0 && (pics != null) && (theMainPic != null)) {
		// find the specified pic, and set it as theImage's source
		for (var ix=0; ix < totalPic; ix++) {
			var thePic  = pics[ix];
			var picElm  = thePic.childNodes;
			var purl    = picElm[0].firstChild;
			var pwidth  = picElm[1].firstChild;
			var pheight = picElm[2].firstChild;
			var beginSearch = purl.nodeValue.lastIndexOf("/");
			var pn  = purl.nodeValue.substr(beginSearch+1);
			var st  = stxt.value.toLowerCase();
			pn = pn.toLowerCase();

			if (pn.indexOf(st) >= 0) {
				// found a match, so show it as the main picture
			  curPic = ix;
				theMainPic.src    = purl.nodeValue;
				theMainPic.width  = pwidth.nodeValue;
				theMainPic.height = pheight.nodeValue; 			  
				theMainPic.alt    = (curPic+1) + " of " + totalPic;
				theMainPic.title  = (curPic+1) + " of " + totalPic;
				var start = theMainPic.src.lastIndexOf("/");
				var fname = theMainPic.src.substr(start+1);
				fname = fname.replace(/%20/g, " ");
				picName.innerHTML = fname;
				// set the main pic as the first in the thumbnails
				bfound = true;
				curThumb = curPic;
				prepThumbnails();
//alert(theMainPic.src);
				break;
			}
		}
	}
	if (bfound == false) {
	  stxt.value = "Not found.";
	  stxt.select();
	  stxt.focus();
	}
	return false;
}
	
//.............................................................................getTotalPic()
function getTotalPic()
{
	var prevPic, nextPic;
	if (HM_IE) {
		theMainPic = document.all.item("theImage");
		prevPic = document.all.item("picPrev");
		nextPic = document.all.item("picNext");
		picName = document.all.item("picName");
		prevThumb = document.all.item("prev");
		nextThumb = document.all.item("next");
		picBuy    = document.all.item("picBuy");
		picBuySet = document.all.item("picBuySet");
		picCat = document.all.item("picCat");
	}
	else {
		theMainPic = document.getElementById("theImage");
		prevPic = document.getElementById("picPrev");
		nextPic = document.getElementById("picNext");
		picName = document.getElementById("picName");
		prevThumb = document.getElementById("prev");
		nextThumb = document.getElementById("next");
		picBuy    = document.getElementById("picBuy");
		picBuySet = document.getElementById("picBuySet");
		picCat = document.getElementById("picCat");
	}

	totalPic = 0;
	var xmlDoc;

	if (HM_Opera) {
//		alert("it's Opera");
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	}
	else if (HM_IE) {
//		alert("it's IE");
		xmlDoc = document.all("picList").XMLDocument;
	}
	else {
//		alert("it's Moz");
		xmlDoc = document.getElementById("picList");
	}

  parentNode = getNoneTextNode(xmlDoc);
	if (parentNode.nodeType==1) {
		if (parentNode.hasChildNodes) {
		  totalPic = parentNode.childNodes.length;
		  pics = parentNode.childNodes;
		}
	}
	if (totalPic <= 1)
	{
		prevPic.disabled = "disabled";
		nextPic.disabled = "disabled";
		prevPic.enabled = "";
		nextPic.enabled = "";
	}
	else 
	{
		prevPic.enabled = "enabled";
		nextPic.enabled = "enabled";
		prevPic.disabled = "";
		nextPic.disabled = "";
	}

  if (prevThumb != null) {
		prevThumb.disabled = "disabled";
		prevThumb.enabled = "";
		if (totalPic <= 3)
		{
			prevThumb.disabled = "disabled";
			nextThumb.disabled = "disabled";
			prevThumb.enabled = "";
			nextThumb.enabled = "";
		}
		else 
		{
			nextThumb.enabled = "enabled";
			nextThumb.disabled = "";
		}
	}
		
  if (picBuy != null)
		picBuy.style.visibility = "visible";
  if (picBuy != null && picBuySet != null && picCat != null) {
		picBuySet.style.visibility = "hidden";
		if (picCat.innerHTML.indexOf("CardSet_") == 0)
		{
			picBuySet.style.visibility = "visible";
			picBuy.style.visibility = "hidden";
		}
		if (picCat.innerHTML.indexOf("CardSet") == 0)
			picBuy.style.visibility = "hidden";
	}

	// find the main pic and set the curPic
	var mpname  = theMainPic.src;
	for (var ix=0; ix < totalPic; ix++) {
		var thePic  = pics[ix];
		var picElm  = thePic.childNodes;
		var purl    = picElm[0].firstChild;
		var puname  = purl.nodeValue.substr(1);
		puname = puname.replace(/%20/g, " ");
		var fidx = mpname.indexOf(puname) 
		if (fidx != -1) {
		  curPic = ix;
			curThumb = curPic;
			prepThumbnails();
		  break;
		}
	}	
}
	
function onPreviousPic()
{
		theMainPic.src   = "";
		theMainPic.alt   = "";
		theMainPic.title = ""; 			  
    setTimeout("onPreviousPic2()", picDelay);
}
function onPreviousPic2()
{
	if (totalPic >= 0 && (pics != null) && (theMainPic != null)) {
	  curPic--;
		if (curPic < 0)
		  curPic = totalPic-1;
		// select the n-th pic and set it as theImage's source
		var thePic  = pics[curPic];
		var picElm  = thePic.childNodes;
		var purl    = picElm[0].firstChild;
		var pwidth  = picElm[1].firstChild;
		var pheight = picElm[2].firstChild;
		theMainPic.src    = purl.nodeValue;
		theMainPic.width  = pwidth.nodeValue;
		theMainPic.height = pheight.nodeValue; 			  
		theMainPic.alt    = (curPic+1) + " of " + totalPic;
		theMainPic.title  = (curPic+1) + " of " + totalPic;
		var start = theMainPic.src.lastIndexOf("/");
		var fname = theMainPic.src.substr(start+1);
		fname = fname.replace(/%20/g, " ");
		picName.innerHTML = fname;
	}
}

function onNextPic()
{
		theMainPic.src   = "";
		theMainPic.alt   = "";
		theMainPic.title = ""; 			  
    setTimeout("onNextPic2()", picDelay);
}
function onNextPic2()
{
	if (totalPic >= 0 && (pics != null) && (theMainPic != null)) {
	  curPic++;
		if (curPic >= totalPic)
		  curPic = 0;
		// select the n-th pic and set it as theImage's source
		var thePic  = pics[curPic];
		var picElm  = thePic.childNodes;
		var purl    = picElm[0].firstChild;
		var pwidth  = picElm[1].firstChild;
		var pheight = picElm[2].firstChild;
		theMainPic.src    = purl.nodeValue;
		theMainPic.width  = pwidth.nodeValue;
		theMainPic.height = pheight.nodeValue; 			  
		theMainPic.alt    = (curPic+1) + " of " + totalPic;
		theMainPic.title  = (curPic+1) + " of " + totalPic;
		var start = theMainPic.src.lastIndexOf("/");
		var fname = theMainPic.src.substr(start+1);
		fname = fname.replace(/%20/g, " ");
		picName.innerHTML = fname;
	}
}

function loadFullPic(fpath)
{
	if (totalPic >= 0 && (pics != null) && (theMainPic != null)) {
		// find the specified pic, and set it as theImage's source
		for (var ix=0; ix < totalPic; ix++) {
			var thePic  = pics[ix];
			var picElm  = thePic.childNodes;
			var purl    = picElm[0].firstChild;
			var pwidth  = picElm[1].firstChild;
			var pheight = picElm[2].firstChild;
			if (purl.nodeValue == fpath) {
			  curPic = ix;
				theMainPic.src    = purl.nodeValue;
				theMainPic.width  = pwidth.nodeValue;
				theMainPic.height = pheight.nodeValue; 			  
				theMainPic.alt    = (curPic+1) + " of " + totalPic;
				theMainPic.title  = (curPic+1) + " of " + totalPic;
				var start = theMainPic.src.lastIndexOf("/");
				var fname = theMainPic.src.substr(start+1);
				fname = fname.replace(/%20/g, " ");
				picName.innerHTML = fname;
				break;
			}
		}
	}
}

function thumbPrev()
{
	if (totalPic >= 0 && (pics != null) && (theMainPic != null)) {
		curThumb -= 3;
		prepThumbnails();
	}
}

function thumbNext()
{
	if (totalPic >= 0 && (pics != null) && (theMainPic != null)) {
		curThumb += 3;
		prepThumbnails();
	}
}

function enableDisableThumbButton()
{
	if (prevThumb != null) {
		prevThumb.enabled = "enabled";
		nextThumb.enabled = "enabled";
		prevThumb.disabled = "";
		nextThumb.disabled = "";
		if (curThumb <= 0) 
		{
			curThumb = 0;
			prevThumb.disabled = "disabled";
		}
		if (curThumb+3 >= totalPic) 
		{
			nextThumb.disabled = "disabled";
		}
	}
}

function prepThumbnails()
{
	if (prevThumb == null)return;
	// starting with the n-th pic, set thumbnail source and onclick()
	enableDisableThumbButton();
	for (var tx=curThumb, i=0; i < 3; tx++, i++) {
		if (tx < totalPic) {
			var thePic  = pics[tx];
			var picElm  = thePic.childNodes;
			var purl    = picElm[0].firstChild;
			var psize   = picElm[3].firstChild;
		}
		else
			purl = null;
			
		var thumb, thumbA, thumbC, thumbid, thumbAid, thumbCid;
		thumbid  = "thumb" + i;
		thumbAid = "thumbAnchor" + i;
		thumbCid = "thumbCell" + i;
		if (HM_IE) {
			thumb = document.all.item(thumbid);
			thumbA = document.all.item(thumbAid);
			thumbC = document.all.item(thumbCid);
		}
		else {
			thumb = document.getElementById(thumbid);
			thumbA = document.getElementById(thumbAid);
			thumbC = document.getElementById(thumbCid);
		}

		if (thumb != null && thumbA != null) {
			if (purl == null) {
			  thumb.src		= "spacer.gif";
			  thumbA.href = "";
			  thumb.title = "";
			  thumbC.style.visibility = "hidden";
			}
			else {
			  thumbC.style.visibility = "visible";
				thumb.src    = seethumb + purl.nodeValue;
				var sdx, ext;
				if ((sdx = thumb.src.indexOf("CardSet_")) > 0) {
					// extract just the file name without the .jpg extension
					ext = thumb.src.lastIndexOf('.');
					var subdir = thumb.src.substr(sdx, ext - sdx);
					thumbA.href = "photos.aspx?cat=" + subdir;
					ttip = "Click to view this Card Set:\n";
					var start = thumb.src.lastIndexOf("/");
					var fname = thumb.src.substr(start+1);
					thumb.title = ttip + fname;
				}
				else {
					thumbA.href  = "javascript:loadFullPic('" + purl.nodeValue.replace(/'/g, "\\'") + "');";
					var start = thumb.src.lastIndexOf("/");
					var fname = thumb.src.substr(start+1);
					thumb.title = ttip + fname + "\nSize: " + psize.nodeValue + "KB";
				}
			}
		}
	}
}

function getNoneTextNode(node)
{
  if (node.hasChildNodes && node.firstChild.nodeType!=3) {
    return node.firstChild;
  } 
  else if (node.hasChildNodes && node.childNodes[1].nodeType==1) {
    return node.childNodes[1];
  }
  else if (node.hasChildNodes && node.firstChild.nodeType==1) {
    return node.firstChild;
  }
  return null;
}


	// called when the orderPics.aspx loads
	function fillOrder()
	{
	  var pspec = " - Format[c/m/f], Size[ x ], Qty[1]";
	  var po;
		if (HM_IE) {
			po = document.all.item("picsToBuy");
		}
		else {
		  po = document.getElementById("picsToBuy");
		  po.focus();
		}
		  
    if (po != null){ 
			var pos = document.cookie.split(";");
			var postext = "";
//			alert(pos.length);
			for (var i=0; i < pos.length; i++){
				// check if this cookie is a pic order
				var idx;
				if ((idx=pos[i].indexOf("picOrder")) != -1) {
					// extract filename
					var start = idx + 10;
					var end = pos[i].indexOf(";", start);
					if (end == -1) end = pos[i].length;
					var value = pos[i].substring(start, end);
					// 'value' is the complete path, so extract just the filename
					// for CardSet_, we need to include the subdir name as well
					var csi = value.indexOf("CardSet_");
					var fname;
					if (csi > 0)
					  fname = value.substr(csi);
					else {
						start = value.lastIndexOf("/");
						fname = value.substr(start+1);
					}
					
					// make sure the file doesn't exist already
					if (postext.indexOf(fname) == -1) {
						postext += fname;
						postext += pspec;
						postext += "\n";
					}
				}
			}

			if (HM_IE) 
				po.innerText = postext;
			else
			  po.innerHTML = postext;
		}
	}

	// called when the printForm button is clicked
	function printOrderForm()
	{
	  var po, cname, street, city, state, zip;
		if (HM_IE) {
			po = document.all.item("picsToBuy");
			cname = document.all.item("customerName");
			street = document.all.item("addrStreet");
			city = document.all.item("addrCity");
			state = document.all.item("addrState");
			zip = document.all.item("addrZip");
		}
		else {
		  po = document.getElementById("picsToBuy");
		  cname = document.getElementById("customerName");
		  street = document.getElementById("addrStreet");
		  city = document.getElementById("addrCity");
		  state = document.getElementById("addrState");
		  zip = document.getElementById("addrZip");
		}

    if (po != null){ 
			var postext = "";
			if (HM_IE) 
				postext = po.innerText;
			else
			  postext = po.innerHTML;
			  
			if (postext.length == 0) {
				status='To print an order form, please add pictures to buy.';
			  po.focus();
			  return false;
			}
		}

    if (cname.value.length == 0) {
       cname.focus();
			 status='To print an order form, please enter your name.';
       return false;
    }
    if (street.value.length == 0) {
       street.focus();
			 status='To print an order form, please enter your street.';
       return false;
    }
    if (city.value.length == 0) {
       city.focus();
			 status='To print an order form, please enter your city.';
       return false;
    }
    if (state.value.length == 0) {
       state.focus();
			 status='To print an order form, please enter your state.';
       return false;
    }
    if (zip.value.length == 0) {
       zip.focus();
			 status='To print an order form, please enter your zip code.';
       return false;
    }

    postext = postext.replace(/\n/g, "^");
		window.open("printOrder.aspx?order=" + postext + "&cname=" + cname.value + "&street=" + street.value + "&city=" + city.value + "&state=" + state.value + "&zip=" + zip.value);
		return true;
	}

	// called when the user clicks the "save" button
	function onPicBuy()
	{
	  var po, imgsrc, picname;
	  if (theMainPic != null) {
		  imgsrc = theMainPic.src;
			if (imgsrc.length == 0)
			  return;
		}
		  
		// extract just the /Pictures/... path
		var idx = imgsrc.indexOf("Pictures/");		
	  var ppath = imgsrc.substr(idx);
	  picname = "./";
    picname += ppath;
    
		// see if "picOrder" cookie is available
		var allcookies = document.cookie;
		var pos = allcookies.indexOf("orderNum=");
		var order = 1;
		if (pos == -1) {
			// "orderNum" isn't there; so create it
			document.cookie = "orderNum=1";
		}
		else {
			// extract orderNum value
			var start = pos + 9;
			var end = allcookies.indexOf(";", start);
			if (end == -1) end = allcookies.length;
			var value = allcookies.substring(start, end);
			order = value;
		}

		// store this picture as the ordered cookie
		var picCookie = "picOrder" + order + "=" + picname.replace(/%20/g, " ");
		document.cookie = picCookie;
//		alert(picCookie);
		order++;
		document.cookie = "orderNum=" + order;
		return false;
	}		 

	function saveAddr()
	{
	  var po, cname, street, city, state, zip, email, phone;
		if (HM_IE) {
			po = document.all.item("picsToBuy");
			cname = document.all.item("customerName");
			street = document.all.item("addrStreet");
			city = document.all.item("addrCity");
			state = document.all.item("addrState");
			zip = document.all.item("addrZip");
			email = document.all.item("addrEmail");
			phone = document.all.item("addrPhone");
		}
		else {
		  po = document.getElementById("picsToBuy");
		  cname = document.getElementById("customerName");
		  street = document.getElementById("addrStreet");
		  city = document.getElementById("addrCity");
		  state = document.getElementById("addrState");
		  zip = document.getElementById("addrZip");
		  email = document.getElementById("addrEmail");
		  phone = document.getElementById("addrPhone");
		}
    if (cname.value.length > 0) {
			document.cookie = "customerName=" + cname.value;
    }
    if (street.value.length > 0) {
			document.cookie = "street=" + street.value;
    }
    if (city.value.length > 0) {
			document.cookie = "city=" + city.value;
    }
    if (state.value.length > 0) {
			document.cookie = "state=" + state.value;
    }
    if (zip.value.length > 0) {
			document.cookie = "zip=" + zip.value;
    }
    if (email.value.length > 0) {
			document.cookie = "email=" + email.value;
    }
    if (phone.value.length > 0) {
			document.cookie = "phone=" + phone.value;
    }
	}	

	function loadMenu()
	{
    var myMenu = new Menu("myMenu");
	  if (!HM_IE)
			myMenu.fontSize = 12;
//    myMenu.addMenuItem("G e n e r a l", "location='photos.aspx'");
    myMenu.addMenuItem("N a t u r e", "location='photos.aspx?cat=nature'");
    myMenu.addMenuItem("R o m a n c e", "location='photos.aspx?cat=romance'");
    myMenu.addMenuItem("S c e n e s", "location='photos.aspx?cat=scenes'");
    myMenu.addMenuItem("F u n", "location='photos.aspx?cat=fun'");
    myMenu.addMenuItem("R o c k s", "location='photos.aspx?cat=rocks'");
    myMenu.addMenuItem("H o l i d a y s", "location='photos.aspx?cat=holidays'");
    myMenu.addMenuItem("A n i m a l s",  "location='photos.aspx?cat=animals'");
    myMenu.addMenuItem("C a r d  S e t s",  "location='photos.aspx?cat=CardSets'");
    myMenu.writeMenus();
  }
//-->
