<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet  version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dir="http://www.xsearchservices.com/namespaces/directives"
                xmlns:rss="http://www.xsearchservices.com/namespaces/rss"
                >
  <xsl:include href="../../includes/systemheader.xsl" /><xsl:include href="../includes/header.xsl" />
  <xsl:include href="../includes/widgets.xsl" />
  <xsl:include href="../../includes/xsl_functions/string.xsl" />

  <xsl:template name="header">
    <title>company - <xsl:value-of select="/response/procxml/root/company/name" /></title>
    <meta name="title" content="company" />
    <meta name="keywords" content="company" />
    <meta name="description" content="" />
    <link rel="stylesheet" type="text/css" href="/easyethical/company/all.css" />
    <link rel="stylesheet" type="text/css" href="/easyethical/includes/widgets.css" />
    <script type="text/javascript" src="/easyethical/company/all.js" />

    <link rel="stylesheet" href="/includes/jquery/v1.3.2/flora.slider.css" type="text/css" />
    <link rel="stylesheet" href="/easyethical/css/tabs.css" type="text/css" />
    <script type="text/javascript" src="/includes/jquery/v1.3.2/ui.core.js"></script>
    <script type="text/javascript" src="/includes/jquery/v1.3.2/ui.slider.js"></script>
    <script type="text/javascript" src="/includes/jquery/v1.3.2/ui.sortable.js"></script>
    <script type="text/javascript" src="/includes/jquery/v1.3.2/ui.tabs.js"></script>
  </xsl:template>

  <xsl:template name="contextualmenus">
    <li class="item_hover_exclusive_global contextual">company
      <div class="item_contents"><ul>
        <li><a href="{$link_base}/company/seedarticle">seed article</a></li>
        <li class="item_hover_exclusive_global last disabled">article order
          <div class="item_contents"><ul>
              <li><a class="disabled" href="#">latest first</a></li>
              <li><a class="disabled" href="#">alphabetical</a></li>
              <li><a class="disabled" href="#">most agreeable</a></li>
              <li class="last"><a class="disabled" href="#">by source</a></li>
          </ul></div>
        </li>
      </ul></div>
    </li>
  </xsl:template>

  <xsl:template match="root">
    <table class="layout"><tr><xsl:apply-templates /></tr></table>
  </xsl:template>

  <xsl:template match="noxml|notfound">
    your search for “<xsl:value-of select="/root/term" />” yielded no results
  </xsl:template>

  <xsl:template match="manyfound">
    your search for “<xsl:value-of select="/root/term" />” yielded many results
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="externalsource"></xsl:template>

  <xsl:template match="company">
    <td class="{local-name()}">
      <h1>
        <img alt="company" src="/easyethical/images/{$theme}/48x48/company.png" />
        <xsl:if test="../externalsource"><xsl:apply-templates select="../externalsource" mode="widget_externalsource_inline" /> on </xsl:if>
        <xsl:apply-templates select="." mode="widget_company_inline" />
      </h1>
      
      <!-- notabs gets replaced with aretabs and the jQuery tab system at startup -->
      <div class="notabs">
        <ul>
          <li><a href="#summary" ><span>summary<xsl:if test="not(summaries/summary)"> (!)</xsl:if></span></a></li>
          <li><a href="#articles" ><span>articles (<xsl:value-of select="count(rss:feed/rss:items/articles/article)" />)</span></a></li>
          <li><a href="#lists" ><span>lists (<xsl:value-of select="count(rss:feed/rss:items/lists/list)" />)</span></a></li>
          <li><a href="#taggroups"><span>subjects (<xsl:value-of select="count(taggroups/taggroup)" />)</span></a></li>
          <li><a href="#related"  ><span>related companies (<xsl:value-of select="count(related/entities/*)" />)</span></a></li>
          <li><a href="#forum"    ><span>forum (0)</span></a></li>
        </ul>

        <div id="summary">
          <div class="message">
            Company summaries are not developed yet. 
          </div>
          <p>
            Company summaries will be linked with the wikipedia definition.
            Updates to this summary will auto change the ethics section of the wikipedia page and vice-versa.
            Two types of summary will be available: Technical and Ethics.
            Only people who have read many of the documents will be able to edit this part.
          </p>
        </div>

        <div id="lists">
          <div class="message">
            Lists are not developed yet. 
          </div>
          <p>
            Lists are ranked collections of companies around a particular task or product type.
            e.g. "Which supermarket" or "The best DVD player"<br />
            This tab will show all the lists that this company appears in.
          </p>
        </div>

        <div id="articles">
          <form action="/company/seedarticle" method="post"><div class="forminline">
            <input type="submit" value="seed article" />
          </div></form>
          (add a new article into the system from the Internet)
          <form action="/source/addedit" method="post"><div class="forminline">
            <input type="submit" value="add source" />
          </div></form>
          (add and index an entire website into the system)
          <div class="message">Pageing through articles is in development.</div>
          <xsl:apply-templates select="rss:feed" />
        </div>

        <div id="taggroups">
          <xsl:apply-templates select="taggroups" />
        </div>

        <div id="related">
          <xsl:apply-templates select="related" />
        </div>

        <div id="forum">
          <div class="message">Forums are not developed yet.</div>
        </div>
      </div>
    </td>
  </xsl:template>

  <!-- ################################ taggroups ######################################## -->
  <xsl:template match="taggroups">
    <xsl:call-template name="widget_cloud" />
  </xsl:template>

  <xsl:template match="taggroup">
    <a href="{$link_base}/taggroup/{@id}"><xsl:value-of select="rss:title" /></a>
  </xsl:template>

  <!-- ################################ related ######################################## -->
  <xsl:template match="related">
    <xsl:apply-templates mode="widget_entities_inlinelist" />
  </xsl:template>
  
  <!-- ################################ articles ######################################## -->
  <xsl:template match="articles">
    <h2>articles 
      <span class="count">(<xsl:value-of select="count(*)" />/<xsl:value-of select="@count" />):</span>
    </h2>
    <ul><xsl:apply-templates /></ul>
  </xsl:template>

  <xsl:template match="article">
    <li class="{local-name()}"><xsl:apply-templates /></li>
  </xsl:template>

  <xsl:template match="article/rss:title">
    <h3 class="{local-name()}">
      <a href="{$link_base}/article/{../@id}?entityid={/response/procxml/root/company/@id}"><xsl:apply-templates /></a>
    </h3>
  </xsl:template>

  <xsl:template match="article/source">
    <span class="{local-name()}">
      - <a title="{domain}" href="{$link_base}/source/{@id}"><xsl:value-of select="rootpagetitle" /></a>
    </span>
  </xsl:template>

  <xsl:template match="article/date">
    <span class="{local-name()}"><xsl:apply-templates /></span>
    <ul class="stats_article">
      <li><xsl:call-template name="widget_starrating_inline"><xsl:with-param name="stars" select="3" /></xsl:call-template></li>
      <li>comments total / this week / today: 0/0/0</li>
    </ul>
  </xsl:template>
  
  <xsl:template match="article/rss:pubdate"></xsl:template>
  
  <xsl:template match="descriptions">
    <ul class="{local-name()}"><xsl:apply-templates /></ul>
  </xsl:template>

  <xsl:template match="sentences|summaries">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="firstpara|sentence|summary">
    <li class="{local-name()}">
      <xsl:apply-templates />
      <xsl:if test="@truncated = 'true'">
        ... <span class="more">
          [<a href="#">more</a>]
        </span>
      </xsl:if>
    </li>
  </xsl:template>

  <xsl:template match="tags">
    <xsl:apply-templates select="." mode="widget_tags_list">
      <xsl:with-param name="cutoff" select="20" />
    </xsl:apply-templates>
  </xsl:template>

  <!-- ############################# session ############################################## -->
  <xsl:template match="session">
    <td class="{local-name()}"><xsl:apply-templates select="." mode="widget_session_bar" /></td>
  </xsl:template>
</xsl:stylesheet>
