<?xml version="1.0" encoding="UTF-8"?>
<!--
 -
 -  $Id$
 -
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -
 -  Copyright (C) 1998-2018 OpenLink Software
 -
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -
-->
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:v="http://www.openlinksw.com/vspx/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
  <head profile="http://internetalchemy.org/2003/02/profile">
    <base href="<?V POLLS.WA.host_url () || http_path () ?>" /><![CDATA[<!--[if IE]></base><![endif]-->]]>
    <?vsp
      declare domainName varchar;

      domainName := POLLS.WA.domain_name (self.domain_id);
      http(sprintf('<link rel="foaf" type="application/rdf+xml" title="FOAF" href="%s" />', POLLS.WA.foaf_url (self.account_id)));
      if (POLLS.WA.domain_is_public (self.domain_id))
      {
        http(sprintf('\n<link rel="meta" type="application/rdf+xml" title="SIOC" href="%s" />', POLLS.WA.sioc_url (self.domain_id)));
      http (sprintf ('\n    <link rel="search" type="application/opensearchdescription+xml" title="%s OpenSearch Description" href="%sexport.vspx?mode=opensearchdescription" />', domainName, POLLS.WA.polls_url (self.domain_id)));
      }
      http (sprintf ('\n    <link rel="alternate" type="application/rss+xml" title="%V RSS" href="%s" />', domainName, POLLS.WA.gems_url (self.domain_id)||'Polls.rss'));
      http (sprintf ('\n    <link rel="alternate" type="application/atom+xml" title="%V Atom" href="%s" />', domainName, POLLS.WA.gems_url (self.domain_id)||'Polls.atom'));
      http (POLLS.WA.geo_url (self.domain_id, self.account_id));

      SIOC..rdf_links_header (self.rdf_iri);
      SIOC..rdf_links_head (self.rdf_iri);
    ?>
    <link rel="stylesheet" href="css/style.css" type="text/css"/>
    <link rel="stylesheet" href="/ods/common.css" type="text/css" />
    <link rel="stylesheet" href="/ods/typeahead.css" type="text/css" />
    <meta name="dc.description" content="<?V POLLS.WA.utf2wide (POLLS.WA.domain_description (self.domain_id)) ?>" />
    <meta name="dc.title" content="<?V POLLS.WA.utf2wide (POLLS.WA.domain_description (self.domain_id)) ?>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <![CDATA[
      <script type="text/javascript" src="/ods/oat/loader.js"></script>
      <script type="text/javascript">
        OAT.Preferences.imagePath = '/ods/images/oat/';
        OAT.Preferences.stylePath = '/ods/oat/styles/';
        OAT.Preferences.showAjax = false;
        
        // DAV
        var davOptions = {
          imagePath: OAT.Preferences.imagePath,
          pathHome: '/home/',
          path: '<?V POLLS.WA.dav_logical_home (self.account_id) ?>',
          user: '<?V POLLS.WA.account_name (self.account_id) ?>',
          connectionHeaders: {Authorization: '<?V POLLS.WA.account_basicAuthorization (self.account_id) ?>'}
        };

      	/* load stylesheets */
      	OAT.Style.include("grid.css");
      	OAT.Style.include("webdav.css");

        var featureList=["ajax", "json", "anchor", "dialog", "barchart", "piechart", "calendar"];
        OAT.Loader.load(featureList);
    </script>
      <script type="text/javascript" src="/ods/tbl.js"></script>
      <script type="text/javascript" src="/ods/typeahead.js"></script>
      <script type="text/javascript" src="/ods/app.js"></script>
      <script type="text/javascript" src="js/polls.js"></script>
      <script type="text/javascript">
        function myInit() {
          if (!OAT._loaded) {
            setTimeout(myInit, 100);
            return;
          }
        
          if (<?V cast (get_keyword ('app', self.settings, '0') as integer) ?> > 0)
            generateAPP('app_area', {appActivation: "<?V case when cast (get_keyword ('app', self.settings, '1') as integer) = 2 then 'hover' else 'click' end ?>"});
            
      		// init tabs
          showTab('p', 2, 0);
          showTab('s', 2, 0);

          setFooter();
          window.onresize = function() {setFooter();}

          OAT.MSG.send(OAT, 'PAGE_LOADED');
        }
        OAT.MSG.attach(OAT, 'PAGE_LOADED2', myInit);
        window.onload = function(){OAT.MSG.send(OAT, 'PAGE_LOADED2');};
      </script>
    ]]>
    <title></title>
  </head>
  <body>
    <v:page xmlns:v="http://www.openlinksw.com/vspx/">
        <v:variable persist="0" name="domain_id" type="integer" default="-1" />
        <v:variable persist="0" name="account_id" type="integer" default="-1" />
      <v:variable persist="0" name="account_rights" type="varchar" default="''" />
      <v:variable persist="0" name="owner_id" type="integer" default="null" />
        <v:variable persist="0" name="settings" type="any" />
      <v:variable persist="0" name="rdf_iri" type="varchar" default="null" />
      <v:on-init>
        <![CDATA[
          set ISOLATION = 'Committed';
          set http_charset = 'utf-8';

          -- Initialize variables
          declare aSessInfo any;

          aSessInfo := POLLS.WA.session_restore (params);
          self.domain_id := cast(get_keyword('domain_id', aSessInfo, '-1') as integer);
          self.account_id := cast (get_keyword ('account_id', aSessInfo, '-1') as integer);
          self.account_rights := get_keyword ('account_rights', aSessInfo);
          self.owner_id := POLLS.WA.domain_owner_id (self.domain_id);
          self.settings := vector_concat (vector ('app', DB.DBA.WA_USER_APP_ENABLE (self.account_id)), POLLS.WA.settings (self.domain_id));
        ]]>
      </v:on-init>

      <v:after-data-bind>
        <![CDATA[
          if (POLLS.WA.frozen_check(self.domain_id)) {
            declare freeze_page varchar;
            freeze_page := POLLS.WA.frozen_page(self.domain_id);
            if (freeze_page is null or freeze_page = '' or freeze_page = 'default') {
              http_rewrite ();
              http_request_status ('HTTP/1.1 404 Not found');
              http (sprintf('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><head><TITLE>404 Not Found</TITLE></HEAD><body><H1>Not Found</H1>Resource %s not found.</BODY></HTML>', http_path (POLLS.WA.page_name())));
              http_flush();
              return;
            }
            http_rewrite ();
            http_request_status ('HTTP/1.1 302 Found');
            http_header(sprintf('Location: %s\r\n\r\n', freeze_page));
            http_flush();
            return;
          }
        ]]>
      </v:after-data-bind>

      <v:placeholder />
    </v:page>
  </body>
</html>
