<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1" indent="no"/>
<xsl:variable name="fontname">Arial</xsl:variable>
<xsl:variable name="TotalPageLength">95</xsl:variable>
<xsl:variable name="PageHeaderLength">10</xsl:variable>
<xsl:variable name="DetailHeaderLength">5</xsl:variable>
<xsl:variable name="CallDetailsGroupNameLength">1</xsl:variable>
<xsl:variable name="PageFooterLength">6</xsl:variable>
<xsl:variable name="countcalldet"><xsl:value-of select="count(/Main/CallDetails)"/></xsl:variable>
<xsl:variable name="countidet"><xsl:value-of select="count(/Main/CallDetails/IDetails)"/></xsl:variable>

<xsl:variable name="PHDet">
	<xsl:value-of select="57"/>
</xsl:variable>

<xsl:variable name="totgprsamt"><xsl:value-of select="/Main/CallDetails[@Desc='GPRS Downloads']/@TotalAmt"/></xsl:variable>
<xsl:variable name="totgprsdur"><xsl:value-of select="/Main/CallDetails[@Desc='GPRS Downloads']/@TotalDuration"/></xsl:variable>
<xsl:variable name="totgprscall"><xsl:value-of select="count(/Main/CallDetails[@Desc='GPRS Downloads']/IDetails)"/></xsl:variable>

<xsl:variable name="totduration"><xsl:value-of select=" /Main/ItemDetails/@TotalDurationFreeCalls"/></xsl:variable>


<xsl:template match="/">
<html>
<head><title></title></head>
<body leftmargin="20" topmargin="10" marginheight="0" marginwidth="0" width="680" align="center">
	<xsl:call-template name="Page_Header_Section"/>
	<table border="0" width="100%" cellSpacing="0" cellPadding="0">
		<tr>
			<td width="49%" valign="top">
				<table border="0" width="100%" cellSpacing="0" cellPadding="0">
					<xsl:call-template name="CallDetails_Column_Header"/>
					<xsl:call-template name="CallDetails_Body"/>
		     	</table>
		   	</td>    
		</tr>
	</table>
     <table border="0" >
        <tr>
           <td>&#160;</td>
        </tr>
     </table>
	<xsl:call-template name="Page_Footer_Section"/>

</body>
</html>
</xsl:template>
<xsl:template name="Page_Header_Section">
      <table border="0" width="100%" cellSpacing="0" cellPadding="0">
            <tr>
                  <td>&#160;</td>
             </tr> 
      </table> 
            <table border="0" width="100%" cellSpacing="0" cellPadding="0">
         <tr>
        <td width="50%">
          <table border="1" width="100%" cellSpacing="0" cellPadding="0">
          <tr>
               <td width="50%"><font face="{$fontname}" color="" size="1">&#160;Customer Number</font></td>
               <td width="50%" align="left"><font face="{$fontname}" color="" size="1">&#160;<xsl:value-of select="/Main/HeaderInfo/@CustomerNo"/>&#160;</font></td>

          </tr>

          <tr>

               <td width="50%"><font face="{$fontname}" color="" size="1">&#160;Mobile Number</font></td>

               <td width="50%" align="left"><font face="{$fontname}" color="" size="1">&#160;0<xsl:value-of select="/Main/HeaderInfo/@MSISDNNo"/>&#160;</font></td>

          </tr>

          <tr>

               <td width="50%"><font face="{$fontname}" color="" size="1">&#160;Statement Date</font></td>

               <td width="50%" align="left"><font face="{$fontname}" color="" size="1">&#160;<xsl:value-of select="/Main/HeaderInfo/@InvoiceDate"/>&#160;</font></td>

          </tr>

          <tr>

               <td width="50%"><font face="{$fontname}" color="" size="1">&#160;Page Number</font></td>

               <td width="50%" align="left"><font face="{$fontname}" color="" size="1">&#160;PAGENUMBER of PAGETOTAL &#160;</font></td>

          </tr>

          <tr>

               <td width="70%">

                    <table border="0" width="100%" cellSpacing="0" cellPadding="0">

                         <tr>

                              <td width="80%"><font face="{$fontname}" color="" size="1">&#160;Amount Due</font></td>

                              <td width="20%" align="right"><font face="{$fontname}" color="" size="1">Rs.&#160;</font></td>

                         </tr>

                    </table>

               </td>

               <td width="30%" align="left"><font face="{$fontname}" color="" size="1">&#160;<xsl:value-of select="format-number(/Main/HeaderInfo/@AmountWithTax,'###,###.00')"/>&#160;</font></td>

          </tr>
     </table>
     </td>

       <td width="50%">

              <table border="0" width="90%" cellSpacing="0" cellPadding="0">
        <tr>
               <td width="100%" colspan="3" align='right'>&#160;</td>
          </tr>
          <tr>

                <td>&#160;</td>

          </tr>

       </table>
       </td>
      </tr>
     </table>


	<table border="0" width="100%" cellSpacing="0" cellPadding="0">
		<tr>
			<td width="3%">&#160;</td>
			<td width="47%">
				<table border="0" width="100%" cellSpacing="0" cellPadding="0">
					<tr><td>
						<font face="{$fontname}" color="" size="2">
                                   <b><xsl:value-of select="/Main/HeaderInfo/@Designation"/></b>&#160;
							<b><xsl:value-of select="/Main/HeaderInfo/@SubFirstName"/></b>&#160;
							<b><xsl:value-of select="/Main/HeaderInfo/@SubMidName"/></b>&#160;
							<b><xsl:value-of select="/Main/HeaderInfo/@SubLastName"/></b>
						</font>
					</td></tr>
					<tr><td><font face="{$fontname}" color="" size="1">&#160;</font></td></tr>
				</table>
			</td>
			<td width="47%">
				<table border="0" width="100%" cellSpacing="0" cellPadding="0">

					<tr>

						<td align="right">

							<font face="{$fontname}" color="" size="1">

								<b>&#160;</b>

							</font>

						</td>

					</tr>

					<tr>

						<td align="right">

							<font face="{$fontname}" color="" size="1">

								<b>&#160; </b>

							</font>

						</td>

					</tr>

				</table>			

			</td>

			<td width="3%">&#160;</td>

		</tr>

		<tr>

			<td colspan="4">

				<font face="{$fontname}" color="" size="1">&#160;</font>

			</td>

		</tr>

		<tr>

			<td colspan="4" align="center" bgcolor="black">

				<font face="{$fontname}" color="white" size="3"><b>ITEMISED BILL</b></font>

			</td>

		</tr>

		<tr>

			<td colspan="4">

				<font face="{$fontname}" color="" size="1">&#160;</font>

			</td>

		</tr>

	</table>


</xsl:template>



<xsl:template name="CallDetails_Column_Header">
	<tr>

		<td colspan="13" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

	</tr>

	<tr>

		<td width="0" align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

		<td width="15%" valign="top" align="center">

			<font face="{$fontname}" color="" size="-7%">Date</font>

		</td>

		<td width="0" align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

		<td width="10%" valign="top" align="center">

			<font face="{$fontname}" color="" size="-7%">Time</font>

		</td>

		<td width="0"  align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

		<td width="26%" valign="top" align="center">

			<font face="{$fontname}" color="" size="-7%" >Dialled&#160;Number</font>

		</td>

		<td width="0" align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

		<td width="20%" valign="top" align="center">

			<font face="{$fontname}" color="" size="-7%">Duration {HH:MI:SS}<br></br> / Volume in Kb</font>

		</td>

		<td width="0" align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

		<td width="20%" align="center" valign="top">

			<font face="{$fontname}" color="" size="-7%">

				Rate per Min <br></br>{Rs.} 

			</font>

		</td>

		<td width="0" align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

		<td width="18%"  align="center" valign="top">

			<font face="{$fontname}" color="" size="-7%">

				Call&#160;Charge<br></br>{Rs.}

			</font>

		</td>

		<td width="0" align="left" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

	</tr>

	<tr>

		<td colspan="13" bgcolor="#000000">

			<font face="{$fontname}" color="" size="-7"></font>

		</td>

	</tr>


</xsl:template>



<xsl:template name="CallDetails_Body">

	<xsl:for-each select="/Main/CallDetails">
                  <xsl:sort select="@ItemCode" data-type="number" />
                   <xsl:variable name="desc"><xsl:value-of select="@Desc"/></xsl:variable>
                                <tr>
                                        <td colspan="13" bgcolor="#000000">
                                                <font face="{$fontname}" color="" size="-7"></font>
                                        </td>
                                </tr>
                                <xsl:text>
                                        <![CDATA[

                                                </table></td>
                                                <td width="1%">&#160;</td>
                                                <td width="49%" valign="top">
                                                        <table border="0" width="100%" cellSpacing="0" cellPadding="0">
                                        ]]>
                                </xsl:text>
                      <xsl:call-template name="CallDetails_Column_Header"/>
             <xsl:call-template name="CallDetails_GroupName">
    		<xsl:with-param name="XPath">
    			<xsl:value-of select="@Desc"/>
    		</xsl:with-param>
    	</xsl:call-template>
		<xsl:for-each select="IDetails">
                                <tr>
                                        <td colspan="13" bgcolor="#000000">
                                                <font face="{$fontname}" color="" size="-7"></font>
                                        </td>
                                </tr>
                                <xsl:text>
                                        <![CDATA[
                                                </table></td>
                                                <td width="1%">&#160;</td>
                                                <td width="49%" valign="top">
                                                        <table border="0" width="100%" cellSpacing="0" cellPadding="0">
                                        ]]>
                                </xsl:text>
                        <xsl:call-template name="CallDetails_Column_Header"/>
		    <tr>

<xsl:comment>
quillrec
</xsl:comment>

	

			<td width="0" align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>
				</td>
				<td width="17%" valign="top">
					<font face="{$fontname}" color="" size="-7%"> &#160;<xsl:value-of select="@IDate"/>&#160; </font>
				</td>
				<td width="0" align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>
				</td>

				<td width="12%" valign="top">
					<font face="{$fontname}" color="" size="-7%">&#160;<xsl:value-of select="@Time"/>&#160;</font>
				</td>
				<td width="0"  align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>

				</td>

				<td width="26%" valign="top">
					<font face="{$fontname}" color="" size="-7%" >&#160;<xsl:value-of select="@DialledNo"/></font>
				</td>

				<td width="0" align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>
				</td>

				<td width="15%" align='right' valign="top">
					<font face="{$fontname}" color="" size="-7%">
                            <xsl:if test="@Duration !='SMS' and  $desc!='GPRS Downloads'">
                                 <xsl:if test="@Duration > '0'"> 
                                   <xsl:variable name="TempMin"><xsl:value-of select="@Duration div 60"/></xsl:variable>
                                       <xsl:variable name="SS"><xsl:value-of select="round(@Duration mod 60)"/></xsl:variable>
                                          <xsl:choose>
                                                <xsl:when test="$TempMin=''">
                                                    <xsl:value-of select="format-number($HH, '00')"/>:<xsl:value-of select="format-number($MM, '00')"/>:<xsl:value-of select="$SS"/>&#160;
                                                </xsl:when>
                                             <xsl:otherwise>
                                                <xsl:variable name="MM"><xsl:value-of select="$TempMin mod 60"/></xsl:variable>
                                                <xsl:variable name="HH"><xsl:value-of select="substring-before(number($TempMin) div 60, '.')"/></xsl:variable>
                                                 <xsl:if test="$TempMin &gt;60 or $TempMin &lt;60">  
                                                      <xsl:value-of select="format-number($HH,'00')"/>:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>&#160;
                                                 </xsl:if>
                                                 <xsl:if test="$TempMin = 60">
                                                      01:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>&#160;
                                                 </xsl:if>
                                             </xsl:otherwise>
                                          </xsl:choose>
                                     </xsl:if>
                                      <xsl:if test="@Duration = 0">
                                       00:00:00&#160;
                                      </xsl:if>
                                  </xsl:if>
                               <xsl:if test="@Duration ='SMS'">
                                      SMS&#160;
                                </xsl:if>
                                  <xsl:if test="@Duration ='ROAMING'">
                                      ROAMING&#160;
                                </xsl:if>
                                
                              <xsl:if test="$desc='GPRS Downloads'">
                                  <xsl:if test ="@Duration > 0">
                                    <xsl:value-of select="format-number(@Duration,'###,###')"/> Kb&#160;
                                 </xsl:if>
                                 <xsl:if test ="@Duration = 0"> 
                                  0 Kb&#160;
                                 </xsl:if>

                               </xsl:if>
                             </font>

				</td>

				<td width="0" align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>
				</td>
				<td width="18%" align="right">
                                    <xsl:if test="@RatPerMin ='SMS' or @RatPerMin='ROAMING'">
                                            <font face="{$fontname}" color="" size="-7%"><xsl:value-of select="@RatPerMin"/>&#160;</font>
                                         </xsl:if>
                                         <xsl:if test="@RatPerMin!='SMS' and @RatPerMin!='ROAMING' and $desc!='GPRS Downloads' and $desc!='Premium  Calls'">
                                           <font face="{$fontname}" color="" size="-7%"><xsl:value-of select="format-number(@RatPerMin,'###,###.00')"/>&#160;</font>
                                         </xsl:if>
                                         <xsl:if test="$desc='GPRS Downloads'">
                                          <font face="{$fontname}" color="" size="-7%">GPRS&#160;</font>
                                         </xsl:if>
                                         <xsl:if test="$desc='Premium  Calls'">
                                          <font face="{$fontname}" color="" size="-7%">PREMIUM&#160;</font>
                                         </xsl:if>

				</td>
				<td width="0" align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>
				</td>
				<td width="16%"  align="right">
					<font face="{$fontname}" color="" size="-7%"><xsl:value-of select="format-number(@CallCharge,'###,###.00')"/>&#160;</font>
				</td>

				<td width="0" align="left" bgcolor="#000000">
					<font face="{$fontname}" color="" size="-7"></font>
				</td>

			</tr>

     			<tr>
					<td colspan="13" bgcolor="#000000">
						<font face="{$fontname}" color="" size="-7"></font>
					</td>
				</tr>
     			<xsl:call-template name="PageBreak"/>
		</xsl:for-each>
               <tr>

                <td colspan="13" bgcolor="#000000">

                        <font face="{$fontname}" color="" size="-7"></font>

                </td>

        </tr>
                                <tr>
                                        <td colspan="13" bgcolor="#000000">
                                                <font face="{$fontname}" color="" size="-7"></font>
                                        </td>
                                </tr>
                                <xsl:text>
                                        <![CDATA[
                                                </table></td>
                                                <td width="2%">&#160;</td>
                                                <td width="49%" valign="top">
                                                        <table border="0" width="100%" cellSpacing="0" cellPadding="0">
                                        ]]>
                                </xsl:text>
                        <xsl:call-template name="CallDetails_Column_Header"/>

        <tr>
                                        <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>

                                </td>
                                            <td width="15%" valign="top">
                                        <font face="{$fontname}" color="" size="-7%">&#160;</font>

                                </td>
                                 <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>

                                </td>


                                <td  valign="top" align="center">
                                        <font face="{$fontname}" color="" size="-7%"><b>Total</b></font>
                                </td>
                                 <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>

                                </td>

                                 <td  valign="top" align="center">
                                        <font face="{$fontname}" color="" size="-7%">&#160;</font>
                                </td>
                                 <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>

                                </td>

                                <td width="15%" align='right' valign="top">

                                        <font face="{$fontname}" color="" size="-7%"><b>

                                  <xsl:if test="@TotalDuration > 0 and $desc!='GPRS Downloads'">

                                   <xsl:variable name="TempMin"><xsl:value-of select="@TotalDuration div 60"/></xsl:variable>

                          <xsl:variable name="SS"><xsl:value-of select="round(@TotalDuration mod 60)"/></xsl:variable>

                              <xsl:choose>

                                   <xsl:when test="$TempMin=''">

                                        <xsl:value-of select="format-number($HH, '00')"/>:<xsl:value-of select="format-number($MM, '00')"/>:<xsl:value-of select="$SS"/>&#160;

                                   </xsl:when>

                                   <xsl:otherwise>

                                      <xsl:variable name="MM"><xsl:value-of select="$TempMin mod 60"/></xsl:variable>
                                   <xsl:variable name="HH"><xsl:value-of select="substring-before(number($TempMin) div 60, '.')"/></xsl:variable>  
                                            <xsl:if test="$TempMin = 60">
                                          01:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>
                                        </xsl:if>
                                           <xsl:if test="$TempMin!=60"> 
                                           <xsl:value-of select="format-number($HH,'00')"/>:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>
                                          </xsl:if>
                                 </xsl:otherwise>
                               </xsl:choose>
                              </xsl:if>
                              <xsl:if test="$desc='GPRS Downloads'">
                                  <xsl:if test ="@TotalDuration > 0">
                                    <xsl:value-of select="format-number(@TotalDuration,'###,###')"/> Kb&#160;
                                 </xsl:if>
                               </xsl:if>
                            </b> </font>
                                </td>
                                <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>
                                </td>
                                <td width="18%" align="right">
                                        <font face="{$fontname}" color="" size="-7%">&#160;</font>
                                </td>
                                <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>
                                </td>
                                <td width="16%"  align="right">
                                        <font face="{$fontname}" color="" size="-7%"><b><xsl:value-of select="format-number(@TotalAmt,'###,###.00')"/></b></font>
                                </td>
                                <td width="0" align="left" bgcolor="#000000">
                                        <font face="{$fontname}" color="" size="-7"></font>
                                </td>
                        </tr>
                                <tr>
                                        <td colspan="13" bgcolor="#000000">
                                                <font face="{$fontname}" color="" size="-7"></font>
                                        </td>
                                </tr>
                                <xsl:text>
                                        <![CDATA[
                                                </table></td>
                                                <td width="2%">&#160;</td>
                                                <td width="49%" valign="top">
                                                        <table border="0" width="100%" cellSpacing="0" cellPadding="0">
                                        ]]>
                                </xsl:text>
                        <xsl:call-template name="CallDetails_Column_Header"/>

	</xsl:for-each>
                           <tr>

                <td colspan="13" bgcolor="#000000">

                        <font face="{$fontname}" color="" size="-7"></font>

                </td>

        </tr>
		<xsl:call-template name="Filler_Section">
	         <xsl:with-param name="RowCount">
	             <xsl:value-of select="1"/>
	         </xsl:with-param>
	    </xsl:call-template>

	    <xsl:text>
			<![CDATA[ 
				</table></td>
				<td width="2%">&#160;</td>
				<td width="49%" valign="top">
					<table border="0" width="100%" cellSpacing="0" cellPadding="0">

			]]>

		</xsl:text>

		<xsl:call-template name="CallDetails_Column_Header"/>
	         <xsl:call-template name="Filler_Section">
	         <xsl:with-param name="RowCount">
	             <xsl:value-of select="1"/>
	         </xsl:with-param>
	    </xsl:call-template>

	    <xsl:text>

			<![CDATA[ 

		       	</table>

			]]>

		</xsl:text>

		<xsl:call-template name="Filler_Section">

	         <xsl:with-param name="RowCount">

	             <xsl:value-of select="1"/>

	         </xsl:with-param>


	    </xsl:call-template>

</xsl:template>





<xsl:template name="PageBreak">
	<xsl:text>
	<![CDATA[
	        </table>
	        </td>    
		</tr>
		</table>
	 ]]>
	</xsl:text>
    <xsl:comment> PAGE BREAK </xsl:comment> 	
    <xsl:call-template name="Page_Header_Section"/>
    <xsl:text>
    <![CDATA[
        <table border="0" width="100%" cellSpacing="0" cellPadding="0">
		<tr>
			<td width="49%" valign="top">
				<table border="0" width="100%" cellSpacing="0" cellPadding="0">
        ]]>
 	</xsl:text>
	<xsl:call-template name="CallDetails_Column_Header"/>
</xsl:template>

<xsl:template name="Page_Footer_Section">
	<br></br>
	<table border="1" width="80%" cellSpacing="0" cellPadding="0">
		<tr>
			<td width="50%"><font face="{$fontname}" color="" size="1">&#160;Total Number of Calls</font></td>
			<td width="50%" align="right"><font face="{$fontname}" color="" size="1"><xsl:value-of select="/Main/ItemDetails/@ChargedCalls - $totgprscall"/>&#160;</font></td>
		</tr>
		<tr>
			<td width="50%"><font face="{$fontname}" color="" size="1">&#160;Total Duration of Calls</font></td>
                   
                   <td width="50%" align="right"><font face="{$fontname}" color="" size="1"> 
                  <xsl:choose> 
                         <xsl:when test="$totgprscall &gt; 0">
                             <xsl:variable name="outgprs"><xsl:value-of select="/Main/ItemDetails/@TotalDuration - $totgprsdur"/></xsl:variable>
                              <xsl:if test="$outgprs &gt; 0 ">
                              <xsl:variable name="TempMin"><xsl:value-of select="$outgprs div 60"/></xsl:variable>
                              <xsl:variable name="SS"><xsl:value-of select="round($outgprs mod 60)"/></xsl:variable>
                               <xsl:choose>
                                    <xsl:when test="$TempMin=''">
                                        <xsl:value-of select="format-number($HH, '00')"/>:<xsl:value-of select="format-number($MM, '00')"/>:<xsl:value-of select="$SS"/>
                                   </xsl:when>
                                   <xsl:otherwise>
                                      <xsl:variable name="MM"><xsl:value-of select="$TempMin mod 60"/></xsl:variable>

                                   <xsl:variable name="HH"><xsl:value-of select="substring-before(number($TempMin) div 60, '.')"/></xsl:variable>
                                        <xsl:value-of select="format-number($HH,'00')"/>:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>&#160;
                                 </xsl:otherwise>
                               </xsl:choose>
                         </xsl:if>
                         <xsl:if test="$outgprs = 0 ">
                              00:00:00
                          </xsl:if>
                         </xsl:when>
                          <xsl:otherwise>
                           <xsl:if test="/Main/ItemDetails/@TotalDuration &gt; 0 ">
                           <xsl:variable name="TempMin"><xsl:value-of select="/Main/ItemDetails/@TotalDuration div 60"/></xsl:variable>
                              <xsl:variable name="SS"><xsl:value-of select="round(/Main/ItemDetails/@TotalDuration mod 60)"/></xsl:variable>
                               <xsl:choose>
                                    <xsl:when test="$TempMin=''">
                                        <xsl:value-of select="format-number($HH, '00')"/>:<xsl:value-of select="format-number($MM, '00')"/>:<xsl:value-of select="$SS"/>
                                   </xsl:when>
                                   <xsl:otherwise>
                                      <xsl:variable name="MM"><xsl:value-of select="$TempMin mod 60"/></xsl:variable>

                                   <xsl:variable name="HH"><xsl:value-of select="substring-before(number($TempMin) div 60, '.')"/></xsl:variable>
                                        <xsl:value-of select="format-number($HH,'00')"/>:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>&#160;
                                 </xsl:otherwise>
                               </xsl:choose>
                             </xsl:if>
                              <xsl:if test="/Main/ItemDetails/@TotalDuration = 0">
                              00:00:00
                          </xsl:if>               
                          </xsl:otherwise>
                        </xsl:choose>
			</font></td>
		</tr>
		<tr>
			<td width="70%">
				<table border="0" width="100%" cellSpacing="0" cellPadding="0">
					<tr>
						<td width="80%"><font face="{$fontname}" color="" size="1">&#160;Total Call Charges</font></td>
						<td width="20%" align="right"><font face="{$fontname}" color="" size="1">Rs.&#160;</font></td>			
					</tr>
				</table>
			</td>
                <td width="30%" align="right"><font face="{$fontname}" color="" size="1">
                <xsl:choose>
                          <xsl:when test="$totgprscall &gt; 0">
                             <xsl:value-of select="format-number(/Main/ItemDetails/@TotalCallCharges - $totgprsamt,'###,###.00')"/>&#160;
                          </xsl:when>
                      <xsl:otherwise>
                                  <xsl:value-of select="format-number(/Main/ItemDetails/@TotalCallCharges,'###,###.00')"/>
                        &#160;  </xsl:otherwise>
                       </xsl:choose>
                        </font></td>
		</tr>					
		<tr>
			<td width="50%"><font face="{$fontname}" color="" size="1">&#160;Total Number of Free Calls</font></td>
			<td width="50%" align="right"><font face="{$fontname}" color="" size="1"><xsl:value-of select="/Main/ItemDetails/@TotalNoFreeCalls"/>&#160;</font></td>
		</tr>
		<tr>
			<td width="50%"><font face="{$fontname}" color="" size="1">&#160;Total Duration of Free Calls</font></td>
			<td width="50%" align="right"><font face="{$fontname}" color="" size="1">
                <xsl:choose>
                         <xsl:when test="$totduration &gt; 0">
                              <xsl:variable name="TempMin"><xsl:value-of select="$totduration div 60"/></xsl:variable>
                              <xsl:variable name="SS"><xsl:value-of select="round($totduration mod 60)"/></xsl:variable>
                               <xsl:choose>
                                    <xsl:when test="$TempMin=''">
                                        <xsl:value-of select="format-number($HH, '00')"/>:<xsl:value-of select="format-number($MM, '00')"/>:<xsl:value-of select="$SS"/>
                                   </xsl:when>
                                   <xsl:otherwise>
                                      <xsl:variable name="MM"><xsl:value-of select="$TempMin mod 60"/></xsl:variable>

                                   <xsl:variable name="HH"><xsl:value-of select="substring-before(number($TempMin) div 60, '.')"/></xsl:variable>
                                        <xsl:value-of select="format-number($HH,'00')"/>:<xsl:value-of select="format-number($MM,'00')"/>:<xsl:value-of select="format-number($SS, '00')"/>&#160;
                                 </xsl:otherwise>
                               </xsl:choose>
                         </xsl:when>
               <xsl:otherwise>
               00:00:00&#160;
              </xsl:otherwise>
             </xsl:choose>


              </font></td>
		</tr>
            <tr>
               <td width="50%"><font face="{$fontname}" color="" size="1">&#160;Total Number of GPRS Calls </font></td>
               <td width="50%" align="right"><font face="{$fontname}" color="" size="1"><xsl:value-of select="$totgprscall"/>&#160;</font></td>
          </tr>
             <tr>
               <td width="50%"><font face="{$fontname}" color="" size="1">&#160;Total Volume of GPRS Calls </font></td>
               <td width="50%" align="right"><font face="{$fontname}" color="" size="1">
                       <xsl:choose>
                          <xsl:when test="$totgprscall &gt; 0">
                                 <xsl:value-of select="format-number($totgprsdur,'###,###')"/> Kb&#160;
                          </xsl:when>
                          <xsl:otherwise>
                                  0 Kb&#160;
                          </xsl:otherwise>
                       </xsl:choose>
            </font></td>
          </tr>
           <tr>
                <td width="70%">
                    <table border="0" width="100%" cellSpacing="0" cellPadding="0">
                         <tr>
                              <td width="80%"><font face="{$fontname}" color="" size="1">&#160;Total GPRS Call Charges</font></td>
                              <td width="20%" align="right"><font face="{$fontname}" color="" size="1">Rs.&#160;</font></td>
                         </tr>
                    </table>
               </td>

               <td width="30%" align="right"><font face="{$fontname}" color="" size="1">

                    <xsl:choose>
                          <xsl:when test="$totgprscall &gt; 0">
                             <xsl:value-of select="format-number($totgprsamt,'###,###.00')"/>&#160;
                          </xsl:when>
                      <xsl:otherwise>
                                  0.00&#160; 
                          </xsl:otherwise>
                       </xsl:choose>
               </font></td>
          </tr>




	</table>
</xsl:template>


<xsl:template name="Filler_Section">

	<xsl:param name="RowCount"/>

	<xsl:param name="TotalRows"/>

	<xsl:if test="$RowCount &lt;= $TotalRows">

		<tr>

			<td width="0" align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>

			<td width="15%" valign="top"><font face="{$fontname}"  size="-7%"> &#160;</font></td>

			<td width="0" align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>

			<td width="10%" valign="top"><font face="{$fontname}" color="#FFFFFF " size="-7%">&#160;</font></td>

			<td width="0"  align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>

			<td width="26%" valign="top"><font face="{$fontname}" color="" size="-7%">&#160;</font></td>

			<td width="0" align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>

			<td width="15%" valign="top"><font face="{$fontname}" color="#FFFFFF" size="-7%">&#160;</font></td>

			<td width="0" align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>

			<td width="18%" valign="top"><font face="{$fontname}" color="#FFFFFF" size="-7">&#160;</font></td>

			<td width="0" align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>

			<td width="16%" valign="top"><font face="{$fontname}" color="#FFFFFF" size="-7%">&#160;</font></td>

			<td width="0" align="left" bgcolor="#000000">

				<font face="{$fontname}" color="" size="-7"></font>

			</td>


		</tr>	

		

		<xsl:call-template name="Filler_Section">

             <xsl:with-param name="RowCount">

                 <xsl:value-of select="($RowCount + 1)"/>

             </xsl:with-param>

             <xsl:with-param name="TotalRows">

                 <xsl:value-of select="$TotalRows"/>

             </xsl:with-param >

         </xsl:call-template>

     

         <xsl:if test="$RowCount &gt;= $TotalRows">

             <tr>

				<td colspan="13" bgcolor="#000000">

					<font face="{$fontname}" color="" size="-7"></font>

				</td>

			</tr>

         </xsl:if>

         

	</xsl:if>

</xsl:template>



<xsl:template name="CallDetails_GroupName">
	<xsl:param name="XPath"/>
	<tr bgcolor="#CCCCCC">
		<td width="0" align="left" bgcolor="#000000">
			<font face="{$fontname}" color="" size="-7"></font>
		</td>
		<td width="15%" align="left" >
			<font face="{$fontname}" color="#FFFFFF" size="-7%">.</font>
		</td>
		<td colspan='10' valign="top"  align='left'>
			<font face="{$fontname}" color="" size="-7%"><xsl:value-of select="$XPath"/></font>
		</td>

		<td width="0" align="left" bgcolor="#000000">
			<font face="{$fontname}" color="" size="-7"></font>
		</td>
	</tr>

</xsl:template>



</xsl:stylesheet>

