function getSubmitURL() {
    return "intcontrol.action";
}

function parasData() {
   var xmlData = ajaxObject.responseXML;
   var root = xmlData.getElementsByTagName("root")[0];
   if ( root != null ) {
        step = getXMLValue( root, "step" );
        var view = getXMLNode( root, "view" );
        var select = getXMLNode( root, "select" );
        var info = getXMLNode( root, "info" );
        var pricing = getXMLNode( root, "pricing" );
        var control = getXMLNode( root, "control" );
        var navigation = getXMLNode( root, "navigation" );
        var select2 = getXMLNode( root, "select2" );
        var size = getXMLNode( root, "size" );

        if ( step == 'CBINFO_FINISH' ) finish();
        if ( view != null ) {
           refreshView( view );
        }
        if ( select != null ) refreshSelect( select );
        if ( info != null ) refreshInfo( info );
//        if ( pricing != null ) refreshPricing( pricing );
        if ( control != null ) refreshControl( control );
//        if ( navigation != null ) refreshNavigation( navigation );            
        if ( navigation != null ) refreshStepNavigation( navigation, step );            
        if ( select2 != null ) refreshSelect2( select2 );
        if ( size != null ) refreshSize( size );
        refreshInstructions( step );
   }
   else {
        location.reload();
   }
}

function refreshSelect( select ) {
//alert( "select" );
      var result="";
      var title="";
      var fvid = [];
      var fvcode = [];
      var fvname = [];
      var fvimg = [];

      var tab1content = document.getElementById( "tab1content" );
      var tab2container = document.getElementById( "tab2container" );
      var tab2content = document.getElementById( "tab2content" );

      var etitle = document.getElementById( "tab1title" );
      var elmt = document.getElementById( "tab1select" );

      title = getXMLValue( select, "title" );
      etitle.innerHTML = title.toUpperCase();

      var fd = getXMLNode( select, "fd" );
      var fdid = getXMLValue( fd, "fdid" );
      var fdcode = getXMLValue( fd, "fdcode" );
      var fdname = getXMLValue( fd, "fdname" );
      var choices = getXMLNodes( fd, "choice" );
      for (var i=0;i<choices.length;i++) {
        fvid[i]= getXMLValue( choices[i], "fvid" );
        fvcode[i]= getXMLValue( choices[i], "fvcode" );
        fvname[i]= getXMLValue( choices[i], "fvname" );
        fvimg[i]= getXMLValue( choices[i], "fvimg" );
      }

      var index;
      if ( step == "CBINFO_CONF" ) {
          tab2container.style.display = "none";
          tab1content.style.height = "325px";

          result += '<table width="100%" >';
          result += '<tr valign="bottom">';
          result += '<td width="12%" align="center">';
          if ( ( index = indexOf( fvcode, '100' ) ) >= 0 ) {
            result += '<a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index] + '" title="' + fvname[index] + '" height="74" border="0" /></a>';
          }
          result += '</td>';
          result += '<td width="13%" align="center">';
          result += '</td>';
          result += '<td width="11%" align="center">';
          result += '</td>';
          result += '<td width="14%" align="center">';
          result += '</td>';
          result += '<td width="12%" align="center">';
          if ( ( index = indexOf( fvcode, '10B' ) ) >= 0 ) {
            result += '<a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index] + '" title="' + fvname[index] + '" height="74" border="0" /></a>';
          }
          result += '</td>';
          result += '<td width="14%" align="center">';
          result += '</td>';
          result += '<td width="7%" height="90" align="center">';
          result += '</td>';
          result += '<td width="17%" align="center">';
          result += '</td>';
          result += '</tr>';
          result += '<table width=100%>';
          result += '<tr align="left" valign="middle">';
          result += '<td bgcolor="#eeeeee" width="50%"  class="style10"><span class="style19">SINGLE DOOR CONFIGURATIONS: </span></td>';
          result += '<td bgcolor="#eeeeee" width="50%"  class="style10"><span class="style19">Bi-folds: </span></td>';
          result += '</tr>';
          result += '</table>';
          result += '<table width="100%">';
          result += '<tr valign="bottom">';
          result += '<td width="17%" height="96" align="center">';
          if ( ( index = indexOf( fvcode, '200' ) ) >= 0 ) {
            result += '<a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index] + '" title="' + fvname[index] + '" height="74" border="0" /></a>';
          }
          result += '</td>';
          result += '<td width="12%" align="center">';
          result += '</td>';
          result += '<td width="21%" align="center">';
          result += '</td>';
          result += '<td width="17%" align="center">';
          if ( ( index = indexOf( fvcode, '20T' ) ) >= 0 ) {
            result += '<a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index] + '" title="' + fvname[index] + '" height="74" border="0" /></a>';
          }
          result += '</td>';
          result += '<td width="12%" align="center">';
          result += '</td>';
          result += '<td width="21%" align="center">&nbsp;</td>'
          result += '</tr>';
          result += '</table>';
          result += '<table width=100%>';
          result += '<tr align="left" valign="middle">';
          result += '<td bgcolor="#eeeeee" class="style10"><span class="style19">DOUBLE DOOR CONFIGURATIONS:</span></td>';
          result += '</tr>';
          result += '</table>';
          result += '<table width="100%">';      
          result += '<tr valign="bottom">';
          result += '<td width="12%" align="center">';
          if ( ( index = indexOf( fvcode, '400' ) ) >= 0 ) {
            result += '<a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index] + '" title="' + fvname[index] + '" height="74" border="0" /></a>';
          }
          result += '</td>';
          result += '<td width="13%" align="center" height="75" class="style10">';
          result += '</td>';
          result += '<td width="11%" align="center">&nbsp;</td>';
          result += '<td width="14%" align="center">&nbsp;</td>';
          result += '<td width="205%" align="center">&nbsp;</td>';
          result += '<td width="14%" align="center">&nbsp;</td>';
          result += '<td width="16%" align="center">&nbsp;</td>';
          result += '</tr>';
          result += '</table>';
          result += '<table width=100%>';
          result += '<tr align="left" valign="middle">';
          result += '<td class="style10" bgcolor="#eeeeee"><strong class="style19">SLAB ONLY:</strong></td>';
          result += '</tr>';
          result += '</table>';
      }
      else if ( step == "CBINFO_SIZE" ) {
          tab2container.style.display = "none";
          tab1content.style.height = "325px";

          result += '<table width="100%" class="style10" >';
  	  result += '<tr align="center">';
  	  result += '<td width="8%" height="25" align="left" valign="middle" bgcolor="#CCCCCC" class="style10"></td>';
  	  result += '<td width="15%" align="left" valign="middle" bgcolor="#CCCCCC" class="style10">Nominal <br />Door Width</td>';
  	  result += '<td width="16%" valign="middle" bgcolor="#CCCCCC" class="style10">Nominal <br />Door Height</td>';
  	  result += '<td width="26%" valign="middle" bgcolor="#CCCCCC" class="style10">Prehung Unit Size</td>';
          result += '<td width="25%" valign="middle" bgcolor="#CCCCCC" class="style10">Rough Opening </td>';
          result += '</tr>';
          var bgcolor;
          for (var i=0;i<choices.length;i++) {
            if ( i%2 == 0 ) {
                bgcolor = "#efefef";
            }
            else {
                bgcolor = "#ffffff";
            }
            result += '<tr valign="top" bgcolor="' + bgcolor + '" >';
            result += '<td align="center" ><input type="radio" name="dmsn" onclick="nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[i] + ' )" /></td>';
            result += '<td align="center" >' + getXMLValue( choices[i], "attrs3" ) + '</td>';
            result += '<td align="center" >' + getXMLValue( choices[i], "attrs4" ) + '</td>';
            result += '<td align="center" >' + getXMLValue( choices[i], "attrs1" ) + '</td>';
            result += '<td align="center" >' + getXMLValue( choices[i], "attrs2" ) + '</td>';
            result += '</tr>';
          }        
          result += '</table>';
      }
      else if ( step == "CBINFO_COLLECTION" ) {
          tab2container.style.display = "none";
          tab1content.style.height = "325px";

          result += '<table width="100%" height="300"  class="style10" >';
          result += '<tr valign="top">';
          for (var index=0;index<choices.length;index++) {
            if ( index%4 == 0 && index != 0 ) {
                   result += '</tr><tr valign="top">';
            }
            if ( getXMLValue( choices[index], "status" ) == "2" ) {  
                   result += '<td height="150" align="left" ><div class="style11" ><a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] 
                          + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index]  + '" title="' + fvname[index]
                          + '" width="100" height="100" border="0"  /><br>' + fvname[index] + '</a></div></td>';
            }
            else {
                   result += '<td height="150" align="left" ><div class="style22" ><img src="' 
                          + rpath + fvimg[index] + '" alt="' + fvname[index] + '" title="' + fvname[index] + '" width="100" height="100" border="0"  /><br>' 
                          + fvname[index] + '</div></td>';
            }
          }
          result += '</tr>';
          result += '</table>';

      }
      else if ( step == "CBINFO_STYLE" ) {
          tab1content.style.height = "75px";
          result += '<table width="100%" height="70"  class="style10" >';
          result += '<tr valign="top">';
          result += '<td height="63" align="left" >';
          for (var index=0;index<choices.length;index++) {
            if ( getXMLValue( choices[index], "status" ) == "2" ) {  
                   result += '<td><div class="style11" ><a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] 
                          + ' )" ><img src="' + rpath + fvimg[index] + '" '
                          + ' onmouseover="javascript:MM_showHideLayers(\'finish_' + fvcode[index] + '\',\'\',\'show\')" '
                          + ' onmouseout="javascript:MM_showHideLayers(\'finish_' + fvcode[index] + '\',\'\',\'hide\')" '
                          + '" width="65" height="35" border="0" /><br>' 
                          + fvname[index] + '</a></div></td>';
            }
            else {
                   result += '<td><div class="style22" ><img src="' 
                          + rpath + fvimg[index] + '" '
                          + ' onmouseover="javascript:MM_showHideLayers(\'finish_' + fvcode[index] + '\',\'\',\'show\')" '
                          + ' onmouseout="javascript:MM_showHideLayers(\'finish_' + fvcode[index] + '\',\'\',\'hide\')" '
                          + '" width="65" height="35" border="0" /><br>' 
                          + fvname[index] + '</div></td>';
            }
          }
          result += '</td>';
          result += '</tr>';
          result += '</table>';

      }
      else if ( step == "CBINFO_GRILLE" ) {
          tab2container.style.display = "none";
          tab1content.style.height = "325px";

          result += '<table width="100%" height="300"  class="style10" >';
          result += '<tr valign="top">';
          for (var index=0;index<choices.length;index++) {
            if ( index%4 == 0 && index != 0 ) {
                   result += '</tr><tr valign="top">';
            }
            result += '<td height="150" width="100" align="center" ><div class="style11" ><a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[index] 
                   + ' )"><img src="' + rpath + fvimg[index] + '" alt="' + fvname[index]  + '" title="' + fvname[index]
                   + '" width="40" height="125" border="0"  /><br>' + fvname[index] + '</a></div></td>';
          }
          result += '</tr>';
          result += '</table>';

      }
      elmt.innerHTML = result;

}

function refreshInstructions( step ) {
//alert( "default instructions" );
      var result="";

      var elmt = document.getElementById( "instructions" );

      elmt.style.height = "164px";
      elmt.style.width = "239px";

      if ( step == "CBINFO_CONF" ) {
        result += '<table width="100%" >';
        result += '<tr>';
        result += '<td width="87%" height="20" align="left" valign="top" class="style10"><strong>CONFIGURATION<br />';
        result += '</strong></td>';
        result += '</tr>';
        result += '<tr>';
        result += '<td align="left" valign="top" class="style10">';
        result += 'Please select the type of interior door configuration that you would like to assemble. Then please click on the "Next" button to move forward.';
        result += '</td>';
        result += '</tr>';
        result += '</table>';
      }
      else if ( step == "CBINFO_SIZE" ) {
        elmt.style.height = "230px";
        result += '<table width="100%" >';
        result += '<tr>';
        result += '<td width="87%" height="20" align="left" valign="top" class="style10"><strong>DIMENSIONS<br />';
        result += '</strong></td>';
        result += '</tr>';
        result += '<tr>';
        result += '<td align="left" valign="top" class="style10">';
        result += 'Select the desired dimensions specifications for this unit. The "Nominal Door Width" and "Nominal Door Height" reflect the relative size of the actual slab. The "Prehung Unit Size" is the size of the unit once it is Prehung.  The "Rough Opening" is the size of the opening of the doorway which the prehung unit will fit into. For Slab Only and Bi-fold units the values for "Rough Opening" and "Prehung Unit Size" is estimated. Then please click on the "Next" button to move forward.';
        result += '</td>';
        result += '</tr>';
        result += '</table>';
      }
      else if ( step == "CBINFO_COLLECTION" ) {
        result += '<table width="100%" >';
        result += '<tr>';
        result += '<td width="87%" height="20" align="left" valign="top" class="style10"><strong>COLLECTION<br />';
        result += '</strong></td>';
        result += '</tr>';
        result += '<tr>';
        result += '<td align="left" valign="top" class="style10">';
        result += 'Please select the interior collection you are looking for.';
        result += '</td>';
        result += '</tr>';
        result += '</table>';
      }
      else if ( step == "CBINFO_STYLE" || step == "999" ) {
        result += '<table width="100%" >';
        result += '<tr>';
        result += '<td width="87%" height="20" align="left" valign="top" class="style10"><strong>WOOD SPECIES &amp; STYLE<br />';
        result += '</strong></td>';
        result += '</tr>';
        result += '<tr>';
        result += '<td align="left" valign="top" class="style10">';
        result += 'Please choose the wood species and then door style you would like.  Note that some door styles will have multiple glass caming choices available (Brass, Patina, Zinc). Then please click on the "Next" button to move forward.';
        result += '</td>';
        result += '</tr>';
        result += '</table>';
      }
      else if ( step == "CBINFO_GRILLE" ) {
        result += '<table width="100%" >';
        result += '<tr>';
        result += '<td width="87%" height="20" align="left" valign="top" class="style10"><strong>Pine Grille<br />';
        result += '</strong></td>';
        result += '</tr>';
        result += '<tr>';
        result += '<td align="left" valign="top" class="style10">';
        result += 'If you would like to add an unfinished Pine Grille, you may select the one you would like.  The Pine Grille will be shipped unattached and there will be one unfinished Pine Grille per door. If you would prefer to not include a pine grille with this unit, please select the "None" choice. Click on the "Next" button to move forward.';
        result += '</td>';
        result += '</tr>';
        result += '</table>';
      }
      else if ( step == "CBINFO_FINISH" ) {
        result += '<table width="100%" >';
        result += '<tr>';
        result += '<td width="87%" height="20" align="left" valign="top" class="style10"><strong><br />';
        result += '</strong></td>';
        result += '</tr>';
        result += '<tr>';
        result += '<td align="left" valign="top" class="style10">';
        result += 'To print out this door configuration you have designed select the "PRINT VIEW" button. After printing your design please take it to your nearest Home Depot sales assocaiate whom can help complete your order and answer any questions you may have. The "Store Locator" button will help you to find the nearest Home Depot. Or to create another design, press the "START OVER" button';
        result += '</td>';
        result += '</tr>';
        result += '</table>';

      }
      else {
      }
      elmt.innerHTML = result;
}

function refreshSelect2( select ) {
      var result="";
      var title="";
      var fvid = [];
      var fvcode = [];
      var fvname = [];
      var fvimg = [];
      var fvattrs1 = [];
      var fvattrs2 = [];

      var etitle = document.getElementById( "tab2title" );
      var elmt = document.getElementById( "tab2select" );
      var tab2container = document.getElementById( "tab2container" );
      var tab2content = document.getElementById( "tab2content" );

      title = getXMLValue( select, "title" );

      if ( title == "null" ) {
        etitle.innerHTML = "";
        elmt.innerHTML = "";
        return
      }

      var fd = getXMLNode( select, "fd" );
      var fdid = getXMLValue( fd, "fdid" );
      var fdcode = getXMLValue( fd, "fdcode" );
      var fdname = getXMLValue( fd, "fdname" );

      var choices = getXMLNodes( fd, "choice" );
      for (var i=0;i<choices.length;i++) {
        fvid[i]= getXMLValue( choices[i], "fvid" );
        fvcode[i]= getXMLValue( choices[i], "fvcode");
        fvname[i]= getXMLValue( choices[i], "fvname" );
        fvimg[i]= getXMLValue( choices[i], "fvimg" );
        fvattrs1[i]= getXMLValue( choices[i], "attrs1" );
        fvattrs2[i]= getXMLValue( choices[i], "attrs2" );
      }

      etitle.innerHTML = title.toUpperCase();
      var index;
      if ( step == "CBINFO_STYLE" ) {
          tab2container.style.display = "block";
          tab2container.style.top = "240px";
          tab2content.style.height = "200px";

          result += '<table width="100%" height="199">';
          result += '<tr align="left">';
          result += '<td height="14" width="100%" align="left" valign="middle" bgcolor="#CCCCCC" class="style10">Choose Door Style</td>';
          result += '</tr>';
          result += '<tr valign="top">';
          result += '<td align="center" class="whitebg" >';
          result += '<div id="DS_DOOR_STYL" class="style10" >';
          result += '<ul>';
          for (var i=0;i<choices.length;i++) {
              
              result += '<li><a href="javascript:nextAction( ' + rqtControl_FDFV + ',' + fdid + ',' + fvid[i] + ' )">'
                        + '<img src="' + rpath + fvimg[i] + '" '
                        + ' height="75" border="0" ';
              if ( fvattrs2[i] == 'Panel' || fvattrs2[i] == 'Clear' ) {
                  result += ' alt="' + fvname[i] + ' - ' + fvattrs2[i] + '" ' + ' title="' + fvname[i] + ' - ' + fvattrs2[i] + '" ';
              }
              else {
                  result += ' onmouseover="ShowContent( \'glass\',\'' + rpath + 'iglass/' + fvattrs1[i] + fvcode[i] + '.jpg\' )" onmouseout="HideContent( \'glass\' )" ';
              }
              result += ' /><br>' + fvattrs1[i] + fvcode[i] + '</a></li>';
          }
          result += '</ul>';
          result += '</div>';
          result += '</td>';
	  result += '</tr>';
          result += '</table>';
      }
   
      elmt.innerHTML = result;
}

function refreshStepNavigation( navigation, step ) {
      var pages = getXMLNodes( navigation, "page" );

      var result = "";
      var elmt;
// alert( "refreshStepNavigation: " + step );      
      result += '<table align="left" border="0" height="15px" cellpadding="0" cellspacing="0">';
      result += '<tr>';
      result += getNavStep( pages, step, "CBINFO_CONF", "CONFIGURATION", "190px" );
      result += getNavStep( pages, step, "CBINFO_SIZE", "DIMENSIONS", "157px" );
      result += getNavStep( pages, step, "CBINFO_COLLECTION", "COLLECTION", "157x" );
      result += getNavStep( pages, step, "CBINFO_STYLE", "SPECIES & STYLE", "180px" );
      result += getNavStep( pages, step, "CBINFO_GRILLE", "GRILLE OPTION", "198px" );
      result += getNavStep( pages, step, "CBINFO_FINISH", "FINISH", "74px" );

      result += '</tr>';
      result += '</table>';
      elmt = document.getElementById( "StepNav" );
      elmt.innerHTML = result;

      var ballClass;
      switch ( step ) {
         case "CBINFO_CONF": ballClass = "INTNumberBall-1";
                  break;
         case "CBINFO_SIZE": ballClass = "INTNumberBall-2";
                  break;
         case "CBINFO_COLLECTION": ballClass = "INTNumberBall-3";
                  break;
         case "CBINFO_STYLE": ballClass = "INTNumberBall-4";
                  break;
         case "CBINFO_GRILLE": ballClass = "INTNumberBall-5";
                  break;
         case "CBINFO_FINISH": ballClass = "INTNumberBall-6";
                  break;
         otherwise: ballClass = "";
     }
     ballElmt = document.getElementById( "NumberBall" );
     ballElmt.className = ballClass;
}

function finish() {
      var url_printview = 'intprintview.action?' + tokenName + '=' + token;
      var url_newdesign = 'javascript:new_design()';

      var tab1content = document.getElementById( "tab1content" );
      var tab2container = document.getElementById( "tab2container" );
      tab2container.style.display = "none";
      tab1content.style.height = "275px";

      var etitle = document.getElementById( "tab1title" );
      var elmt = document.getElementById( "tab1select" );
      var result = "";

      etitle.innerHTML = '';

      result += '<div id="finish" >';
      result += '<br/><br/>';
      result += 'CONGRATULATIONS! YOUR PASSAGE IS ALMOST A REALITY...';
      result += '<br/><br/>';
      result += '<div style="padding-left: 10px; text-align: left;" >';
      result += '<p><a href="' + url_printview + '" target="_blank" >Print</a> this worksheet and bring it to a <a href="' + url_HOMEDEPOT + '" target="_blank" >Home Depot</a> sales associate who can complete your order and answer any final questions you might have.</p>';
      result += '</div>';
      result += '<br/><br/><br/>';
      result += '<a href="' + url_newdesign + '" ><img src="' + rpath + 'nextbttn/startOver.jpg" border="0"/></a>&nbsp;&nbsp;&nbsp;&nbsp;';
      result += '<a href="' + url_HOMEDEPOT + '" target="_blank" ><img src="' + rpath + 'nextbttn/locatorUp.png" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;';
      result += '<a href="' + url_printview + '" target="_blank" ><img src="' + rpath + 'nextbttn/printUp.png" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;';
      result += '</div>';
      elmt.innerHTML = result;
}

