﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:recalcXmlUtil="urn:recalcXmlUtil"
                exclude-result-prefixes="msxsl recalcXmlUtil">

   <xsl:output method="html" indent="yes"/>  
   
   <xsl:variable name="javaScript">
      function setCurrentLine(event) {
         var elem = JSUI.Util.getEventSource(event);
         if ( elem &amp;&amp; elem.tagName != "INPUT" ) {
            var elemLineId; 
            while ( elem &amp;&amp; !(elemLineId = elem.getAttribute("lineid") ) ) {
      elem = $(elem).parent()[0];
      }
      if ( elemLineId ) selectLine( elemLineId );
      }
      }

      function moveLineUp() {
      var lineToMove = $(".xRecalcLine[curr]");
      var lineToMoveBefore = lineToMove.prev(".xRecalcLine");
      $(lineToMove).insertBefore(lineToMoveBefore);
      return false;
      }

      function moveLineDown() {
      var lineToMove = $(".xRecalcLine[curr]");
      var lineToMoveAfter = lineToMove.next(".xRecalcLine");
      $(lineToMove).insertAfter(lineToMoveAfter);
      return false;
      }

      function showQuickView() {
      var lineId = $(".xRecalcLine[curr]").attr("lineid");
      return expShowLineQuickView(lineId);
      }

      function showBomView() {
      var lineId = $(".xRecalcLine[curr]").attr("lineid");
      return expShowLineBomView(lineId);
      }
      var cssPath = <xsl:value-of select="recalcXmlUtil:GetCssPath()"/>
   </xsl:variable>

   <xsl:template match="/">
      <div class="xPage" notitle="">
         <xsl:copy-of select="recalcXmlUtil:GetPageHeading()"/>
         <xsl:copy-of select="recalcXmlUtil:GetToolBar()"/>
         <xsl:copy-of select="recalcXmlUtil:GetPageDescription()"/>
         <div class='xRecalcLines' scrollable="">
            <xsl:for-each select="mpcconfiguration/lineitem" >
               <xsl:variable name="lineItemId" select="@id" />
               <div class='xRecalcLine' recalculate='recalculate' onclick='setCurrentLine(event)'>
                  <xsl:attribute name="lineid">
                     <xsl:value-of select="$lineItemId"/>
                  </xsl:attribute>
                  <xsl:copy-of select="recalcXmlUtil:GetLineCheckBox($lineItemId, true())" />
                  <span class="configDisplayName">
                     <xsl:attribute name="lineid">
                        <xsl:value-of select="$lineItemId"/>
                     </xsl:attribute>
                     <xsl:value-of select="recalcXmlUtil:GetConfigurationDisplayName($lineItemId)" disable-output-escaping="yes" />
                  </span>
                  <div class="xRecalcLineResult">
                     <xsl:attribute name="lineid">
                        <xsl:value-of select="$lineItemId"/>
                     </xsl:attribute>
                     <!--The empty xsl:text element below this is only there to prevent the lineResult div from getting self closed by XSLT.-->
                     <xsl:text> </xsl:text>
                  </div>
               </div>
            </xsl:for-each>
         </div>
      </div>
      <script type="text/javascript">
         <xsl:value-of select="$javaScript" disable-output-escaping="yes" />
      </script>
   </xsl:template>
</xsl:stylesheet>