/*--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( strImgId, strSwatchDivId, strStyleNum, strColorNum, bIsWS, swatchRef ) { _clrid = _prefix + strStyleNum + "_" + strColorNum; _imgid = strImgId; _textid = _prefix + "text_" + strStyleNum + "_" + bIsWS; _swatches = _prefix + strSwatchDivId; mainswap( strStyleNum, strColorNum, bIsWS ); hrefswap( strStyleNum, strColorNum, bIsWS, swatchRef.getAttribute('href') ); try { if($('comparecheck_' + strStyleNum)){ $('comparecheck_' + strStyleNum).value = strStyleNum + '-' + bIsWS + '-' + strColorNum; } } catch( e ) { HandleError( "Checkbox Exists:", e, M_strPageName ); } } /* 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 ) { var imgid = "img_" + strStyleNum + "_" + bIsWS; var divid = "swatches_" + strStyleNum + "_" + bIsWS; this.swapColor( imgid, divid, 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 on category pages if($(_textid)){ var aText = $A($(_textid).getElementsByTagName("a")); aText.each( function(node) { node.setAttribute("href", sRef); }); } if($('comparebox')) { compareColorSwap(strStyleNum, strColorNum, bIsWS, sRef); } } }