<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="PAGED-LIST">
<script language="javascript">
function pagedListDoSort(orderBy, orderType) {
	document.location.href="<xsl:value-of select="PAGER/URL"/>?pageNum=1&amp;orderBy=" + escape(orderBy)
		+ "&amp;orderType=" + escape(orderType);
}
function setCheckboxStatus(status) {
	form = document.forms.listForm;
	for (var n = 0; n &lt; form.elements.length; n++) {
		if (form.elements[n].type == 'checkbox') {
			if (!form.elements[n].disabled) {
				form.elements[n].checked = status;
			}
		}
	}
}
function countSelectedCheckBoxes() {
	result = 0;
	form = document.forms.listForm;
	for (var n = 0; n &lt; form.elements.length; n++) {
		if (form.elements[n].type == 'checkbox') {
			if (form.elements[n].checked) {
				++result;
			}
		}
	}
	return result;
}
</script>
	<fieldset class="sb-toolbar-fieldset">
		<legend class="sb-label-toolbar-title"><xsl:value-of select="TOOLBAR/@TITLE"/></legend>
		<xsl:apply-templates select="TOOLBAR"/>
		<xsl:choose>
			<xsl:when test="PAGER/TOTAL-RECORDS &gt; 0">
				<xsl:apply-templates select="PAGER"/>
				<form name="listForm" method="post" action="{$baseUrl}" style="paffing:0px;margin:0px">
					<input type="hidden" name="action" value=""/>
					<xsl:apply-templates select="LIST"/>
				</form>
				<xsl:apply-templates select="PAGER"/>
			</xsl:when>
			<xsl:otherwise>
				<table width="100%" class="sb-gridview-emptydatarow" >
					<tr><td><xsl:value-of select="MSG-NO-RECORDS"/></td></tr>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</fieldset>
</xsl:template>

<xsl:template match="PAGED-LIST/LIST">
<table cellspacing="1" border="0" style="width:100%;">
	<xsl:apply-templates select="HEADER" />
	<xsl:apply-templates select="ITEM" />
</table>
</xsl:template>

<xsl:template name="LIST-HEADER-ITEM">
<xsl:param name="align"/>
<xsl:param name="field"/>
<xsl:param name="title"/>
<xsl:param name="width"/>
<xsl:param name="currentSortField"/>
<xsl:param name="currentSortType"/>

<xsl:variable name="orderType">
<xsl:choose>
	<xsl:when test="$field = $currentSortField">
		<xsl:choose>
			<xsl:when test="$currentSortType = 'ASC'">DESC</xsl:when>
			<xsl:otherwise>ASC</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>ASC</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<th class="sb-gridview-header" scope="col" style="width:{$width};text-align:{$align}; vertical-align: middle; white-space:nowrap;" >
<!-- background-color: rgb(214, 223, 247); font-size: 11px; height: 24px; white-space: nowrap; -->
	<xsl:if test="$field = $currentSortField">
		<xsl:attribute name="class">sb-gridview-header-sorted</xsl:attribute>
	</xsl:if>
	
	<xsl:if test="../../LIST[@CONTEXT-HELP-SUPPORT = '1']">
		<xsl:attribute name="onmouseout">SetContextHelp();</xsl:attribute>
		<xsl:attribute name="onmouseover">SetContextHelp('CONTEXT-HELP-LIST-HEADER-<xsl:value-of select="$field"/>');</xsl:attribute>
	</xsl:if>
	
	<xsl:choose>
		<xsl:when test="$field">
			<a href="javascript:pagedListDoSort('{$field}','{$orderType}');">
				<xsl:if test="$field != $currentSortField">
					<xsl:attribute name="style">color: Black;</xsl:attribute>
				</xsl:if>
				<xsl:value-of select="$title"/>
			</a>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$title"/>
		</xsl:otherwise>
	</xsl:choose>

	<xsl:if test="$field = $currentSortField">
		<xsl:choose>
			<xsl:when test="$currentSortType = 'ASC'">
				<img style="display: inline; vertical-align: middle; border-width:0px;">
					<xsl:attribute name="src"><xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SKIN-PATH/."/>/images/dlg_sort_up.gif</xsl:attribute>
				</img>
			</xsl:when>
			<xsl:otherwise>
				<img style="display: inline; vertical-align: middle; border-width:0px;">
					<xsl:attribute name="src"><xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SKIN-PATH/."/>/images/dlg_sort_down.gif</xsl:attribute>
				</img>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:if>
	<img style="display: inline; vertical-align: middle; border-width:0px; width: 1px; height:16px;">
		<xsl:attribute name="src"><xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SKIN-PATH/."/>/images/empty.gif</xsl:attribute>
	</img>
</th>
</xsl:template>

<xsl:template name="LIST-ROW-CLASS">
<xsl:param name="position"/>
<xsl:choose>
	<xsl:when test="$position mod 2">sb-gridtext</xsl:when>
	<xsl:otherwise>sb-gridtext-alter</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="LIST-ROW-ITEM">
<xsl:param name="align"/>
<xsl:param name="title"/>
<xsl:param name="action"/>
<xsl:param name="icon"/>
<xsl:param name="contextHelp"/>
<td style="text-align:{$align};padding-left:4px;padding-right:4px;">
	<xsl:choose>
		<xsl:when test="$action != ''">
			<a>			
				<xsl:choose>
					<xsl:when test="substring-before($action,':')='javascript'">
						<xsl:attribute name="onclick"><xsl:value-of select="$action"/></xsl:attribute>
						<xsl:attribute name="href">#</xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="href"><xsl:value-of select="$action"/></xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>			
			
				<xsl:if test="$contextHelp">
					<xsl:attribute name="onmouseout">SetContextHelp();</xsl:attribute>
					<xsl:attribute name="onmouseover">SetContextHelp('CONTEXT-HELP-LIST-ROW-<xsl:value-of select="$contextHelp"/>');</xsl:attribute>
				</xsl:if>
				<xsl:if test="$icon">
				<img style="border-width:0px;width:16px;height:16px">
					<xsl:attribute name="src"><xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SKIN-PATH/."/>/icons/<xsl:value-of select="$icon"/></xsl:attribute>
				</img>
				</xsl:if>
				<xsl:value-of select="$title"/>
			</a>
		</xsl:when>
		<xsl:otherwise>
			<xsl:if test="$icon">
				<img style="border-width:0px;width:16px;height:16px">
					<xsl:if test="$contextHelp">
						<xsl:attribute name="onmouseout">SetContextHelp();</xsl:attribute>
						<xsl:attribute name="onmouseover">SetContextHelp('CONTEXT-HELP-LIST-ROW-<xsl:value-of select="$contextHelp"/>');</xsl:attribute>
					</xsl:if>
					<xsl:attribute name="src"><xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SKIN-PATH/."/>/icons/<xsl:value-of select="$icon"/></xsl:attribute>
				</img>
			</xsl:if>
			
			<xsl:call-template name="nl2br">
				<xsl:with-param name="string" select="$title"/>
			</xsl:call-template>
		</xsl:otherwise>
	</xsl:choose>
</td>
</xsl:template>


<xsl:template match="PAGED-LIST/TOOLBAR">
<script language="javascript">
function pagedListShowAll() {
	if (document.forms.toolBarForm.filterValue) {
		if (document.forms.toolBarForm.filterValue.disabled) {
			document.forms.toolBarForm.filterValue.disabled = false;
		}
		
		document.forms.toolBarForm.filterValue.selectedIndex = 0;
	}
		
	document.forms.toolBarForm.searchString.value='';
	document.forms.toolBarForm.submit();
}
function pagedListSearchItems() {
	document.forms.toolBarForm.submit();
}
function pagedListChangeFilter() {
	document.forms.toolBarForm.submit();
}
</script>

<xsl:choose>
	<xsl:when test="@FORM-TAG='no'">
		<xsl:call-template name="TOOLBAR-FORM-CONTENT" />
	</xsl:when>
	<xsl:otherwise>
		<form name="toolBarForm" method="get" action="{@ACTION}" style="padding:0px; margin:0px">
			<xsl:call-template name="TOOLBAR-FORM-CONTENT" />
		</form>
	</xsl:otherwise>
</xsl:choose>	

</xsl:template>

<xsl:template name="TOOLBAR-FORM-CONTENT">
	<input type="hidden" name="pageNum" value="1"/>
	<table cellspacing="0" cellpadding="5" border="0" style="border-collapse:collapse;" width="100%">
		<xsl:if test="count(../LIST/ITEM) &gt; 0">
			<tr>
				<td colspan="3" style="padding-top:10px;">
					<xsl:apply-templates select="OPERATIONS"/>
				</td>
			</tr>
		</xsl:if>
		
		<tr>
			<td style="padding-top:10px;" width="10"><xsl:apply-templates select="LIST-VIEW-STATES"/></td>
			<td style="padding-top:10px;" width="10"><xsl:apply-templates select="SEARCH-PANEL"/></td>
			<td style="padding-top:10px;" width="90%">
			</td>
			
		</tr>
	</table>
	<!--</fieldset>-->
</xsl:template>

<xsl:template match="PAGED-LIST/TOOLBAR/OPERATIONS">
<table cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;" >
<tr>
<xsl:for-each select="OPERATION">
	<td style="padding-right: 4px;">
			<a href="#">
				<xsl:attribute name="onclick"><xsl:value-of select="@ACTION"/></xsl:attribute>
				<img border="0" alt="" width="16" height="16">
					<xsl:attribute name="src"><xsl:value-of select="$skinPath"/>/icons/<xsl:value-of select="@ICON"/></xsl:attribute>
				</img>
			</a>
	</td>
	<td style="padding-right: 8px;">
		<a href="#" style="color: Black;">
			<xsl:attribute name="onclick"><xsl:value-of select="@ACTION"/></xsl:attribute>
			<xsl:value-of select="@TITLE"/>
		</a>
	</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>

<xsl:template match="PAGED-LIST/TOOLBAR/LIST-VIEW-STATES">
<table cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;" >
	<tr>
		<td valign="middle" class="sb-text" style="padding-right: 5px;"><xsl:value-of select="@TITLE"/></td>
		<td valign="middle" style="padding-right: 5px;">
			<select name="filterValue" onchange="pagedListChangeFilter();" class="sb-text">
				<xsl:if test="@DISABLED = 1"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
				<xsl:for-each select="STATE">
					<option>
						<xsl:if test="../@SELECTED = @VALUE"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>
						<xsl:attribute name="value"><xsl:value-of select="@VALUE"/></xsl:attribute>
						<xsl:value-of select="@TITLE"/>
					</option>
				</xsl:for-each>
			</select>
		</td>
	</tr>
</table>
</xsl:template>

<xsl:template match="PAGED-LIST/TOOLBAR/SEARCH-PANEL">
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td style="width: 150px; white-space: nowrap;padding-right: 10px;">
		<input name="searchString" type="text" value="{.}" class="sb-text" style="border-color:#999EA1;border-width:1px;border-style:Solid;width:145px;"/>
	</td>
	<td align="center" style="width: 10; padding-right: 10px">
		<table cellpadding="0" cellspacing="0" border="0" onclick="pagedListSearchItems();" type="button" style="cursor:pointer;">
		<tr>
			<td align="center">
				<img src="{$skinPath}/icons/search.png" alt="" width="16" height="16"/>
			</td>
			<td align="center" class="sb-text" style="text-decoration:underline;padding-left:5px;white-space:nowrap;"><xsl:value-of select="@SEARCH-TITLE"/></td>
		</tr>
		</table>
	</td>
	<td align="left" style="width: 10;">
		<table cellpadding="0" cellspacing="0" border="0" onclick="pagedListShowAll();" type="button" name="ImageButtonShowAll" style="cursor:pointer;">
			<tr>
				<td align="center">
					<img src="{$skinPath}/icons/showall.png" alt="" width="16" height="16"/>
				</td>
					<td align="center" class="sb-text" style="text-decoration:underline;padding-left:5px;white-space:nowrap;"><xsl:value-of select="@SHOW-ALL-TITLE"/></td>
			</tr>
		</table>
	</td>
	</tr>
</table>
</xsl:template>

</xsl:stylesheet>
