/*** COPYRIGHT 2009  BY CUTSEY BUSINESS SYSTEMS LTD. - ALL RIGHTS RESERVED ***/
/* product.js -- Product Page Javascript                                     */
/*****************************************************************************/
/* T020005 04/06/11 JJD- IE backspace fix for browse filters.                */
/* T020004 08/24/10 JB - Reset preSell value to be logical for comparison.   */
/* T020003 08/23/10 JB - Fix sponsor reference from test.                    */
/* T020002 08/23/10 JB - Ensured presell confirm is newly created every call.*/
/* T020001 08/18/10 JB - Presell functionality.                              */
/* T020000 06/22/10 RB - Show images by size group.                          */
/*****************************************************************************/
/* 040008 04/20/10 APY- Add check for blank colorCode.                       */
/* 040007 03/10/10 APY- Remove hardcoded scroll to top in addToCart.         */
/* 040006 03/08/10 JD2- Last version closed without code changes.            */
/* 040005 03/04/10 JD2- Show/hide multiple divs for showVideo()/hideVideo(). */
/* 040004 03/03/10 JD2- OOS message was not hiding for in stock items.       */
/*                    - OOS message fix for multi size mode. Display the     */
/*                      stock message when qty is not passed to showOOSMsg() */
/* 040003 03/02/10 APY- OOS correction when selecting default style image.   */
/* 040002 03/01/10 JZ - Site option for defaulting selection of first color. */
/* 040001 02/22/10 JD2- Don't redisplay comparables here.                    */
/*                    - Updated goStyle to just call golink for short urls.  */
/* 040000 02/10/10 JD2- Merged changes from TEA. T010010,T010009,T010008,    */
/*                      T010007.                                             */
/*                    - T010006: Added validation for ttSize fullDesc/desc.  */
/*****************************************************************************/
/*T010010 10/06/09 APY- Update avail-sizes display when selecting color.     */
/*T010009 07/30/09 JD2- PERM - Unforce disclaimer display for all sales.     */
/*                      Fixed in super-get-price.                            */
/*T010008 07/01/09 APY- TEMP - Force disclaimer display for all sales untill */
/*                      disclaimer is fixed in super-get-price.              */
/*T010007 04/06/09 JZ - Tooltip for selecting size and scroll to top when    */
/*                      something is added to the bag.                       */
/*T010006 03/11/09 APY- Styling changes.                                     */
/*****************************************************************************/
/* 030205 02/02/10 APY- Add logic to set color from cookie or hash.          */
/* 030204 01/28/10 APY- Fix for when vMaxUnits is 0 / not set.               */
/* 030203 01/22/10 JD2- Updated flashembed for transparency.                 */
/* 030202 01/22/10 JD2- Update hideVideo to stop the video when playing.     */
/* 030201 01/10/10 JD2- Added showVideo and hideVideo functions.             */
/* 030200 01/17/10 JD2- Added product review functions.                      */
/* 030101 01/07/10 APY- Add max qty limit checks.                            */
/* 030100 12/21/09 JB - Changes to stock checking (E020000).                 */
/* 030000 12/17/09 JD2- Template changes. Build comparables on the server.   */
/*****************************************************************************/
/* 020000 11/16/09 APY- MagicZoom upgrade, add start/stop and alt image zoom.*/
/*****************************************************************************/
/* 010103 09/22/09 SB - Delete a stray line from last check-in.              */
/* 010102 09/22/09 SB - Allow setColor back to style (no-color) default.     */
/* 010101 05/15/09 JD2- Use ttItem.order-limit.                              */
/* 010100 05/01/09 JZ - Static catalog mods.                                 */
/* 010010 04/07/09 JB - Use new enviro vars, new swatch error type.          */
/*        04/14/09 APY- Fix pricing display on comparables.                  */
/* 010009 04/03/09 JB - Change "hide" to "swatch" for image replacement.     */
/* 010008 04/02/09 JB - Added conditions for product mode.                   */
/* 010007 03/30/09 JD2- Added default price.                                 */
/* 010006 03/17/09 APY- If only a single size select by default.             */
/* 010005 03/17/09 APY- Reduce avail qty when successfully adding to cart.   */
/* 010004 02/26/09 SB - Add color name under swatch display grid.            */
/* 010003 02/09/08 APY- Updated default multi dim size when on 1 detail rec. */
/* 010002 12/30/08 APY- Corrected swatchHex, add altView update Comparables  */
/* 010001 12/16/08 APY- Add Multi-view, nocache, use hostURL and appURL      */
/*                    - Add alternate comparables display location           */
/* 010000 12/03/08 APY- Created.                                             */
/*****************************************************************************/
/****** Globals JS Vars Defined in product.w ******
var allStylesObj = new Object();
var styleObj     = new Object();
var vLockedImg = "";
var vDefaultWhse  = "";
var vComparableDir = "";
var vSelectedProd = "";
var vSelectedSize  = "";
var vSelectedColor = "";
var vSelectedSizeDesc  = "";
var vSelectedColorDesc = "";
var vSelectedPrice = "";
var vSelectedMultiSize = new Array();
var vRegPriceLabel  = "";
var vRegOnSaleLabel = "";
var vIsRetail = true/false;
var vDispColorDesc = true/false;
var vBrowseParam = ""
var vSponsorCode = ""
var vProdType = "s" or "i"
var vOrderLimit = 0
var vOrderLimitMsg = ""
var vTotalOrderQty = 0
var vPreSellCopy = "" - marketing copy for preSell items             T020001
var vSelectFirstColor = get-option(v-select-first-color) - yes/no        040002
** - hostDomain and appPath js vars used from header **              010010
******************************************/
var vStyleList = new Array();
var zoomObj;
var vImgHtml = "";                                                 /* 030200 */
var vVideoEmbed = "";                                              /* 030202 */
var vToday = new Date();                                           /* T020001 */

//========--------   Load / Display   --------========\\
function loadStyle(vStyle,vSponsor){
 var vFoundStyle = false;
 zoomObj = document.getElementById('zoom1');
 $.each(vStyleList,function(j){
   if(vStyleList[j] != null && vStyleList[j].styleCode == vStyle &&
      vStyleList[j].styleColor && vStyleList[j].styleColor[0] != null &&
      vStyleList[j].styleSize  && vStyleList[j].styleSize[0] != null)
   { styleObj = vStyleList[j]; vFoundStyle = true; }
 });
 if(vFoundStyle){
  displayStyle();

  if (vSelectFirstColor)                                           /* 040002 */
   setColor(vSelectedColor,"","");                                 /* 040002 */
 }
 else{
  var vCurrTime = new Date();
  var vCurrSecs  = (((vCurrTime.getHours() * 60) + vCurrTime.getMinutes()) * 60) + vCurrTime.getSeconds();
  var vNoCache = "&nocache=" + vCurrSecs;
  $.ajax({
    type: "GET",
    url: hostDomain + appPath + "/olc/get-style.w?style=" + vStyle + "&division=" + escape(vDivision) + /* T020000 */
         "&frames=no&target=main&sponsor=" + vSponsor + vNoCache,  /* 010010 */
    dataType: "xml",
    complete: function(data) {
       allStylesObj = $.xmlToJSON(data.responseXML); // Save XML in JSON
       //Return a single style Object
       $.each(allStylesObj.ttStyle,function(i){
          var vAddMe = true;
          $.each(vStyleList,function(j){
            if(vStyleList[j] != null && vStyleList[j].styleCode == allStylesObj.ttStyle[i].styleCode)
            { vAddMe = false; return; }
          });
          if (vAddMe)
          { vStyleList[vStyleList.length] = allStylesObj.ttStyle[i];}
          if (allStylesObj.ttStyle[i].styleCode == vStyle) {
            styleObj = allStylesObj.ttStyle[i];
            if (vSelectedProd != vStyle) {
              vSelectedProd = vStyle;
              vSelectedColor = "";
              vSelectedSize = "";
              vSelectedSizeGroup = ""; /* T020000 */
              vLockedImg = "";
              vSelectedSizeDesc = "";
              vSelectedColorDesc = "";
              vSelectedPrice = "";
              vSelectedMultiSize = new Array();
            }
          }
       });
       /***vv 030205 vv***/
       var hashCheck = getHash();
       var vHasHashColor = false;
       $(hashCheck).each(function(){
         if(this.name=="color" && this.value){
            vSelectedColor = this.value;
            vHasHashColor = true;
         }
       });
       if (!vHasHashColor){
        var vCookieColor = getCookie("prodColor");
        vCookieColor = vCookieColor.split(",");
        if (vCookieColor.length==2 && vCookieColor[0].toLowerCase() == vSelectedProd)
          vSelectedColor = vCookieColor[1];
       }
       /***^^ 030205 ^^***/
       /********************v T020004 v********************/
       styleObj.preSell = (styleObj.preSell == "true") ? true : false;
       for (i=0;i<styleObj.ttColor.length;i++){
         styleObj.ttColor[i].preSell = (styleObj.ttColor[i].preSell == "true") ? true : false;
       }
       for (i=0;i<styleObj.ttItem.length;i++){
         styleObj.ttItem[i].preSell = (styleObj.ttItem[i].preSell == "true") ? true : false;
       }
       /********************^ T020004 ^********************/
       displayStyle();

       if (vSelectFirstColor)                                      /* 040002 */
        setColor(vSelectedColor,"","");                            /* 040002 */
    }
  });
 }

}
function displayStyle(){
  var vZoomInit;
  var bFoundSizeImg = false; /* T020000 */
  if (vSelectedColor != ""){
    /**************v T020000 v**************/
      var sizeGroups = styleObj.sizeGroups.toString().split(",");

      for(var i=0; i<styleObj.ttColor.length; i++)
      {
          if (styleObj.ttColor[i].colorCode.toString().toLowerCase() == vSelectedColor.toString().toLowerCase())
          {
              for(var k=0; k < sizeGroups.length; k++)
              {
                 for(var j=0; j<styleObj.ttColor[i].ttImage.length; j++)
                 {
                    if ((!bFoundSizeImg) && (styleObj.ttColor[i].ttImage[j].imageLg != "") &&
                        (sizeGroups[k].toString().toLowerCase() == styleObj.ttColor[i].ttImage[j].sizeGroup.toString().toLowerCase()))
                    {
                        bFoundSizeImg = true;
                        $(".imageCell").attr("src",styleObj.ttColor[i].ttImage[j].imageLg);
                        vLockedImg = styleObj.ttColor[i].ttImage[j].imageLg;
                        if(styleObj.ttColor[i].ttImage[j].imageZm != "")
                          vZoomInit = styleObj.ttColor[i].ttImage[j].imageZm;
                    }
                 }
              }
          }
      }
    /**************^ T020000 ^**************/

    if (!bFoundSizeImg) /* T020000 */
    $.each(styleObj.ttColor,function(i){
      if (styleObj.ttColor[i].colorCode == vSelectedColor && styleObj.ttColor[i].imageLg != "" ) {
        $(".imageCell").attr("src",styleObj.ttColor[i].imageLg);
        vLockedImg = styleObj.ttColor[i].imageLg;
        if(styleObj.ttColor[i].imageZm != "")
          vZoomInit = styleObj.ttColor[i].imageZm;
      }
    });
  }
  if (vLockedImg == "" || vLockedImg == null){
    if (styleObj.ttColor!=null&&styleObj.ttColor[0].imageLg != "" && styleObj.ttColor[0].imageLg != null){  /* 010008 */
      $(".imageCell").attr("src",styleObj.ttColor[0].imageLg);
      vLockedImg = styleObj.ttColor[0].imageLg;
      if (styleObj.ttColor[0].imageZm != "" && styleObj.ttColor[0].imageZm != null)
        vZoomInit = styleObj.ttColor[0].imageZm;
    }
    else{
      $(".imageCell").attr("src",styleObj.imageLg);
      vLockedImg = styleObj.imageLg;
      if (styleObj.imageZm != "" && styleObj.imageZm != null)
        vZoomInit = styleObj.imageZm;
    }
  }                                                               /* T010006 */

  if (styleObj.imageMill != "" && styleObj.imageMill != null)
    $(".prodMillImg").html("<img src=\"" + styleObj.imageMill + "\" alt=\"\">");

  displayColors();
  if(styleObj.ttSizeScale && styleObj.ttSizeScale[1] != null){
    styleObj.ttSizeScale.sort(function(a,b){ return a.sortIndex - b.sortIndex }); //Ensure array is Sorted by sortIndex
    $.each(styleObj.ttSizeScale,function(i){
       if(styleObj.ttSizeScale[i].ttSizeScaleValue.length == 1)  /* 010003 */
         vSelectedMultiSize[i] = styleObj.ttSizeScale[i].ttSizeScaleValue[0].dimValue;
       else
         vSelectedMultiSize[i] = "";
    });
    displayMultiSizes();
  }
  else if(styleObj.ttSize!=null)  /* 010008 */
    displaySizes();
  displayFeatIcons();
  if(styleObj.ttAltView)
    showAltViews('');

  /* 030000 - removed call to displayComprables() */
  /* 040001 - removed second call to displayComprables() */

  if(vZoomInit != "" && vZoomInit != null)
     $(".MagicZoomBigImageCont > div > img").attr("src",vZoomInit);

  if($(".prodDisplay").css("display")=="none"){
    $(".prodDisplay").fadeIn(250);
  }
  if (vShowImgLib)
     showImgLib(vSelectedProd,vSelectedColor);

  if (typeof vDefaultPrice == "boolean") /* 010007 */
  {
	  if (vDefaultPrice)
	     priceItem("","",styleObj.ttItem[0].itemNumber);
  }

  /******v 010101 v******/

  if ( styleObj.ttItem.length == 1 && vSelectedProd == styleObj.ttItem[0].itemNumber  ) {

     if (isNaN(styleObj.ttItem[0].orderLimit) == false)
        vOrderLimit = parseFloat(styleObj.ttItem[0].orderLimit);

     if (isNaN(styleObj.ttItem[0].orderQty) == false)
        vTotalOrderQty = parseFloat(styleObj.ttItem[0].orderQty);

     if (vOrderLimit == 1) {
        $("#qty").val("1");
        $(".prodQty").hide();
        $(".prodOrder").show();
     }
     else if (vOrderLimit == -1)
        $(".prodOrder").hide();
     else
        $(".prodOrder").show();
  }
  else
     $(".prodOrder").show();
  /******^ 010101 ^******/
}

/***************v T020000 v***************/
function setImg(vColorCode)
{
    var vSwitchImgLg;
    var vSwitchImgZm; 
    var bFoundSizeImg = false;
    var sizeGroups;

   if(styleObj.ttColor!=null)
    for(var i=0; i<styleObj.ttColor.length; i++)
    {
        if (styleObj.ttColor[i].colorCode.toString().toLowerCase() == vColorCode.toString().toLowerCase())
        {
            bFoundSizeImg = false;
    
            if (vSelectedSizeGroup != "")
            {
                sizeGroups = new Array();
                sizeGroups[0] = vSelectedSizeGroup;
            }
            else
            {
                sizeGroups = styleObj.sizeGroups.toString().split(",");
            }
            
    
            for(var k=0; k < sizeGroups.length; k++)
            {
               for(var j=0; j<styleObj.ttColor[i].ttImage.length; j++)
               {
                  if ((!bFoundSizeImg) && (styleObj.ttColor[i].ttImage[j].imageLg != "") &&
                      (sizeGroups[k].toString().toLowerCase() == styleObj.ttColor[i].ttImage[j].sizeGroup.toString().toLowerCase()))
                  {
                      vSwitchImgLg = styleObj.ttColor[i].ttImage[j].imageLg;
                      vSwitchImgZm = styleObj.ttColor[i].ttImage[j].imageZm;
                      bFoundSizeImg = true;
                  }
               }
            }
    
            if (!bFoundSizeImg)
            {
                if (styleObj.ttColor[i].imageLg != ""){
                   vSwitchImgLg = styleObj.ttColor[i].imageLg;
                   vSwitchImgZm = styleObj.ttColor[i].imageZm;
                }
                else{
                  vSwitchImgLg = styleObj.imageLg;
                  vSwitchImgZm = styleObj.imageZm;
                }
            }

            var myid = styleObj.styleCode + vColorCode;
            $("#" + myid).attr("href", vSwitchImgZm);
            $("#" + myid).attr("rev", vSwitchImgLg);
            swapImg(vSwitchImgLg);
        }
    }

}
/***************^ T020000 ^***************/

function displayColors(){
    
       var vColorHTML = "";
       var vColorDesc ="";
       var vClass;
       var vStockQty=-1;                                           /* E020000 */
       var vSwitchImgLg;   /* 020000 */
       var vSwitchImgZm; /* 020000 */

       var vHexPercent2 = "75,25";
       var vHexPercent3 = "50,25,25";
       var vHexPercent4 = "25,25,25,25";
       var bFoundSizeImg = false; /* T020000 */

       if(styleObj.ttColor!=null)  /* 010008 */
       for(var i=0; i<styleObj.ttColor.length; i++){
         if(vSelectedSize == "" || checkItem(styleObj.ttColor[i].colorCode,vSelectedSize) ) {

           if(vSelectedColor=='' && i==0 && document.getElementById("color" + vSelectedProd))
                document.getElementById("color" + vSelectedProd).value = ''; /* 010102 */

           if(vSelectedColor==styleObj.ttColor[i].colorCode) {
             vSelectedColorDesc = styleObj.ttColor[i].description;

             if (styleObj.ttColor[i].fabDesc != "" && styleObj.ttColor[i].fabDesc != null)
             { vSelectedColorDesc += " " + styleObj.ttColor[i].fabDesc; }

             $(".selectedColor").html(vSelectedColorDesc);
             /********************v E020000 v********************/
             /***vv T020001 vv***/
             vStreetDate = parseDate(styleObj.ttColor[i].streetDate);
             vStockQty=checkStock(styleObj.ttColor[i].colorCode,vSelectedSize,vDefaultWhse)
             if(vSelectedSize == "" || vStockQty > 0 || vStockQty==-1)
              vClass = "colorOuterSelected";
             else
              vClass = "colorOuterOOSSelected";
             if(styleObj.ttColor[i].preSell && vStreetDate > vToday ){
               if(vSelectedSize == "" || vStockQty > 0 || vStockQty==-1)
                vClass = "colorOuterPreSellSelected";
               else
                vClass = "colorOuterPreSellOOSSelected";  
             }
             else if(styleObj.ttColor[i].preSell)
               vClass = "colorOuterSelected";             
             /***^^ T020001 ^^***/
           } else {
             /***vv T020001 vv***/
             vStreetDate = parseDate(styleObj.ttColor[i].streetDate);
             if(vSelectedSize == "" || vStockQty > 0 || vStockQty==-1){
               if(styleObj.ttColor[i].preSell && vStreetDate>vToday)
                 vClass = "colorOuterPreSell"; 
               else
                 vClass = "colorOuter";
             }
             else{
               if(styleObj.ttColor[i].preSell && vStreetDate > vToday )
                 vClass = "colorOuterPreSellOOS"; 
               else
                 vClass = "colorOuterOOS";
             }
             /***^^ T020001 ^^***/
               /********************^ E020000 ^********************/
           }
           vColorDesc = styleObj.ttColor[i].description;
           if (styleObj.ttColor[i].fabDesc != "" && styleObj.ttColor[i].fabDesc != null)
             { vColorDesc += " " + styleObj.ttColor[i].fabDesc; }

           /*********v T020000 v*********/
           bFoundSizeImg = false;

           var sizeGroups = styleObj.sizeGroups.toString().split(",");

           for(var k=0; k < sizeGroups.length; k++)
           {
              if (!bFoundSizeImg)
              for(var j=0; j<styleObj.ttColor[i].ttImage.length; j++)
              {
                 if ((styleObj.ttColor[i].ttImage[j].imageLg != "") &&
                     (sizeGroups[k].toString().toLowerCase() == styleObj.ttColor[i].ttImage[j].sizeGroup.toString().toLowerCase()))
                 {
                     vSwitchImgLg = styleObj.ttColor[i].ttImage[j].imageLg;
                     vSwitchImgZm = styleObj.ttColor[i].ttImage[j].imageZm;
                     bFoundSizeImg = true;
                 }
              }
           }
           /*********^ T020000 ^*********/
           
           /***v 020000 v***/
           if (!bFoundSizeImg) /* T020000 */
           {
               if (styleObj.ttColor[i].imageLg != ""){
                  vSwitchImgLg = styleObj.ttColor[i].imageLg;
                  vSwitchImgZm = styleObj.ttColor[i].imageZm;
               }
               else{
                 vSwitchImgLg = styleObj.imageLg;
                 vSwitchImgZm = styleObj.imageZm;
               }
           }
           /***^ 020000 ^***/

           /***************v T020000 v***************/
           vColorHTML += '<a id="' + styleObj.styleCode + styleObj.ttColor[i].colorCode + '" href="" rel="zoom-id:zoom1;" rev="" ' +
                         'onmouseover="setImg(\'' + styleObj.ttColor[i].colorCode + '\');' +
                         '$(\'.selectedColor\').html(\'' + vColorDesc + '\'); ';
           /***************^ T020000 ^***************/

           if(vClass == "colorOuterOOS" || vClass == "colorOuterOOSSelected")
           /********************v E020000 v********************/
           {
             var vStockQty=checkStock(styleObj.ttColor[i].colorCode,vSelectedSize,vDefaultWhse);
             vColorHTML += 'showOOSMsg(\'' + styleObj.ttColor[i].description + '\',vSelectedSizeDesc,'+vStockQty+');';
           }
           /********************^ E020000 ^********************/

           vColorHTML += ' " onmouseout="restoreImg();$(\'.selectedColor\').html(vSelectedColorDesc); ';

           if(vClass == "colorOuterOOS" || vClass == "colorOuterOOSSelected")
             vColorHTML += 'hideOOSMsg();';

           vColorHTML += ' " onclick="setColor(\'' + styleObj.ttColor[i].colorCode + '\',\'\'); return false;">';

           if (vDispColorDesc) {                                   /* 010004 */
             vColorHTML += '<div class="swatchbox">';
             vColorHTML += '<div class="swatchcenter">';
           }

           vColorHTML += '<div class="' + vClass + '" colorcode="' + styleObj.ttColor[i].colorCode + '">';

           if (styleObj.ttColor[i].imageSw == "" || styleObj.ttColor[i].imageSw == null ){
             if (styleObj.ttColor[i].hexColor != "" && styleObj.ttColor[i].hexColor != null && styleObj.ttColor[i].hexColor.indexOf(",") != -1){ //Check for multiple hex values
               vHexArray = styleObj.ttColor[i].hexColor.split(",");
               switch(vHexArray.length){
                 case 2:
                   vHexPerArray = vHexPercent2.split(",");
                   break;
                 case 3:
                   vHexPerArray = vHexPercent3.split(",");
                   break;
                 case 4:
                   vHexPerArray = vHexPercent4.split(",");
                   break;
                 default:
                   vHexPerArray = vHexPercent2.split(",");
               }
               vColorHTML += '<div class="colorInner">';
               for(var j=0; j<vHexArray.length; j++){
                  vColorHTML += '<div style="margin:0px;padding:0px;float:left;height:100%;width:' + vHexPerArray[j] + '%;background-color:#' + vHexArray[j] + ';"></div>';
               }
               vColorHTML += '</div>';
             }
             else
               vColorHTML += '<div class="colorInner" style="background-color:#' + styleObj.ttColor[i].hexColor + ';"></div>';
           }
           else
             vColorHTML += '<img src="' + styleObj.ttColor[i].imageSw + '" onerror="top.ImageError(this,\'swatch\')" alt="" class="colorImg"/>';  /* 010009 */

           if (vDispColorDesc) {                                   /* 010004 */
             vColorHTML += '</div>'; // colorOuter
             vColorHTML += '</div>'; // swatchcenter
             vColorHTML += '<span class="swatchboxtxt">' + styleObj.ttColor[i].description + '</span>';
           }

           vColorHTML += '</div></a>'; // swatchbox || colorOuter
         }
       }
       $(".prodColors").html(vColorHTML);
}
function displaySizes(){
   /*******v T020000 v*******/
   var vSwitchImgLg;
   var vSwitchImgZm;
   var bFoundSizeImg = false;
   var bFoundColorImg = false;
   /*******^ T020000 ^*******/

   var vSizeHTML = "";
   var vClass;
   var vStockQty=-1;                                               /* 030100 */
   var vSizeDesc="";                                               /* 040000 */

   if (styleObj.ttSize.length==1){
     vSelectedSize = styleObj.ttSize[0].sizeCode;
     vSelectedSizeDesc = styleObj.ttSize[0].description;
     vSelectedSizeGroup = styleObj.ttSize[0].sizeGroup; /* T020000 */
     $(".selectedSize").html(vSelectedSizeDesc);
   }
   // $(".sizeHeading").html("Size:"); /* 010007 */                /* 030100 */
   $.each(styleObj.ttSize,function(i){
     if( checkItem(vSelectedColor,styleObj.ttSize[i].sizeCode) )
     {
      /***vv T020001 vv***/
      var vTmpItem = $(styleObj.ttItem).filter(function(){ 
         if(this.colorCode==vSelectedColor&&this.sizeCode==styleObj.ttSize[i].sizeCode)
           return true;
      });
      /***^^ T020001 ^^***/
      vStockQty=checkStock(vSelectedColor,styleObj.ttSize[i].sizeCode,vDefaultWhse);  /* E020000 */
      if(vSelectedSize==styleObj.ttSize[i].sizeCode){
         if(vStockQty==-1 || vStockQty > 0)                        /* E020000 */
          vClass = "sizeOuterSelected";
         else
          vClass = "sizeOuterOOSSelected";
         /***vv T020001 vv***/
         if(vTmpItem.length==1){
           vStreetDate = parseDate(vTmpItem[0].streetDate);
           if(vTmpItem[0].preSell && vStreetDate > vToday ){
             if(vStockQty==-1 || vStockQty > 0)   
              vClass = "sizeOuterPreSellSelected";
             else
              vClass = "sizeOuterPreSellOOSSelected";
           }
         }
         /***^^ T020001 ^^***/
       }
       else{
       if(vStockQty==-1 || vStockQty > 0 || vSelectedColor == "") /* E020000 */ /* 040003 */
        vClass = "sizeOuter";
       else
        vClass = "sizeOuterOOS";
         /***vv T020001 vv***/
         if(vTmpItem.length==1){
           vStreetDate = parseDate(vTmpItem[0].streetDate);
           if(vTmpItem[0].preSell && vStreetDate > vToday ){
             if(vStockQty==-1 || vStockQty > 0)   
              vClass = "sizeOuterPreSell";
             else
              vClass = "sizeOuterPreSellOOS";
           }
         }
         /***^^ T020001 ^^***/
       }
       if (styleObj.ttSize[i].fullDesc != "") vSizeDesc = styleObj.ttSize[i].fullDesc; /* 040000 */
       else vSizeDesc = styleObj.ttSize[i].description; /* 040000 */

       /*****************v T020000 v*****************/
       
       bFoundSizeImg = false;

       for(var n=0; n<styleObj.ttColor.length; n++)
       {
           if (styleObj.ttColor[n].colorCode == vSelectedColor)
           {
              if (!bFoundSizeImg)
              for(var j=0; j<styleObj.ttColor[n].ttImage.length; j++)
              {
                 if ((styleObj.ttColor[n].ttImage[j].imageLg != "") &&
                     (styleObj.ttSize[i].sizeGroup.toString().toLowerCase() == styleObj.ttColor[n].ttImage[j].sizeGroup.toString().toLowerCase())) 
                 {
                     vSwitchImgLg = styleObj.ttColor[n].ttImage[j].imageLg;
                     vSwitchImgZm = styleObj.ttColor[n].ttImage[j].imageZm;
                     bFoundSizeImg = true;
                 }
              }
           }
       }

       if (!bFoundSizeImg)
       {
          bFoundColorImg = false;

          for(var n=0; n<styleObj.ttColor.length; n++)
          {
             if ((styleObj.ttColor[n].colorCode == vSelectedColor) &&
                 (styleObj.ttColor[n].imageLg != ""))
             {
                vSwitchImgLg = styleObj.ttColor[n].imageLg;
                vSwitchImgZm = styleObj.ttColor[n].imageZm;
                bFoundColorImg = true;
             }
          }

          if (!bFoundColorImg)
          {
             vSwitchImgLg = styleObj.imageLg;
             vSwitchImgZm = styleObj.imageZm;
          }
       }
       /*****************^ T020000 ^*****************/

       vSizeHTML += '<div class="' + vClass + '" sizecode="' + styleObj.ttSize[i].sizeCode + '"' +
                    'onmouseover="swapImg(\'' + vSwitchImgLg + '\');' + /* T020000 */
                    '$(\'.selectedSize\').html(\'' + vSizeDesc + '\'); '; /* 040000 */

       vSizeHTML += 'showOOSMsg(vSelectedColorDesc,\'' + vSizeDesc + '\','+vStockQty+');';   /* E020000 */ /* 040000 */

       vSizeHTML += '" onmouseout="restoreImg(); $(\'.selectedSize\').html(vSelectedSizeDesc); '; /* T020000 */

         vSizeHTML += 'hideOOSMsg();';                             /* E020000 */
       if (!vIsRetail) { vClass += " sizeb2b"; }
       vSizeHTML += '" onclick="setSize(\'' + styleObj.ttSize[i].sizeCode + '\',this)" class="' + vClass + '" >' +
                    '<div class="sizeInner">' + styleObj.ttSize[i].description + '</div>' +
                    '</div>';
     }
   });
   if(vSelectedColor == "") displayColors(); /* 040003 */
   if(vSizeHTML!="") $(".prodSizes").html(vSizeHTML);              /* 030100 */
}
function displayMultiSizes(){
   var vSizeHTML = "";
   var vClass;
   var vSizeDesc="";                                               /* 040000 */
   if (styleObj.ttSizeScale.length == 1 && styleObj.ttSizeScale[0].ttSizeScaleValue.length == 1)
   { vSelectedMultiSize = styleObj.ttSizeScale[0].ttSizeScaleValue[0].dimValue; }
   if ($("#mainSizeHeading"))       /* 010007 */
      $("#mainSizeHeading").hide(); /* 010007 */
   $.each(styleObj.ttSizeScale,function(i){
      vSizeHTML += "<div class='sizeHeading'>" + styleObj.ttSizeScale[i].description + "</div><div class='prodSizes'>";
      $.each(styleObj.ttSizeScale[i].ttSizeScaleValue,function(j){
         if(multiSizeCheckItem(i,styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue)){
            /***vv T020001 vv***/
            if(vSelectedMultiSize[i]==styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue){
              if(multiSizeCheckStock(i,styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue) > 0){
                if(multiSizeCheckPreSell(i,styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue))
                  vClass = "sizeOuterPreSellSelected" + i;  
                else
                  vClass = "sizeOuterSelected" + i;
              }
              else{
                if(multiSizeCheckPreSell(i,styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue))
                  vClass = "sizeOuterPreSellOOSSelected" + i;
                else
                  vClass = "sizeOuterOOSSelected" + i;
              }
            }
            else{
              if(multiSizeCheckPreSell(i,styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue))              
                vClass = "sizeOuterPreSell" + i;
              else if(multiSizeCheckStock(i,styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue) > 0)
                vClass = "sizeOuter" + i;
              else
                vClass = "sizeOuterOOS" + i;
            }
            /***^^ T020001 ^^***/                                   
            if (styleObj.ttSize[i].fullDesc != "") vSizeDesc = styleObj.ttSize[i].fullDesc; /* 040000 */
            else vSizeDesc = styleObj.ttSize[i].description; /* 040000 */

            vSizeHTML += '<div class="' + vClass + '" dimValue="' + styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue + '"' +
                         'onmouseover="$(\'.selectedSize' + i + '\').html(\'' + vSizeDesc + '\'); '; /* 040000 */
            if(vClass == "sizeOuterOOS" + i || vClass == "sizeOuterOOSSelected" + i || vClass == "sizeOuterPreSellOOSSelected") /* T020001 */
              vSizeHTML += 'showMultiSizeOOSMsg(vSelectedColorDesc,' + i + ',\'' + styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue + '\');';

            vSizeHTML += '" onmouseout="$(\'.selectedSize' + i + '\').html(vSelectedSizeDesc); ';

            if(vClass == "sizeOuterOOS" + i || vClass == "sizeOuterOOSSelected" + i || vClass == "sizeOuterPreSellOOSSelected" + i) /* T020001 */
              vSizeHTML += 'hideOOSMsg();';

            vSizeHTML += '" onclick="setMultiSize(' + i + ',\'' + styleObj.ttSizeScale[i].ttSizeScaleValue[j].dimValue + '\',this)">' +
                         '<div class="sizeInner">' + styleObj.ttSizeScale[i].ttSizeScaleValue[j].description + '</div>' +
                         '</div>';
         }
      });
      vSizeHTML += "</div>";
   });
   if(vSelectedColor == "") displayColors(); /* 040003 */
   if(vSizeHTML!="") $(".prodSizes").html(vSizeHTML);              /* 030100 */
}
function switchComp(vType,curObj){
 $(".compTypeContainerH").hide();
 $(".compSelected").removeClass("compSelected");
 $(curObj).addClass("compSelected");
 vType = "#" + vType;
 $(vType).fadeIn(250);
}

/* 040001 - removed displayComprables(). */

function goStyle(vStyleCode,vStyleColor){
   golink("b2c/product.w?product=" + vStyleCode + "&color=" + vStyleColor + vBrowseParam,"main"); /* 040001 */
}

//========--------   Color/Size Selection   --------========\\

function setSize(vSizeCode,vThis){
  var vStockQty=-1;                                                /* E020000 */
  if(vSizeCode=="none" || !vIsRetail ) { return; }
  $(".cartError").html("");
  vSelectedSize = vSizeCode;

  if(document.getElementById("size" + vSelectedProd))
    document.getElementById("size" + vSelectedProd).value = vSizeCode;
  $(".sizeOuterSelected").attr("class","sizeOuter");
  $(".sizeOuterOOSSelected").attr("class","sizeOuterOOS");
  /******vv T020001 vv******/
  $(".sizeOuterPreSellSelected").attr("class","sizeOuterPreSell"); 
  $(".sizeOuterPreSellOOSSelected").attr("class","sizeOuterPreSellOOS"); 
   vStockQty=checkStock(vSelectedColor,vSelectedSize,vDefaultWhse); /* E020000 */
   if(vStockQty > 0 || vStockQty==-1){                              /* E020000 */
     if(checkPreSell(vSelectedColor,vSelectedSize))
       vClass="sizeOuterPreSellSelected";
     else
       vClass="sizeOuterSelected";
   }
   else{
     if(checkPreSell(vSelectedColor,vSelectedSize))
       vClass="sizeOuterPreSellOOSSelected";
     else
       vClass="sizeOuterOOSSelected";
   }
  /******^^ T020001 ^^******/
  if(vThis == "")
    $("div[sizeCode='" + vSizeCode + "']").addClass(vClass);
  else
    vThis.className=vClass;

  $.each(styleObj.ttSize,function(i){
    if (styleObj.ttSize[i].sizeCode == vSizeCode) {
      vSelectedSizeGroup = styleObj.ttSize[i].sizeGroup; /* T020000 */
      if (styleObj.ttSize[i].fullDesc != "") vSelectedSizeDesc = styleObj.ttSize[i].fullDesc; /* 040000 */
      else vSelectedSizeDesc = styleObj.ttSize[i].description;             /* 040000 */
      $(".selectedSize").html(vSelectedSizeDesc);
    }
  });

  /****************v T020000 v****************/
  var bFoundSizeImg = false;
  var sizeGroups;

  if((styleObj.ttColor!=null) && (vSelectedSizeGroup != ""))
  for(var i=0; i<styleObj.ttColor.length; i++)
  {
      if (styleObj.ttColor[i].colorCode.toString().toLowerCase() == vSelectedColor.toString().toLowerCase())
      {
          bFoundSizeImg = false;
          sizeGroups = new Array();
          sizeGroups[0] = vSelectedSizeGroup;

          for(var k=0; k < sizeGroups.length; k++)
          {
             for(var j=0; j<styleObj.ttColor[i].ttImage.length; j++)
             {
                if ((!bFoundSizeImg) && (styleObj.ttColor[i].ttImage[j].imageLg != "") &&
                    (sizeGroups[k].toString().toLowerCase() == styleObj.ttColor[i].ttImage[j].sizeGroup.toString().toLowerCase()))
                {
                    newLgImg = styleObj.ttColor[i].ttImage[j].imageLg;
                    newZmImg = styleObj.ttColor[i].ttImage[j].imageZm;
                    bFoundSizeImg = true;
                }
             }
          }

          if (!bFoundSizeImg)
          {
              if ((styleObj.ttColor[i].imageLg != "") && (styleObj.ttColor[i].imageLg != null))
              {
                 newLgImg = styleObj.ttColor[i].imageLg;
                 newZmImg = styleObj.ttColor[i].imageZm;
              }
              else{
                newLgImg = styleObj.imageLg;
                newZmImg = styleObj.imageZm;
              }
          }
      }
  }

  if(newZmImg != "" && newZmImg != null){
    MagicZoom.stop(zoomObj);
    MagicZoom.update(zoomObj,newZmImg,newLgImg); 
    MagicZoom.start(zoomObj);
  }
  else
    MagicZoom.stop(zoomObj);


  vLockedImg = $(".imageCell").attr("src"); 

  /****************^ T020000 ^****************/
  
  if (vSelectedSize != "" && vSelectedColor != "")
  {
   /********************v T010007 v********************/
   if (vTooltipSettings != "") {                                   /* 040000 */

      /* Hide the tool tip for selected a size. */
      $("#tip").remove();
      $(".btnShoppingBag").cluetip({});
      $(".btnWishlist").cluetip({});
   }                                                               /* 040000 */

   /********************^ T010007 ^********************/

   priceItem(vSelectedColor,vSelectedSize);
  }

  displayColors();
}
function setColor(vColorCode,vThis,vImgSwitch){

  resetFlash();                                                    /* 030200 */
  var vStockQty=-1;                                                /* 030100 */
  var newLgImg;
  var newZmImg;
  var vColorObj;                                                   /* 010102 */

  $(".cartError").html("");
  if(vColorCode=="none") { return; }
  if(document.getElementById("#imgLibDiv")) $("#imgLibDiv").hide();
  vSelectedColor = vColorCode;

  if(document.getElementById("color" + vSelectedProd))
    document.getElementById("color" + vSelectedProd).value = vColorCode;

  if(vColorCode == '') {                                           /* 010102 */
    newLgImg = styleObj.imageLg;
    newZmImg = styleObj.imageZm;
  }

  /**************v T020000 v**************/
  var bFoundSizeImg = false;
  var sizeGroups;

  if(styleObj.ttColor!=null)
  for(var i=0; i<styleObj.ttColor.length; i++)
  {
      if (styleObj.ttColor[i].colorCode.toString().toLowerCase() == vColorCode.toString().toLowerCase())
      {
          bFoundSizeImg = false;

          if (vSelectedSizeGroup != "")
          {
              sizeGroups = new Array();
              sizeGroups[0] = vSelectedSizeGroup;
          }
          else
          {
              sizeGroups = styleObj.sizeGroups.toString().split(",");
          }


          for(var k=0; k < sizeGroups.length; k++)
          {
             for(var j=0; j<styleObj.ttColor[i].ttImage.length; j++)
             {
                if ((!bFoundSizeImg) && (styleObj.ttColor[i].ttImage[j].imageLg != "") &&
                    (sizeGroups[k].toString().toLowerCase() == styleObj.ttColor[i].ttImage[j].sizeGroup.toString().toLowerCase()))
                {
                    newLgImg = styleObj.ttColor[i].ttImage[j].imageLg;
                    newZmImg = styleObj.ttColor[i].ttImage[j].imageZm;
                    bFoundSizeImg = true;
                }
             }
          }

          if (!bFoundSizeImg)
          {
              if ((styleObj.ttColor[i].imageLg != "") && (styleObj.ttColor[i].imageLg != null))
              {
                 newLgImg = styleObj.ttColor[i].imageLg;
                 newZmImg = styleObj.ttColor[i].imageZm;
              }
              else{
                newLgImg = styleObj.imageLg;
                newZmImg = styleObj.imageZm;
              }
          }

          $(".prodSizeRange").html(styleObj.ttColor[i].availSizes);
      }
  }
  /**************^ T020000 ^**************/
  if(vImgSwitch)
     swapImg(newLgImg);

  if(newZmImg != "" && newZmImg != null){
    MagicZoom.stop(zoomObj);
    MagicZoom.update(zoomObj,newZmImg,newLgImg); /* 020000 */
    MagicZoom.start(zoomObj);
  }
  else
    MagicZoom.stop(zoomObj);

  vLockedImg = $(".imageCell").attr("src");

  $(".colorOuterSelected").attr("class","colorOuter");
  $(".colorOuterOOSSelected").attr("class","colorOuterOOS");
  /***vv T020001 vv***/
  $(".colorOuterPreSellSelected").attr("class","colorOuterPreSell");
  $(".colorOuterPreSellOOSSelected").attr("class","colorOuterPreSellOOS");
  vStockQty=checkStock(vSelectedColor,vSelectedSize,vDefaultWhse);
  if(vSelectedSize == "" || vStockQty > 0 || vStockQty==-1){        /* E020000 */
    if(checkPreSell(vColorCode))
      vClass="colorOuterPreSellSelected";
    else
      vClass="colorOuterSelected";
  }
  else{
    if(checkPreSell(vColorCode))
      vClass="colorOuterPreSellOOSSelected";
    else
    vClass="colorOuterOOSSelected";
  }
  /***^^ T020001 ^^***/
  if(vThis == "" && vColorCode != "") /* 040008 */
    $("div[colorCode='" + vColorCode + "']").addClass(vClass);
  else
    vThis.className=vClass;

  $.each(styleObj.ttColor,function(i){
    if (styleObj.ttColor[i].colorCode == vColorCode) {
      vColorObj = styleObj.ttColor[i];
    }
  });

  /*vvv 010102 vvv*/

  vSelectedColorDesc = '';
  if (vColorObj != null) {
    vSelectedColorDesc = vColorObj.description;
    if (vColorObj.fabDesc != '' && vColorObj.fabDesc != null)
      vSelectedColorDesc += ' ' + vColorObj.fabDesc;
  }

  $(".selectedColor").html(vSelectedColorDesc);

  /*^^^ 010102 ^^^*/

  if (vSelectedSize != "" && vSelectedColor != "")
  { priceItem(vSelectedColor,vSelectedSize); }

  if(styleObj.ttSizeScale && styleObj.ttSizeScale[1] != null)
    displayMultiSizes();
  else if(styleObj.ttSize!=null)  /* 010008 */
    displaySizes();
  if(styleObj.ttAltView)
    switchAltViews(vColorCode);
}

function setMultiSize(vIndex,vDimValue,vThis){
  if(!vIsRetail ) { return; }
  var vFullSizeCode = "";
  var vFullSize = true;

  vSelectedMultiSize[vIndex] = vDimValue;
  $(".sizeOuterSelected" + vIndex).attr("class","sizeOuter" + vIndex);
  vThis.className="sizeOuterSelected" + vIndex;
  $.each(vSelectedMultiSize, function(i){
     vFullSizeCode += vSelectedMultiSize[i];
     if(vSelectedMultiSize[i] == "")
       vFullSize = false;
  });

  if(vFullSize){
    vSelectedSize = vFullSizeCode;
    $.each(styleObj.ttSize,function(i){
      if (styleObj.ttSize[i].sizeCode == vSelectedSize) {
        if (styleObj.ttSize[i].fullDesc != "") vSelectedSizeDesc = styleObj.ttSize[i].fullDesc; /* 040000 */
        else vSelectedSizeDesc = styleObj.ttSize[i].description;             /* 040000 */
        $(".selectedSize").html(vSelectedSizeDesc);
      }
    });
    displayColors();
  }
  else
    vSelectedSize = "";

  if (vSelectedSize != "" && vSelectedColor != "")
  { priceItem(vSelectedColor,vSelectedSize); }
  displayMultiSizes();
}
//========--------   size / stock checking   --------========\\

/********************v E020000 v********************/

function checkStock(vColorCode,vSizeCode,vWhse){
  var vAvailQty = -1;
  $.each(styleObj.ttItem,function(i){
    if(styleObj.ttItem[i].colorCode == vColorCode && styleObj.ttItem[i].sizeCode == vSizeCode) {
      if (styleObj.ttItem[i].availQty == null)
        vAvailQty = -1;
      else
        vAvailQty = styleObj.ttItem[i].availQty;
      return; // returns from $.each function
    }
  });

  /********************^ E020000 ^********************/
  return vAvailQty;
}

function checkStockItem()
{
 var vAvailQty = 0;
  $.each(styleObj.ttItem,function(i)
  {
      if (styleObj.ttItem[i].availQty == null)
        vAvailQty = 1;
      else
        vAvailQty = styleObj.ttItem[i].availQty;
      return; // returns from $.each function
  });
  return vAvailQty;
}

function setStock(vColorCode,vSizeCode,vQty){
  var vAvailQty = 0;
  $.each(styleObj.ttItem,function(i){
    if(styleObj.ttItem[i].colorCode == vColorCode && styleObj.ttItem[i].sizeCode == vSizeCode) {
      styleObj.ttItem[i].availQty -= vQty;
      return; // returns from $.each function
    }
  });
}

function setStockItem(vQty){
  var vAvailQty = 0;
  $.each(styleObj.ttItem,function(i){

      styleObj.ttItem[i].availQty -= vQty;
      return; // returns from $.each function

  });
}


function multiSizeCheckStock(vIndex,vDimValue,vWhse){
  var vAvailQty = 0;
  var vTempSize = "";
  var vSize     = "";
  
  //Return if no color is selected
  if(vSelectedColor == "") return 1; /* 040003 */
  //return true if no other size dimension is selected
  $.each(vSelectedMultiSize,function(k){
     if (k != vIndex)
        vTempSize += vSelectedMultiSize[k];
     if (k == vIndex)
        vSize += vDimValue;
     else
        vSize += vSelectedMultiSize[k];
  });
  if (vTempSize == "")
  { return 1; }

  $.each(styleObj.ttItem,function(i){
    if(styleObj.ttItem[i].colorCode == vSelectedColor && styleObj.ttItem[i].sizeCode == vSize) {
      if (styleObj.ttItem[i].availQty == null)
        vAvailQty = 1;
      else
        vAvailQty = styleObj.ttItem[i].availQty;
      return; // returns from $.each function
    }
  });
  return vAvailQty;
}
function checkItem(vColorCode,vSizeCode){
  var vFound = false;
  $.each(styleObj.ttItem,function(k){
    if(styleObj.ttItem[k].colorCode == vColorCode && styleObj.ttItem[k].sizeCode == vSizeCode)
    { vFound = true; return; }
  });
  return vFound;
}
function multiSizeCheckItem(vIndex,vDimValue){
  var vFound = false;
  var vTempSize = "";
  var vSize     = "";

  //return true if no color or other size dimension is selected
  if(vSelectedColor == "")
  { return true; }
  $.each(vSelectedMultiSize,function(k){
     if (k != vIndex)
        vTempSize += vSelectedMultiSize[k];
     if (k == vIndex)
        vSize += vDimValue;
     else
        vSize += vSelectedMultiSize[k];
  });
  if (vTempSize == "")
  { return true; }
  return checkItem(vSelectedColor,vSize);
}
//========----   Feature Icon Display  ----========\\
function displayFeatIcons(){
  if(styleObj.ttFeatIcon){
    $.each(styleObj.ttFeatIcon,function(i){
     $(".prodIcons").append("<img src='" + styleObj.ttFeatIcon[i].icon + "' class='featureIcon' alt='" + styleObj.ttFeatIcon[i].description + "' />");
    });
  }
}
//========--------   Update Price   --------========\\
function priceItem(vColorCode,vSizeCode,vItemNumber){ /* 010007 */
  var newPrice = "";
  $.each(styleObj.ttItem,function(k){
    if((styleObj.ttItem[k].colorCode == vColorCode && styleObj.ttItem[k].sizeCode == vSizeCode) || vItemNumber == styleObj.ttItem[k].itemNumber){ /* 010007 */
      if(styleObj.ttItem[k].salePrice <= 0 ){
        $(".disclaimer").hide();
        $(".salePriceDiv").hide();
        $(".regPriceStrike").addClass("regPrice");
        $(".regPriceStrike").removeClass("regPriceStrike");
        newPrice = parseFloat(styleObj.ttItem[k].regPrice);
        $(".regPrice").html("$" + newPrice.toFixed(2));
        $(".regPriceLabel").html(vRegPriceLabel);
        vSelectedPrice = newPrice.toFixed(2);
      }
      else{
        newPrice = parseFloat(styleObj.ttItem[k].regPrice);
        $(".regPriceLabel").html(vRegOnSaleLabel);
        $(".regPrice").html("$" + newPrice.toFixed(2));
        $(".regPrice").addClass("regPriceStrike");
        $(".regPrice").removeClass("regPrice");
        newPrice = parseFloat(styleObj.ttItem[k].salePrice);
        vSelectedPrice = newPrice.toFixed(2);
        $(".salePrice").text("$" + newPrice.toFixed(2));
        $(".salePriceDiv").show();
        if(styleObj.ttItem[k].disclaimer == "true") /* T010008 */ /* T010009 */
         $(".disclaimer").show();
        else
         $(".disclaimer").hide();

      }
      return;
    }
  });
}
//========--------   MouseOvers   --------========\\
function swapImg(vNewImg,vNoLock){
  resetFlash();                                                    /* 030200 */
  if(vNewImg != "" ){
    if(!vNoLock)
      vLockedImg = $(".imageCell").attr("src");
    $(".imageCell").attr("src",vNewImg);
  }
}
function restoreImg(){
  if(vLockedImg != "" && $(".imageCell").attr("src") != vLockedImg)
  { $(".imageCell").attr("src",vLockedImg); }
}
function showOOSMsg(vColor,vSize,vQty){
  if (vQty==-1) return;
  var vPosition   = $(".imgUpper").position();

  if (vQty>0) { $("#imgMessage").hide(); return; }                 /* 040004 */

  if(vQty==0 || vQty == undefined)                    /* 030100 */ /* 040004 */
  $(".imgMessageText").html(vColor + " is currently out of stock in " + vSize);
  else                                                             /* 030100 */
  if(!vIsRetail)                                                   /* 030100 */
    $(".imgMessageText").html(vColor + " currently has " + vQty + " available in " + vSize);

  var vTopOffset  = ( $(".prodImgInner").outerHeight() - $("#imgMessage").outerHeight() - ( $("#imgMessage").outerHeight()/2) );
  var vLeftOffset = ( $(".imgUpper").outerWidth() - $("#imgMessage").outerWidth() )/2;

  $("#imgMessage").css("top",vPosition.top + vTopOffset);
  $("#imgMessage").css("left",vPosition.left + vLeftOffset);
  $("#imgMessage").show();
}
function showMultiSizeOOSMsg(vColor,vIndex,vDimValue){
  var vSize     = "";
  var vSizeDesc = "";
  $.each(vSelectedMultiSize,function(k){
     if (k == vIndex)
        vSize += vDimValue;
     else
        vSize += vSelectedMultiSize[k];
  });
  $.each(styleObj.ttSize,function(i){
     if(styleObj.ttSize[i].sizeCode == vSize){
        if (styleObj.ttSize[i].fullDesc != "") vSizeDesc = styleObj.ttSize[i].fullDesc; /* 040000 */
        else vSizeDesc = styleObj.ttSize[i].description;           /* 040000 */
        return;
     }
  });
  showOOSMsg(vColor,vSizeDesc);
}
function hideOOSMsg(){
  $("#imgMessage").hide();
}
/****** Retail Add to Cart ******/
function retailAddToCart(vProduct,vColor,vSize,vOrderType){
  var vOrderQty = $("#qty").attr("value");
  if(vProdType=="S")  /* 010008 */
  {
   if(vColor == "" || vColor == "none" || vColor == null){
     $(".cartError").html("Please choose a color to continue.");
     return;  }
   if(vSize == "" || vSize == "none" || vSize == null) {
     $(".cartError").html("Please choose a size to continue.");
     return;  }
  }
  if (vOrderQty == "" ) {
    $(".cartError").html("Please enter a quantity before adding item(s) to shopping bag.");
    return;  }
  if (isNumeric(vOrderQty) == false) {
    $(".cartError").html("Please enter a numeric quantity before adding item(s) to shopping bag.");
    $("#qty").attr("value","")
    $("#qty").focus();
    return;  }
  if (vOrderQty <= 0)  {
    $(".cartError").html("Please enter a quantity before adding item(s) to shopping bag.");
    return;  }

  /******v 010101 v******/

  if (vOrderLimit > 1 && (vTotalOrderQty + parseFloat(vOrderQty))  > vOrderLimit) {
     if (vOrderLimitMsg.indexOf("<qty>") != -1)
        vOrderLimitMsg = vOrderLimitMsg.replace("<qty>",vOrderLimit);
     alert(vOrderLimitMsg);
     return;
  }

  /******^ 010101 ^******/

  var invAvail=0;  /* 010008 */
  if(vProdType=="S") invAvail = parseInt(checkStock(vColor,vSize));  /* 010008 */
  if(vProdType=="I") invAvail = parseInt(checkStockItem());
  /***vv 030101 vv***/
  if (vMaxUnits > 0 && vOrderQty > vMaxUnits) /* 030204 */
  {
    alert("The maximum number of units that may be purchased at one time is " + vMaxUnits.toString() + ".  Please contact our customer service department to order more than " + vMaxUnits.toString() + ".");
    invAvail = vMaxUnits;
    $("#qty").attr("value",invAvail)
    $("#qty").focus();
    return;
  }
  /***^^ 030101 ^^***/
  if(invAvail < vOrderQty)  {
    if (invAvail <= 0)
     $(".cartError").html("The selected item is currently out of stock.");
    else{
     var alertMsg = "You have ordered " + vOrderQty + " however only ";
     if (invAvail == 1)
       alertMsg += "1 is available.";
     else
       alertMsg += invAvail + " are available.";
     alert(alertMsg);
    }
    if (invAvail <= 0 )
       invAvail = 1;
    $("#qty").attr("value",invAvail)
    $("#qty").focus();
    return;
  }
  if(checkPreSell(vSelectedColor,vSelectedSize))
   preSellInfoBox(vProduct,vSelectedColor,vSelectedSize,vOrderQty,vOrderType);
  else            
  {
   addToCart(vProduct,vColor,vSize,vOrderQty,vOrderType);
   if(vProdType=="S") setStock(vColor,vSize,vOrderQty);  /* 010008 */
   if(vProdType=="I") setStockItem(vOrderQty);  /* 010008 */
   vTotalOrderQty += + parseFloat(vOrderQty); /* 010101 */
  }
}
/*===---- Retail Functions ----===*/
function clearmessage(){
  $(".cartError").html("");
}
function enterCheck(event,id)
{
  if(event.keyCode == 13)
  {
    $("#retailAddToCart").click();
    return false;
  }
  return true;
}

function bookmarkMe(){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(location.href,document.title);
  }
  else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(document.title,location.href,"");
  }
  else {
   if(agt.indexOf("opera")!= -1)
    alert("Press CTRL-T to bookmark this page.");
   else
    alert("Press CTRL-D to bookmark this page.");
  }
}

function openBlogText(vDescription,vImgPth,vFullDesc){
 if (styleObj){
   if (styleObj.description)
     vDescription = styleObj.description;
   if (styleObj.fullDesc != "" && styleObj.fullDesc != null)
     vFullDesc = styleObj.fullDesc;
   if (styleObj.imageTh != "" && styleObj.imageTh != null)
     vImgPth = styleObj.imageTh;
 }
 var vBlogHTML = "<table cellspacing='0' cellpadding='0' border='0' class='blogTable'>" +
                 "<tr><td colspan='2' style='font-weight:bold;font-size:12pt;'>" + document.title +
                 "</td></tr><tr><td rowspan='2'><img src='" + vImgPth + "' alt=''></td>" +
                 "<td style='text-align:center;vertical-align:top;height:25px;'><a style='font-weight:bold;font-size:11pt;' href='" + appPath + "/site.w?location=b2c/product.w&product=" + vSelectedProd +   /* 010010 */
                 "&frames=no&target=main&sponsor=" + vSponsorCode + "'>" + vDescription + "</a>" +
                 "</td><tr><td style='vertical-align:top;'>" + vFullDesc + "</td></tr></table>";
 vBlogHTML = "<div style='width:400px;text-align:center;margin:none;pading:none;'><table cellspacing='0' cellpadding='0' border='0' style='width:400px'><tr><td class='blogInstructions' style='text-align:center;'>Copy and paste the HTML text below to share this product on your blog or online profile.</td></tr></table>" + vBlogHTML + "<br/> <textarea>" + vBlogHTML + "</textarea></div>";
 if(!document.getElementById("blogPost")){
   $("body").append("<div id='blogPost' title='Blog HTML' style='width:400px;' />");
   $("#blogPost").html(vBlogHTML);
   $("#blogPost").dialog({width:450,height:475,resizable:false} );
 }
 else
   $("#blogPost").dialog("open");
}

function showAltViews(vColorCode){
 var vAltViewHTML = "";
 var vAlt;
 if(document.getElementById("altViews")){
   $("#altViews").html('');
   $.each(styleObj.ttAltView,function(i){
     if(styleObj.ttAltView[i].colorCode == vColorCode){
        vAlt = $($(document.createElement("div")));
        vAlt.attr("id","altView" + styleObj.ttAltView[i].altId)
            .attr("colorCode",vColorCode)
            .attr("rel","zoom-id:zoom1")
            .attr("rev",styleObj.ttAltView[i].imageLg)
            .attr("href",styleObj.ttAltView[i].imageZm)
            .mouseover(function(){ swapImg(styleObj.ttAltView[i].imageLg,true); })
            .mouseout(function(){ restoreImg(); })
            .click(function(){
                vLockedImg=styleObj.ttAltView[i].imageLg;
                if(styleObj.ttAltView[i].imageZm != ""){
                  MagicZoom.stop(zoomObj);
                  MagicZoom.update(zoomObj,styleObj.ttAltView[i].imageZm,styleObj.ttAltView[i].imageLg);
                  MagicZoom.start(zoomObj);
                }
                else{
                  MagicZoom.stop(zoomObj);
                }
             })
            .html("<img src='" + styleObj.ttAltView[i].imageSm + "' alt='' />");

        $("#altViews").append(vAlt);
     }
   });
   if ($(".altViewSide"))
     $(".prodDesc").width($(".prodDesc").width() - $(".altViewSide").outerWidth() );
   $("#altViews").css("display","block");
 }
}
/***vv 020000 vv***/
function switchAltViews(vColorCode){
 var vAltViewHTML = "";
 var vAltViewId;
 if(document.getElementById("altViews")){
   $("#altViews").html('');
   $.each(styleObj.ttAltView,function(i){
     if(styleObj.ttAltView[i].colorCode == vColorCode){
        vAlt = $($(document.createElement("div")));
        vAlt.attr("id","altView" + styleObj.ttAltView[i].altId)
            .attr("colorCode",vColorCode)
            .attr("rel","zoom-id:zoom1")
            .attr("rev",styleObj.ttAltView[i].imageLg)
            .attr("href",styleObj.ttAltView[i].imageZm)
            .mouseover(function(){ swapImg(styleObj.ttAltView[i].imageLg,true); })
            .mouseout(function(){ restoreImg(); })
            .click(function(){
                vLockedImg=styleObj.ttAltView[i].imageLg;
                if(styleObj.ttAltView[i].imageZm != ""){
                  MagicZoom.stop(zoomObj);
                  MagicZoom.update(zoomObj,styleObj.ttAltView[i].imageZm,styleObj.ttAltView[i].imageLg);
                  MagicZoom.start(zoomObj);
                }
                else{
                  MagicZoom.stop(zoomObj);
                }
             })
            .html("<img src='" + styleObj.ttAltView[i].imageSm + "' alt='' />");

        $("#altViews").append(vAlt);
     }
   });
   //reset all non color specific altViews to defaults
   $.each(styleObj.ttAltView,function(i){
     if(styleObj.ttAltView[i].colorCode == "" && !document.getElementById("altView" + styleObj.ttAltView[i].altId) ){
        vAlt = $($(document.createElement("div")));
        vAlt.attr("id","altView" + styleObj.ttAltView[i].altId)
            .attr("colorCode",vColorCode)
            .attr("rel","zoom-id:zoom1")
            .attr("rev",styleObj.ttAltView[i].imageLg)
            .attr("href",styleObj.ttAltView[i].imageZm)
            .mouseover(function(){ swapImg(styleObj.ttAltView[i].imageLg,true); })
            .mouseout(function(){ restoreImg(); })
            .click(function(){
                vLockedImg=styleObj.ttAltView[i].imageLg;
                if(styleObj.ttAltView[i].imageZm != ""){
                  MagicZoom.stop(zoomObj);
                  MagicZoom.update(zoomObj,styleObj.ttAltView[i].imageZm,styleObj.ttAltView[i].imageLg);
                  MagicZoom.start(zoomObj);
                }
                else{
                  MagicZoom.stop(zoomObj);
                }
             })
            .html("<img src='" + styleObj.ttAltView[i].imageSm + "' alt='' />");

        $("#altViews").append(vAlt);
     }
   });

 }
}
/***^^ 020000 ^^***/

/***vv 030200 vv***/

function productFlash(vFlash) {
  vImgHtml = $(".prodImg").html();
  $(".prodImg").html("");
  $(".prodImg").flashembed({                                       /* 030203 */
     src: vFlash,
     wmode: "transparent"
  });
}
function resetFlash() {
   if (vImgHtml != "") {
      $(".prodImg").html(vImgHtml);
      vImgHtml = "";
   }
}

/***^^ 030200 ^^***/

/***vv 030201 vv***/
/***vv 040006 vv***/

function showVideo(vVideo,vHideSections) {
   vHideSections = vHideSections.split(",");
   if ($("#" + vVideo).html() == "")                               /* 030202 */
      $("#" + vVideo).html(vVideoEmbed);                           /* 030202 */
   $("#" + vVideo).show();
   vVideoEmbed = $("#" + vVideo).html();                           /* 030202 */
   $.each(vHideSections,function(i) {
      $("#" + vHideSections[i]).hide();
   });
}
function hideVideo(vVideo,vShowSections) {
   vShowSections = vShowSections.split(",");
   $("#" + vVideo).html("");                                       /* 030202 */
   $("#" + vVideo).hide();
   $.each(vShowSections,function(i) {
      $("#" + vShowSections[i]).show();
   });
}
/***^^ 040006 ^^***/
/***^^ 030201 ^^***/
/***vv T020001 vv***/
function multiSizeCheckPreSell(vIndex,vDimValue){
  var vTempSize = "";
  var vSize     = "";
  
  if(vSelectedColor == "") return false;
  $.each(vSelectedMultiSize,function(k){
     if (k != vIndex)
        vTempSize += vSelectedMultiSize[k];
     if (k == vIndex)
        vSize += vDimValue;
     else
        vSize += vSelectedMultiSize[k];
  });
  if (vTempSize == "")
  { return false; }
  var vTmpItem = $(styleObj.ttItem).filter(function(){ 
     if(this.colorCode==vSelectedColor&&this.sizeCode==vSize)
       return true;
  });
  if(vTmpItem.length==1){
    vStreetDate = parseDate(vTmpItem[0].streetDate);
    if(vTmpItem[0].preSell && vStreetDate > vToday )
     return true;
  }
  else
   return false;
}
function checkPreSell(vColorCode,vSizeCode){
  var vPreSell = false;

  if( (vColorCode==""||vColorCode==null||typeof(vColorCode)=="undefined") &&
      (vSizeCode==""||vSizeCode==null||typeof(vSizeCode)=="undefined")
  ){
    //Style
    vStreetDate = parseDate(styleObj.streetDate);     
    if(styleObj.preSell && vStreetDate > vToday){
      vPreSell = true; 
      setPreSell(styleObj.preSellDesc,styleObj.streetDate);
    }
    else
      clearPreSell();
  }
  else if(vSizeCode==""||vSizeCode==null||typeof(vSizeCode)=="undefined"){
    //Color
    $.each(styleObj.ttColor,function(k){
      if(styleObj.ttColor[k].colorCode == vColorCode && styleObj.ttColor[k].sizeCode == vSizeCode){
        vStreetDate = parseDate(this.streetDate);     
        if(this.preSell && vStreetDate > vToday){
          vPreSell = true; 
          setPreSell(this.preSellDesc,this.streetDate);
        }
        else
          clearPreSell();
        return; 
      }
    });
  }
  else{
    //Item
    $.each(styleObj.ttItem,function(k){
      if(styleObj.ttItem[k].colorCode == vColorCode && styleObj.ttItem[k].sizeCode == vSizeCode){
        vStreetDate = parseDate(this.streetDate);     
        if(this.preSell && vStreetDate > vToday){
          vPreSell = true; 
          setPreSell(this.preSellDesc,this.streetDate);
        }
        else
          clearPreSell();
        return; 
      }
    });
  }

  return vPreSell;
}

function setPreSell(vPreSellDesc,vStreetDate){
  vStreetDate = formatDate(parseDate(vStreetDate),"MM/dd/yyyy"); /* B010001 */
  $(".presellDesc").html(vPreSellDesc).show();
  $(".streetDate").html(vStreetDate).show();  
  $(".preSellCopy").html(vPreSellCopy).show();
}
function clearPreSell(){
  $(".presellDesc").hide();
  $(".streetDate").hide();
  $(".preSellCopy").hide();
}
//Date Parsing Functions
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];
  value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);
  while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}
  if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase())
  {if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);
  if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23))
  {return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);
  if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}
  if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++)
  {var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}
/***^^ T020001 ^^***/
function preSellInfoBox(vProduct,vColor,vSize,vOrderQty,vOrderType)
{
 $.ajax({
   type: "GET",
   url: hostDomain + appPath + "/b2c/presell-confirm.w?product=" + vProduct + "&color="+vColor+"&size="+vSize+"&qty="+vOrderQty+"&ordertype="+vOrderType+"&price="+vSelectedPrice+"&frames=no&target=main&sponsor=" + fdmSponsor+"&nocache="+getNoCacheParam(),   /* T020002 */  /* T020003 */
   dataType: "html",
   complete: function(data) {
               if(document.getElementById("presellConfirm"))
                $("#presellConfirm").dialog("destroy");

               $("body").append("<div id='presellConfirm' title='Pre-ordered Item'/>");
               $("#presellConfirm").html(data.responseText);
               $("#presellConfirm").dialog({
                   modal: true,
                   resizable:false,
                   buttons: {
                    Okay: function() {
                     addToCart(vProduct,vColor,vSize,vOrderQty,vOrderType);
                     if(vProdType=="S") setStock(vColor,vSize,vOrderQty);  
                     if(vProdType=="I") setStockItem(vOrderQty);  
                     vTotalOrderQty += + parseFloat(vOrderQty); 
                     $(this).dialog('close');
                    },
                    'Cancel': function() {
                     $(this).dialog('close');
                    }
                   }                                               /* T020003 */
                  } 
                );
               if(document.getElementById("presellConfirm"))       /* T020002 */
               $("#presellConfirm").dialog("open");
             }
      });
}
// Treat backspace like the back button. IE issue with losing hash when using backspace.
document.onkeydown = document.onkeypress = function (evt) {
 if (typeof evt == 'undefined') {
 evt = window.event;
 }
 if (evt) {
 var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
 if (keyCode == 8) {
  history.go(-1);
  return false;
 }
 else {
  return true;
 }
 }
 else {
  return true;
 }
}



