
<!-- REQUEST ID: TIME=1258951474337:NODE=c2a3802:THREAD=3085 -->








    

  
    
  
  
  
    
      
      
      var elementOption = "";  // Tracks the users progress through the cat/prod tree
      var elementArray = new Array();  // Tracks the dropdowns added to the page  
      var elementArrayLen = "";
      var elementContainer = document.getElementById('dr_ProductFinderNav');  // The target for all dynamically generated dropdowns
      var httpObject = getHttpObject();  // The Ajax connection
      
      /******************************************************************************
      * getHttpObject()
      * 
      * The "getHttpObject" function is called at the beginning of the script and  
      * creates the appropriate httpObject for the browser being used
      *
      *****************************************************************************/
        
      function getHttpObject() {
        var objType = false;
        try {
          objType = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {
          try {
              objType = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e) {
              objType = new XMLHttpRequest();
          }
        }
        return objType;
      }      
      
      /******************************************************************************
      * changeSelectState()
      * 
      * The "changeSelectState" function is called by the "dataRequest" function and   
      * "dataResponse" function and toggles the disabled state of all selects 
      * presently rendered on the page from "true" to "false".
      *
      *****************************************************************************/
      
      function changeSelectState(disable) {
        var selectArray = document.getElementsByName("select"); 
        var selectArrayLen = selectArray.length;
            
        if (selectArrayLen > 0) {
          for (i=0; i<=selectArrayLen-1; i++) { 
            x = i + 1;        
            disableSelect = document.getElementById("dr_configSelect" + x);
            disableSelect.disabled=disable;
          }          
        }
      }
  
      /******************************************************************************
      * loadMessage()
      * 
      * The "loadMessage" function adds and removes the loading text and icon as a
      * user traverses the category and product tree
      *
      *****************************************************************************/
      
      function loadMessage(status) {
        loadContainer = document.getElementById("dr_ProductFinderNav");
        if (status == "on") {
          loadTxt = document.createTextNode("Loading...");
          i = document.createElement('img');
          i.setAttribute("src","//drh2.img.digitalriver.com/DRHM/Storefront/SiteImplementation/ea/eaSI/version/84/images/pf_load.gif");
          p = document.createElement('p');
          p.setAttribute("id","dr_load");
          p.appendChild(loadTxt);
          p.appendChild(i);
          loadContainer.appendChild(p);  
        } else {
          loadContainer.removeChild(p);
        }
      }
      
      /******************************************************************************
      * dataRequest()
      * 
      * The "dataRequest" function is called when a dropdown option is selected and 
      * serves multiple roles:
      *
      * 1. Tracks current dropdowns on the page
      * 2. Removes dropdowns if one is selected "upstream" 
      * 3. Opens the ajax connection and passes the "objectID" and "option"
      * 4. Triggers "dataResponse" on readyStateChange
      * 5. Triggers "load" icon
      *
      *****************************************************************************/
      
      function dataRequest(id,opt) {
        elementOption = opt;          
        elementArrayLen = elementArray.length;        
        
        changeSelectState(true);
        
        if (elementArray[elementOption - 1] == undefined && id != "SELECT_ONE") { 
          elementArray[elementOption - 1] = elementOption;      
        } else {
          for (i=elementOption; i<=elementArrayLen; i++) {
            delObject = document.getElementById("dr_formLineSelect" + i);
            elementContainer.removeChild(delObject);
          }    
          if (id == "SELECT_ONE") {
            elementOption = elementOption - 1;
            changeSelectState(false);
          }      
          elementArrayRange = elementArrayLen - elementOption;
          elementArray.splice(elementOption,elementArrayRange);
        }    
        if (id != "SELECT_ONE" && id != "") {
          //document.getElementById("dr_load").style.display = "block";
          loadMessage("on");
          connID = id;
          connHttp = httpObject;    
          connHttp.open('GET', '/servlet/ControllerServlet?Action=DisplayPage&id=ProductFinderLogicPage&Locale=en_IE&SiteID=ea&objectID=' + connID + '&option=' + opt, true);      
          connHttp.onreadystatechange = dataResponse; 
          connHttp.send(null); 
        }    
      }  
    
      /******************************************************************************
      * dataResponse()
      * 
      * The "dataResponse" function is called by the "dataRequest" function upon a 
      * ready-state-change.  This function serves multiple roles:
      *
      * 1. Creates a div and attaches it to page via the dom
      * 2. Adds the contents of the Ajax response to the div 
      * 3. Hides "load" icon
      *
      *****************************************************************************/
    
      function dataResponse() {
        if (connHttp.readyState == 4) {
          d = document.createElement('div');
          d.setAttribute("id","dr_formLineSelect" + elementOption);
          d.className = "dr_formLine";
          if (connHttp.status == 200) {
            d.innerHTML = connHttp.responseText;
          } else {
            d.innerHTML = "An error was encountered while processing your request.";
          }
          elementContainer.appendChild(d);  
          //document.getElementById("dr_load").style.display = "none";  
          loadMessage("off");          
          changeSelectState(false);
        }
      }
      dataRequest(22046100,1);
      
    
  
  
  
        
  

