  var strpath;
  var buttonindex = 1;

  var pagebgcolor='#000000';
  var pagefgcolor='#ffffff';

  var urlreferrer = document.referrer;

  var media = '4x6strut,4x6 strut mount,6.00:4x6strutch,4x6 strut mount charity,10.00:10x15pr,10x15 print,20.00:cdfull,cdrom full resolution,15.00:';

  var testprice = 10.00;
  var testtax = 0.00;
  var testmedia = '9"x6"_mounted_print'; // 4x6strutmount';

  var bautoload = 1;
  var lastautoload = "";

//  function enableAutoLoad( benable )
//  {
//	// 1 = enabled, 0 = disabled
//	bautoload = benable
//  }
  function toggleAutoLoad( strname )
  {
	// 1 = enabled, 0 = disabled
	bautoload = bautoload ^ 1;
	if(bautoload == 0)
	{
	  lastautoload = strname;
	}
	else
	{
	  changemainimageout( lastautoload );
	  changemainimage( strname );
	}
  }

  function addlinkhtm( name )
  {
    var strlink32 = "img/logo/milk.jpg";
    var strlink64 = "img/logo/" + name + "_64.jpg";
    var strid = "button" + ( '' + buttonindex );

    document.write("<a href='" + name + ".htm' valign='middle'>");
    document.write("<img valign='middle' alt='"+name+"' src='"+strlink32+"' name='" +strid +"' ");
    document.write('onmouseover="document.images.');
    document.write(strid);
    document.write(".src='" + strlink64 + "'");
    document.write('" ');
    document.write('onmouseout="document.images.');
    document.write(strid);
    document.write(".src='" + strlink32 + "'");
    document.write('" ');
    document.write("border='0'></a> ");

    buttonindex = buttonindex + 1;
  }

  function addlinkasp( name )
  {
    var strlink32 = "img/logo/milk.jpg";
    var strlink64 = "img/logo/" + name + "_64.jpg";
    var strid = "button" + ( '' + buttonindex );

    document.write("<a href='imgbrowse.asp?group=portfolio&event=" + name + "&referrer=default.asp' valign='middle'>");
    document.write("<img valign='middle' alt='"+name+"' src='"+strlink32+"' name='" +strid +"' ");
    document.write('onmouseover="document.images.');
    document.write(strid);
    document.write(".src='" + strlink64 + "'");
    document.write('" ');
    document.write('onmouseout="document.images.');
    document.write(strid);
    document.write(".src='" + strlink32 + "'");
    document.write('" ');
    document.write("border='0'></a> ");

    buttonindex = buttonindex + 1;
  }

  function addlinklibrary( name )
  {
    var strlink32 = "img/logo/milk.jpg";
    var strlink64 = "img/logo/" + name + "_64.jpg";
    var strid = "button" + ( '' + buttonindex );

    document.write("<a href='imgbrowse.asp?group=" + name + "' valign='middle'>");
    document.write("<img valign='middle' alt='"+name+"' src='"+strlink32+"' name='" +strid +"' ");
    document.write('onmouseover="document.images.');
    document.write(strid);
    document.write(".src='" + strlink64 + "'");
    document.write('" ');
    document.write('onmouseout="document.images.');
    document.write(strid);
    document.write(".src='" + strlink32 + "'");
    document.write('" ');
    document.write("border='0'></a> ");

    buttonindex = buttonindex + 1;
  }

  function addlinktemp( name )
  {
    var strlink32 = "img/logo/milk.jpg";
    var strlink64 = "img/logo/" + name + "_64.jpg";
    var strid = "button" + ( '' + buttonindex );

    document.write("<table border='2' cellpadding=0 cellspacing=0><tr><td><a align='left' href='event_" + name + ".asp' valign='top'>");
    document.write( name );
    document.write("</a></td></tr></table> ");

    buttonindex = buttonindex + 1;
  }

  function beginimagepalette( palettewidth, logo )
  {
    strpath = "img/"+logo+"/";
    document.write("<body bgcolor="+pagebgcolor+" text="+pagefgcolor+">");
    document.write("<table border='0' cellpadding='2' cellspacing='0' height='100%'>");
    document.write("<tr span='100%'><td valign='top'>");
    document.write("<img src='img/logo/" + logo + "_64.gif'>");
    document.write("</td></tr>");
    document.write("<tr>");

    document.write("<td align='left' valign='top' height='100%'>");
    document.write("<table border=0 cellpadding=0 cellspacing=0 width=" + palettewidth + " height=100%>");
    document.write("<tr><td valign='top'><p>");
  }

  function beginimagepalette2( palettewidth, group, event, subevent, subevents )
  {
	document.write("<table border='0' cellpadding='2' cellspacing='0' height='100%'>");
    
	// page number array


    document.write("<tr>");
    document.write("<td align='left' valign='top' height='100%'>");
    document.write("<table border=0 cellpadding=0 cellspacing=0 width=" + palettewidth + " height=100%>");
    document.write("<tr><td valign='top'><p>");
  }

  function addimage( strname )
  {
    //document.write(" <img name='" + strname + "' id='" + strname + "' src='" + strpath + strname + "_64.jpg' onMouseover=document.images.MainImage.src='" + strpath + strname + ".jpg'>");
    //document.write(" <img src='" + strpath + strname + "_64.jpg' onMouseover=document.images.MainImage.src='" + strpath + strname + ".jpg'>");
    document.write(" <img src='" + strpath + strname + "_64.jpg' onMouseover=document.images.MainImage.src='" + strpath + strname + ".jpg'>");
  }

//function changemainimage( strimgpath, strname )
//  function changemainimage( strimgpath, strname, sidc, sGroup, sEvent, iSubEvent, sReferrer, sHttp, sFirstLeaf )
  function changemainimage( strimgpath, strname, sidc, sGroup, sEvent, iSubEvent, sReferrer )
  {
	if(bautoload == 1)
	{
		//document.getElementById( strname ).border.style = 'border: 1px red solid';
		//document.getElementById( strname ).border = 1;
		//document.getElementById( strname ).style = 'border-color:white';
//		document.getElementById( strname ).style.borderColor = 'white';

		var sHttp = strimgpath;
		var sFirstLeaf = strname;
//		document.images.MainImage.src="/img/loadingIcon.gif";
		document.images.MainImage.src=strimgpath + "/" + strname + ".jpg";
		document.getElementById('MainImageCaption').innerHTML = strimgpath + "/" + strname + ".jpg";
		document.getElementById('MainImageBuyButton').href = "imgbrowse.asp?sidc=" + sidc + "&group="+ sGroup + "&event=" + sEvent + "&page=" + iSubEvent + "&referrer=" + sReferrer + "&addtobasket=" + sHttp + "/" + sFirstLeaf + ".jpg";
	}
  }

  function changemainimagewithbuy( strimgpath, strname, sidc, sGroup, sEvent, iSubEvent, sReferrer )
  {
	if(bautoload == 1)
	{
		//document.getElementById( strname ).border.style = 'border: 1px red solid';
		//document.getElementById( strname ).border = 1;
		//document.getElementById( strname ).style = 'border-color:white';
//		document.getElementById( strname ).style.borderColor = 'white';

		var sHttp = strimgpath;
		var sFirstLeaf = strname;
//		document.images.MainImage.src="/img/loadingIcon.gif";
		document.images.MainImage.src=strimgpath + "/" + strname + ".jpg";
		document.getElementById('MainImageCaption').innerHTML = strimgpath + "/" + strname + ".jpg";
	//	document.getElementById('MainImageBuyButton').href = href='imgbrowse.asp?sidc=" + cstr(Session("sids")) + "&group="+ sGroup + "&event=" + sEvent + "&page=" + cstr(iSubEvent) + "&referrer=" + sReferrer + "&addtobasket=" + sHttp + "/" + sFirstLeaf + ".jpg';
		document.getElementById("MainImageBuyButton").href = "imgbrowse.asp?sidc=" + sidc + "&group="+ sGroup + "&event=" + sEvent + "&page=" + iSubEvent + "&referrer=" + sReferrer + "&addtobasket=" + sHttp + "/" + sFirstLeaf + ".jpg";
	}
  }


  function changemainimageout( strname )
  {
	if(bautoload == 1)
	{
//    document.getElementById( strname ).border = 1;
      document.getElementById( strname ).style.borderColor = 'black';
	 }
   }

  function getLocalYear()
  {
    var currentTime = new Date();
    return currentTime.getFullYear();
  }

  function backbutton( )
  {
//    document.write("<p><a href='default.asp'><img alt='Home' src='img/logo/milk_left.jpg' border='0'></a><br>");
    document.write("<p><a href='index.htm'><img alt='Home' src='img/back_button.jpg' border='0'></a><br>");
//    document.write("<font size='2'>healthy choice weddings &copy; 2008</font></p>");
    document.write("<font size='2'>healthy choice weddings &copy; " + getLocalYear() + "</font></p>");
	// ###############################################
	// Blank line in case scroll bar obscures bottom of page
	// ###############################################
	document.write("<p></p>");
  }
  function backbutton2( group )
  {
//    document.write("<p><a href='imgbrowse.asp?sidc=" + Session("sids") + "&group=" + group + "'><img alt='Home' src='img/logo/milk_left.jpg' border='0'></a><br>");
//    document.write("<p><a href='imgbrowse.asp?group=" + group + "'><img alt='Home' src='img/logo/milk_left.jpg' border='0'></a><br>");
    document.write("<p><a href='imgbrowse.asp?group=" + group + "'><img alt='Home' src='img/back_button.gif' border='0'></a><br>");
//    document.write("<font size='2'>fullfatphotography &copy; 2008</font></p>");
    document.write("<font size='2'>healthy choice weddings &copy; " + getLocalYear() + "</font></p>");
	// ###############################################
	// Blank line in case scroll bar obscures bottom of page
	// ###############################################
//	document.write("<br>");
  }
  function backbutton3( url )
  {
    if(url == "")
    {  
      url = "clientarea.htm";
    }
    document.write("<p><a href='" + url + "'><img alt='Back' src='img/back_button.jpg' border='0'></a><br>");
    document.write("<font size='2'>healthy choice weddings &copy; " + getLocalYear() + "</font></p>");
	// ###############################################
	// Blank line in case scroll bar obscures bottom of page
	// ###############################################
	document.write("<p></p>");
  }

  function endimagepalette( )
  {
    document.write("</p></td></tr>");
    document.write("<tr valign='bottom'><td align='middle'>");
    backbutton();
    document.write("<p><br></p>");
    document.write("</td></tr>");
    document.write("</table>");
    document.write("</td>");
  }
  function endimagepalette2( group, referrer, group, event, subevent, subevents )
  {
    document.write("</p></td></tr>");



//	document.write("<tr span='100%'>");

	// show page number
	document.write("<td valign='top'>");

	// page paragrpah

    document.write("</td>");

    document.write("<tr height='100%' valign='bottom'><td height='100%' valign='bottom' align='middle'>");

	if(subevents >1)
	{
		document.write("<p>");
		document.write("<font face='verdana,arial,helvetica' size='-1'>");
		var i;
		for(i=0;i<subevents;i++)
		{
		  var s;
		  s = "";
		  s = s + i;

		  var svis;
		  svis = "";
		  svis = svis + (i + 1);

		  if(i==subevent)
		  {
			document.write( " Page" + svis + "&nbsp;&nbsp;");
		  }
		  else
		  {
			//document.write( " Page" + svis + "&nbsp;&nbsp;");
			document.write( "<a href='imgbrowse.asp?group="+ group + "&event=" + event + "&page=" + s + "'> Page" + svis + "</a>&nbsp;&nbsp;");
		  }
		}
		document.write("</font>");
		document.write("</p>");
	}





    if(referrer == "")
	{
	  backbutton2( group );
	}
	else
	{
	  backbutton( );
	}
   // document.write("<p><br></p>");
    document.write("</td></tr>");
    document.write("</table>");
    document.write("</td>");
  }
  function createmainimage( strname )
  {
    document.write("<td align='left' valign='top'>");
    document.write(" <img src='" + strpath + strname + ".jpg' border='0' name='MainImage' align='left'>");
    document.write("</td>");
    document.write("</tr></table></body>");
  }  
  function createmainimage2( strimgpath, strname, subevent, subevents  )
  {
    document.write("<td align='left' valign='top'>");
    document.write(" <img src='" + strimgpath + "/" + strname + ".jpg' border='0' name='MainImage' align='left'>");
    document.write("</td>");
    document.write("</tr>");




    document.write("</table></body>");
  }
 


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function addToBasket( sAddToBasket )
{
	if(readCookie("basket") == null)
	{
		createCookie("basket", sAddToBasket + "|", 7);
	}
	else
	{
		createCookie("basket", readCookie("basket") + sAddToBasket + "|", 7);
	}
}

function removeFromBasket( sRemoveFromBasket )
{
	var sbuffer;
	var sarray;
	var tbuffer;

	tbuffer = "";
	sbuffer = "" + readCookie( "basket");
	sarray=sbuffer.split("|");
	for(i=1;i<sarray.length;i++)
	{
		if(i != sRemoveFromBasket)
		{
			tbuffer = tbuffer + sarray[i-1] + "|";
		}
	}
	createCookie("basket", tbuffer, 7);
}

function showPrice()
{
	var iunitprice = testprice;
	var iunittax = testtax;
	var iunittotal = iunitprice + iunittax;

	// Show unitprice
//	document.write( "<td valign='top' width='100%' align='right'>&#163;" + iunittotal.toFixed(2) + "</td>");
	document.write( "&#163;" + iunittotal.toFixed(2));
}

function showBasket( sidc, group, event, page, referrer )
{
	var sbuffer;
	var sarray;

	document.write("<table border=0 cellspacing=0 cellpadding=0>");
	document.write("<tr>");

	document.write( "<td>");
	// ###############################################
	// Show shopping basket item count
	// ###############################################
	document.write("<img src='img/searchBarBasketIcon.gif' border='0'>");
	document.write( "</td>");

	document.write( "<td>");
	document.write("<font size='2'>");

	sbuffer = "" + readCookie( "basket");

	sarray = sbuffer.split("|");

	var sarrays;
	sarrays = "" + sarray.length-1;
	document.write( sarrays + "&nbsp;" + "items.");
	if(sarray.length > 1)
	{
		document.write("&nbsp;Price&nbsp;includes&nbsp;postage.&nbsp;Other&nbsp;formats&nbsp;available.");
	}
	document.write("</font>");
	document.write( "</td>");

	// ###############################################
	// Show paypal checkout link
	// ###############################################
	document.write( "<td width='100%' align='right'>");
	document.write( "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1&business=sales@fullfatphotography.com&currency_code=GBP");
	for(i=1;i<sarray.length;i++)
	{
		var ibuffer;
		var iarray;
		ibuffer = sarray[i-1];
		iarray = ibuffer.split("|");	// items are stored as <description>,<media>,<unitprice>,<quantity>
		var idesc = iarray[0];
		var imedia = iarray[1];
		var iquantity = iarray[2];

		// lookup price for the specified media
		iquantity = 1;
		imedia = testmedia;
		var iunitprice = testprice;
		var iunittax = testtax;

		var is;
		is = "" + (i);
		//document.write( "&item_name_" + is + "="+sarray[i-1] + "&amount_" + is + "=0.03&quantity_" + is + "=1&tax_" + is + "=" + iunittax.toFixed(2));
		document.write( "&item_name_" + is + "="+sarray[i-1] + " [ " + imedia + " ] " + "&amount_" + is + "=" + iunitprice.toFixed(2) + "&quantity_" + is + "=" + iquantity + "&tax_" + is + "=" + iunittax.toFixed(2));
	}
	document.write( "'>");
	document.write( "<img title='Pay with either PayPal or just your credit card.' border=0 valign='top' align='right' src='img/icon-paypal.gif'>");
	document.write( "</a>");
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");

	// ###############################################
	// Show snailmail checkout link
	// ###############################################
	// TODO

	document.write( "<hr width='100%' noshade size=1 >");

	// ###############################################
	// Show shopping list
	// ###############################################
	for(i=1;i<sarray.length;i++)
	{
		var ibuffer;
		var iarray;
		ibuffer = sarray[i-1];
		iarray = ibuffer.split("|");	// items are stored as <description>,<media>,<unitprice>,<quantity>
		var idesc = iarray[0];
		var imedia = iarray[1];
		var iquantity = iarray[2];

		// lookup price for the specified media
		iquantity = 1;
		imedia = testmedia;
		var iunitprice = testprice;
		var iunittax = testtax;
		var iunittotal = iunitprice + iunittax;

		var is;
		is = "" + (i);

		document.write("<table border=0 cellpadding=0 cellspacing=0><tr>");

		// REMOVE ITEM button
		document.write("<td valign='top'>");
		document.write("<a href='imgbrowse.asp?sidc=" + sidc + "&group="+ group + "&event=" + event + "&page=" + page + "&referrer=" + referrer + "&removefrombasket=" + is +"'>");
		document.write("<img title='Remove' border=0 src='img/delete_button.gif'>");
		document.write("</a>");
		document.write("&nbsp;&nbsp;</td>");

		// VIEW ITEM button
		//document.write("<td><a href=''><img title='View' border=0 width=16 height=16 src='" + sarray[i-1]  +"'></a>&nbsp;&nbsp;</td>");
		document.write("<td valign='top'>");
		document.write("<a href='imgbrowse.asp?sidc=" + sidc + "&group="+ group + "&event=" + event + "&page=" + page + "&referrer=" + referrer + "&viewitem=" + idesc +"'>");
		document.write("<img title='Viewz' border=0 width=16 height=16 src='" + sarray[i-1]  +"'>");
		document.write("</a></td>");
		
		// Show item description / media
		document.write( "<td valign='top'>");
		document.write("<font size='2'>");
		document.write("&nbsp;" + sarray[i-1] + "&nbsp;[&nbsp;" + imedia + "&nbsp;]&nbsp;");
		document.write("</font>");
		document.write("</td>");
		// Show unitprice
		document.write( "<td valign='top' width='100%' align='right'>");
		document.write("<font size='2'>");
		document.write("&#163;" + iunittotal.toFixed(2));
		document.write("</font>");
		document.write("</td>");
		document.write("</tr></table>");
	}

	if(sarray.length <=1)
	{
		document.write("<font size='2'>");
		document.write("Your basket is empty.<br>");
		document.write("</font>");
	}

	// ###############################################
	// Blank line in case scroll bar obscures bottom of page
	// ###############################################
	document.write("<br>");

}


  function milkbutton( name )
  {
//    var strlink32 = "img/logo/milk.jpg";
    var strlink32 = "img/logo/applebutton.jpg";

    var strlink64 = "img/logo/" + name + "_64.jpg";
    var strid = "button" + ( '' + buttonindex );

    document.write("<img valign='middle' title='"+name+"' src='"+strlink32+"' name='" +strid +"' ");
    document.write('onmouseover="document.images.');
    document.write(strid);
    document.write(".src='" + strlink64 + "'");
    document.write('" ');
    //document.write('onmouseout="document.images.');
    //document.write(strid);
    //document.write(".src='" + strlink32 + "'");
    //document.write('" ');
    document.write("border='0'></a> ");

    buttonindex = buttonindex + 1;
  }
