// JavaScript Document
<!--

function _BrowserAgent() {
    var b = navigator.appName;
    var v = this.version = navigator.appVersion;
    var ua = navigator.userAgent.toLowerCase();
    this.v = parseInt(v);
    this.safari = ua.indexOf("safari")>-1;
    this.opera = ua.indexOf("opera")>-1;
    this.ns = !this.opera && !this.safari && (b=="Netscape");
    this.ie = !this.opera && (b=="Microsoft Internet Explorer");
    this.gecko = ua.indexOf('gecko')>-1;
    if (this.ns) {
        this.ns4 = (this.v==4);
        this.ns6 = (this.v>=5);
        this.b = "Netscape";
    }else if (this.ie) {
        this.ie4 = this.ie5 = this.ie55 = this.ie6 = false;
        if (v.indexOf('MSIE 4')>0) {this.ie4 = true; this.v = 4;}
        else if (v.indexOf('MSIE 5')>0) {this.ie5 = true; this.v = 5;}
        else if (v.indexOf('MSIE 5.5')>0) {this.ie55 = true; this.v = 5.5;}
        else if (v.indexOf('MSIE 6')>0) {this.ie6 = true; this.v = 6;}
        else if (v.indexOf('MSIE 7')>0) {this.ie7 = true; this.v = 7;}
        this.b = "MSIE";
    }else if (this.opera) {
        this.v=parseInt(ua.substr(ua.indexOf("opera")+6,1));
        this.opera6=(this.v>=6);
        this.opera7=(this.v>=7);
        this.b = "Opera";
    }else if (this.safari) {
        this.ns6 = (this.v>=5);
        this.b = "Safari";
    }
    this.dom = (document.createElement && document.appendChild && document.getElementsByTagName)? true : false;
    this.def = (this.ie||this.dom);
    this.win32 = ua.indexOf("win")>-1;
    this.mac = ua.indexOf("mac")>-1;
    this.other = (!this.win32 && !this.mac);
    this.supported = (this.def||this.ns4||this.ns6||this.opera)? true:false;
    this.broadband=false;
    this._bws=new Date;
};

var bAgent = new _BrowserAgent();

// Tab controls
function TabBar() {
  _tabBar = this;
  this.tabs = new Array();
  this.initTabId = 'tab-1';
  this.currTabId = this.initTabId;
  this.newTabId = this.initTabId;

  this.getTabObj = function(tabId) {
    var y = 0;
      while (tab = this.tabs[y++]) {  
        if (tab.id == tabId) {
          return tab;
          break;
        }
      }
  }

  this.initTab = function(tabId) {
    this.initTabId = tabId;

    var tabImg = MM_findObj(tabId);
    if (tabImg != null) {
      var tabObj = this.getTabObj(tabId);
      tabImg.src = tabObj.activeImg;  
      this.currTabId = tabId;
    }
  }

  this.setCurrTabId = function(tabId) {
    var tabObj = this.getTabObj(tabId);
    if (tabObj != null) { this.currTabId = tabId; }
  }

  this.setNewTabId = function(tabId) {
    var tabObj = this.getTabObj(tabId);
    if (tabObj != null) { this.newTabId = tabId; }
  }

  this.mouseover = function(tabId) { if (tabId == this.currTabId) { return; }
    var tabImg = MM_findObj(tabId);
    if (tabImg != null) {
      var tabObj = this.getTabObj(tabId);
      if (tabObj != null) { tabImg.src = tab.activeImg; }
    }
  }

  this.mouseout = function(tabId) {
    if (tabId == this.currTabId) { return; }
    var tabImg = MM_findObj(tabId);
    if (tabImg != null) {
      var tabObj = this.getTabObj(tabId);
      if (tabObj != null) { tabImg.src = tab.inactiveImg; }
    }
  }

  this.setActiveTab = function(newTabId)   {
    if (newTabId != this.currTabId) {
      var newTabImg = MM_findObj(newTabId);
      if (newTabImg != null) {
        var newTabObj = this.getTabObj(newTabId);
        newTabImg.src = newTabObj.activeImg;  

        var currTabImg = MM_findObj(this.currTabId);
        var currTabObj = this.getTabObj(this.currTabId);
        currTabImg.src = currTabObj.inactiveImg;   
        this.currTabId = newTabId;
      }
    }
  }

  this.onHistClick = function(newTabId) {
    var newTabObj = this.getTabObj(newTabId);
    var newTabId = newTabObj.id;
    var modIdx = 0;

    if (this.currTabId != newTabId) {
      var newTabImg = MM_findObj(newTabId);
      if (newTabImg != null) {        
        var newTabObj = this.getTabObj(newTabId);
        this.setNewTabId(newTabId);
        //onTabChange(newTabObj.pageId, newTabObj.modId, modIdx);
      }
    }
    else {
      return;
    }
  }

  this.onclick = function(newTabId) {
    var newTabObj = this.getTabObj(newTabId);
    var newTabId = newTabObj.id;
    var modIdx = 0;

    if (this.currTabId != newTabId) {
      var newTabImg = MM_findObj(newTabId);
      if (newTabImg != null) {        
        var newTabObj = this.getTabObj(newTabId);
        this.setNewTabId(newTabId);
        onTabChange(newTabObj.pageId, newTabObj.modId, modIdx);
      }
    }
    else {
      return;
    }
  }

  this.onSwitchView = function() {
    var newTabId = this.currTabId;
    var modIdx = 0;
    if (newTabId == 'tab-1' || newTabId == 'tab3') {
      newTabId = 'tab0';
    }

    var newTabImg = MM_findObj(newTabId);
    if (newTabImg != null){      
      var newTabObj = this.getTabObj(newTabId);
      this.setNewTabId(newTabId);
      onTabChange(newTabObj.pageId, newTabObj.modId, modIdx);
    }
  }

  this.doContinue = function(tabId) {
    var newTabId = tabId;   
    var modIdx = 0;

    var newTabImg = MM_findObj(newTabId);
    if (newTabImg != null){      
      var newTabObj = this.getTabObj(newTabId);
      this.setNewTabId(newTabId);
      onTabChange(newTabObj.pageId, newTabObj.modId, modIdx);
      shouldAnchor = false;
    }
  }

  this.moveToTab = function(tabId, modId, modIdx) {
    var tabObj = this.getTabObj(tabId);
    this.setNewTabId(tabId);
    shouldAnchor = true;
    onTabChange(tabObj.pageId, modId, modIdx);        
    /*handleTabContent(tabId);
    this.setActiveTab(tabId); */
  }
} // end tab

function switchView(nvType) {
  if (nvType != vType) {
    vType = nvType;
    _tabBar.onSwitchView();
  }
}

function doContinue() {
  var newIabId = 'tab3';
  if (_tabBar.currTabId == 'tab-1') {
    newIabId = 'tab0'
  }
  else if (_tabBar.currTabId == 'tab0') {
    newIabId = 'tab1'
  }
  else if (_tabBar.currTabId == 'tab1') {
    newIabId = 'tab2'
  }
  else if (_tabBar.currTabId == 'tab2') {
    newIabId = 'tab3'
  }
  else if (_tabBar.currTabId == 'tab3') {
    newIabId = 'tab1'
  }

  _tabBar.doContinue(newIabId);
}

function doBackContinue() {
  var newIabId = '';
  if (_tabBar.currTabId == 'tab0') {
    newIabId = 'tab-1'
  }
  else if (_tabBar.currTabId == 'tab1') {
    newIabId = 'tab0'
  }
  else if (_tabBar.currTabId == 'tab2') {
    newIabId = 'tab1'
  }
  else if (_tabBar.currTabId == 'tab3') {
    newIabId = 'tab2'
  }

  _tabBar.doContinue(newIabId);
}

function doCheckout() {
  var newIabId = 'tab3';
  _tabBar.doContinue(newIabId);
}

function moduleVisited() {
  var outofLabel;

  if (_tabBar.newTabId == 'tab0') {
    outofLabel = 'components';
  }
  else if (_tabBar.newTabId == 'tab1') {
    outofLabel = 'accessories';
  }
  else if (_tabBar.newTabId == 'tab2') {
    outofLabel = 'printers';
  }

  var totalMods = _moduleBar.moduleIcons.length - 1;
  var currIdx = _moduleBar.currIdx;
  //var totalModsDiv = getAnElement('total-mods-div');
  var currModsDiv = getAnElement('out-of-div');
  
  if (currModsDiv != null) {
    currModsDiv.innerHTML =  "Showing" + '&nbsp;' + (currIdx + 1) + '&nbsp;of&nbsp;' + (totalMods + 1) + '&nbsp;' + outofLabel;
  }
}

function ModuleBar() {
  _moduleBar = this;
  this.moduleIcons = new Array();
  this.lastIconIdx = this.moduleIcons.length - 1;
  this.currIdx = 0;
  this.tabId = "tab-1";
  this.moduleWidth = "88";

  this.initModule = function() { this.handleButton(); }

  this.setCurrModIdxById = function(modId) {
    var modIconObj = null;
    var i;
    for (i = 0; i < this.moduleIcons.length; i++) {
      if (modId == this.moduleIcons[i].moduleId) {
        modIconObj = this.moduleIcons[i];
        break;
      }
    }
    if (modIconObj != null) { this.currIdx = modIconObj.moduleIdx; }
  }

  this.scroll = function(direction) {    
    this.lastIconIdx = this.moduleIcons.length - 1;

    if (direction == "right") {
      this.currIdx = this.currIdx + 1;
      if (this.currIdx > this.lastIconIdx) {
        this.currIdx = this.lastIconIdx;        
      }
      this.iconVisited(this.currIdx - 1);
      this.iconCurrent(this.currIdx);
    }

    if (direction == "left") {
      this.currIdx = this.currIdx - 1;
      if (this.currIdx < 0) { 
        this.currIdx = 0;         
      }
      this.iconVisited(this.currIdx + 1);
      this.iconCurrent(this.currIdx);
    }

    onCategoryChange(this.moduleIcons[this.currIdx].moduleId);
  }

  this.scrollToModule = function(modIdx) {
    modIdx = eval(modIdx);

    if (modIdx == this.currIdx) { jumpScroller(); return; }
    else {
      this.iconVisited(this.currIdx);
      this.currIdx = modIdx;

      onCategoryChange(this.moduleIcons[this.currIdx].moduleId);      
      this.iconCurrent(modIdx);
      jumpScroller();
    }
  }

  this.scrollToConflictModule = function(modId) {
	  var modIconObj = null;
    var modIdx = 0;
    var i;
    for (i = 0; i < this.moduleIcons.length; i++)
    {
	    if (modId == this.moduleIcons[i].moduleId) {
        modIconObj = this.moduleIcons[i];
        modIdx = modIconObj.moduleIdx;
        break;
      }
    }

    if (_tabBar.currTabId == "tab3") {
      _tabBar.moveToTab('tab0', modId, modIdx);
      return;
    }

    if (vType == "lv") {
        scrollToAnchor(modId);
        return;
    }

    var overlayCompsObj = getAnElement("overlay-module-list-options-div");  
    if (overlayCompsObj != null) {
      if (overlayCompsObj.innerHTML.length > 0) {
        scrollToAnchor(modId);
        return;
      }
    }

	  this.scrollToModule(modIdx);
  }

  this.iconVisited = function(modIdx) {
    var oneModule = this.moduleIcons[modIdx];
      if (oneModule != null) {
      var modImg = MM_findObj(oneModule.moduleImgId);
      
      if (modImg != null) {
        modImg.src = oneModule.vImage;
      }
      oneModule.visited = true;
    }
  }

  this.iconCurrent = function() {
    var oneModule = this.moduleIcons[this.currIdx];
      if (oneModule != null) {
      var modImg = MM_findObj(oneModule.moduleImgId);
      
      if (modImg != null) {
        modImg.src = oneModule.hImage;
      }
      oneModule.visited = false;
      oneModule.current = true;
    }
  }

  this.iconMouseOver = function(modIdx) {
    var oneModule = this.moduleIcons[modIdx];
    if (oneModule != null) {
      var modImg = MM_findObj(oneModule.moduleImgId);
      if (modImg != null) {
        modImg.src = oneModule.hImage;
      }
    }
  }

  this.iconMouseOut = function(modIdx) {
    var oneModule = this.moduleIcons[modIdx];
    if (oneModule != null) {
      var modImg = MM_findObj(oneModule.moduleImgId);
      if (modImg != null) {
        if (oneModule.visited) {
          modImg.src = oneModule.vImage;
        }      
        else {
          if (oneModule.current == false) { 
            modImg.src = oneModule.gImage;
          }
        }
      }
    }
  }

  this.handleButton = function() {
    var titleLen = 25;
    this.lastIconIdx = this.moduleIcons.length - 1;
    
    // pre
    if (this.currIdx <= 0) {
      updateShowHide('mod_pre_div', false);      
    }

    if (this.currIdx > 0) {
      updateShowHide('mod_pre_div', true);
      var preModTitle = this.moduleIcons[this.currIdx - 1].moduleIconTitle;
      var preTxtNode = getAnElement("pre_txt");
      if (preModTitle.length >= titleLen) {
         preModTitle = preModTitle.substring(0,titleLen) + "&hellip;";
      }
      if (preTxtNode != null) {
        preTxtNode.innerHTML = preModTitle;
      }      
    }

    if (this.currIdx == 0) {
      updateShowHide('pre-html-btn1', false);
      updateShowHide('pre-html-btn2', false);
      handleModulePrevHtmlBtn('show');
    }
    else {
      updateShowHide('pre-html-btn1', false);
      updateShowHide('pre-html-btn2', false);
      handleModulePrevHtmlBtn('hide');
    }

    // next
    if (this.currIdx >= this.lastIconIdx) {
      updateShowHide('mod_nxt_div', false);
      //handleModuleNextHtmlBtn('show');
    }

    if (this.currIdx < this.lastIconIdx) {
      updateShowHide('mod_nxt_div', true);
      //handleModuleNextHtmlBtn('hide');
      var nxtModTitle = this.moduleIcons[this.currIdx + 1].moduleIconTitle;
      var nxtTxtNode = getAnElement("nxt_txt");
      if (nxtModTitle.length >= titleLen) {
        nxtModTitle = nxtModTitle.substring(0,titleLen) + "&hellip;";
      }
      if (nxtTxtNode != null) {
        nxtTxtNode.innerHTML = nxtModTitle;
      }      
    }

    if (this.currIdx == this.lastIconIdx) {
      updateShowHide('nxt-html-btn0', false);
      updateShowHide('nxt-html-btn1', false);
      updateShowHide('nxt-html-btn2', false);
      handleModuleNextHtmlBtn('show');
    }
    else {
      handleModuleNextHtmlBtn('hide');
    }

    moduleVisited();
  }
}

function ModuleIconObject(moduleIconTitle, moduleIconName, moduleId, isVisited) {
  this.moduleIconTitle = moduleIconTitle;
  this.moduleIconName = moduleIconName;
  this.moduleId = moduleId;
  this.moduleIdx = _moduleBar.moduleIcons.length;
  this.gImage = moduleIconName.replace('_l','_g');
  this.vImage = moduleIconName.replace('_l','_v');
  this.hImage = moduleIconName.replace('_l','_h');
  this.visited = false;
  this.current = false;
  this.moduleImgId = "mod_img_" + moduleId;  

  if (isVisited != null) {
    this.visited = isVisited;
  }
  this.modIconSpanTag = document.createElement("span");
  this.modIconImgTag = document.createElement("IMG");
  this.modIconImgTag.name = "mod_img_" + moduleId;
  this.modIconImgTag.id = "mod_img_" + moduleId;
  //this.modIconImgTag.className = "imageElement";
  //alert('moduleIconName : ' + moduleIconName + " this.visited : " + this.visited);
  if (this.visited)
    this.modIconImgTag.setAttribute("src", this.vImage);
  else
    this.modIconImgTag.setAttribute("src", this.gImage);
  
  this.modIconImgTag.setAttribute("width", "88");
  this.modIconImgTag.setAttribute("height", "71");
  this.moduleIconTitle = moduleIconTitle;

  /* this.modIconImgTag.setAttribute("onclick","_moduleBar.scrollToModule(" + this.moduleIdx + ");return false;_moduleBar.iconMouseClick(" + this.moduleIdx + ");");
  this.modIconImgTag.setAttribute("onmouseover","_moduleBar.iconMouseOver(" + this.moduleIdx + ");"); 
  this.modIconImgTag.setAttribute("onmouseout","_moduleBar.iconMouseOut(" + this.moduleIdx + ")");  */

  this.modIconImgTag["onclick"] = new Function("_moduleBar.scrollToModule(" + this.moduleIdx + ");");
  this.modIconImgTag["onmouseover"] = new Function("_moduleBar.iconMouseOver(" + this.moduleIdx + ");"); 
  this.modIconImgTag["onmouseout"] = new Function("_moduleBar.iconMouseOut(" + this.moduleIdx + ")");
    
  this.modIconSpanTag.appendChild(this.modIconImgTag);
  this.modulebarContainerTag = document.getElementById("module-bar-icons-div");
  this.modulebarContainerTag.appendChild(this.modIconImgTag);

  _moduleBar.moduleIcons[_moduleBar.moduleIcons.length] = this;  
}

// Module bar
var moduleIconList = null;

var _moduleBar = new ModuleBar();
var shouldAnchor = false;

// scroller
var menuwidth = 528
var menuheight = 71
var scrollspeed = 6
var iconWidth = 88;

var iedom = document.all||document.getElementById;

var actualwidth='';
var moduleBarIconsDivObj;
var windowLoaded = 0;
function initModuleScroller(){   
  moduleBarIconsDivObj = document.getElementById? document.getElementById("module-bar-icons-div") : document.all.module-bar-icons-div;
  //moduleBarIconsDivObj.innerHTML = document.getElementById("module-bar-icons-full-div").innerHTML;
  actualwidth = _moduleBar.moduleIcons.length * iconWidth; //document.all? moduleBarIconsDivObj.offsetWidth : document.getElementById("module-bar-icons-full-div").offsetWidth;

  resetScroller();
  if (_moduleBar.moduleIcons.length > 0) {
    //_moduleBar.iconCurrent();
  }
  windowLoaded = 1
}

/*function isWindowLoaded()
{
  windowLoaded = 1;
}
window.onload=isWindowLoaded */

function moveleft(){
  if (windowLoaded){
    var imgObj = MM_findObj('left-arrow');
    if (parseInt(moduleBarIconsDivObj.style.left) < 0) {
      moduleBarIconsDivObj.style.left = parseInt(moduleBarIconsDivObj.style.left)+scrollspeed+"px";
    }
    handleArrow();
  }
  righttime=setTimeout("moveleft()", 50);
}

function moveright() {
  if (windowLoaded){
    var imgObj = MM_findObj('right-arrow');
    if (parseInt(moduleBarIconsDivObj.style.left) > (menuwidth - actualwidth)) {
      moduleBarIconsDivObj.style.left = parseInt(moduleBarIconsDivObj.style.left)-scrollspeed+"px";      
    }
    handleArrow();
  }
  lefttime=setTimeout("moveright()", 50);  
}

function resetScroller() {
  moduleBarIconsDivObj.style.left = '0px';
  //jumpScroller();

  var rightArrObj = MM_findObj('right-arrow');
  var leftArrObj = MM_findObj('left-arrow');
  //leftArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/left_disabled.gif';
  leftArrObj.src = "http://hpshopping.speedera.net/www.shopping.hp.com/s.gif";
  if (actualwidth <= menuwidth) {
    rightArrObj.src = "http://hpshopping.speedera.net/www.shopping.hp.com/s.gif";
    //rightArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/right_disabled.gif';    
  }
  else {
    rightArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/right.gif';
  }
}

function jumpScroller() {
  var debugDiv = getAnElement("debug-div");  
  //_moduleBar.currIdx = jumpTo;

  var currModIdx = _moduleBar.currIdx;
  var modCount = 5;
  var modLen = _moduleBar.moduleIcons.length;
  var maxX = iconWidth * (modLen  - modCount);
  var inView = true;
  var haltAt;

  var currX = parseInt(moduleBarIconsDivObj.style.left) / _moduleBar.moduleWidth + currModIdx;
  if (currX < 0) {
	  haltAt = -((currModIdx) *_moduleBar.moduleWidth)      
	  inView = false;
  } else if (currX > (modCount) ) {
	  haltAt = ((  modCount * _moduleBar.moduleWidth)  - (_moduleBar.currIdx * _moduleBar.moduleWidth));      
	  inView = false;
  } 

  if (inView == false) {
     moduleBarIconsDivObj.style.left = haltAt + 'px';
     handleArrow();
  }
}

function stopModuleScroller(dir) {
  var delta = 10;
  var currPosX = parseInt(moduleBarIconsDivObj.style.left);
  currPosX = currPosX * -1;
  var currPosInt = Math.round(-1 * (currPosX / iconWidth));

  var debugDiv = getAnElement("debug-div");  

  if (dir == 'left') {
    clearTimeout(lefttime);
  }
  if (dir == 'right') {
    clearTimeout(righttime);
  }

  /* var movePos = currPosInt * iconWidth;
  if (movePos > 0) {
    movePos = movePos * -1;
  }    

  moduleBarIconsDivObj.style.left = movePos + 'px'; 
  handleArrow();*/

  /* currPosX = parseInt(moduleBarIconsDivObj.style.left);
  if (currPosX < movePos) 
    dir = 'left';
  else
    dir = 'right';
  motionScroll(movePos, dir); */ 

  //debugDiv.innerHTML = "currPosX : " + currPosX + " currPosInt : " + currPosInt + " movePos : " + movePos;
}

function handleArrow() {  
  var leftArrObj = MM_findObj('left-arrow');
  var rightArrObj = MM_findObj('right-arrow');
  var maxWidth = actualwidth;
  var currPosX = parseInt(moduleBarIconsDivObj.style.left);
  currPosX = parseInt(currPosX);

  var debugDiv = getAnElement("debug-div");
  debugDiv.innerHTML = "maxWidth : " + maxWidth + " currPosX : " + currPosX;

  if (currPosX < 0) {
    leftArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/left.gif';    
  }
  if (currPosX == 0) {
    //leftArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/left_disabled.gif';    
    leftArrObj.src = "http://hpshopping.speedera.net/www.shopping.hp.com/s.gif";
  }

  if (((currPosX * -1) + menuwidth) >= maxWidth) {
    //rightArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/right_disabled.gif';    
    rightArrObj.src = "http://hpshopping.speedera.net/www.shopping.hp.com/s.gif";
  }
  if (((currPosX * -1) + menuwidth) < maxWidth) {
    rightArrObj.src = 'http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/right.gif';    
  }
}
// ----

// common utils
function getAbsPosition(obj) {
	var pos = new Object;
	pos.x = 0;
	pos.y = 0;

	if (obj) {
		pos.x = obj.offsetLeft;
		pos.y = obj.offsetTop;

		if(obj.offsetParent) {
			var parentpos = getAbsPosition(obj.offsetParent);
			pos.x += parentpos.x;
			pos.y += parentpos.y;
		}
	}

	return pos;
}

function getAnElement(id) {
  return document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id];
}

function processResultsNodes(results) {
  isTimeOut(results);

  var y = 0;
  while (node = results[y++]) {
    updateInnerHtml(node);
  }
}

function isTimeOut(results) {
  if (results[0]) {
    if (results[0].TIME_OUT_VALUE != 'undefined') {
      if (results[0].TIME_OUT_VALUE == 'TIME_OUT') {
        window.location.href = timeOutURL;
      }
    }
  }
}

function updateInnerHtml(result) {      
  /* if (!result.content) {
      return;
  } */
    
  var newhtml = result.content;
  var multiple = result.mult;
  var id = result.id;

  //alert("id : " + id + " newhtml : " +  newhtml + " multiple : " + multiple);
  if (multiple && multiple == 'true') {
    var nodes = document.getElementsByName(id);
    var y = 0;
    while (el = nodes[y++]) {
      el.innerHTML = decodeHtml(newhtml);
    }
  }
  else {
  //alert(newhtml)
	var node = getAnElement(id);
    if (node) {      
      if (id.indexOf("-img") > -1) {
        node.src = newhtml;
      }
      else  { 
        node.innerHTML = decodeHtml(newhtml); 
      }
    }

	if(id == "module-learn-more-div")
	{
	  var ramMessage = document.getElementById("ramMessage");		
	  if(ramMessage!=null && ramMessage.style.visibility=="hidden")
	    ramMessage.style.display="none"   
 
	  var pcpUidId = document.getElementsByName("pcpUidId")[0];

	  if(pcpUidId!=null && pcpUidId.style.visibility!="hidden"){}
	  else {
	    var helpMeDecide = document.getElementById("helpMeDecidePopupId");
		var moduleLearn = document.getElementById("module-learn-more-div");
		if(helpMeDecide==null)	{
		  moduleLearn.style.display="none";
		}
		else {
		  moduleLearn.style.display="";
		}
	  } 
	}
  }

  // for dmpromo IE fix
  var dmPromoTagName = result.id;
  if (dmPromoTagName.indexOf(":dm_promo") > -1) {
    if (result.content == '') { 
      updateShowHide(dmPromoTagName, false);
    }
    else {
      updateShowHide(dmPromoTagName, true);
    }
  }

  // what's in
  handlerMyCompsHeader(result.id, result.content);
}

function updateShowHide(tagname, show) {
  var nodestyle;
  var nodes = document.getElementsByName(tagname);
  var y = 0;
  var node;
  while (node = nodes[y++]) {
    nodestyle = node.style;
    nodestyle.visibility = (show) ? "visible" : "hidden";
    nodestyle.display = (show) ? '' : "none";
  }
}

// cto specific response handling
function processSystemPrice(systemPrice) {
  var y = 0;
  while (node = systemPrice[y++]) {
    updateInnerHtml(node);

    var nodeDivId = node.id;
    var nodeTrId = nodeDivId.replace('div', 'tr');
    var show = false;

    if (node.visible == 'true') {
      show = true;
    }

    updateShowHide(nodeTrId, show);

    if (nodeTrId == 'your-price-tr') {
      updateShowHide("your-price-tr", show);
      if (show) {
        getAnElement('epp-price-tr').style.color = '#000000';
        //getAnElement('priceBlock').style.fontSize = '10px';
        getAnElement('epp-price-tr').style.fontWeight = '';
        getAnElement('epp-price-label').innerHTML = 'Price';

        getAnElement('epp-price-div').style.color = 'black';
        getAnElement('epp-price-div').style.fontSize = '12px';
        getAnElement('epp-price-div').style.fontWeight = '';
      }
      else {
        //getAnElement('epp-price-tr').style.color = '#cc0000';
        getAnElement('epp-price-tr').style.fontSize = '15px';
        getAnElement('epp-price-tr').style.fontWeight = 'bold';
        getAnElement('epp-price-label').innerHTML = 'Total:';

        getAnElement('epp-price-div').style.color = '#c00';
        getAnElement('epp-price-div').style.fontSize = '142%';
        getAnElement('epp-price-div').style.fontWeight = 'bold';
      }
    }

    if (nodeTrId == 'you-saved-tr') {
      updateShowHide("you-saved-tr", show);
      if (show) {
        getAnElement('rebatePriceLine1').style.display = '';
      }
      else {
        getAnElement('rebatePriceLine1').style.display = 'none';
      }
    }

    if (nodeTrId == 'efin-promo-msg-tr') {
      updateShowHide("efin-promo-msg-tr", show);
    }
  }
}

function processModuleIconList(moduleIconList) {
  if (moduleIconList) {
    var modIconContentDiv = document.getElementById("module-bar-icons-div");    
    if (modIconContentDiv) {
      modIconContentDiv.innerHTML = "";
      //movetop();        
    }  
    
    var y = 0;
    var el;
    while (el = moduleIconList[y++]) {
        eval(el);
    }

    _moduleBar.initModule();
    initModuleScroller();
  }
}

function onTabComplete(objHttpRequest) {
  if (objHttpRequest) {
    var resp = objHttpRequest.responseText;
    eval(resp);
    processResultsNodes(results);
    processSystemPrice(systemPrice);
    processResultsNodes(selectionList);
    if (moduleIconList != null) {
      processModuleIconList(moduleIconList);
      initModuleScroller();
      _moduleBar.setCurrModIdxById(_lastMod);
      _moduleBar.iconCurrent();
    }
  }

  handleTabContent(_tabBar.newTabId);        
  _tabBar.setActiveTab(_tabBar.newTabId);
  moduleVisited();
  updateBtnNav();
  _moduleBar.handleButton(); // moved
  displayViewToggler(_tabBar.currTabId);    
  
  scrollRightDiv();
  //resizeMyCompsDiv();    
  resizeXsells();
  if(typeof postOmniData == 'function') {
    postOmniData();
  } 
}

function onComponentOrModuleComplete(objHttpRequest) {
  if (objHttpRequest) {
    var resp = objHttpRequest.responseText;
    eval(resp);
    processResultsNodes(results);
    processSystemPrice(systemPrice);
    processResultsNodes(selectionList);
    _moduleBar.handleButton(); // moved

    if (vType == 'dv') {
      updateShowHide("module-options-div", true);
      updateShowHide("module_video", false);
    }

    resizeMyCompsDiv();

    if (vType == 'dv') {
      if (_lastAction == 'mc') {
        resizeMyConfigModules();
      }
      if (_lastAction == 'cc') {
        resizeXsells();
      }    
    }
  }
}

function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}

function handlerMyCompsHeader(id, cnt) {
  if ((id == 'my-components-div') || (id == 'my-accessories-div') || (id == 'my-addons-div')) {
    if (cnt != null && cnt.length > 0)
      updateShowHide(id + '-header', true);
    else
      updateShowHide(id + '-header', false);
  }
}

function resizeMyCompsDiv() {
 /* var tabId = _tabBar.currTabId;
  var resize = false;

  if (tabId == 'tab-1' || tabId == 'tab3') {
    resize = true;
  }
  
  if (tabId == 'tab0' || tabId == 'tab1' || tabId == 'tab2') {
    if (vType == 'dv') {
      resize = true;
    }
    else {
      getAnElement('whats-in-cnt-div').style.height = '200px';
    }
  }

  if (resize) {
    //alert(parseInt(document.getElementById('config-table').offsetHeight));
    var tableHeight = parseInt(document.getElementById('config-table').offsetHeight);

    var pos = getAbsPosition(getAnElement("whats-in-cnt-div"));
    var whatCntY = parseInt(pos.y);
    //alert(whatCntY);

    var whatsHight = (tableHeight - whatCntY) - 25;
    //getAnElement('whats-in-cnt-div').style.height = whatsHight + 'px;';
  } */ 
}

function resizeXsells() {
  var resWidth = screen.width;
  var resHeight = screen.height;
 
  var xsellDivVisible = isXSellDivVisible();
  if (resHeight <= 768) {
    if (xsellDivVisible) {
      getAnElement('module-options-div').style.height =  '100%'; //opsHeight + 'px;';
      return;
    }
    else {
      resizeMyConfigModules();
      return;
    }
  }
  else {
    resizeMyConfigModules();
    return;
  }
}

function resizeMyConfigModules() {
  var vpWidth, vpHeight;
  var padBottom = 110;
  var minHeight = 245;
  var resWidth = screen.width;
  var resHeight = screen.height;
  
  /*if (resHeight <= 768) {
    getAnElement('module-options-div').style.height =  '100%'; //opsHeight + 'px;';
    return;
  } */

  if (self.innerHeight) { // all except Explorer
    vpWidth = self.innerWidth;
    vpHeight = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
    vpWidth = document.documentElement.clientWidth;
    vpHeight = document.documentElement.clientHeight;
  }
  else if (document.body) { // other Explorers
    vpWidth = document.body.clientWidth;
    vpHeight = document.body.clientHeight;
  }  

  var pos = getAbsPosition(getAnElement("module-options-div"));
  var posY = parseInt(pos.y);
  
  getAnElement('module-options-div').style.height =  '170px'
  var moduleOpsObj = getAnElement("module-options-div");
  var vScroll = false;
  var opsHeight = moduleOpsObj.scrollHeight;
  var setHeight;
  if ((posY + opsHeight + padBottom) > vpHeight) { // need to adjust the height now
    setHeight = vpHeight - padBottom - posY;
    if (setHeight < minHeight) {
      setHeight = minHeight;
    }
    getAnElement('module-options-div').style.height = setHeight + 'px';
  }
  else {
    getAnElement('module-options-div').style.height =  '100%'; //opsHeight + 'px;';
  }

  if (moduleOpsObj.clientHeight < moduleOpsObj.scrollHeight) 
    vScroll = true;
  else 
    vScroll = false;

  /* var debugDiv = getAnElement("debug-div");
  debugDiv.innerHTML = "vpHeight : " + vpHeight + " posY : " + posY + " opsHeight : " + opsHeight + " setHeight : " + setHeight 
                       + " moduleOpsObj.scrollHeight : " + moduleOpsObj.scrollHeight; */
}

var baseUrl = '';
var appendUniqueId = false;
var idResponseNode = 'responseDiv';
var waitMsg = 'Please wait ...';
var _currCat = '';
var _currParent = '';

function handleKey(e) {
  var pKey = document.all? window.event.keyCode:e.which;

  if (pKey == 32 || pKey == 9 || pKey == 13 || pKey == 37 || pKey == 38 || pKey == 39 || pKey == 40 || pKey == 0) {
    return false;
  } else {  
    return true;
  }
}

function disableKeyPress() {
  document.onkeypress = handleKey;
  document.onkeydown = handleKey;
  document.onkeyup = handleKey;
}

function enableKeyPress() {
  document.onkeypress = '';
  document.onkeydown = '';
  document.onkeyup = '';
}

function onParentComponentChange(form, catId, compId, compIndex) {
  showOverlayDelay();
  if (helpmeDecideWindowObj != null) {
    helpmeDecideWindowObj.close();
  }
  
  _lastAction = 'cc';
  var params = ""; //"?";
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=pc" + "&";

  params += "catId" + "=" + catId + "&";
  params += "compId" + "=" + compId + "&";
  params += "compIndex" + "=" + compIndex + "";    

  _currCat = catId;
  _currParent = catId;
  toggleVista(form, catId, compId, compIndex);
  SendHttpRequest(baseUrl, params, onParentComponentComplete, waitMsg, false);
}

function onParentComponentComplete(objHttpRequest) {
  if (objHttpRequest) {
    var resp = objHttpRequest.responseText;
    eval(resp);
    processResultsNodes(results);
    processSystemPrice(systemPrice);
    processResultsNodes(selectionList);
    _moduleBar.handleButton(); // moved

    var overlayCompsObj = getAnElement("overlay-module-list-options-div");  
    if (overlayCompsObj != null) {
      if (overlayCompsObj.innerHTML.length > 0) {
        showOverlayCnt();
      }
      else {
        hideOverlayCnt();
      }
    }
    /* if (vType == 'dv') {
      updateShowHide("module-options-div", true);
      updateShowHide("module_video", false);
    } */

    /* resizeMyCompsDiv();

    if (vType == 'dv') {
      if (_lastAction == 'mc') {
        resizeMyConfigModules();
      }
      if (_lastAction == 'cc') {
        resizeXsells();
      }     
    }*/
  }
}

function onOverlayAction(form, overlayAction) {
  //_lastAction = 'cc';
  showOverlayDelay();
  var params = ""; //"?";
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=" + overlayAction + "&"; // oct or oca

  params += "catId" + "=" + _currParent;
  /* params += "compId" + "=" + compId + "&";
  params += "compIndex" + "=" + compIndex + "";     */

  //_currCat = catId;
  // toggleVista(form, catId, compId, compIndex);
  SendHttpRequest(baseUrl, params, onOverlayActionComplete, waitMsg, false);
}

function onOverlayActionComplete(objHttpRequest) {
  if (objHttpRequest) {
    var resp = objHttpRequest.responseText;
    eval(resp);
    processResultsNodes(results);
    processSystemPrice(systemPrice);
    processResultsNodes(selectionList);
    _moduleBar.handleButton(); // moved

    var overlayCompsObj = getAnElement("overlay-module-list-options-div");  
    if (overlayCompsObj != null) {
      overlayCompsObj.innerHTML = "";
    }
    hideOverlayCnt();

    /* if (vType == 'dv') {
      updateShowHide("module-options-div", true);
      updateShowHide("module_video", false);
    } */

    /* resizeMyCompsDiv();

    if (vType == 'dv') {
      if (_lastAction == 'mc') {
        resizeMyConfigModules();
      }
      if (_lastAction == 'cc') {
        resizeXsells();
      }     
    }*/
  }
}

// begin overlay
function setOverlayHeight() {
  var btmPos = getAbsPosition(getAnElement("bid"));
  if (btmPos != null) {
    var btmY = parseInt(btmPos.y);
    var btmX = parseInt(btmPos.x);

    var posFixed = false;
    if (bAgent.ie4 || bAgent.ie5 || bAgent.ie55 || bAgent.ie6) {
      posFixed = false;
    }
    else {
      posFixed = true;
    }

    var overObj = getAnElement("overlay");
    if (overObj != null) {
      overObj.style.height = btmY + 'px';
      if (posFixed == false) {
        overObj.style.width = parseInt(document.body.clientWidth) + 'px'; //parseInt(window.screen.width) + 'px';
      } else {
        overObj.style.position = 'fixed';
      }
    }
  }  
}

function setOverlayHeightCC() {
  var btmPos = getAbsPosition(getAnElement("size-marker")); // continueBtn  
  if (btmPos != null) {
    var btmY = parseInt(btmPos.y);
  
    var overObj = getAnElement("overlay");
    if (overObj != null) {
      if (btmY != -1) {
        overObj.style.height = btmY + 'px';
        overObj.style.width = parseInt(window.screen.width) + 'px';
      }      
    }  
  }  
}


function showOverlayDelay() {
  if (helpmeDecideWindowObj != null) {
    helpmeDecideWindowObj.close();
  }

  //scroll(0,0);
  window.location = "#" + 'anchor-top';
  disableKeyPress();
  var overlayDelayObj = getAnElement("overlay-delay");

  updateShowHide("overlay", true);
  updateShowHide("overlayCnt", false);
  updateShowHide("overlay-delay", true);
}

function showOverlayCnt() {
  updateShowHide("overlay-delay", false);
  updateShowHide("overlayCnt", true);
}

function hideOverlayCnt() {
  enableKeyPress();
  updateShowHide("overlay-delay", false);
  updateShowHide("overlayCnt", false);
  updateShowHide("overlay", false);
}
// end overlay

function onComponentChange(form, catId, compId, compIndex) {
  _lastAction = 'cc';
  var params = ""; //"?";
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=cc" + "&";

  params += "catId" + "=" + catId + "&";
  params += "compId" + "=" + compId + "&";
  params += "compIndex" + "=" + compIndex + "";    

  _currCat = catId;
  toggleVista(form, catId, compId, compIndex);
  SendHttpRequest(baseUrl, params, onComponentOrModuleComplete, waitMsg, false);
}

function onXsellComponentChange(form, catId, compId, xsellId, compIndex) {
  _lastAction = 'xc';
  var params = ""; //"?";
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=xc" + "&";

  params += "catId" + "=" + catId + "&";
  params += "compId" + "=" + compId + "&";
  params += "compIndex" + "=" + compIndex + "&";    
  params += "xsellId" + "=" + xsellId + "";

  SendHttpRequest(baseUrl, params, onComponentOrModuleComplete, waitMsg, false);
}

function onCategoryChange(catId) {
  _lastAction = 'mc';
  _lastMod = catId;
  var params = ""; //"?";
  var d = new Date();
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=mc" + "&";
  params += "get_cat" + "=" + catId + "";

  updateModuleIdInTab(catId);

  var modIdx = _moduleBar.currIdx;
  var histFrame = document.getElementById("historyFrame");
  var page_id = _tabBar.currTabId.replace('tab', '');
  if (histFrame != null) {
    histFrame.src = "/shopping/jsi/historyFrame.htm?" + d.getTime() + '&config_action=mc' + "&page_id=" + page_id + '&get_cat=' + catId + '&modIdx=' + modIdx + "&vType=" + vType;
  }
  
  SendHttpRequest(baseUrl, params, onComponentOrModuleComplete, waitMsg, false);  
}

function onTabChange(pageId, catId, modIdx) {
  _lastAction = 'tc';
  _lastMod = catId;
  _currCat = catId;
  var params = ""; //"?";
  var d = new Date();
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=tc" + "&";
  params += "page_id" + "=" + pageId + "&";
  params += "get_cat" + "=" + catId + "&";
  params += "modIdx" + "=" + modIdx + "";  
  
  var histFrame = document.getElementById("historyFrame");
  if (histFrame != null) {
    histFrame.src = "/shopping/jsi/historyFrame.htm?" + d.getTime() + '&config_action=tc' + '&page_id=' + pageId + '&get_cat=' + catId + '&modIdx=' + modIdx  + "&vType=" + vType;
  }
  
  SendHttpRequest(baseUrl, params, onTabComplete, waitMsg, false);  
}

function onTabHChange(pageId, catId, modIdx) {
  _lastAction = 'tc';
  _lastMod = catId;
  var params = ""; //"?";
  var d = new Date();
  params += "conf=" + conversationId + "&";
  params += "baseId=" + baseId + "&";
  params += "config_mode=" + vType + "&";
  params += "config_action=tc" + "&";
  params += "page_id" + "=" + pageId + "&";
  params += "get_cat" + "=" + catId + "&";
  params += "modIdx" + "=" + modIdx + "";  
  
  SendHttpRequest(baseUrl, params, onTabComplete, waitMsg, false);  
}

function onHistoryTabChange(tabId, nvType, pageId, catId, modIdx) {
  var overlayCompsObj = getAnElement("overlay-module-list-options-div");  
  if (overlayCompsObj != null) {
    if (overlayCompsObj.innerHTML.length > 0) {
      // no back
      onOverlayAction(this.form, 'oca');
    }
    else
    {
      if (nvType != vType) {
        vType = nvType;   
      }

    _tabBar.onHistClick(tabId);  
    onTabHChange(pageId, catId, modIdx);
    }
  }
}

function updateModuleIdInTab(modId) {
  var tabId = _tabBar.currTabId;

  var tabObj = _tabBar.getTabObj(tabId);
  tabObj.modId = modId;
}

function toggleVista(form, catId, compId, compIndex) {
  var vistaDiv = catId + "-" + compId + "-vista-div";

  if (getAnElement(vistaDiv) != null)
  {
    var btnType = '';
    var show = false;
    
    var fld = form.elements[catId];
    if (fld.length > 0) { // radio or identically named checkboxes
      btnType = fld[compIndex].type;
    }
    else {
      show = fld.checked;
      btnType = fld.type;
    }

    if (btnType == 'checkbox')
    {
      show = fld[compIndex].checked;
    }

    if (getAnElement(vistaDiv) != null) {
      updateShowHide(vistaDiv, true);      
    }

    if (btnType == 'radio') {    
      if (fld.length > 0) {
        for (var i = 0; i < fld.length; i++) { 
          if (compId != "c_" + i) {
            vistaDiv = catId + "-" + "c_" + i + "-vista-div";

            updateShowHide(vistaDiv, false);
          }
        }
      }
    }
  }
}

function isXSellDivVisible() {
  getAnElement('debug-div').innerHTML = '';

  var form = document.forms["ctoForm"];
  var catId = _currCat;
  var divName = ':xsell_content_div';

  var xsellDivVisible = false;
  if (catId != '') {
    //var form = document.forms["ctoForm"];
    if (form != null){
      var fld = form.elements[catId];
      if (fld != null) {
        var len = fld.length;
        if (len > 0) {
          for (var i = 0; i < len; i++) { 
            var xsellCntDivId = catId + ":" + "a_" + i + divName;
            var xsellCntDiv = getAnElement(xsellCntDivId);
            if (xsellCntDiv != null) {
              var xsellCntDivStyle = xsellCntDiv.style;
              //getAnElement('debug-div').innerHTML =  getAnElement('debug-div').innerHTML + " , " + " Found xsellCntDivId : " + xsellCntDivId + " xsellCntDivStyle.visibility : " + xsellCntDivStyle.visibility;
              if (xsellCntDivStyle.visibility != 'hidden' && xsellCntDivStyle.display != 'none') {
                xsellDivVisible = true; // atleast one xsells are visible
                break;
              }
            }          
          } // end for
        }
      }
    }
  }

  return  xsellDivVisible;
}

function toggleXSellDiv(form, catId, compId, compIndex) {
  var xsellDiv = catId + ":" + compId + ":xsell_div";
  var xsellBar = catId + ":" + compId + ":xsbar";
  var xsellMWSDiv = catId + ":" + compId + ":mws";
  var btnType = '';
  var show = false;
  
  var fld = form.elements[catId];
  if (fld.length > 0) { // radio or identically named checkboxes
    btnType = fld[0].type;
    if (btnType == 'radio') {
      show = fld[compIndex + 1].checked;
    }
    if (btnType == 'checkbox') {
      show = fld[compIndex].checked;
    }
  }
  else {
    show = fld.checked;
    btnType = fld.type;
  }

  /* if (btnType == 'checkbox')
  {
    show = fld[compIndex].checked;
  } */

  if (getAnElement(xsellBar) != null) {
    var xBarStyle = getAnElement(xsellBar).style;

    updateShowHide(xsellBar, show);
    updateShowHide(xsellDiv, show);     
    updateShowHide(xsellMWSDiv, show);    
  }

  if (btnType == 'radio') {    
    if (fld.length > 0) {
      for (var i = 0; i < fld.length; i++) { 
        if (compId != "a_" + i) {
          xsellBar = catId + ":" + "a_" + i + ":xsbar";
          xsellDiv = catId + ":" + "a_" + i + ":xsell_div";
          xsellMWSDiv = catId + ":" + "a_" + i + ":mws";
          updateShowHide(xsellBar, false);
          updateShowHide(xsellDiv, false);     
          updateShowHide(xsellMWSDiv, false);
        }
      }
    }
  }
}

function toggleCrossSellContentDiv(form, catId, compId, compIndex) {
  var xsellDiv = catId + ":" + compId + ":xsell_content_div";
  var xsellMWSDiv = catId + ":" + compId + ":mws";
  var node = getAnElement(xsellDiv).style;
  var show = false;

  if (node.display == 'none') {
    show = true;
  }
  updateShowHide(xsellDiv, show);
  updateShowHide(xsellMWSDiv, show);

  var xsellAnchor = catId + ":" + compId + ":xsell_anchor";
  var anchorLabel;
  var anchorImg;
  
  node = getAnElement(xsellAnchor);
  node.innerHTML = (show) ? "hide accessories" : "show accessories";

  var xsellAnchorImg = catId + ":" + compId + ":xsell_aimg";
  var anchorImg = MM_findObj(xsellAnchorImg);
  anchorImg.src = (show) ? "http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/close.gif" 
                           : "http://hpshopping.speedera.net/www.shopping.hp.com/shopping/images/cto/show.gif";

  resizeXsells();
}

function onClickMyComponents(tabId, modId, modIdx) {
  if (tabId == _tabBar.currTabId) {
    if (vType == "lv") {
      scrollToAnchor(modId);
      return;
    }
    else {
      _moduleBar.scrollToModule(modIdx);
    }
  }
  else {
    _tabBar.moveToTab(tabId, modId, modIdx);
  }
}

function scrollToAnchor(modId) {
  if (modId != '') {
    window.location = "#" + 'anchor-' + modId;
  }
  else {
    scroll(0,0);
    //window.location = "#";
  }
}

function handleTabContent(newTabId) {
  if (newTabId == "tab-1") {
    updateShowHide("config-overview-div", true);
    updateShowHide("module-total-div", true);          
    updateShowHide("whats-in-div", true);    
    updateShowHide("blank-module-bar-td", true); 
    updateShowHide("continue_btn", true);
    updateShowHide("checkout_btn", true);
    
    updateShowHide("config-list-modules-div", false);
    updateShowHide("module-bar-td", false);          
    updateShowHide("config-modules-div", false);
    updateShowHide("config-review-div", false);
    updateShowHide("review-right-div", false);
    updateShowHide("bottom-nav-div", false);
    updateShowHide("add_btn", false);
    updateShowHide("continueTr", false);
    changeBgColor('#FFFFFF');
  }
  else if (newTabId == "tab3") {
    updateShowHide("config-review-div", true);
    updateShowHide("review-right-div", true);
    updateShowHide("module-total-div", true); 
    updateShowHide("blank-module-bar-td", true);
    updateShowHide("add_btn", true);
    
    updateShowHide("config-list-modules-div", false);
    updateShowHide("config-overview-div", false);          
    updateShowHide("module-bar-td", false);          
    updateShowHide("config-modules-div", false);
    updateShowHide("whats-in-div", false);   
    updateShowHide("bottom-nav-div", false);
    updateShowHide("checkout_btn", false);
    updateShowHide("continue_btn", false);
    updateShowHide("continueTr", false);
    changeBgColor('#FFFFFF');
  }
  else { // tab0/1/2
    if (vType == 'dv')
    {
      updateShowHide("config-modules-div", true);
      updateShowHide("module-bar-td", true);
      updateShowHide("bottom-nav-div", true);
      updateShowHide("config-list-modules-div", false);
      updateShowHide("blank-module-bar-td", false);
      updateShowHide("module-options-div", true);
      updateShowHide("module_video", false);
      updateShowHide("continueTr", false);
      changeBgColor('#FFFFFF');

      initModuleScroller();
    }

    if (vType == 'lv')
    {
      updateShowHide("config-list-modules-div", true);
      updateShowHide("config-modules-div", false);
      updateShowHide("module-bar-td", false);
      updateShowHide("bottom-nav-div", false);
      updateShowHide("blank-module-bar-td", true);
      updateShowHide("continueTr", true);
      changeBgColor('#E7E7E7');

      var speciaOffer = getAnElement('module-list-promos-div');
      if (speciaOffer != null) {
        var specialOfferCnt = speciaOffer.innerHTML
        if (specialOfferCnt.length <= 0) {
          updateShowHide("module-list-header", false);
        }
        else {
          updateShowHide("module-list-header", true);
        }
      }

      //scrollRightDiv();
    }
                  
    updateShowHide("module-total-div", true);          
    updateShowHide("whats-in-div", true);     
    updateShowHide("continue_btn", true);
    updateShowHide("checkout_btn", true);
        
    updateShowHide("config-overview-div", false);
    updateShowHide("config-review-div", false);
    updateShowHide("review-right-div", false);
    updateShowHide("add_btn", false);
  }  
}

function changeBgColor(color) {  
    var oneRowObj = MM_findObj('rc1');
    oneRowObj.style.backgroundColor = color;
    oneRowObj = MM_findObj('rc2');
    oneRowObj.style.backgroundColor = color;
    oneRowObj = MM_findObj('rc3');
    oneRowObj.style.backgroundColor = color;
}

function displayViewToggler(tabId) {
  if (tabId != 'tab-1' && tabId != 'tab3') {
    if (vType == 'dv') {
      updateShowHide("switch-to-dv", false);
      updateShowHide("switch-to-lv", true);
    }
    else if (vType == 'lv')
    {
      updateShowHide("switch-to-dv", true);
      updateShowHide("switch-to-lv", false);
    }
  }
  else {
    updateShowHide("switch-to-dv", false);
    updateShowHide("switch-to-lv", false);
  }
}

function updateBtnNav() {
  var tabId = _tabBar.currTabId;

  if (tabId == 'tab-1') {
    updateShowHide("pricer-btn-nav", false);
  }
  else {
    updateShowHide("pricer-btn-nav", true);
  }

  if (tabId == 'tab0') {    
    updateShowHide("tab0-btns", true);
    updateShowHide("tab1-btns", false);
    updateShowHide("tab2-btns", false);
    updateShowHide("tab3-btns", false);

    if (vType == 'lv') {
      updateShowHide("tab0-header-txt-div", true);
      updateShowHide("tab1-header-txt-div", false);
      updateShowHide("tab2-header-txt-div", false);
    }
  }

  if (tabId == 'tab1') {
    updateShowHide("tab0-btns", false);
    updateShowHide("tab1-btns", true);
    updateShowHide("tab2-btns", false);
    updateShowHide("tab3-btns", false);

    if (vType == 'lv') {
      updateShowHide("tab0-header-txt-div", false);
      updateShowHide("tab1-header-txt-div", true);
      updateShowHide("tab2-header-txt-div", false);
    }
  }

  if (tabId == 'tab2') {
    updateShowHide("tab0-btns", false);
    updateShowHide("tab1-btns", false);
    updateShowHide("tab2-btns", true);
    updateShowHide("tab3-btns", false);

    if (vType == 'lv') {
      updateShowHide("tab0-header-txt-div", false);
      updateShowHide("tab1-header-txt-div", false);
      updateShowHide("tab2-header-txt-div", true);
    }
  }

  if (tabId == 'tab3') {
    updateShowHide("tab0-btns", false);
    updateShowHide("tab1-btns", false);
    updateShowHide("tab2-btns", false);
    updateShowHide("tab3-btns", true);
	        
    enableOrDisableBtn('addToCartBtn', 1);
    enableOrDisableBtn('checkoutBtn', 1);

    if (document.getElementById("conflict-msg-div").innerHTML.length > 0) {
      enableOrDisableBtn('addToCartBtn', 0);
      enableOrDisableBtn('checkoutBtn', 0);
    }
  }
}

function enableOrDisableBtn(id, state) {
  var btnObj = getAnElement(id);
  if (btnObj != null) {
    if (state == true) {
      if (id == 'addToCartBtn') {
        btnObj.className = 'commButton fr m0505';
      } else if (id == 'checkoutBtn') {
        btnObj.className = 'commButton mt10';
      } else {
        btnObj.style.backgroundColor = 'red';
        btnObj.style.borderBottom = '#c00 2px solid';
        btnObj.style.borderLeft = '#ff9899 2px solid';
        btnObj.style.borderRight = '#c00 2px solid';
        btnObj.style.borderTop = '#ff9899 2px solid';
        btnObj.style.borderStyle = 'solid';
        btnObj.style.color = '#FFFFFF';
        btnObj.style.borderWidth = '2px';
      }
      btnObj.disabled = false;
    }
    else {  // disable
      if (id != 'addToCartBtn' && id != 'checkoutBtn') {
        btnObj.style.backgroundColor = '#ccc';
        btnObj.style.borderBottom = '#999 2px solid';
        btnObj.style.borderLeft = '#e7e7e7 2px solid';
        btnObj.style.borderRight = '#999 2px solid';
        btnObj.style.borderTop = '#e7e7e7 2px solid';
        btnObj.style.borderStyle = 'solid';
        btnObj.style.color = '#666';
        btnObj.style.borderWidth = '2px';
      }
      btnObj.disabled = true;
    }
  }
}

function handleModuleNextHtmlBtn(btnState) {
  var tabId = _tabBar.currTabId;
  var currTabNum = -1;

  if (tabId.indexOf('-1') > -1) currTabNum = -1;
  if (tabId.indexOf('0') > -1) currTabNum = 0;
  if (tabId.indexOf('1') > -1) currTabNum = 1;
  if (tabId.indexOf('2') > -1) currTabNum = 2;
  var nextBtnId = 'nxt-html-btn' + currTabNum;

  if (btnState == 'show') {
    updateShowHide(nextBtnId, true);
  }

  if (btnState == 'hide') {
    updateShowHide(nextBtnId, false);
  }
}

function handleModulePrevHtmlBtn(btnState) {
  var tabId = _tabBar.currTabId;
  var currTabNum = -1;

  if (tabId.indexOf('-1') > -1) currTabNum = -1;
  if (tabId.indexOf('0') > -1) currTabNum = 0;
  if (tabId.indexOf('1') > -1) currTabNum = 1;
  if (tabId.indexOf('2') > -1) currTabNum = 2;
  var prevBtnId = 'pre-html-btn' + currTabNum;

  if (btnState == 'show') {
    updateShowHide(prevBtnId, true);
  }

  if (btnState == 'hide') {
    updateShowHide(prevBtnId, false);
  }
}


// scroll right pricer div

var ns4=document.layers?1:0
var ie4=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xParent(e,bNode){
  //if (!(e=xGetElementById(e))) return null;
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  else if (xDef(e.parentLayer)){if (e.parentLayer!=window) p=e.parentLayer;}
  return p;
}

function xPageY(e) {
  //if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.pageY)) return e.pageY;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xParent(e);
  }
  return y;
}

function slider() {  
  var tabId = _tabBar.currTabId;
  if ((tabId == 'tab0' || tabId == 'tab1' || tabId == 'tab2') && (vType == 'lv')) {
    var exeFixed = false;
    if (bAgent.ie4 || bAgent.ie5 || bAgent.ie55 || bAgent.ie6) {
      exeFixed = false;
    }
    else {
      exeFixed = true;
    }

    //if ((bAgent.b != 'MSIE') && (site != "call_center"))
    if ((exeFixed) && (site != "call_center"))
    {     
      var mm = document.getElementById('sliderMarker');
      var my = 0;
      my = (document.body.scrollTop > 0) ? document.body.scrollTop : my;
      my = (document.documentElement.scrollTop > 0) ? document.documentElement.scrollTop : my;
      var mmy = xPageY(mm);

      if (my < mmy)
        my = mmy;
      else
        my = my + 10;

      var continueBtnPos = getAbsPosition(getAnElement("continueBtn"));
      var cntBtnY = parseInt(continueBtnPos.y);
      if (my > cntBtnY) {
        my = cntBtnY;
      }

      var sdiv = document.getElementById("slider");
      if (my != mmy) {  	
        sdiv.style.position = 'fixed';
        sdiv.style.top = '0';
        sdiv.style.width = '21.5%'; //'23.5%';
      }
      else {
        sdiv.style.position = 'relative';
        sdiv.style.width = '100%';
      }      
      
      var lm = document.getElementById('config-list-modules-div');
      //lm.style.width='75%';

      setTimeout("slider()", 200);
    } // end ie7/ff main

    if (site == "call_center")  // ((bAgent.b == 'MSIE') && (site == "call_center")) 
    {
      var sw = document.getElementById('slider');
      sw.style.width='230px';
      var mm = document.getElementById('sliderMarker');
      var my = 0;
      //my = (document.body.scrollTop > 0) ? document.body.scrollTop : my;
      //my = (document.documentElement.scrollTop > 0) ? document.documentElement.scrollTop : my;
      my = document.getElementById('right').scrollTop;  // for tomi    
            
      var mmy = xPageY(mm);

      if (mmy > my) {
        my = mmy - 115;
      }

      //getAnElement('debug-div').innerHTML = 'mmy : ' + mmy + ' my : ' + my;
      with (document.getElementById('slider').style) {
        position = 'absolute';    
      }

      var sliderObj = document.getElementById('slider');
      if (ie4) {sliderObj.style.pixelTop = my;}
      else if (ns6) {document.getElementById("slider").style.top = my + "px";}

      setOverlayHeightCC();

      setTimeout("slider()",200);
    } // end call_center
  }    
}

function scrollRightDiv() {
  var tabId = _tabBar.currTabId;
  if (tabId != null) {
    var sdiv = document.getElementById('slider');
    if (tabId == 'tab-1' || tabId == 'tab3') {      
      //sdiv.style.position = 'relative';      
      with (document.getElementById('slider').style) {
          position = 'relative';   
          sdiv.style.top = '0';
          sdiv.style.width = '100%';
          scrollToAnchor('');
      }
      sdiv.style.height = '';
    }
    else if (vType == 'dv') {
      if (tabId == 'tab0' || tabId == 'tab1' || tabId == 'tab2') {
        with (document.getElementById('slider').style) {
          position = 'relative';   
          sdiv.style.top = '0';        
        }
      }
      sdiv.style.height = '';
    }
    else if (vType == 'lv') {    
      if (tabId == 'tab0' || tabId == 'tab1' || tabId == 'tab2') {
        //sdiv.style.position = 'absolute';
        with (document.getElementById('slider').style) {
          position = 'absolute';    
          sdiv.style.top = '';
        }

        if (shouldAnchor) {
          scrollToAnchor(_lastMod);
          shouldAnchor = false;
        }
        else {
          scrollToAnchor('');
        }
        slider();
      }    
    }
  }
}

function addonSwapImg(img, id, roll, recommendFlag, modId) {
  if (img.indexOf("http://") > -1) {
    // it's s7
  } else {  
    img = "http://hpshopping.speedera.net/www.shopping.hp.com" + img;
  }

  var modImgObj = getAnElement("cat_img" + "_" + modId); // MM_findObj("cat_img" + "_" + modId);
  if (roll == 'over') {
    if (modImgObj != null) {
      if (modImgObj.src != img) {
        modImgObj.src = img;
      }      
    }
  }

  if (roll == 'out') {
    var selModImgObj = getAnElement("sel_cat_img" + "_" + modId); // MM_findObj("sel_cat_img" + "_" + modId);
    if (modImgObj != null) {
      if (modImgObj.src != selModImgObj.src) {
        modImgObj.src = selModImgObj.src;
      }      
    }
  }  

  var oneRowObj = MM_findObj(id);
  if (oneRowObj != null) {
    if (roll == 'over') {
      if (recommendFlag) {
        oneRowObj.style.backgroundColor = '#FFFFCC';
      } else {
        oneRowObj.style.backgroundColor = '#e7e7e7';
      }

      oneRowObj.style.borderColor = '#ccc';
      oneRowObj.style.borderStyle = 'solid';
      oneRowObj.style.borderWidth = '0px';
    }
    else { // out
      if (recommendFlag) {
        oneRowObj.style.backgroundColor = '#FFFFCC';
      } else {
        oneRowObj.style.backgroundColor = 'white';
      }

      oneRowObj.style.borderColor = 'white';
      oneRowObj.style.borderStyle = '';
      oneRowObj.style.borderWidth = '';
    }
  }
}

function setSelectedImg(optEle, modId) {
  if (vType == 'dv') {
    var selImg = getAnElement('sel_cat_img' + "_" + modId);
    var modImg = getAnElement('cat_img' + "_" + modId);
    var speedraPath = "http://hpshopping.speedera.net/www.shopping.hp.com";
    var optImgSrc = "";
    if (optEle.type == 'radio' || optEle.checked) {
      optImgSrc = optEle.attributes.getNamedItem('opt_img').value;

      if (optImgSrc != '') {
        if (optImgSrc.indexOf("http://") > -1) {
          speedraPath = "";
        }
        selImg.src = speedraPath + optImgSrc;
        modImg.src = speedraPath + optImgSrc;
      }        
      return;
    } // end radio
    else // checkbox unchecked
    {
      var orgModImgObj = getAnElement('org_cat_img' + "_" + modId); //MM_findObj('org_cat_img' + "_" + modId);
      if (orgModImgObj != null) {
        img = orgModImgObj.src;
        if (img != '') {
          selImg.src = img;
          modImg.src = img;
          return;
        }
      }
    } // end check box
  }  
}

function toggleVideo(uid, toggler) {
  if (vType == 'dv') {
    var videoObj = getAnElement("module_video");
    if (videoObj != null) {
      if (toggler == '1') {        
        updateShowHide("module-options-div", false);
		updateShowHide("module_video", true);
      } 
      else {
        updateShowHide("module_video", false);
        updateShowHide("module-options-div", true);
      }
    }
  }

  if (vType == 'lv') {
    var videoObj = getAnElement("video_" + uid);
    if (videoObj != null) {
      if (toggler == '1') { 
        updateShowHide("module_option_" + uid, false);
        updateShowHide("video_" + uid, true);
      } 
      else {
        updateShowHide("video_" + uid, false);
        updateShowHide("module_option_" + uid, true);
      }
    }
  }
}

function decodeHtml(str) {
  str = str + "";
  str = str.replace(/&quot;/g,'"');
  return str;
}
//-->