function swatch(col) {
  if (col == 1) document.images["productimage"].src = "/templates/2/images/Contents/skipper/med/True Wind Sailcloth Skipper Tote Navy_Lime.jpg";
  if (col == 2) document.images["productimage"].src = "/templates/2/images/Contents/skipper/med/True Wind Sailcloth Skipper Tote Navy_Pink.jpg";
  if (col == 3) document.images["productimage"].src = "/templates/2/images/Contents/skipper/med/True Wind Sailcloth Skipper Tote Navy_Red.jpg";
  if (col == 4) document.images["productimage"].src = "/templates/2/images/Contents/skipper/med/True Wind Sailcloth Skipper Tote Navy_Yellow.jpg";
  if (col == 5) document.images["productimage"].src = "/templates/2/images/Contents/skipper/med/True Wind Sailcloth Skipper Tote Red_Navy.jpg";
  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.ST'].value;
  if ((val > 1) && frm.SELECT___ST___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.ST'].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___ST___4.options[frm.SELECT___ST___4.selectedIndex].value == "0") errors+='- Color\n';
  // was size selected?
  if (frm.SELECT___ST___3.options[frm.SELECT___ST___3.selectedIndex].value == "0") errors+='- Size\n';
  
  // if monogramming was checked, make sure options are there
  if (frm.SELECT___ST___15.checked) {
    if (frm.SELECT___ST___10.options[frm.SELECT___ST___10.selectedIndex].value == "0") errors+='- Thread Color\n';
	if (frm.SELECT___ST___8.options[frm.SELECT___ST___8.selectedIndex].value == "0") errors+='- Monogram Type\n';
	if (frm.TEXTBOX___82___ST___11.value == "") errors+='- Name / Initials\n';
  } else {
    // reset monogramming fields
	frm.SELECT___ST___10.selectedIndex = 0;
	frm.SELECT___ST___8.selectedIndex = 0;
	frm.TEXTBOX___82___ST___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=ST";
  	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___ST___10.options.length-1; i>=0; i--) {
    document.MainForm.SELECT___ST___10.options[i] = null;
  }

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

  // Navy with Lime Stripes
  if (col == 1) { addoption("Lime", "90");  addoption("Navy", "76");   	}
  // Navy with Pink Stripes
  if (col == 2) { addoption("Navy", "76");  addoption("Pink", "97");   	}
  // Navy with Red Stripes
  if (col == 3) { addoption("Navy", "76"); addoption("Red", "83");		}  
  // Navy with Yellow Stripes
  if (col == 4) { addoption("Navy", "76"); addoption("Yellow", "79");	} 
  // Red with Navy Stripes
  if (col == 5) { addoption("Navy", "76"); addoption("Red", "83");	} 
  
  document.MainForm.SELECT___ST___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");
  // addoption("Pink", "97");

}

function addoption(opt_text, opt_value) {
  var newOpt = new Option();
  newOpt.text = opt_text;
  newOpt.value = opt_value;
  document.MainForm.SELECT___ST___10.options[document.MainForm.SELECT___ST___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___ST___15.checked) {
  	// checked, show
	MM_showHideLayers('monogramform','','show');
	MM_showHideLayers('nomonogramsubmit','','hide');	
  } else {
    // not checked, hide
	MM_showHideLayers('monogramform','','hide');
	MM_showHideLayers('nomonogramsubmit','','show');		
  }
}