<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="no" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />

    <xsl:template name="pickLayout">
        <form action="/rps/service" name="serviceEdit" id="serviceEdit" method="post" onSubmit="modifyField('submitButton','disable')">
            <div class="section">
                <xsl:call-template name="helpLink" />
                <xsl:call-template name="successMessageGeneral">
                    <xsl:with-param name="successMessage">Services successfully updated!</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="openRunStatusMessage" />

                <xsl:call-template name="serviceEdit" />
            </div>
            <xsl:call-template name="buttons" />
        </form>
    </xsl:template>


    <xsl:template name="serviceEdit">
        <input type="hidden" name="formSubmit" value="1" />
        <input type="hidden" name="c" value="edit" />
        <div class="fixedWidthTable">
            <p class="formHeader">Modify service settings here.</p>
            <xsl:call-template name="errorMessageGeneral" />
            <xsl:call-template name="serviceEditTable" />
        </div>
    </xsl:template>


    <xsl:template name="serviceEditTable">
        <table class="textChart smallChart hiOn">
            <tbody>
                <xsl:choose>
                    <xsl:when test="Access/rps/ca_license/edit and Access/rps/license/edit">
                        <tr>
                            <th class="serviceCol"></th>
                            <th class="rowRight mechanicalCol" colspan="2">
                                Exclude&#160;Mechanicals?
                            </th>
                        </tr>
                        <tr>
                            <th>Service</th>
                            <th>Canadian</th>
                            <th>United States</th>
                        </tr>
                    </xsl:when>
                    <xsl:otherwise>
                        <tr>
                            <th class="serviceCol">Service</th>
                            <th class="rowRight mechanicalCol">Exclude Mechanicals?</th>
                        </tr>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:for-each select="Form/ServiceList/Service">
                    <xsl:call-template name="serviceRow" />
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>


    <xsl:template name="serviceRow">
        <tr class="row{position() mod 2}">
            <td>
                <xsl:value-of select="ServiceName" />
            </td>
            <xsl:if test="/Root/Access/rps/ca_license/edit">
                <td class="icon rowRight">
                    <xsl:if test="/Root/Access/rps/license/edit">
                        <xsl:attribute name="class">icon</xsl:attribute>
                    </xsl:if>
                    <input type="hidden" name="Form_ServiceList_Service_{@i}_ExcludeCAMechanicals" id="Form_ServiceList_Service_{@i}_ExcludeCAMechanicals" value="{ExcludeCAMechanicals}" />
                    <input type="checkbox" name="Trigger_Form_ServiceList_Service_{@i}_ExcludeCAMechanicals" id="Trigger_Form_ServiceList_Service_{@i}_ExcludeCAMechanicals" onClick="checkCheckBox(this,'Form_ServiceList_Service_{@i}_ExcludeCAMechanicals')">
                        <xsl:if test="ExcludeCAMechanicals = 1">
                            <xsl:attribute name="checked">checked</xsl:attribute>
                        </xsl:if>
                        <xsl:if test="$openCARuns &gt; 0">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </td>
            </xsl:if>
            <xsl:if test="/Root/Access/rps/license/edit">
                <td class="icon rowRight">
                    <input type="hidden" name="Form_ServiceList_Service_{@i}_ExcludeMechanicals" id="Form_ServiceList_Service_{@i}_ExcludeMechanicals" value="{ExcludeMechanicals}" />
                    <input type="checkbox" name="Trigger_Form_ServiceList_Service_{@i}_ExcludeMechanicals" id="Trigger_Form_ServiceList_Service_{@i}_ExcludeMechanicals" onClick="checkCheckBox(this,'Form_ServiceList_Service_{@i}_ExcludeMechanicals')">
                        <xsl:if test="ExcludeMechanicals = 1">
                            <xsl:attribute name="checked">checked</xsl:attribute>
                        </xsl:if>
                        <xsl:if test="$openUSRuns &gt; 0">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </td>
            </xsl:if>
        </tr>
    </xsl:template>


    <xsl:template name="submitButton">
        <input name="submit" type="submit" value="Update" id="submitButton">
            <xsl:if test="(not(Access/rps/ca_license/edit) and $openCARuns &gt; 0) or (not(Access/rps/license/edit) and $openUSRuns &gt; 0) or ($openUSRuns &gt; 0 and $openCARuns &gt; 0)">
                <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
        </input>
    </xsl:template>


    <xsl:template name="cancelButton">
		<input type="button" name="Back" value="Back to Admin" onClick="location.href='/rps/display?d=config'" />
    </xsl:template>


</xsl:stylesheet>
