VariantSwatchesProductVariations_variantGroup_950_4 = { SwatchArray: { 3325: { SwatchURL: '/images/calysi_bandeau_catalinablue.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3326: { SwatchURL: '/images/calysi_bandeau_cobra.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3327: { SwatchURL: '/Shared/images/Product/AT40000P-PTO.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3328: { SwatchURL: '/Shared/images/Product/AT40003X-ONX.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3329: { SwatchURL: '/images/calysi_bandeau_pomegranate.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3330: { SwatchURL: '/images/calysi_bandeau_hamptonblue.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3331: { SwatchURL: '/images/calysi_bandeau_onyx.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3332: { SwatchURL: '/images/calysi_bandeau_apollo.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3333: { SwatchURL: '/images/calysi_bandeau_martinque.jpg', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3465: { SwatchURL: '', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3466: { SwatchURL: '', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3467: { SwatchURL: '', ControlPath: 'ProductVariations_variantGroup_950_4' }, 3468: { SwatchURL: '', ControlPath: 'ProductVariations_variantGroup_950_4' } }, ImagingMode: "Resizer", ProductPhotoOverride: "", ProductThumbOverride: "", ZoomPhotoOverride: "", SetResizedImageLinks: function(img, zoom, swatchUrl, sZoomScript) { var zoomWidth = 1000; var zoomHeight = 1000; var newMainImageUrl = img.attr("src"); var newScaledUpImageUrl = ""; if(this.ImagingMode == "ExternalImaging") { var oldMainImageOptions = window.resizehelper.getExternalImageOptionsFromUrl(this.ProductPhotoOverride, img.attr("src")); newMainImageUrl = window.resizehelper.getExternalImageUrl(this.ProductPhotoOverride, swatchUrl, oldMainImageOptions.width, oldMainImageOptions.height); newScaledUpImageUrl = window.resizehelper.getExternalImageUrl(this.ZoomPhotoOverride, swatchUrl, zoomWidth, zoomHeight); } else { var baseResizerPath = window.resizehelper.getBaseResizerPath(swatchUrl); var oldParams = ""; if(baseResizerPath.indexOf('?') > -1) { oldParams = baseResizerPath.substring(baseResizerPath.indexOf('?') + 1); var poStartIndex = oldParams.indexOf("po="); if(poStartIndex < 0) poStartIndex = oldParams.indexOf("path="); if(poStartIndex > -1) { var ampAfterIndex = oldParams.substring(poStartIndex).indexOf("&"); if(ampAfterIndex > -1) oldParams = oldParams.substring(poStartIndex + ampAfterIndex + 1); } } newMainImageUrl = img.attr("src").replace(/\/resize\/.+(\?.*)/, baseResizerPath + oldParams); newScaledUpImageUrl = baseResizerPath + "lr=t&bw=" + zoomWidth + "&w=" + zoomWidth + "&bh=" + zoomHeight + "&h=" + zoomHeight } img.attr("src", newMainImageUrl); img.siblings("img").attr("src", newScaledUpImageUrl); zoom.attr("href", newScaledUpImageUrl) .attr("onclick", sZoomScript); }, SelectVariant: function (groupID, variantID, setDropDown) { var mainPhotoPresent = false; //if (typeof msPhotoImgCtl != 'undefined') // mainPhotoPresent = true; var $img = $("#PhotoThumbnails_imgPhoto"); if ($img.length > 0) mainPhotoPresent = true; var sZoomScript = ( $("#PhotoThumbnails_dlPicture").length ) ? "return hs.expand(this, config1);" : "return hs.expand(this);" $(".varpicmax_img[id^='varswatch_" + groupID + "_" + "']").removeClass("ProductDetailsSelectedVariant"); var o = VariantSwatchesProductVariations_variantGroup_950_4.SwatchArray[variantID]; if (o) { if (setDropDown) $("[id$='" + o.ControlPath + "']").val(variantID).change(); if (mainPhotoPresent) $zoomlink = $img.parent(); if (o.SwatchURL != "" && mainPhotoPresent) { if(this.ImagingMode == "ExternalImaging") { this.SetResizedImageLinks($img, $zoomlink, o.SwatchURL, sZoomScript); } else { if ( $img.attr("src").indexOf("path=") != -1){ if ($img.attr("src").indexOf("&") != -1){ $img.attr("src", $img.attr("src").replace(new RegExp("path=.+?&"), "path=" + o.SwatchURL + "&")).attr("alt","").attr("title", ""); $img.siblings("img").attr("src", o.SwatchURL); $zoomlink .attr("href", $zoomlink.attr("href").replace(new RegExp("path=.+?&"), "path=" + o.SwatchURL + "&")) .attr("onclick", sZoomScript); }else{ $img.attr("src", $img.attr("src").replace(new RegExp("path=.+"), "path=" + o.SwatchURL)).attr("alt","").attr("title", ""); $zoomlink .attr("href", $zoomlink.attr("href").replace(new RegExp("path=.+"), "path=" + o.SwatchURL)) .attr("onclick", sZoomScript); } } else if ( $img.attr("src").indexOf("/resize/") != -1){ this.SetResizedImageLinks($img, $zoomlink, o.SwatchURL, sZoomScript); } else{ $img.attr("src", o.SwatchURL ).attr("alt", "").attr("title", ""); $img.siblings("img").attr("src", o.SwatchURL); $zoomlink.attr("href", o.SwatchURL).attr("onclick", sZoomScript); } } } else if (setDropDown) { var groupVars = []; var hasSwatch = false; $("[id$='" + o.ControlPath + "']").val(variantID).change(); } if (mainPhotoPresent) { if (o.SwatchURL != ""){ if(this.ImagingMode == "ExternalImaging") { this.SetResizedImageLinks($img, $zoomlink, o.SwatchURL, sZoomScript); } else { if ( $img.attr("src").indexOf("path=") != -1){ $zoomlink = $img.parent(); if ($img.attr("src").indexOf("&") != -1){ $img.attr("src", $img.attr("src").replace(new RegExp("path=.+?&"), "path=" + o.SwatchURL + "&")).attr("alt","").attr("title", ""); $img.siblings("img").attr("src", o.SwatchURL); $zoomlink .attr("href", $zoomlink.attr("href").replace(new RegExp("path=.+?&"), "path=" + o.SwatchURL + "&")) .attr("onclick", sZoomScript); }else{ $img.attr("src", $img.attr("src").replace(new RegExp("path=.+"), "path=" + o.SwatchURL)).attr("alt","").attr("title", ""); $img.siblings("img").attr("src", o.SwatchURL); $zoomlink .attr("href", $zoomlink.attr("href").replace(new RegExp("path=.+"), "path=" + o.SwatchURL)) .attr("onclick", sZoomScript); } } else if ( $img.attr("src").indexOf("/resize/") != -1){ this.SetResizedImageLinks($img, $zoomlink, o.SwatchURL, sZoomScript); } else{ $img.attr("src", o.SwatchURL ).attr("alt", "").attr("title", ""); $img.siblings("img").attr("src", o.SwatchURL); $zoomlink.attr("href", o.SwatchURL).attr("onclick", sZoomScript); } } } else { var groupVars = []; var hasSwatch = false; $("#" + o.ControlPath).children().each(function () { var v = VariantSwatches.SwatchArray[$(this).val()]; if (v && v.SwatchURL !== "") { hasSwatch = true; } }); if(typeof ResetImage == 'function' && hasSwatch) ResetImage(); } } else if(typeof ResetImage == 'function' ) ResetImage(); } $(".varpicmax_img[id^='varswatch_" + groupID + "_" + variantID + "_" + "']").addClass("ProductDetailsSelectedVariant"); } } $(function(){ $("select[id$='ProductVariations_variantGroup_950_4']").change(function() { VariantSwatchesProductVariations_variantGroup_950_4.SelectVariant( $(this).parent().find("input[type=hidden]").val() , $(this).val(), false) }); })