/*--New product page functions*/ function ProdColorChanger( intMainImgHt, intMainImgWid, styleOn, styleOff ) { var _srcpre = "/tsimages/"; var _srcpst = ".fpx?"; var _styleon = styleOn; var _styleoff = styleOff; var _imgid = ""; var _textid = ""; var _clrid = ""; var _prodhref = ""; var _swatches = ""; var _prefix = ""; this.swapColor = function( strStyleNum, strColorNum, bIsWS, swatchRef ) { _clrid = _prefix + strStyleNum + "_" + strColorNum; _imgid = _prefix + "img_" + strStyleNum + "_" + bIsWS; _textid = _prefix + "text_" + strStyleNum + "_" + bIsWS; _swatches = _prefix + "swatches_" + strStyleNum + "_" + bIsWS; mainswap( strStyleNum, strColorNum, bIsWS ); hrefswap( strStyleNum, strColorNum, bIsWS, swatchRef.getAttribute('href') ); } /* used on collection_sort.jsp */ this.swapColorCS = function( strStyleNum, strColorNum, bIsWS, swatchRef ) { _prefix = "cs_"; this.swapColor(strStyleNum, strColorNum, bIsWS, swatchRef); } this.altprodswap = function( strStyleNum, strColorNum, bIsWS, ref ) { this.swapColor( strStyleNum, strColorNum, bIsWS, ref ); } this.statswap = function( strStyleNum, strColorNum, bIsWS ) { _swatches = "main_swatches"; _clrid = strStyleNum + "_" + strColorNum; _imgid = "img_" + strStyleNum + "_" + bIsWS; mainswap( strStyleNum, strColorNum, bIsWS ); } function mainswap( strStyleNum, strColorNum, bIsWS ) { var arrQS = $(_imgid).src.split("?"); var imgsrc = _srcpre + strStyleNum + "_" + strColorNum + _srcpst + arrQS[1]; var prdimg = $(_imgid); // Mod img src prdimg.setAttribute("src", imgsrc); // Move selection around var aImgs = $A($(_swatches).getElementsByTagName("img")); aImgs.each( function(node) { node.id == _clrid ? node.className = _styleon : node.className = _styleoff; }); } function hrefswap( strStyleNum, strColorNum, bIsWS, sRef ) { var prdimg = $(_imgid); var prdhref = prdimg.parentNode.setAttribute("href", sRef); // Mod href var aText = $A($(_textid).getElementsByTagName("a")); aText.each( function(node) { node.setAttribute("href", sRef); }); } }