function swatch(col) {
  if (col == 3) {
	  // black/red
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Black_Red.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 1; // color
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size
  } else if (col == 4) {
	  // black/royal
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Black_Royal.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 2; // color
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size
  } else if ((col == 5) || (col == 13)) {
	  // navy/lime
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Navy_Lime.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 6; // color
	  if (col == 13)
	  document.MainForm.SELECT___ND___3.selectedIndex = 1; // size
	  else
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size
  } else if ((col == 6) || (col == 14))  {
	  // navy/orange
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Navy_Orange.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 3; // color
	  if (col == 14)
	  document.MainForm.SELECT___ND___3.selectedIndex = 1; // size
	  else
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size 
  } else if ((col == 7) || (col == 15)) {
	  // navy/red
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Navy_Red.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 4; // color
	  if (col == 15)
	  document.MainForm.SELECT___ND___3.selectedIndex = 1; // size
	  else
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size	  
  } else if ((col == 8) || (col == 16))  {
	  // navy/yellow
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Navy_Yellow.jpg";  
	  document.MainForm.SELECT___ND___4.selectedIndex = 5; // color
	  if (col == 16)
	  document.MainForm.SELECT___ND___3.selectedIndex = 1; // size
	  else
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size
  } else if ((col == 9) || (col == 17)) {
	  // red/navy
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Red_Navy.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 7; // color
	  if (col == 17)
	  document.MainForm.SELECT___ND___3.selectedIndex = 1; // size
	  else
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size	  
  } else if (col == 10) {
	  // royal/yellow	  
	  document.images["productimage"].src = "/templates/2/images/Contents/navigator/med/True Wind Sailcloth Navigator Duffel Royal_Yellow.jpg";
	  document.MainForm.SELECT___ND___4.selectedIndex = 8; // color
	  document.MainForm.SELECT___ND___3.selectedIndex = 2; // size	  
  } else {
	  document.MainForm.SELECT___ND___4.selectedIndex = 0; // color
	  document.MainForm.SELECT___ND___3.selectedIndex = 0; // size	 
	  document.MainForm.all_options.selectedIndex = 0;
  }
  setthread(col);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function show_hide_qty_alert(frm) {
  var val = frm.elements['QTY.ND'].value;
  if ((val > 1) && frm.SELECT___ND___15.checked) 
  	MM_showHideLayers('mono_qty_alert','','show'); 
  else 
    MM_showHideLayers('mono_qty_alert','','hide');
}

function alert_monogram(frm) {
  var val = document.forms[0].elements['QTY.ND'].value;
  alert("You have selected " + val + " bags. If you would like a different monogram on each bag, you will need to add this product to your cart once for each different monogram.");
}

function validation(frm) {
  errors = "";
  
  // was color selected? 
  if (frm.SELECT___ND___4.options[frm.SELECT___ND___4.selectedIndex].value == "0") errors+='- Color\n';
  // was size selected?
  if (frm.SELECT___ND___3.options[frm.SELECT___ND___3.selectedIndex].value == "0") errors+='- Size\n';
  
  // if monogramming was checked, make sure options are there
  if (frm.SELECT___ND___15.checked) {
    if (frm.SELECT___ND___10.options[frm.SELECT___ND___10.selectedIndex].value == "0") errors+='- Thread Color\n';
	if (frm.SELECT___ND___8.options[frm.SELECT___ND___8.selectedIndex].value == "0") errors+='- Monogram Type\n';
	if (frm.TEXTBOX___82___ND___11.value == "") errors+='- Name / Initials\n';
  } else {
    // reset monogramming fields
	frm.SELECT___ND___10.selectedIndex = 0;
	frm.SELECT___ND___8.selectedIndex = 0;
	frm.TEXTBOX___82___ND___11.value = "";
  }
  
  if (errors) {
    alert('Please complete the following required fields before adding this product:\n\n'+ errors);
	return false;
  } else {
	frmAct = "ProductDetails.asp?ProductCode=ND";
  	frm.action = frmAct;
    return true;
  }  	
}

// function to set thread colors based on selected bag color
function setthread(col) {
  // first, clear the listbox
  for (var i=document.MainForm.SELECT___ND___10.options.length-1; i>=0; i--) {
    document.MainForm.SELECT___ND___10.options[i] = null;
  }

  // add the first default selection
  addoption(" - select - ", "0");

  // Black with Red Stripes	
  if (col == 3) { addoption("Black", "75"); 	addoption("Red", "83"); 	}
  
  // Black with Royal Stripes
  if (col == 4) { addoption("Black", "75");  	addoption("Royal", "84"); 	}
 
  // Navy with Orange Stripes
  if ((col == 6) || (col == 14)) { addoption("Navy", "76");		addoption("Orange", "77"); 	}
  
  // Navy with Red Stripes
  if ((col == 7) || (col == 15)) { addoption("Navy", "76"); 		addoption("Red", "83");  	}
  
  // Navy with Yellow Stripes
  if ((col == 8) || (col == 16)) { addoption("Navy", "76"); 									}  
  
  // Navy with Lime Stripes
  if ((col == 5) || (col == 13)) { addoption("Lime", "90"); addoption("Navy", "76");  									}  
  
  // Red with Navy Stripes
  if ((col == 9) || (col == 17)) { addoption("Red", "83");		addoption("Navy", "76");	} 
  
  // Royal with Yellow Stripes
  if (col == 10) { addoption("Royal", "84"); 								}      
  
  document.MainForm.SELECT___ND___10.selectedIndex = 0; 

  
  // COLOR options
  // addoption("Black", "75");
  // addoption("Navy", "76");
  // addoption("Orange", "77");  
  // addoption("White", "78");  
  // addoption("Yellow", "79");  
  // addoption("Red", "83");  
  // addoption("Royal", "84");  
  // addoption("Lime", "90");  
 
}

function addoption(opt_text, opt_value) {
  var newOpt = new Option();
  newOpt.text = opt_text;
  newOpt.value = opt_value;
  document.MainForm.SELECT___ND___10.options[document.MainForm.SELECT___ND___10.options.length] = newOpt;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function togglemonogram(frm) {
  show_hide_qty_alert(frm);
  if (frm.SELECT___ND___15.checked) {
  	// checked, show
	MM_showHideLayers('monogramform','','show');
	MM_showHideLayers('nomonogramsubmit','','hide');	
  } else {
    // not checked, hide
	MM_showHideLayers('monogramform','','hide');


	MM_showHideLayers('nomonogramsubmit','','show');		
  }
}