<!--
var SelColorNdx		// index into Color SELECT list
var SelShadeNdx		// index into Shade SELECT list
var prmColor			// Color ID delivered in command line query string
var prmColorNdx		// Color index within the selColor SELECT object
var prmShade			// Shade ID delivered in command line query string
var prmShadeNdx		// Shade index within the selShade SELECT object
var xmlHttp				// Object for xmlHttp communication with host
var hostShadeRtn	// URL which delivers shades for the current color
hostShadeRtn = "XtrctShadesAJAX"

function StartUp()
{
	var MatchDetailSender = RegExp(".*details.php.*");
	var FromDetail = document.referrer.match(MatchDetailSender);
	loadParams();
	loadShadeList(prmColorNdx,prmShadeNdx);
	document.frmColorShade.selColor.options[prmColorNdx].selected = true;
	document.frmColorShade.selShade.options[prmShadeNdx].selected = true;
//	if (FromDetail == null)
//	  alert("We will close Friday, December 28th and re-open Monday, January 7th.  Orders placed while we are closed will be shipped on January 7th.  Thank you for your understanding.");
}

//
//  SetBtnOn & SetBtnOff are not currently used, but they could be handy.
//  Pass the row & column for a button and they accomplish MouseOver and MouseOut functionality.
//
function SetBtnOn(RC)
{
  document.images["btn" + RC].src = ButtonsPath + "btn" + ProdCodes[RC] + "Over.jpg" ;
}

function SetBtnOff(RC)
{
  document.images["btn" + RC].src = ButtonsPath + "btn" + ProdCodes[RC] + ".jpg" ;
}

function loadParams()
{
	/*
  var args = getArgs();

  if (args["c"] != null)
	  prmColor = args["c"];
	else
	  prmColor = 0;

  if (args["ci"] != null)
	  prmColorNdx = args["ci"];
	else
	  prmColorNdx = 0;

  if (args["s"] != null)
	  prmShade = args["s"];
	else
	  prmShade = 0;

  if (args["si"] != null)
	  prmShadeNdx = args["si"];
	else
	  prmShadeNdx = 0;
*/		
	if (SelColorNdx==null)
	  SelColorNdx=0
	if (SelShadeNdx==null)
	  SelShadeNdx=0
}

// Load the Shades selection list for color currently selected in Colors list
function loadShadeList(parmColorNdx, parmShadeNdx) {
    SelColorNdx = parmColorNdx;
    var Shades = Colors[SelColorNdx][1];
    document.frmColorShade.selShade.options.length = Shades.length;
//    document.frmColorShade.selShade.options[0] = new Option("All", 0);
    for (i=0; i<Shades.length; i++) { 
        document.frmColorShade.selShade.options[i] = new Option(Shades[i][0], i);
    }
		UpdateSelectedShade(parmShadeNdx);
}

function UpdateSelectedShade(parmShadeNdx) {
//  alert ("SelShadeNdx / parmShadeNdx: " + SelShadeNdx + " / " + parmShadeNdx)
  SelShadeNdx = parmShadeNdx
	var ActionBefore;
	var ActionAfter;
	var qrystrpos;
	ActionBefore = document.frmColorShade.action;
	qrystrpos = ActionBefore.search(/\?.*&/);	// if ampersand is present, there are params already in place
	if (qrystrpos==-1)														// -1 says there was no ampersand
	{
		qrystrpos = ActionBefore.search(/\?.*$/);
	}

	ActionAfter = ActionBefore.substring(0,qrystrpos) + 
	              "?c=" + Colors[SelColorNdx][0][1] +
	              "&ci=" + document.frmColorShade.selColor.value +
	              "&s=" + Colors[SelColorNdx][1][SelShadeNdx][1] +
								"&si=" + document.frmColorShade.selShade.selectedIndex;
  document.frmColorShade.action=ActionAfter;
}

function resetLists() { 
    loadShadeList(0, 0);
    document.frmColorShade.selColor.options[0].selected = true;
}

function BuyGiftCertificateBtn(PayPalID, ReturnURL, ShoppingURL, CancelURL)
{
  document.write('<input type="hidden" name="cmd" value="_oe-gift-certificate">');
  document.write('<input type="hidden" name="business" value="' + PayPalID + '">');
  document.write('<input type="hidden" name="lc" value="US">');
  document.write('<input type="hidden" name="no_note" value="0">');
  document.write('<input type="hidden" name="no_shipping" value="2">');
  document.write('<input type="hidden" name="return" value="' + ReturnURL + '">');
  document.write('<input type="hidden" name="shopping_url" value="' + ShoppingURL + '">');
  document.write('<input type="hidden" name="cancel_return" value="' + CancelURL + '">');
  document.write('<input type="hidden" name="style_color" value="PPL">');
  document.write('<input type="hidden" name="min_denom" value="5.00">');
  document.write('<input type="hidden" name="max_denom" value="50.00">');
	document.write('<input type="hidden" name="currency_code" value="USD">');
  document.write('<input type="hidden" name="bn" value="PP-GiftCertBF:btn_gift_LG.gif:NonHosted">');
  document.write('<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_gift_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">');
  document.write('<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">');
}

function SubmitFormById(FormId)
{
	document.forms[FormId].submit();
}


