///////////////////////////////////////////
//
// Copyright FAST 2000-2004
//
// Code may not be used, copied or modified 
// without permission.
//
// webmaster@fast-thales.net
//
///////////////////////////////////////////

// JAVASCRIPT - fast.js

var lineno;
var news_type;
var nonews;
var old_news;
var no_show;
var topframe=-1;
var base="http://www.fast-thales.net/";
//var base="";
var archive_year=0;

function validatename(field)
{
  var validchar = " -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  if (field.length == 0) return false;
  for (var i=0; i < field.length; i++)
  {
     ch = field.substring(i, i+1);
     if (validchar.indexOf(ch) < 0) return false;
  }
  return true;
}

function validateemail(emailStr)
{
   // checks if the e-mail address is valid
   // Routine based on original by Sandeep V. Tamhankar (stamhankar@hotmail.com) at 
   // The JavaScript Source!! http://javascript.internet.com
   // Routine modified by Anthony Harrison (anthony.harrison@btinternet.com) to
   // allow email addresses of the form firstname.surname@company.domain
   // var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
   // Modifed again to allow domain names of the format x-ltd.com
   // var emailPat = /^([A-za-z](\w|\.|-)*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
   var emailPat = /^([A-za-z](\w|\.|-)*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z](\w|\.|-)*(\.[A-Za-z](\w|\.|-)*)+)$/;
   var matchArray = emailStr.match(emailPat);
   if (matchArray == null) return false;
   return true;
}

function verify(formid)
{
   if (!validatename(formid.Name.value))
   {
      alert ("That doesn't look like your name. Please re-enter your full name");
      return false;
   }
   if (!validatename(formid.Organisation.value))
   {
      alert("You must specify the full name of your organisation");
      return false;
   }
   if (!validateemail(formid.Email.value))
   {
      alert("I can't keep you informed if you don't specify a VALID email address. Please re-enter.");
      return false;
   }
   return true;
}

function show_date(thedate)
{
   var day = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
   var month = new Array("January","February","March","April","May","June","July","August", "September","October","November","December");
   var days = new Array("","st","nd", "rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st");
   var lastDate=formdate(thedate);
   document.write(lastDate.getDate() + days[lastDate.getDate()]+'&nbsp;');
   document.write(month[lastDate.getMonth()] + '&nbsp;');
   document.writeln(lastDate.getFullYear() + '&nbsp;');
}

function formdate(datestr)
{
   if (datestr.substring(4) >"50") formeddate=new Date(19+datestr.substring(4),datestr.substring(2,4)-1,datestr.substring(0,2),23,59);
   else formeddate=new Date(20+datestr.substring(4),datestr.substring(2,4)-1,datestr.substring(0,2),23,59);
   return formeddate;
}

function newsyear(datestr)
{
   if (datestr.substring(4) >"50") year='19'+datestr.substring(4)
   else year = '20'+datestr.substring(4);
   return year;
}

function start_news(type)
{
   set_nonews(1);
   no_show = 0;
   news_type = type;
   lineno = 0;
}

function get_nonews()
{
   if (browser.isIE)
   {
      x = myform.nonews.value; // Reference to myform
   }
   else x=0;
   return x;
}

function set_nonews(val)
{
   if (browser.isIE) myform.nonews.value=val;
}


function get_old_news()
{
   if (browser.isIE)
   {
      old = myform.oldnews.value; // Reference to myform
   }
   else old=0;
   return old;
}

function set_old_news(val)
{
   if (browser.isIE) myform.oldnews.value=val;
   if (val == 0) archive_year=0;
}

function set_news_format(val)
{
   if (browser.isIE) myform.newsformat.value=val;
}

function get_news_format()
{
   if (browser.isIE)
   {
      news_format = myform.newsformat.value; // Reference to myform
   }
   else news_format=0;
   return news_format;
}

function show_old_news(page)
{
   set_old_news(1);
   location.replace(location.href);
}

function set_archive(year)
{
   set_old_news(1);
   archive_year=year;
}

function news (newsdate, expires, link, item)
{
   // Check item has not expired
   // Expires format is ddmmyy as a string
   today=new Date();
   expiredate=formdate(expires);
   if (get_old_news() > 0)
   {
     show = (today.getTime() < expiredate.getTime() ? 0: 1);
     if (show > 0)
     {
        // News has expired
        show = (newsyear(newsdate) == archive_year ? 1 : 0);
     }
   }
   else
   {
     show = (today.getTime() < expiredate.getTime() ? 1: 0);
   }
   //if (get_news_format() > 0)
   //{
   //   show = show_new(newsdate,expires);
   //}
   if (show > 0)
   {
      // Still newsworthy!
      document.write('<tr><td class=news>');
      if (get_news_format() == 0)
      {
         show_date(newsdate);
      }
      news_date=formdate(newsdate);
      if (show_new(newsdate,expires))
      {
         document.write ('<IMG border=0 src="pics/new.gif" alt="New">');
      }
//  14nov    document.write('</td><td>');
      document.write('</td></tr><tr><td>');
if (get_news_format() > 0)
{
   max=25;
   if (item.length > max)
   {
      document.write (item.substr(0,max) + '<a href="' + link + '" target=right> More...</a>');
   }
   else
   {
      document.write('<a href="' + link + '" target=right>' + item + '</a>');
   }

}
else
{
      if (link != "")
      {
         document.write('<a href="' + link + '"');
         if (get_news_format() > 0)
         {
            document.write (' target=right');
         }
         document.write('>' + item + '</a>');
      }
      else document.write(item);
}


      document.writeln('</td></tr>');
      set_nonews(0);
   }
   else
   {
      no_show = 1;
   }
}

function stop_news (type)
{
   // Check if any news items have been shown. If not
   // show default value
   if (get_nonews() > 0)
   {
      // No News!
      document.write('<tr><td class=news>');
      document.write('Nothing to report at the moment.');
      document.writeln('</td></tr>');
   }
   //document.writeln('</table>');
   if ((no_show > 0) && (type == 0))
   {
      //if (get_old_news() > 0)
      //{
        // document.write('<p><a href=' + location.href + '>View current news.</a></p>');
        //document.write('<p><a href=' + base + 'news.htm>View current news.</a></p>');
        //set_old_news(0);
      //}
      //else 
      //{
         if (get_news_format() ==0)
         {
            // if (browser.isIE) document.write('<p><a href=' + location.href + ' onClick="javascript:show_old_news();">View old news.</a></p>');
            // if (browser.isIE) document.write('<p><a href=' + location.href + ' onClick="javascript:show_old_news();">View old news.</a></p>');
            if (browser.isIE) 
            {
               document.write('<p>');
               if (archive_year > 0) document.write('<a href=' + base + 'news.htm>View current news.</a>&nbsp;&nbsp;&nbsp;');
               if (archive_year != 1999) document.write('<a href=' + base + 'news1999.htm>1999 News Archive</a>&nbsp;&nbsp;&nbsp;');
               if (archive_year != 2000) document.write('<a href=' + base + 'news2000.htm>2000 News Archive</a>&nbsp;&nbsp;&nbsp;');
               if (archive_year != 2001) document.write('<a href=' + base + 'news2001.htm>2001 News Archive</a>&nbsp;&nbsp;&nbsp;');
               if (archive_year != 2002) document.write('<a href=' + base + 'news2002.htm>2002 News Archive</a>&nbsp;&nbsp;&nbsp;');
               if (archive_year != 2003) document.write('<a href=' + base + 'news2003.htm>2003 News Archive</a>&nbsp;&nbsp;&nbsp;');
               if (archive_year != 2004) document.write('<a href=' + base + 'news2004.htm>2004 News Archive</a>&nbsp;&nbsp;&nbsp;');
               document.write('</p>');            
            }
         }
      //}
   }
}

function last_update()
{

   if (Date.parse(document.lastModified) != 0)
   {
      var day = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
      var month = new Array("January","February","March","April","May","June","July","August", "September","October","November","December");
      var lastDate = new Date(document.lastModified);
      document.write('<p class=footer>Last updated: ');
      // document.write(day[lastDate.getDay()] + ', ');
      document.write(month[lastDate.getMonth()] + ' ');
      document.write(lastDate.getDate() + ', ');
      document.writeln(lastDate.getFullYear() + '.</p>');
   }
   copyright();
}

function copyright()
{
   var today = new Date();
   document.write('<p class=footer>All material &copy; 2000-' + today.getFullYear() + ' FAST. All rights reserved. Please read our <a href="disclaimer.htm">disclaimer</a> and address any comments regarding this site to the <A href="mailto:webmaster@fast-thales.net?Subject=Comments on website">Webmaster</A>. ');
   document.write('Designed and maintained by <a href="http://www.textura.co.uk" target=right>Textura Web Design</a></p>');
   document.write('</td></tr></table>');
}

function siteupdated (updatedate)
{
   document.write('<p class=footer>Last updated: ' + updatedate + '.</p>');
}

function show_new(newsdate,expires)
{
   // Check item has not expired
   // Expires format is ddmmyy as a string
   today=new Date();
   expiredate=formdate(expires);
   news_date=formdate(newsdate);
   news_date.setDate(news_date.getDate()+14);
   if (news_date > expiredate)
   {
      news_date=expiredate;
   }
   return (today < news_date);
}

function set_style()
{
   var stylefile='fast.css';
   // if (screen.availWidth < 800) stylefile='tuessmall.css';
   // alert ('Stylefile: ' + stylefile + '(' + screen.availWidth + ')');
   document.write('<link href="' + stylefile +'" rel=stylesheet type="text/css">');
}

function open_window(f,t,n)
{
   /* IE only */
   
   // Create a cookie we'll use to save state for this web page.
   // Note that we set the expiration 1 year in the future.
   var flashdata = new Cookie(document, "tues", 24*365);

   // First, try to read data stored in the cookie.  
   if (!flashdata.load())
   {
      flashdata.name="FASTFLASH";
   }
   // Keep track of how many times this user has visited the page:
   if (flashdata.visits == null) flashdata.visits = 0;
   flashdata.visits++;
   if (flashdata.visits < n)
   {
       today=new Date();
       expiredate=formdate(t);
       if (today <= expiredate)
       {
         if (browser.isIE)
         {
            var w=window.open(f,"","width=200,height=150,top=0,left=0,status=no,resizable=no,scrollbars=no");
         } 
         else
         {
            var w=window.open(f,"","width=200,height=150,screenY=0,screenX=0,status=no,resizable=no,scrollbars=no");
         }
       } 
   }
   // Store the cookie values so that the expiration date will be reset
   flashdata.store();
}

function close_window()
{
   document.write('<table align=right>');
   document.write('<tr><td><a href="#" onClick="javascript:window.close();">CLOSE</a></td><tr>');
   document.write('</table>');
}

function format_number(num,dp)
{
  var newnum=num;
  var modnum;
  for (i=1;i<=dp;i++)num=num*10;
  modnum=Math.round(num);
  for (i=1;i<=dp;i++)modnum=modnum/10;
  document.write(modnum);
}

/******** FORUM code **********************************/

function show_forum()
{
   /* TEST CODE */
   document.write ('<tr><td></td><td>No questions</td></tr>');
   //document.write ('<tr><td>09 JUNE 2001</td><td><a href="forum/f001.htm">What is French witholding tax?</a></td></tr>');
}

function forumverify(formid)
{
   /*** MANDATORY ITEMS ***/
   if (!validatename(formid.Organisation.value))
   {
      alert("You must specify the full name of your organisation");
      return false;
   }
   if (!validatetext(formid.Subject.value))
   {
      alert("You must specify a subject");
      return false;
   }
   /*** OPTIONAL - Validate if non-blank ***/
   if ((formid.Name.value.length > 0) && (!validatename(formid.Name.value)))
   {
      alert ("That doesn't look like your name. Please re-enter your full name");
      return false;
   }
   if ((formid.Email.value.length > 0) && (!validateemail(formid.Email.value)))
   {
      alert("I can't respond to you if you don't specify a VALID email address. Please re-enter.");
      return false;
   }
   return true;
}

/********* Login code *******************************/

function check()
{
   // If accessed from somewhere offsite, goto default page
   document.write ('<h1>Document.Referrer: ' + document.referrer + '</h1>');
   // if (document.referrer == "" || document.referrer.indexOf("login.htm") == -1) window.location = "homepagenew.htm";
}

//////////////////
///// POPUP //////
//////////////////

function popup(filename,start_date,end_date)
{
   // Expires format is ddmmyy as a string
   today=new Date();
   startdate=formdate(start_date);
   startdate.setUTCHours(12);
   startdate.setMinutes(00);
   enddate=formdate(end_date);
   enddate.setUTCHours(12);
   enddate.setMinutes(00);
   if ((today < startdate) || (today > enddate)) return;
   topX=(screen.availWidth-530)/2;
   topY=(screen.availHeight-370)/2;
   if (browser.isIE)
   {
      var w=window.open(filename,"","width=530,height=370,top=" + topX + ",left=" + topY + ",status=no,resizable=no,scrollbars=no,toolbar=no");
   } 
   else
   {
      var w=window.open(filename,"","width=530,height=370,screenY= " + topX + ",screenX=" + topY + ",status=no,resizable=no,scrollbars=no,toolbar=no");
   }
}



/////////////////////////////
///////               ///////
/////// Menu routines ///////
///////               ///////
/////////////////////////////

var action = false;
var last_name = "";

function display(name)
{
   frame="";
   if (topframe > -1) frame="parent.right.";

   // Remove any submenus on display
   if (last_name == "") last_name=name;
   if ((last_name != name) && (action==true)) display(last_name);
   if (document.all) 
   {
      var layerObj = eval(frame + "document.all." + name + ".style");
      var hide = "hidden";
      var show = "visible";
   }
   else
   {
      var layerObj = eval(frame + "document." + name);
      var hide = "hide";
      var show = "show";
   }
   layerObj.visibility = (action ?  hide : show);
   // layerObj.position = (action ?  "absolute" : "relative");
   action = !action;
   last_name=name;
}

/*
Incorporated ideas from CSS Menu highlight capability - By Marc Boussard (marc.boussard@syntegra.fr)
Modified by DD for NS4 compatibility Visit http://www.dynamicdrive.com for this script
*/
var ns4class='';

var last_level;
function button(level,bname,page,tip,submenu)
{
   var button_name= bname + "_button";
   var gtype = ".png";
   var dir = "graphics/";
   var button_style=0;
   var style="menu" + level;
   var arrow="arrow.gif";

   if (last_level > level)
   {
     document.write ('</table>');
     document.write ('</div>');
     start_table();
   }
   if (submenu > 0)
   {
      document.write ('<tr><td class=' + style +'><a class=' + style + ' class=&{ns4class}; href=# title="' + tip +'"');
      document.write(' onClick=\'javascript:display("' + bname + '");\'');
      document.write('><img SRC="' + arrow + '" width=18 height=9 border=0 valign=center align=right title="Click for more information"');
   }
   else
   {
      document.write ('<tr><td class=' + style +'><a class=' + style + ' class=&{ns4class}; href=' + page + ' title="' + tip +'"');
   }
   if (button_style >0)
   {
      document.write(' onMouseOver="document.' + button_name + ".src='" + dir + button_name + '1' + gtype + '\';"'); 
      document.write(' onMouseOut ="document.' + button_name + ".src='" + dir + button_name + gtype + '\';"'); 
      document.write('><img name=' + button_name + ' SRC="' + dir + button_name + gtype +'" width=100 height=30 border=0>');
   }
   else
   {
      document.write('>' + bname);
   }
   document.write('</a></td></tr>');

   if (submenu > 0)
   {
      document.write ('</table>');
      document.write ('<div id="' + bname + '" style="visibility:hidden; left:0px; height:20px; position:absolute">');
      start_table();
   }
   last_level=level;
}

function start_table()
{
   document.write ('<table summary=ph2 width=100% border=0 bgcolor=#ffffff cellspacing=1 cellpadding=5>');
}

////// PULL DOWN ////////

function start_menu(menu_items)
{
    menu_width=menu_items*70;
    //menu_width="100%";
    //document.write('<hr width=100%>');
    document.write('<table width=' + menu_width + ' bgcolor=#fffffff border=0 cellpadding=0 cellspacing=0><tr>');
}

function pulldown(level,legend,page,tip,frme)
{
   style="menu"+level;
   frame="_top";
   arrow="image/arrow.gif";
   if (level==1)
   {
      if (page != "") document.write('<td class=' + style +' width=90><a class=' + style +' href=' + base + page + ' title="' + tip + '" target=' + frame + '>' + legend + '</a></td>'); 
      else 
      {
         //document.write('<td class=' + style +' width=100><a class=' + style +' href=# title="' + tip + '"  onClick=\'javascript:display("' + legend +'");\'>');
         //document.write('<img SRC="' + arrow + '" width=18 height=9 border=0 valign=center align=right title="Click for more information">' + legend + '</a></td>'); 
      }
   }
   else
   {
//      document.write ('<tr><td class=' + style +'><a class=' + style + ' class=&{ns4class}; href=' + page + ' title="' + tip + '" target=' + frame + '>' + legend + '</a></td></tr>');
//      document.write ('<tr><td bgcolor=#ffffff><a href=' + page + ' title="' + tip + '" target=' + frame + '>' + legend + '</a></td></tr>');


   }
}

function close_menu()
{
   document.write('</tr></table>');
}

function sub_menu(id,legend)
{
   pos=100*(id-1)+10;
   document.write('<td><div id=' + legend + ' style="visibility:hidden; left:' + pos + 'px; height:0px; position:absolute"><table width=150 border=1 cellpadding=0 cellspacing=0>');
}

function end_submenu()
{
    document.write('</table></div></td>');
}

function start_submenus()
{
    document.write('<table width=400 bgcolor=#ffffff border=0 cellpadding=0 cellspacing=0><tr>');
}

function end_menu()
{
   document.write ('</tr></table>');
}

function top_frame(flag)
{
  topframe=flag;
}

function drawmenu()
{
   // Top_frame 1	Framed menu top section
   // Top_frame 0	Framed menu pulldown section
   // Top_frame -1	Non-framed version
   
   if (topframe != 0)
   {
      start_menu(9);
      pulldown(1,"Home","index.html","Return to home page","_top");
      pulldown(1,"About","fast_homepage.htm","Overview of FAST","_top");
      pulldown(1,"FAQ","faq.htm","Frequently asked questions","_top");
      pulldown(1,"Links","links.htm","Links to useful sites","_top");
      pulldown(1,"Contacts","chairmen.htm","Chairmen of associations","_top");
      pulldown(1,"Shares","shareperf.htm","Details of share performance","_top");
      pulldown(1,"Library","library.htm","Reference material for share schemes","_top");
      pulldown(1,"News","news.htm","Find out the latest news","_top");
      pulldown(1,"Search","search.htm","Search site","_top");
      close_menu();
   }
}

function local_shares(country,currency)
{
    if (country != "euro")
    {
       document.write('<td valign=top><img src=http://www.fast-thales.net/sharedata/' + country + '/' + country +'_20day' + currency + '.png height=180 width=320 alt="Share price in ' + currency + '">');
    }
    else
    {
       document.write('<td valign=top><img src=http://www.fast-thales.net/sharedata/Uk/Uk_20dayEuro.png height=180 width=320 alt="Share price in Euros">');
    }
}

function transfer()
{
   location.href=base+association.value+'/index.htm';
}

function mainmenu()
{
    document.write('<table width=640>');
    document.write('<tr><td rowspan=2><IMG border=0 src="' + base + 'pics/fastlogo.gif" width=100 alt="FAST Logo" align=top></td>');
    document.write('<td class=header>Federation of Associations of Staff Shareholders of THALES</td>');
    document.write('<td class=footer>');
    document.write('&nbsp;</td>');
    document.write('</tr><tr><td colspan=2 align=right>Association&nbsp;');
    document.write('<select name=association size=1 onChange=transfer();>');
    document.write('<option>');
    document.write('<option value=aust>Australia');
    document.write('<option value=best>Belgium');
    document.write('<option value=cats>Canada');
    document.write('<option value=apat>France');
    document.write('<option value=detma>Germany');
    document.write('<option value=gates>Greece');
    document.write('<option value=aiset>Italy');
    document.write('<option value=jest>Japan');
    document.write('<option value=swat>Netherlands');
    document.write('<option value=nest>Norway');
    document.write('<option value=tess>Singapore');
    document.write('<option value=tessa>South Africa');
    document.write('<option value=kest>South Korea');
    document.write('<option value=eeat>Spain');
    document.write('<option value=sates>Switzerland');
    document.write('<option value=tues>United Kingdom');
    document.write('<option value=usest>United States');
    document.write('</select>');
    document.write('</td></tr></table>');
    drawmenu();
    if (document.title== "FAST homepage")
    {
       homepage();
       popup("fcpevote.htm","060603","200603");
    }
}

function show_shareprice(file)
{
    document.write('<script language=JavaScript type=text/javascript src=' + base + file + '></script>');
    document.write('<FORM NAME="myform">');
    document.write('<!--     declare global variables -->');
    document.write('<INPUT TYPE="hidden" NAME="oldnews" VALUE="0">');
    document.write('<INPUT TYPE="hidden" NAME="newsformat" VALUE="0">');
    document.write('<INPUT TYPE="hidden" NAME="nonews" VALUE="0">');
    document.write('</FORM>');
    document.write('<table width=630 border=0 cellpadding=0 cellspacing=0><tr><td>');
}

function share_price(euro_value,local_value,change,date)
{
   document.write('<table width=632><tr width=100%>');
   document.write('<td class=shareprice align=center><b>Current share price: &nbsp;&euro;' + euro_value);
   if (local_value.length > 0) 
   {
      document.write('&nbsp;&nbsp;&nbsp;' + local_value);
   }
   document.write('</b>&nbsp;&nbsp;' + change + '&nbsp;&nbsp;Last update: ' + date + '</td>');
   document.write('</tr></table>');
}

function homepage()
{
   document.write('<table width=640 border=0 cellpadding=0 cellspacing=10>');
   document.write('<tr><td width=200 class=mission valign=top>Facilitating employee share ownership in Thales</td>');
   document.write('<td width=300><IMG border=0 src="images/shares.jpg" width=220 height=150 alt="Shares"></td>');
   document.write('<td width=140 valign=top>');
   document.write('<table width=100% cellspacing=0 cellpadding=0><tr></td>');
   document.write('<table cellspacing=0 cellpadding=5>');
   document.write('<tr><td class=subhead>Downloads</td></tr>');
   document.write('<tr><td class=subbody><a href="http://www.fast-thales.net/reports/Thales_2002_UK.pdf" title="Download report" target=right>Thales Annual report</a></td></tr>');
   document.write('<tr><td class=subhead>Register</td></tr>');
   document.write('<tr><td class=subbody><a href=inform.htm target=right>Keep informed of updates to site</a></td></tr>');
   document.write('<tr><td class=subhead>Portfolio</td></tr>');
   document.write('<tr><td class=subbody><a href=http://www.pacteo.com>Manage your shares account</a></td></tr>');
   document.write('</table>');
   document.write('</td></tr></table>');
   document.write('</td>');
   document.write('</tr></table>');
}

mainmenu();

