// JavaScript Document
//
/**
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 * 
 * CodeHouse.com JavaScript Library Module: Cookie Utility Class
 *
 * You can obtain this script at http://www.codehouse.com
 */
function CJL_CookieUtil(name, duration, path, domain, secure)
{
   this.affix = "";
   
   if( duration )
   {   	  
      var date = new Date();
	  var curTime = new Date().getTime();

	  date.setTime(curTime + (1000 * 60 * duration));
	  this.affix = "; expires=" + date.toGMTString();
   }
   
   if( path )
   {
      this.affix += "; path=" + path;
   }
   
   if( domain )
   {
      this.affix += "; domain=" + domain;
   }

   if( secure )
   {
      this.affix += "; secure=" + secure;
   }
   
      
   function getValue()
   {
      var m = document.cookie.match(new RegExp("(" + name + "=[^;]*)(;|$)"));

      return m ? m[1] : null;   
   }
   
   this.cookieExists = function()
   {
      return getValue() ? true : false;
   }
      
   this.expire = function()
   {
      var date = new Date();
	  date.setFullYear(date.getYear() - 1);
	  document.cookie=name + "=noop; expires=" + date.toGMTString(); 
   }
        
   this.setSubValue = function(key, value)
   {
      var ck = getValue();

      if( /[;, ]/.test(value) )
      {
         //Mac IE doesn't support encodeURI
		 value = window.encodeURI ? encodeURI(value) : escape(value);
      }

      
      if( value )
      {
         var attrPair = "@" + key + value;

         if( ck )
         {
             if( new RegExp("@" + key).test(ck) )
	         {
		        document.cookie =
				   ck.replace(new RegExp("@" + key + "[^@;]*"), attrPair) + this.affix;
	         }
	         else
	         {
		        document.cookie =
				   ck.replace(new RegExp("(" + name + "=[^;]*)(;|$)"), "$1" + attrPair) + this.affix;
	         }
         }
         else
         {
	        document.cookie = name + "=" + attrPair + this.affix;
         }
      }
      else
      {      
	     if( new RegExp("@" + key).test(ck) )
	     {
	        document.cookie = ck.replace(new RegExp("@" + key + "[^@;]*"), "") + this.affix;
	     }
      }
   }

      
   this.getSubValue = function(key)
   {
      var ck = getValue();

      if( ck )
      {
         var m = ck.match(new RegExp("@" + key + "([^@;]*)"));

	     if( m )
	     {
	        var value = m[1];

	        if( value )
	        { 
	           //Mac IE doesn't support decodeURI
			   return window.decodeURI ? decodeURI(value) : unescape(value);
	        }
	     }
      }
   }
}
var session = new CJL_CookieUtil("nmasters");

//
// XML startup  - paintings
//

	
	var xmlDoc;
function importXML(archivoXML)
{
  //---this is for IE.
  	if(window.ActiveXObject)
  	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) createTable()
		}
		xmlDoc.load("paintings.xml");
	}
  	else if(document.implementation && document.implementation.createDocument)
	{
    	try
			{//--- this is for FF, opera and others.
				xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.async=false;
		xmlDoc.onload = createTable();		
		xmlDoc.load("paintings.xml");
      		 }
   		 catch(e)
			{// if the other one fails enters here for Safari                        
				xmlDoc = new XMLHttpRequest();                       
				xmlDoc.open("GET", "paintings.xml", false);                        
				xmlDoc.send();                        
				xmlDoc=xmlDoc.responseXML; 
				createTable(); 
  			}
	}
	else
	{
		alert ('n');
	 }

	fullNodes = xmlDoc.documentElement.getElementsByTagName("full");
	thumbNodes = xmlDoc.documentElement.getElementsByTagName("thumb");
	galleryNodes = xmlDoc.documentElement.getElementsByTagName("gallery");
	titleNodes = xmlDoc.documentElement.getElementsByTagName("title");
	mediumNodes = xmlDoc.documentElement.getElementsByTagName("medium");
	paintNodes = xmlDoc.documentElement.getElementsByTagName("paint");
	titleNodes = xmlDoc.documentElement.getElementsByTagName("title");
	descNodes = xmlDoc.documentElement.getElementsByTagName("desc");
	sizeNodes = xmlDoc.documentElement.getElementsByTagName("size");
	priceNodes =    xmlDoc.documentElement.getElementsByTagName("price");
	paintingNodes = xmlDoc.documentElement.getElementsByTagName("painting");
	pNums = new Array(); 

	for (i = 0; i < paintingNodes.length; i++)
	{
  		pNums[i] = paintingNodes[i].getAttribute("pid");

	}
	

}

function createTable()
{
	cTable = 'yes';
}
importXML();
//
// XML startup  - tiles
//

	

function importXMLTiles()
{
  //---this is for IE.

  	if(window.ActiveXObject)
  	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) createTable()
		}
		xmlDoc.load("tiles.xml");
	}
  	else if(document.implementation && document.implementation.createDocument)
	{
    	try
			{//--- this is for FF, opera and others.
				xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.async=false;
		xmlDoc.onload = createTable();		
		xmlDoc.load("tiles.xml");
      		 }
   		 catch(e)
			{// if the other one fails enters here for Safari                        
				xmlDoc = new XMLHttpRequest();                       
				xmlDoc.open("GET", "tiles.xml", false);                        
				xmlDoc.send();                        
				xmlDoc=xmlDoc.responseXML; 
				createTable(); 
  			}
	}
	else
	{
		alert ('n');
	 }

	tileTitleNodes = xmlDoc.documentElement.getElementsByTagName("title");
	tileIdNodes = xmlDoc.documentElement.getElementsByTagName("tileId");

}

function createTable()
{
	cTable = 'yes';
}
importXMLTiles();

//
// initialize cart
//
function initializeCart()
{
	ncards = new Array();
	prints = new Array();	
	tiles = new Array();
	if( !(session.cookieExists()) )
	{
		for (i=0;i<fullNodes.length;i++)
		{
			session.setSubValue("ncards" + i + "=",'0');

			
			session.setSubValue("prints" + i + "=",'0');
		}
		session.setSubValue("ncardsTot=",'0');	
	}
	for (i=0;i<fullNodes.length;i++)
	{
		ncards[i] = session.getSubValue("ncards" + i + "=");
		prints[i] = session.getSubValue("prints" + i + "=");
	}
	for (i=0;i<tileIdNodes.length;i++)
	{
		tiles[i] = session.getSubValue(tileIdNodes[i].firstChild.nodeValue + "=");
	}
	ncardsTot = session.getSubValue("ncardsTot=");
	ncardPrice = 20;
	printPrice = 25; 
	tilePrice = 21.95;
	tileSetPrice= 80.00;
}
initializeCart();
//
// index.htm slide show
//
	function chgPic(delay)
	{
		cycle = 0;
		var delayMs = delay * 1000;
		imgLine = '<img class="grayborder" src="' + fullNodes[cycle].firstChild.nodeValue + '" />';
		document.getElementById("picDisp").innerHTML = imgLine;
		var intval =self.setInterval("nextPic()",delayMs);		
	}
	
	function nextPic()
	{		
		if (cycle < fullNodes.length - 1) {
			cycle++;
		}
		else {
			cycle = 0
		}
 	imgLine = '<img class="grayborder" src="' + fullNodes[cycle].firstChild.nodeValue + '" />'; 
	document.getElementById("picDisp").innerHTML = imgLine; 
	}
 //
 // wearable art picture & text change
 //
 	function wear(view)
	{
		imgFull='<img src="assets/wearablefull/' + view + '.jpg" width="400" height="500" class="posfull" />';		
		imgThumb ='<img src="assets/wearabledetail/' + view + '.jpg" width="200" height="200" class="posdetail" />';
		wearTxt = ' ';
		if (view == "blueback" || view == "bluefront")
			{
				wearTxt = 'Medusa I - Blue jacket <br><br>This jacket is featured in the 2008 fall issue of <b>"Altered Couture"</b> magazine on page 50. This has become my signature jacket.  This was my first major work of wearable art.  The inspiration came from a picture in an advertisement in the back of a craft magazine.  The jacket was my mothers and I never wore it because it was boring and out of style.  I had the most fun putting together the color scheme from fibers, rovings and novelty yarns in my collection, borrowing some and shopping for the accents.  As long as you have a garment that is at least 75% wool, fleece or felt you can machine felt almost anything on to it.  The possibilities are endless.  I do hand beading at any spot that looks like it may be pulled out.  The beading adds the extra icing to the garment.<br><br>After purchasing a felting machine, this was one of my first projects.  I painted the face on muslin and glued it on to the jacket back and then started felting in all kinds of yarns and novelty yarns.';
			}
		if (view == "creamback" || view == "creamfront")
			{
				wearTxt = 'Cream sweater<br><br>This jacket is featured in the 2008 fall issue of "Altered Couture" magazine on page 49. The design on this sweater was done in stages. I pinned on the design and would check it out in a mirror to see if I liked the effect. I used Berroco Hip Hop for the entire sweater. It was felted on the right side, back side and the right side.<br><br>Leaves and flowers were formed by gently teasing the fat part of the yarn into a leaf shape. If more yarn was needed strands could be layered on top and felted in. To make the veins in the leaves, a darker strand was layered on top and felted. The yarn is naturally variegated and lends itself to flowers and leaves. This hand knit sweater was too large and was cut apart and resized with a serger sewing machine. The sleeves were machine felted before stitching them back together.';
			}
		if (view == "collaged")
			{
				wearTxt = 'Collaged Vest<br><br>This vest was created using the fabric from 40 drapery sample books I was given by my local decorating shop.  I thought I was in heaven as I sat on the floor of my studio and surrounded myself with the books and started cutting out swatches of fabric and sorting them in piles of color.<br><br>I cut a fabric pattern in the shape of a vest eliminating the side seams.  I then started placing and pinning the fabric collage pieces on to the fabric pattern.  When I felt it was covered and I was pleased with the design I set my machine on free motion stitching and tacked all the fabric on.  I then satin stitched around the major design elements, such as leaves or flowers.  When they were finished, I free motion random stitched the other pieces of fabric.  I washed the vest and to get the rumpled effect and trimmed any ragged edges with duck billed scissors.<br><br>This may have taken a bit of time to complete, but it is something that I love to do.  Watching the collaged fabric come to life made me keep working on this as my time allowed.';
			}
		if (view == "medusa2")
			{
				wearTxt = 'Medusa II<br><br>This jacket belongs to my sister-in-law Shirley Masters in Buffalo, NY.  I took the portrait from an advertisement for Samsonite Luggage.  I paint the portrait on muslin and glue it on to the jacket and then I start felting the yarns.  I finish off with hand beading.';
			}
		if (view == "duponi")
			{
				wearTxt = 'Duponi Jacket<br><br>This duponi silk jacket is made from hundreds of little squares of duponi silk ranging in size from ½\" to 1 ½\" to sewn together in a bargello pattern design of graduated sizes.  After making the fabric and putting the jacket together I then appliquéd silk yoyos to the surface of the jacket.  I would not even venture to think how many hours have gone into this garment.  I completed the outfit with a silk shell and pants.  There is also a purse to compliment the jacket.<br><br>Yoyos which were in fashion in the 1940\'s have come back into fashion, although updated.  They are round circles that have gathered edges that are then pulled tightly to form a puffy circle.  I stuffed them, layered them, beaded and embroidered them.';
			}
		document.getElementById("wearFull").innerHTML = imgFull; 
		document.getElementById("wearThumb").innerHTML = imgThumb; 
		document.getElementById("weartext").innerHTML = wearTxt;
	}
//
// display painting
//
	function display(pNum)
	{	

		if(pNum == null)
		{
			thumbGallery('Automotive','1');
		}
		else
		{
			var gallery = "";
			var k = 1;
			cellNum = 0;
			for (i=0;i<fullNodes.length;i++)
			{
				if(pNums[i] == pNum)
				{

					gallery = galleryNodes[i].firstChild.nodeValue;
					i= 1000;
				}
			}

			for(i=0;i<fullNodes.length;i++)	
			{
				if(galleryNodes[i].firstChild.nodeValue == gallery)
				{			
					if(pNums[i] == pNum)
					{
						cellNum = k;
						i = 1000;
					}
					else
					{
						k++;
					}
				}
			}
			thumbGallery(gallery,cellNum);
		}
	}
//
// populate thumb gallery
//
	function thumbGallery(subject,galleryNum)
	{
		
		thumbCells = new Array();
		var k = 1;
		document.getElementById("galleryTitle").innerHTML = subject + ' Gallery';
		for(i=0;i<fullNodes.length;i++)	
			{
			if(galleryNodes[i].firstChild.nodeValue == subject)
				{			
				imgLine = '<img src="' + thumbNodes[i].firstChild.nodeValue + '" />';
				thumbCells[k]=i
				cellNum = 'cell' + k;
				document.getElementById(cellNum).innerHTML = imgLine;
				k++;
			}
		}
		for(i=k;i<35;i++)
		{
			imgLine = '';
			cellNum = 'cell' + i;
			document.getElementById(cellNum).innerHTML = imgLine;
		}
		
		displayPainting(galleryNum)
	}
		
//
// display painting and data
//
	function displayPainting(selectNum)
	{
		currentThumb = selectNum;
		m = thumbCells[selectNum];
		if (thumbCells[selectNum] != null)
		{
			imgLine = '<img src="' + fullNodes[m].firstChild.nodeValue + '" class="grayborder" />' ;
			document.getElementById('fullImg').innerHTML = imgLine;
			document.getElementById('title').innerHTML = titleNodes[m].firstChild.nodeValue;
			document.getElementById('size').innerHTML = sizeNodes[m].firstChild.nodeValue;
			document.getElementById('media').innerHTML = paintNodes[m].firstChild.nodeValue + " on " + mediumNodes[m].firstChild.nodeValue;
			document.getElementById('desc').innerHTML = descNodes[m].firstChild.nodeValue;
			document.getElementById('price').innerHTML = priceNodes[m].firstChild.nodeValue;
			if(prints[m] == undefined){prints[m]=0;}
			document.qtyForm.printQty.value = prints[m];
			if(ncards[m] == undefined){ncards[m]=0;}
			document.qtyForm.ncardQty.value = ncards[m];
			if(ncardsTot == undefined){ncardsTot=0;}
			document.qtyForm.ncardTotal.value = ncardsTot;
			if (currentThumb == 1)
			{
				document.getElementById('prevButton').style.display = "none";
			}
			else
			{
				document.getElementById('prevButton').style.display = "inline";
			}
			if (currentThumb == thumbCells.length - 1)
			{
				document.getElementById('nextButton').style.display = "none";
			}
			else
			{
				document.getElementById('nextButton').style.display = "inline";
			}
		}
		if (priceNodes[m].firstChild.nodeValue == 'Inquire for price')
			{
			document.getElementById('priceButton').style.display = "inline";
				mailLink = '<A HREF="mailto:rn1757' + '@' +'aol.com?subject=Inquiry for price&body=Nancy,%0A%0AI am looking for information about buying the original of the painting - ' + titleNodes[m].firstChild.nodeValue + '%0A%0A"> - click here</A>';
				document.getElementById('priceButton').innerHTML = mailLink;
			}
			else
			{
				document.getElementById('priceButton').style.display = "none";
			}
	}
//
// previous/next buttons
//
	function displayNext(direction)
	{

		if(direction == 0)
		{
			if (currentThumb > 1)
			{
				selectNum = parseInt(currentThumb,10) - 1;
				displayPainting(selectNum);
			}
		}
		if(direction == 1)
		{
			if (currentThumb < thumbCells.length - 1)
			{
				selectNum = parseInt(currentThumb,10) + 1;
				displayPainting(selectNum);
			}
		}
	}
//
// mailto
//
	function emailUs()
	{
		mailLink = '<A HREF="mailto:rn1757' + '@' +'aol.com?subject=Inquiry from website">Click here</A>';
		document.getElementById('emailLink').innerHTML = mailLink;
	}
//
// update cookie for print order
//
	function updatePrint()
	{
	printQ = document.qtyForm.printQty.value;
	for (var i = 0; i < printQ.length; i++) {
		var oneChar = printQ.charAt(i)
		if (oneChar < "0" || oneChar > "9") {
			alert("Quantity must be between 1 and 99");
			document.qtyForm.printQty.value = '0';
			return;
		}
	}
	prints[m]=printQ;
	session.setSubValue("prints" + m + "=",prints[m]);	
	}
//
// update cookie for notecard order
//	
	
	function updateNcard()
	{
		

		ncardQ = document.qtyForm.ncardQty.value;
		for (var i = 0; i < ncardQ.length; i++) {
			var oneChar = ncardQ.charAt(i)
			if (oneChar < "0" || oneChar > "9") {
				alert("Quantity must be between 1 and 99");
				document.qtyForm.ncardQty.value = '0';
				ncardQ='0'
				i= ncardQ.length;
			}
		}
	ncardsTot = ncardsTot - ncards[m];
	ncards[m]=parseInt(ncardQ,10);

	ncardsTot = ncardsTot + ncards[m];

	document.qtyForm.ncardTotal.value = ncardsTot;
	session.setSubValue("ncardsTot=", ncardsTot);

	session.setSubValue("ncards" + m + "=",ncards[m]);	
	}
//
// update cookie for tile order
//	
	function updateTile(tileNum)
	{		
	tileQ = document.getElementById("S" + tileNum).selectedIndex;
	alert("Your cart has been updated");
//	tiles[m]=printQ;
	session.setSubValue(tileNum + "=",tileQ);	
	}
//
// display tile page
//

	function tilePage()
	{		
		txtLine = '';
		var k = 1;
		for(i=0;i<tileIdNodes.length;i++)
			{
				if(k%5 == 4 || k%5 == 0)
					{
				txtLine = txtLine + "<div class=\"thumbBox\"><a class=\"thumbnail goLeft\" href=\"#thumb\">  <img src=\"assets/tilesthumb/"+ tileIdNodes[i].firstChild.nodeValue   + ".jpg\"  width=\"120\" height=\"120\" /><span ><img src=\"assets/tilesfull/" + tileIdNodes[i].firstChild.nodeValue + ".jpg\" /><br />" + tileTitleNodes[i].firstChild.nodeValue + "</span></a> <div class=\"desc\"><input class=\"normal short\" type=\"submit\" id=\"" + tileIdNodes[i].firstChild.nodeValue + "\" onClick=\"updateTile('" + tileIdNodes[i].firstChild.nodeValue + "')\" value=\"Add to Cart\" />&nbsp;<span id=\"spryselect1\" ><select id=\"S" + tileIdNodes[i].firstChild.nodeValue + "\"><option>0</option><option selected=\"selected\">1</option><option>2</option><option>3</option><option>4</option><option>5</option></select></span></div></div>";
					}
				else
					{
				txtLine = txtLine + "<div class=\"thumbBox\"><a class=\"thumbnail goRight\" href=\"#thumb\">  <img src=\"assets/tilesthumb/"+ tileIdNodes[i].firstChild.nodeValue   + ".jpg\"  width=\"120\" height=\"120\" /><span ><img src=\"assets/tilesfull/" + tileIdNodes[i].firstChild.nodeValue + ".jpg\" /><br />" + tileTitleNodes[i].firstChild.nodeValue + "</span></a> <div class=\"desc\"><input class=\"normal short\" type=\"submit\" id=\"" + tileIdNodes[i].firstChild.nodeValue + "\" onClick=\"updateTile('" + tileIdNodes[i].firstChild.nodeValue + "')\" value=\"Add to Cart\" />&nbsp;<span id=\"spryselect1\" ><select id=\"S" + tileIdNodes[i].firstChild.nodeValue + "\"><option>0</option><option selected=\"selected\">1</option><option>2</option><option>3</option><option>4</option><option>5</option></select></span></div></div>";
					}
			k++;
		}

		document.getElementById("thumbArray").innerHTML = txtLine;
	}
		


//
// cart display
//
	function cart()
{
	var printTot = 0;
	tileTot = 0;
	tileTotSingle=0;
	tileTotSet=0;
	printOrderIndex = new Array();
	ncardOrderIndex = new Array();
	tileOrderIndex = new Array();
	printTxtLine = "";
	ncardTxtLine = "";
	tileTxtLine = "";
	itemCount = 0;
	var printTotalCost = 0;
	var ncardTotalCost = 0;
	var tileTotalCost = 0;
	flatShippingFlag = 0;
	shippingTotal = 0;
//prints
	var txtLine =  '<table class="black" width="800" border="0" cellspacing="0"  align="center" cellpadding="0"><tr class="headerBlack" align="left"><td> Prints</td></tr><tr bgcolor="#cccccc" class="largeblackUnder" align="center"><td width="350">Title</td><td align="right" width="80">Quantity</td><td align="right" width="110">Price Each</td><td align="right" width="110">Total</td></tr><tr><td>&nbsp</td></tr>';
	var m = 0;
	for (i=0;i<fullNodes.length;i++)
		{
			if(parseInt(prints[i],10) > 0)
			{
				printOrderIndex[m] = i;
				
				printTot += parseInt(prints[i],10);
				txtLine += '<tr><td  width="350 align="left"><A href="gallery.htm?' + pNums[i]+ '"> Print - ' + titleNodes[i].firstChild.nodeValue + '</A></td>';
				
				
				txtLine += '<td width="80"  align="right">' + prints[i] +'</td>';
				
				flatShippingFlag = 1;
				m++;
				txtLine += '<td width="110"  align="right">$' + printPrice + '.00</td>';
				var totItem = printPrice * prints[i];
				printTotalCost += totItem;
				txtLine += '<td width="110"  align="right">$' + totItem + '.00</td></tr>';
				itemCount++;
				printTxtLine += '<input type="hidden" name="item_name_'+ itemCount + '" value="Print - ' + titleNodes[i].firstChild.nodeValue + '">';
				printTxtLine += '<input type="hidden" name="quantity_'+ itemCount + '" value="' + prints[i] + '">';
				printTxtLine += '<input type="hidden" name="amount_'+ itemCount + '" value="' + printPrice + '.00">';
			}
		}
		
		if(printTot < 1)
		{
			txtLine += '<tr><td>No prints ordered</td></tr><tr><td>&nbsp</td></tr><tr><td>&nbsp</td></tr>';
			
		}
		else
		{
			txtLine += '<tr><td>&nbsp</td></tr><tr>';
			txtLine += '<tr bgcolor="#ffdd99"><td  width="350 align="left"> Prints    TOTAL</td>';
			txtLine += '<td width="80"  class="over"   align="right">' + printTot + '</td>';
			txtLine += '<td width="110"  align="right">&nbsp</td>';
			txtLine += '<td width="110"  class="over"    align="right">$' + printTotalCost + '.00</td></tr></tr><tr><td>&nbsp</td></tr><tr><td colspan="3" class="normal">To change a quantity, click on the title of the painting and you will return to its gallery page. <br />To delete an item, change its quantity to 0.</td></tr>';
			txtLine += '</table>';
		}
	document.getElementById('printTable').innerHTML = txtLine;


// notecards
	var txtLine =  '<table class="black" width="800" border="0" cellspacing="0"  align="center" cellpadding="0"><tr class="headerBlack" align="left"><td> Notecards</td></tr><tr bgcolor="#cccccc" class="largeblackUnder" align="center"><td width="350">Title</td><td align="right" width="80">Quantity</td><td align="right" width="110"></td><td align="right" width="110">Total</td></tr><tr><td>&nbsp</td></tr>';
	var m = 0;
	for (i=0;i<fullNodes.length;i++)
		{
			if(parseInt(ncards[i],10) > 0)
			{
				ncardOrderIndex[m] = i;
				
				txtLine += '<tr><td  width="350 align="left"><A href="gallery.htm?' + pNums[i]+ '"> Notecard - ' + titleNodes[i].firstChild.nodeValue + '</A></td>';
				
				txtLine += '<td width="80"  align="right">' + ncards[i] +' cards</td>'	
				m++;
				txtLine += '<td width="110"  align="right">&nbsp</td>';
				var totItem = ncardPrice * ncards[i];
				txtLine += '<td width="110"  align="right">&nbsp</td></tr>';
				flatShippingFlag = 1;
				itemCount++
				ncardTxtLine += '<input type="hidden" name="item_name_'+ itemCount + '" value="Notecard - ' + titleNodes[i].firstChild.nodeValue + '">';
				ncardTxtLine += '<input type="hidden" name="quantity_'+ itemCount + '" value="' + ncards[i] + '">';
				ncardTxtLine += '<input type="hidden" name="amount_'+ itemCount + '" value="0.00">';
			}
		}
		if(ncardsTot < 1 || ncardsTot == undefined)
		{
			txtLine += '<tr><td>No notecards ordered</td></tr><tr><td>&nbsp</td></tr><tr><td>&nbsp</td></tr>';
			
		}
		else
		{
			ncardTotalCost = ncardPrice * Math.ceil(ncardsTot / 8);
			var remainder = 8 - (ncardsTot % 8);
			if(remainder == 8) {remainder = 0};
			txtLine += '<tr><td>&nbsp</td></tr><tr>';
			txtLine += '<tr bgcolor="#ffdd99"><td  width="350 align="left"> Notecards    TOTAL (price is $'+ ncardPrice + '.00 for every 8 cards)</td>';
			txtLine += '<td width="80"  class="over"   align="right">' + ncardsTot + ' cards</td>';
			txtLine += '<td width="110"  align="right">&nbsp</td>';
			txtLine += '<td width="110"  class="over" align="right">$' + ncardTotalCost + '.00</td></tr>';
			itemCount++;
			ncardTxtLine += '<input type="hidden" name="item_name_'+ itemCount + '" value="Notecards Packs of 8">';
			ncardTxtLine += '<input type="hidden" name="quantity_'+ itemCount + '" value="' + Math.ceil(ncardsTot / 8) + '">';
			ncardTxtLine += '<input type="hidden" name="amount_' + itemCount + '" value="' + ncardPrice + '.00">';
			if (remainder != 0)
				{txtLine += '<tr><td>&nbsp</td></tr><tr><td  bgcolor="#ffaaaa" colspan="4">You can choose <span class="largeblack">' + remainder + ' more </span>notecards with no increase in price. Notecards are sold in mix-n-match lots of 8 for $' + ncardPrice + '.00 per lot.  ';
				}
			txtLine += '</td></tr><tr><td>&nbsp</td></tr><tr><td colspan="3" class="normal">To change a quantity, click on the title of the painting and you will return to its gallery page. <br />To delete an item, change its quantity to 0.</td></tr>';
			txtLine += '<tr><td>&nbsp</td></tr></table>';
		}
		document.getElementById('ncardTable').innerHTML = txtLine;
		
// tiles		

var txtLine =  '<table class="black" width="800" border="0" cellspacing="0"  align="center" cellpadding="0"><tr class="headerBlack" align="left"><td> Ceramic Tiles</td></tr><tr bgcolor="#cccccc" class="largeblackUnder" align="center"><td width="350">Title</td><td align="right" width="80">Quantity</td><td align="right" width="110">Price Each</td><td align="right" width="110">Total</td></tr><tr><td>&nbsp</td></tr>';
	var m = 0;
	for (i=0;i<tileIdNodes.length;i++)
		{
			if(parseInt(tiles[i],10) > 0)
			{
				tileOrderIndex[m] = i;
				if (tileIdNodes[i].firstChild.nodeValue.slice(1,2) == 9) 
					{
					tileTotSet += parseInt(tiles[i],10);
					}
				else
					{
					tileTotSingle += parseInt(tiles[i],10);
					}
				tileTot += parseInt(tiles[i],10);
				txtLine += '<tr><td  width="350 align="left"><A href="tiles.html"> Tile - ' + tileTitleNodes[i].firstChild.nodeValue + '</A></td>';
				txtLine += '<td width="80"  align="right">' + tiles[i] +'</td>';
				m++;
				var tileLinePrice = tilePrice;
				if (tileIdNodes[i].firstChild.nodeValue.slice(1,2) == 9) tileLinePrice = tileSetPrice;
				txtLine += '<td width="110"  align="right">$' + tileLinePrice.toFixed(2) + '</td>';
				var totItem = tileLinePrice * tiles[i];
				tileTotalCost += totItem;
				txtLine += '<td width="110"  align="right">$' + totItem.toFixed(2) + '</td></tr>';
				itemCount++;
				tileTxtLine += '<input type="hidden" name="item_name_'+ itemCount + '" value="Tile - ' + tileTitleNodes[i].firstChild.nodeValue + '">';
				tileTxtLine += '<input type="hidden" name="quantity_'+ itemCount + '" value="' + tiles[i] + '">';
				tileTxtLine += '<input type="hidden" name="amount_'+ itemCount + '" value="' + tileLinePrice + '">';
			}
		}
		
		if(tileTot < 1)
		{
			txtLine += '<tr><td>No tiles ordered</td></tr><tr><td>&nbsp</td></tr><tr><td>&nbsp</td></tr>';
		}
		else
		{
			
			txtLine += '<tr><td>&nbsp</td></tr><tr>';
			txtLine += '<tr bgcolor="#ffdd99"><td  width="350 align="left"> Tiles    TOTAL</td>';
			txtLine += '<td width="80"  class="over"   align="right">' + tileTot + '</td>';
			txtLine += '<td width="110"  align="right">&nbsp</td>';
			txtLine += '<td width="110"  class="over"    align="right">$' + tileTotalCost.toFixed(2) + '</td></tr></tr><tr><td>&nbsp</td></tr><tr><td colspan="3" class="normal">To change a quantity, click on the tile name and you will return to the tile page. <br />To delete an item, change its quantity to 0.</td></tr>';
			txtLine += '</table>';
		}
	document.getElementById('tileTable').innerHTML = txtLine;
		
// total
			var txtLine =  '<table class="black" width="800" border="0" cellspacing="0"  align="center" cellpadding="0"><tr class="headerBlack" align="left"><td> TOTAL</td></tr><tr><td>&nbsp</td></tr>';
			txtLine += '<tr bgcolor="#ffdd99"><td  width="350 align="left"> ORDER  TOTAL</td>';
			txtLine += '<td width="80"  align="right">&nbsp</td>';
			txtLine += '<td width="110" align="right">&nbsp</td>';
			OrderTotalCost = ncardTotalCost + printTotalCost + tileTotalCost;
			txtLine += '<td width="110"  class="over"  align="right">$' + OrderTotalCost.toFixed(2) + '</td></tr>';
			txtLine += '<tr><td>&nbsp</td></tr><tr><td colspan="4"align="right"><input name="printOrder" type="button" class="black" align="right" onClick="submitOrder()" value="Go To Checkout" /></td></tr></table>';
		document.getElementById('totalTable').innerHTML = txtLine;
		
}
//
// submit order
//
	function submitOrder()
	{
		if(OrderTotalCost == 0)
		{
			alert("Your cart is empty.");
			return;
		}
		txtLine = '<form name="paypalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
		txtLine += '<input type="hidden" name="cmd" value="_cart">';
		txtLine += '<input type="hidden" name="upload" value="1">';
		txtLine += '<input type="hidden" name="business" value="rn1757@aol.com">';
		txtLine += printTxtLine;
		txtLine += ncardTxtLine;
		txtLine += tileTxtLine;
		if (tileTot >0)
		{
			shippingTotal += tileTotSingle * 5.00;
			shippingTotal += tileTotSet * 10.00;
		}
		if(flatShippingFlag)
		{
			shippingTotal += 5.00;
		}
		txtLine += '<input type="hidden" name="shipping_' + itemCount + '" value="' + shippingTotal + '">';

//		txtLine += '<input type="submit" value="PayPal">';
		txtLine += '</form>';
		
//		txtLine += '<input type="hidden" name="display" value="1">';
		
		document.getElementById('PayPalForm').innerHTML = txtLine;
		document.paypalForm.submit();
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
/*

NOT USED CODE



//
// previous/next buttons new
//
	function displayNext2(direction)
	{

		if(direction == 0)
		{
			if (currentThumb > 1)
			{
				selectNum = parseInt(currentThumb,10) - 1;
				displayPainting2(selectNum);
			}
		}
		if(direction == 1)
		{
			if (currentThumb < thumbCells.length - 1)
			{
				selectNum = parseInt(currentThumb,10) + 1;
				displayPainting2(selectNum);
			}
		}
	}
//
// display painting and data new
//
	function displayPainting2(selectNum)
	{
		for (i = 0; i < paintingNodes.length; i++)
		{
  			if (selectNum == pNums[i])
			{
				var m = i;
				i = 1000;
			}
		}
		
		
		imgLine = '<img src="' + fullNodes[m].firstChild.nodeValue + '" class="grayborder" />' ;
		document.getElementById('fullImg').innerHTML = imgLine;
		document.getElementById('title').innerHTML = titleNodes[m].firstChild.nodeValue;
		document.getElementById('size').innerHTML = sizeNodes[m].firstChild.nodeValue;
		document.getElementById('media').innerHTML = paintNodes[m].firstChild.nodeValue + " on " + mediumNodes[m].firstChild.nodeValue;
		document.getElementById('desc').innerHTML = descNodes[m].firstChild.nodeValue;
		document.getElementById('price').innerHTML = priceNodes[m].firstChild.nodeValue;
		if(prints[m] == undefined){prints[m]=0;}
		document.qtyForm.printQty.value = prints[m];
		if(ncards[m] == undefined){ncards[m]=0;}
		document.qtyForm.ncardQty.value = ncards[m];
		if(ncardsTot == undefined){ncardsTot=0;}
		document.qtyForm.ncardTotal.value = ncardsTot;
		*/
/*		if (currentThumb == 1)
		{
			document.getElementById('prevButton').style.display = "none";
			imgLine = '<img src="assets/thumbnails/P00.jpg" width="165"   />' ;
		document.getElementById('prevThumb').innerHTML = imgLine;
		}
		else
		{
			document.getElementById('prevButton').style.display = "inline";
			imgLine = '<img src="' + thumbNodes[prevNum].firstChild.nodeValue + '" onclick="displayNext2(0)" style="cursor:pointer;" />' ;
		document.getElementById('prevThumb').innerHTML = imgLine;
		}
		if (currentThumb == thumbCells.length - 1)
		{
			document.getElementById('nextButton').style.display = "none";
			imgLine = '<img src="assets/thumbnails/P00.jpg" width="165"   />' ;
		document.getElementById('nextThumb').innerHTML = imgLine;
		}
		else
		{
			document.getElementById('nextButton').style.display = "inline";
			imgLine = '<img src="' + thumbNodes[nextNum].firstChild.nodeValue + '" onclick="displayNext2(1)" style="cursor:pointer;" />' ;
		document.getElementById('nextThumb').innerHTML = imgLine;
		}
	*/
	/*	if (priceNodes[m].firstChild.nodeValue == 'Inquire for price')
			{
			document.getElementById('priceButton').style.display = "inline";
				mailLink = '<A HREF="mailto:rn1757' + '@' +'aol.com?subject=Inquiry for price&body=Nancy,%0A%0AI am looking for information about buying the original of the painting - ' + titleNodes[m].firstChild.nodeValue + '%0A%0A"> - click here</A>';
				document.getElementById('priceButton').innerHTML = mailLink;
			}
			else
			{
				document.getElementById('priceButton').style.display = "none";
			}
	}
	//
// display painting new
//
	function display2(pNum)
	{	

		if(pNum == null)
		{
			thumbGallery2('Automotive','1');
		}
		else
		{
			var gallery = "";
			var k = 1;
			cellNum = 0;
			for (i=0;i<fullNodes.length;i++)
			{
				if(pNums[i] == pNum)
				{

					gallery = galleryNodes[i].firstChild.nodeValue;
					i= 1000;
				}
			}

			for(i=0;i<fullNodes.length;i++)	
			{
				if(galleryNodes[i].firstChild.nodeValue == gallery)
				{			
					if(pNums[i] == pNum)
					{
						cellNum = k;
						i = 1000;
					}
					else
					{
						k++;
					}
				}
			}
		
			displayPainting2(cellNum);
		}
	}
	//
// populate thumb gallery new
//

	function thumbGallery2(subject,galleryNum)
	{
		
		thumbCells = new Array();
		var k = 1;
	//	document.getElementById("galleryTitle").innerHTML = subject + ' Gallery';
		for(i=0;i<fullNodes.length;i++)	
			{
			if(galleryNodes[i].firstChild.nodeValue == subject)
				{			
				imgLine = '<img src="' + thumbNodes[i].firstChild.nodeValue + '" />';
				thumbCells[k]=i
				cellNum = 'cell' + k;
			//	document.getElementById(cellNum).innerHTML = imgLine;
				k++;
			}
		}
		for(i=k;i<35;i++)
		{
			imgLine = '';
			cellNum = 'cell' + i;
		//	document.getElementById(cellNum).innerHTML = imgLine;
		}
		
		displayPainting2(galleryNum)
	}
	*/

