<?xml version="1.0"?>
<!--
 -
 -  $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
 -
-->
<v:page name="ui_profile"
        xmlns:vm="http://www.openlinksw.com/vspx/ods/"
        xmlns:v="http://www.openlinksw.com/vspx/"
	      style="index.xsl"
	      fast-render="1"
        doctype="-//W3C//DTD XHTML 1.0 Transitional//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <v:method name="addProperty" arglist="in obj any, in objProperty varchar, in paramsProperty varchar, in params any">
    <![CDATA[
      declare tmp ay;

      tmp := trim (get_keyword (paramsProperty, params));
      if (not is_empty_or_null (tmp))
        obj := vector_concat (obj, vector (objProperty, tmp));
      return obj;
    ]]>
  </v:method>

  <v:method name="jsonObject" arglist="">
    <![CDATA[
      return subseq (soap_box_structure ('x', 1), 0, 2);
    ]]>
  </v:method>

  <v:method name="checkBox" arglist="in checkField varchar, inout properties any">
    <![CDATA[
      declare S varchar;

      S := '';
      if (get_keyword (checkField, properties, '0') <> '0')
        S := 'checked="checked"';
      http (sprintf ('<input type="checkbox" name="%s" id="%s" value="1" %s />', checkField, checkField, S));
    ]]>
  </v:method>

  <vm:page>
    <vm:header>
      <script type="text/javascript" src="tbl.js">;</script>
      <script type="text/javascript" src="typeahead.js">;</script>
      <link rel="stylesheet" href="typeahead.css" type="text/css" />
      <vm:title>Edit your personal data</vm:title>
    </vm:header>
    <vm:pagewrapper vm_onunload="checkPageLeave (document.forms['page_form'])">
      <v:variable persist="temp" name="msg_msg" type="varchar" default="''"/>
      <v:variable name="tabNo" type="integer" param-name="tabNo" default="0"/>
      <v:variable name="pg" type="integer" param-name="page" default="1"/>
      <v:variable name="is_org" type="integer" default="0" />
      <vm:rawheader caption="Edit your personal data"/>
      <vm:navigation-new on="settings"/>
      <vm:subnavigation-new on="site"/>
      <vm:body>
        <v:before-data-bind>
          <![CDATA[
            self.is_org := coalesce ((select WAUI_IS_ORG from WA_USER_INFO where WAUI_U_ID = self.u_id), 0);
          ]]>
        </v:before-data-bind>
        <script type="text/javascript">
          <![CDATA[
            function getFileName(form, from, to)
            {
              var S = from.value;
              var N;
              var fname;
              if (S.lastIndexOf('\\') > 0)
                N = S.lastIndexOf('\\')+1;
              else
                N = S.lastIndexOf('/')+1;
              fname = S.substr(N,S.length);
              to.value = fname;
            }
            function swPersHide ()
            {
              var lb = $('lb_1');
              if (lb)
                lb.innerHTML = 'Organization Webpage';
              for (i = 1; i <= 20; i++)
                OAT.Dom.hide('pers_'+i);
              OAT.Dom.hide('p_url_2');
            }
            function swPersShow ()
            {
              var lb = $('lb_1');
              if (lb)
                lb.innerHTML = 'Personal Webpage';
              for (i = 1; i <= 20; i++)
                OAT.Dom.show('pers_'+i);
              OAT.Dom.show('p_url_2');
            }
            function swOrg (cb)
            {
              (cb.checked)? swPersHide(): swPersShow();
            }
            function checkRest (form, sel)
            {
              var i;
              if (sel.selectedIndex == 0)
                return;
              for (i = 0; i < form.elements.length; i++)
              {
                var contr = form.elements[i];
                if (contr != null && contr != sel && contr.type == "select-one")
                {
                  if (contr.selectedIndex == sel.selectedIndex)
                    contr.selectedIndex = 0;
                }
              }
            }
            ODSInitArray.push ( function () {
              OAT.Loader.load(["json", "ws", "calendar", "combolist"], function(){OAT.MSG.attach(OAT, "PAGE_LOADED", function(){(<?V self.is_org ?>)? swPersHide(): swPersShow();}); OAT.MSG.send(OAT, 'PAGE_LOADED');});
            });
          ]]>
        </script>
        <vm:login redirect="index.vspx"/>
        <div class="message">
          <v:label name="pwd_msg" value="--self.msg_msg" />
          <input type="hidden" name="dirty_force_global" id="dirty_force_global" value="<?vsp http(get_keyword ('dirty_force_global', self.vc_event.ve_params, 'false')); ?>"/>
          <input type="hidden" name="page" value="<?V self.pg ?>"/>
          <input type="hidden" name="tabNo" id="tabNo" value="<?V self.tabNo ?>"/>
        </div>
        <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
          <tr valign='top'>
            <td>
              <table cellpadding='10' cellspacing='0' border='0' width='100%'>
                <tr>
                  <td class="tab_deck">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="navtab_tabs_ctr">
                        <v:include name="nav" url="uiedit_nav.vspx"/>
                    </table>
                    <table class="tab_page">
                      <tr>
                        <td valign="top" class="tab_page">
                            <v:include url="uiedit_svc.vspx"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </vm:body>
    </vm:pagewrapper>
  </vm:page>
</v:page>
