// ---------------------------------------------------------------------------------------
// parknpool/product_info/english/cas_info/spe-sel-crs-straps-1-head-modal.js
// Copyright (c) 2008 by ParknPool Corp., all rights reserved.
//	All praise honor and glory go to my Lord and Savior Jesus Christ!
//	Romans 15:5,6
//
// 2008/07/16 mv	Copy straight strap version, prepare for publish file inclusion.
// 2008/09/17 mv	Put arrays in separate file for multiple uses.
// 2009/03/20 mv	Copy from Casual Creations and apply to Windward.
// ---------------------------------------------------------------------------------------

function speSelSubmit() {
//	alert('submitSpeSel');
	var optVal = $("#mStrapData").val();
	var strapColor = processStrapColorSelection(optVal);
	var strapColorURL = 'products/65/selection/frames_cross_straps/' + strapColor[0] + '.jpg';
			
	idArray = optVal.split("_");
//	alert('submitSpeSel - Main Strap Value: ' + optVal + ', aID: ' + idArray[0] + ', vID: ' + idArray[1]);
	if( $("#ha1StrapData").val() == '679_0') {
		$("#ha1StrapData").val('679_' + idArray[1]);
//		alert('submitSpeSel - ha1 Value: ' + $("#ha1StrapMenu").val());
	}
	if( $("#ha2StrapData").val() == '680_0') {
		$("#ha2StrapData").val('680_' + idArray[1]);
	}
	if( $("#ha3StrapData").val() == '681_0') {
		$("#ha3StrapData").val('681_' + idArray[1]);
	}
	if( $("#ha4StrapData").val() == '682_0') {
		$("#ha4StrapData").val('682_' + idArray[1]);
	}
	if( $("#ha5StrapData").val() == '683_0') {
		$("#ha5StrapData").val('683_' + idArray[1]);
	}
	if( $("#fa1StrapData").val() == '2_0') {
		$("#fa1StrapData").val('2_' + idArray[1]);
	}
	if( $("#fa2StrapData").val() == '3_0') {
		$("#fa2StrapData").val('3_' + idArray[1]);
	}
	if( $("#fa3StrapData").val() == '4_0') {
		$("#fa3StrapData").val('4_' + idArray[1]);
	}
	if( $("#fa4StrapData").val() == '5_0') {
		$("#fa4StrapData").val('5_' + idArray[1]);
	}
	if( $("#fa5StrapData").val() == '678_0') {
		$("#fa5StrapData").val('678_' + idArray[1]);
	}
}
/* Start Code specific to option selections */

$(document).ready(function() {
	// Code to handle modal window...
	$("#speSelLnk").click(function(e) {
//		alert("click make selections! - " + $("#speSelBtn").attr("src") + " - " + $("#speSelBtn").attr("alt"));
		e.preventDefault();
		$(this).nyroModalManual({
			contentLoading: '<div style="background-color:#fff; padding:10px"><p>If the selection window is not opening, please consider using Internet Explorer 7.0 or Mozilla Firefox</p><a href="#" class="nyroModalClose">Cancel</a></div>', // Loading div content
				debug: false,
				modal: true,
				width: 750,
				closeButton: '<div style="background-color:#dfd; height:26px; text-align:right;"><img src="images/icons/icon_close_dim.gif" border="0" alt="Close" class="nyroModalClose" id="closeBut" style="margin:2px;" /></div>'
		});
		return false;
	}); // End click speSelBtn.
	$.fn.nyroModal.settings.endFillContent = function(elts, settings) {
		// Set Frame Color...
		$("#frameColorMenu", elts.contentWrapper).val($("#frameColorData").val());
		frameColorArray = processFrameColorSelection($("#frameColorData").val());
		frameColorURL = 'url(products/65/selection/frames_cross_straps/top-frame_' + frameColorArray[0] + '.jpg)';
		$("#headFrame", elts.contentWrapper).css("background-image", frameColorURL);
		frameColorURL = 'url(products/65/selection/frames_cross_straps/bot-frame_' + frameColorArray[0] + '.jpg)';
		$("#footFrame", elts.contentWrapper).css("background-image", frameColorURL);
		
		// Main Strap Color...
		$("#mStrapMenu", elts.contentWrapper).val($("#mStrapData").val());
		strapColor = processStrapColorSelection($("#mStrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-strap' + strapColor[0] + '.jpg';
		$("#mStrapImage", elts.contentWrapper).attr("src", strapColorURL);
//				alert("Strap Data: " + $("#mStrapData").val() + ", Strap SRC: " + strapColorURL);
		
		// Vertical Strap Colors (use main strap color...
		strapColorURL = 'products/65/selection/frames_cross_straps/v-tp-sh' + strapColor[0] + '.jpg';
		$(".v-tp-sh", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/v-tp-lg' + strapColor[0] + '.jpg';
		$(".v-tp-lg", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/v-bm-sh' + strapColor[0] + '.jpg';
		$(".v-bm-sh", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/v-bm-lg' + strapColor[0] + '.jpg';
		$(".v-bm-lg", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/v-end-sh' + strapColor[0] + '.jpg';
		$(".v-end-sh", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/v-crs-strap' + strapColor[0] + '.jpg';
		$(".v-crs-strap", elts.contentWrapper).attr("src", strapColorURL);

		// Head Accent Strap Colors...
		$("#ha1StrapMenu", elts.contentWrapper).val($("#ha1StrapData").val());
		strapColor = processStrapColorSelection($("#ha1StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
		$(".h-lt-lg-h1", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-h1", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
		$(".h-rt-lg-h1", elts.contentWrapper).attr("src", strapColorURL);

		$("#ha2StrapMenu", elts.contentWrapper).val($("#ha2StrapData").val());
		strapColor = processStrapColorSelection($("#ha2StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
		$(".h-lt-sh-h2", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-h2", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
		$(".h-rt-sh-h2", elts.contentWrapper).attr("src", strapColorURL);

		$("#ha3StrapMenu", elts.contentWrapper).val($("#ha3StrapData").val());
		strapColor = processStrapColorSelection($("#ha3StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
		$(".h-lt-lg-h3", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-h3", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
		$(".h-rt-lg-h3", elts.contentWrapper).attr("src", strapColorURL);

		$("#ha4StrapMenu", elts.contentWrapper).val($("#ha4StrapData").val());
		strapColor = processStrapColorSelection($("#ha4StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
		$(".h-lt-sh-h4", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-h4", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
		$(".h-rt-sh-h4", elts.contentWrapper).attr("src", strapColorURL);

		$("#ha5StrapMenu", elts.contentWrapper).val($("#ha5StrapData").val());
		strapColor = processStrapColorSelection($("#ha5StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
		$(".h-lt-lg-h5", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-h5", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
		$(".h-rt-lg-h5", elts.contentWrapper).attr("src", strapColorURL);
		
		// Foot Accent Strap Colors...
		$("#fa1StrapMenu", elts.contentWrapper).val($("#fa1StrapData").val());
		strapColor = processStrapColorSelection($("#fa1StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
		$(".h-lt-lg-f1", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-f1", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
		$(".h-rt-lg-f1", elts.contentWrapper).attr("src", strapColorURL);

		$("#fa2StrapMenu", elts.contentWrapper).val($("#fa2StrapData").val());
		strapColor = processStrapColorSelection($("#fa2StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
		$(".h-lt-sh-f2", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-f2", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
		$(".h-rt-sh-f2", elts.contentWrapper).attr("src", strapColorURL);

		$("#fa3StrapMenu", elts.contentWrapper).val($("#fa3StrapData").val());
		strapColor = processStrapColorSelection($("#fa3StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
		$(".h-lt-lg-f3", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-f3", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
		$(".h-rt-lg-f3", elts.contentWrapper).attr("src", strapColorURL);

		$("#fa4StrapMenu", elts.contentWrapper).val($("#fa4StrapData").val());
		strapColor = processStrapColorSelection($("#fa4StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
		$(".h-lt-sh-f4", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-f4", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
		$(".h-rt-sh-f4", elts.contentWrapper).attr("src", strapColorURL);

		$("#fa5StrapMenu", elts.contentWrapper).val($("#fa5StrapData").val());
		strapColor = processStrapColorSelection($("#fa5StrapData").val());
		strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
		$(".h-lt-lg-f5", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
		$(".h-crs-strap-f5", elts.contentWrapper).attr("src", strapColorURL);
		strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
		$(".h-rt-lg-f5", elts.contentWrapper).attr("src", strapColorURL);
	}; // End endFillContent.
	
	$.fn.nyroModal.settings.endShowContent = function(elts, settings) {
//		refererArray = settings.from.href.split("=");
//		alert("End Show Content, From: " + settings.from.href + "\nReferer: " + refererArray[1]);
		function updateCodePriceWeight() {
			var quantity = parseInt($("#qty").val());
			if ( isNaN(quantity) || (quantity < 1) ) {
				// Invalid entry, send message, then reset to 1...
				$("#qty").val("1");
				quantity = 1;
			}
	//		alert("updateCodePriceWeight! Quatity: " + quantity);
	
			// Retrieve option value aid and vid...
			var aidArray = new Array();
			var vidArray = new Array();
			var aidVidPairArray = new Array();
			var aid0PairArray = new Array();
			$(".option").each(function(i) {
				optionValue = $(this).val();
				ovArray = optionValue.split("_");
				aidArray[i] = ovArray[0];
				vidArray[i] = ovArray[1];
				aidVidPairArray[i] = ',' + aidArray[i] + '_' + vidArray[i] + ',' ;
				aid0PairArray[i] = ',' + aidArray[i] + '_0,' ;
				optCount = i + 1;
	//			alert("updateCodePriceWeight-88! Count: " + optCount + ", Option Value: " + optionValue + ", AID VID Pair: " + aidVidPairArray[i] + ", AID 0 Pair: " + aid0PairArray[i]);
			});
	//		alert("updateCodePriceWeight! Size of Model Child Array: " + modelChildArray.length);
	
			// Find child that matches selected option values (aid_vid pairs)...
			for (i = 0; i < modelChildArray.length; i++) {
				var mcMatch = true; // Assume a match to start.
				for (j = 0; j < optCount; j++) {
	//				alert("updateCodePriceWeight-96! MC Count: " + i + ", AVP Count: " + j + ", Child AVPs: " + modelChildArray[i].aidVidPairs + ", AID VID Pair: " + aidVidPairArray[j] + ", AID 0 Pair: " + aid0PairArray[j]);
					if ((modelChildArray[i].aidVidPairs.indexOf(aidVidPairArray[j]) == -1) && (modelChildArray[i].aidVidPairs.indexOf(aid0PairArray[j]) == -1)) {
	//					alert("updateCodePriceWeight-98! No Match");
						mcMatch = false;
						break;
					}
				}
	//			if (mcMatch) { alert("Match") } else { alert("No Match") };
				if (mcMatch) {
					// We have a match, set model code price and weight...
					if (modelChildArray[i].multiplier == 1) {
						var newQtyLabel = ' each';
					} else {
						if (quantity == 1) {
							var newQtyLabel = ' case pack';
						} else {
							var newQtyLabel = ' case packs';
						}
					}
					var newCode = modelChildArray[i].modelCode;
					var newUnitPrice = modelChildArray[i].unitPrice;
					var newCasePrice = modelChildArray[i].casePrice;
					var newWeight = modelChildArray[i].weight;
			
					// Account for quantity and format for display...
					newCasePrice = quantity * newCasePrice;
	//				alert("updateCodePriceWeight! New Unit Price: " + newUnitPrice + ", New Case Price: " + newCasePrice);
					if (newUnitPrice != newCasePrice) {
						newUnitPrice = '(' + currency_format(newUnitPrice) + ' each)';
					} else {
						newUnitPrice = '';
					}
					newCasePrice = currency_format(newCasePrice);
					newWeight = quantity * newWeight + " lbs.";
	//				alert("updateCodePriceWeight! Quantity: " + quantity + ", New Code: " + newCode + ", New Unit Price: " + newUnitPrice + ", New Case Price: " + newCasePrice + ", New Weight: " + newWeight);
	
					// Display
					$("#qtyLabelVal").text(newQtyLabel);
					$("#modelCodeVal").text(newCode);
					$("#unitPriceVal").text(newUnitPrice);
					$("#casePriceVal").text(newCasePrice);
					$("#weightVal").text(newWeight);
					break;
				} // End if mcMatch.
			} // End for each model child
		} // End function updateCodePriceWeight.

		$("#closeBut", elts.contentWrapper).mouseover(function() {
			$(this).attr("src", "images/icons/icon_close.gif");
		});
		$("#closeBut", elts.contentWrapper).mouseout(function() {
			$(this).attr("src", "images/icons/icon_close_dim.gif");
		});
		$(".option", elts.contentWrapper).change(function(e) {
			e.preventDefault();
//			alert("Option selected!");
			
			// Determine id...
//			alert($(this).attr("id") + " = " + $(this).val());
			if ($(this).attr("id") == 'frameColorMenu') {
				frameColorArray = processFrameColorSelection($(this).val());
				$("#frameColorDisp").text(frameColorArray[1]);
				$("#frameColorData").val($(this).val());
				frameColorURL = 'url(products/65/selection/frames_cross_straps/top-frame_' + frameColorArray[0] + '.jpg)';
//				alert('Does DIV id:headFrame exist: ' + $("*", elts.contentWrapper).index($("#headFrame")[0]));
//				alert('Old URL: ' + $("#headFrame", elts.contentWrapper).css("background-image") + "\nNew URL: " + frameColorURL);
				$("#headFrame", elts.contentWrapper).css("background-image", frameColorURL);
				frameColorURL = 'url(products/65/selection/frames_cross_straps/bot-frame_' + frameColorArray[0] + '.jpg)';
				$("#footFrame", elts.contentWrapper).css("background-image", frameColorURL);
			} else {
				strapIDstring = $(this).attr("id");
				strapColor = processStrapColorSelection($(this).val());
//				alert("Strap ID String: " + strapIDstring + ", Strap Text : " + strapColor[1] + "\nNew SRC: " + strapColorURL);
				if (strapIDstring == "ha1StrapMenu") {
//					alert('Does IMG id ' + strapID + ' exist: ' + $("img", elts.contentWrapper).index($("#strap-1-image")[0]));
//					alert('Old SRC: ' + $("#strap-1-image", elts.contentWrapper).attr("src"));
					$("#ha1StrapDisp").text(strapColor[1]);
					$("#ha1StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
					$(".h-lt-lg-h1", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-h1", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
					$(".h-rt-lg-h1", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "ha2StrapMenu") {
					$("#ha2StrapDisp").text(strapColor[1]);
					$("#ha2StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
					$(".h-lt-sh-h2", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-h2", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
					$(".h-rt-sh-h2", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "ha3StrapMenu") {
					$("#ha3StrapDisp").text(strapColor[1]);
					$("#ha3StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
					$(".h-lt-lg-h3", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-h3", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
					$(".h-rt-lg-h3", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "ha4StrapMenu") {
					$("#ha4StrapDisp").text(strapColor[1]);
					$("#ha4StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
					$(".h-lt-sh-h4", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-h4", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
					$(".h-rt-sh-h4", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "ha5StrapMenu") {
					$("#ha5StrapDisp").text(strapColor[1]);
					$("#ha5StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
					$(".h-lt-lg-h5", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-h5", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
					$(".h-rt-lg-h5", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "fa1StrapMenu") {
					$("#fa1StrapDisp").text(strapColor[1]);
					$("#fa1StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
					$(".h-lt-lg-f1", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-f1", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
					$(".h-rt-lg-f1", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "fa2StrapMenu") {
					$("#fa2StrapDisp").text(strapColor[1]);
					$("#fa2StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
					$(".h-lt-sh-f2", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-f2", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
					$(".h-rt-sh-f2", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "fa3StrapMenu") {
					$("#fa3StrapDisp").text(strapColor[1]);
					$("#fa3StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
					$(".h-lt-lg-f3", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-f3", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
					$(".h-rt-lg-f3", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "fa4StrapMenu") {
					$("#fa4StrapDisp").text(strapColor[1]);
					$("#fa4StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
					$(".h-lt-sh-f4", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-f4", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
					$(".h-rt-sh-f4", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "fa5StrapMenu") {
					$("#fa5StrapDisp").text(strapColor[1]);
					$("#fa5StrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
					$(".h-lt-lg-f5", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
					$(".h-crs-strap-f5", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
					$(".h-rt-lg-f5", elts.contentWrapper).attr("src", strapColorURL);
				} else if (strapIDstring == "mStrapMenu") {
					// This should be the main strap color, set unselected accent straps to this color also...
					$("#mStrapDisp").text(strapColor[1]);
					$("#mStrapData").val($(this).val());
					strapColorURL = 'products/65/selection/frames_cross_straps/h-strap' + strapColor[0] + '.jpg';
					$("#mStrapImage", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/v-tp-sh' + strapColor[0] + '.jpg';
					$(".v-tp-sh", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/v-tp-lg' + strapColor[0] + '.jpg';
					$(".v-tp-lg", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/v-bm-sh' + strapColor[0] + '.jpg';
					$(".v-bm-sh", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/v-bm-lg' + strapColor[0] + '.jpg';
					$(".v-bm-lg", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/v-end-sh' + strapColor[0] + '.jpg';
					$(".v-end-sh", elts.contentWrapper).attr("src", strapColorURL);
					strapColorURL = 'products/65/selection/frames_cross_straps/v-crs-strap' + strapColor[0] + '.jpg';
					$(".v-crs-strap", elts.contentWrapper).attr("src", strapColorURL);
					idArray = $(this).val().split("_");
					if( $("#ha1StrapMenu", elts.contentWrapper).val() == '679_0') {
						$("#ha1StrapDisp").text(strapColor[1]);
						$("#ha1StrapData").val('679_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
						$(".h-lt-lg-h1", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-h1", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
						$(".h-rt-lg-h1", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#ha2StrapMenu", elts.contentWrapper).val() == '680_0') {
						$("#ha2StrapDisp").text(strapColor[1]);
						$("#ha2StrapData").val('680_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
						$(".h-lt-sh-h2", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-h2", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
						$(".h-rt-sh-h2", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#ha3StrapMenu", elts.contentWrapper).val() == '681_0') {
						$("#ha3StrapDisp").text(strapColor[1]);
						$("#ha3StrapData").val('681_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
						$(".h-lt-lg-h3", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-h3", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
						$(".h-rt-lg-h3", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#ha4StrapMenu", elts.contentWrapper).val() == '682_0') {
						$("#ha4StrapDisp").text(strapColor[1]);
						$("#ha4StrapData").val('682_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
						$(".h-lt-sh-h4", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-h4", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
						$(".h-rt-sh-h4", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#ha5StrapMenu", elts.contentWrapper).val() == '683_0') {
						$("#ha5StrapDisp").text(strapColor[1]);
						$("#ha5StrapData").val('683_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
						$(".h-lt-lg-h5", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-h5", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
						$(".h-rt-lg-h5", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#fa1StrapMenu", elts.contentWrapper).val() == '2_0') {
						$("#fa1StrapDisp").text(strapColor[1]);
						$("#fa1StrapData").val('2_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
						$(".h-lt-lg-f1", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-f1", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
						$(".h-rt-lg-f1", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#fa2StrapMenu", elts.contentWrapper).val() == '3_0') {
						$("#fa2StrapDisp").text(strapColor[1]);
						$("#fa2StrapData").val('3_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
						$(".h-lt-sh-f2", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-f2", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
						$(".h-rt-sh-f2", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#fa3StrapMenu", elts.contentWrapper).val() == '4_0') {
						$("#fa3StrapDisp").text(strapColor[1]);
						$("#fa3StrapData").val('4_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
						$(".h-lt-lg-f3", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-f3", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
						$(".h-rt-lg-f3", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#fa4StrapMenu", elts.contentWrapper).val() == '5_0') {
						$("#fa4StrapDisp").text(strapColor[1]);
						$("#fa4StrapData").val('5_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-sh' + strapColor[0] + '.jpg';
						$(".h-lt-sh-f4", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-f4", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-sh' + strapColor[0] + '.jpg';
						$(".h-rt-sh-f4", elts.contentWrapper).attr("src", strapColorURL);
					}
					if( $("#fa5StrapMenu", elts.contentWrapper).val() == '678_0') {
						$("#fa5StrapDisp").text(strapColor[1]);
						$("#fa5StrapData").val('678_'+idArray[1]);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-lt-lg' + strapColor[0] + '.jpg';
						$(".h-lt-lg-f5", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-crs-strap' + strapColor[0] + '.jpg';
						$(".h-crs-strap-f5", elts.contentWrapper).attr("src", strapColorURL);
						strapColorURL = 'products/65/selection/frames_cross_straps/h-rt-lg' + strapColor[0] + '.jpg';
						$(".h-rt-lg-f5", elts.contentWrapper).attr("src", strapColorURL);
					}
				}
			}

			updateCodePriceWeight();

			return false;
		});
		
		$("#saveClose", elts.contentWrapper).click(function(e) {
//			alert("Save and Close, Frame Color Data: " + $("#frameColorData").val());
			e.preventDefault();

			quantity = parseInt($("#qty").val());
			if ( isNaN(quantity) || (quantity < 1) ) {
				// Invalid entry, send message, then reset to 1...
				$("#qty").val("1");
			}

			errorSelect = false;
			errorMessage = 'Before closing the selection window';
			if( $("#frameColorMenu", elts.contentWrapper).val() == '655_0') {
				errorSelect = true;
				errorMessage += "\n  - Please select a frame color";
			}
			if( $("#mStrapMenu", elts.contentWrapper).val() == '684_0') {
				errorSelect = true;
				errorMessage += "\n  - Please select a main strap color";
			}

			if (errorSelect) {
				alert(errorMessage);
			} else {
				$.nyroModalRemove();
			}
			return false;
		});
	};
}); // End document ready.

