/*
  Javascript to display an image during about 5 seconds
*/

var image = {

probarrun:false, photoframe:null, probarID:null, proc:0, ypos:0,

photoarray:new Array(),

iniarray:new Array( 'emp', 'jcm', 'sol', 'jfl', 'lpc', 'gpc', 'rpr', 'pht', 'set', 'jph', 'olt', 'hpe', 'psp', 'cat', 'thr', 'jpg', 'mif', 'elh', 'doj', 'sal', 'amf' ),

/* 'flm' */

read:function()
{
  for( var x in this.iniarray )
  {
    var initials = this.iniarray[x];

    this.photoarray[initials] = new Image();

    this.photoarray[initials].src = 'images/portraits/' + initials + '.jpg';
  }
},

keep:function()
{
  this.photoframe = document.getElementById('photoFrame').style;

  var pos = document.body.scrollTop + 0.5 * document.body.clientHeight - 113;

  this.ypos += ( pos - this.ypos ) * 0.12;

  this.photoframe.top = this.ypos;

  setTimeout("image.keep()", 10);
},

load:function(initials,legend)
{
  document.getElementById('groupFrame').style.visibility = "hidden";

  document.getElementById('photo').src = this.photoarray[initials].src; 

  document.getElementById('photoLegend').innerHTML = legend;


  this.probarID = document.getElementById('probar').style;

  this.photoframe.visibility = "visible";

  this.proc = 0;

  if (!this.probarrun)
  {
    this.probarrun = true;

    this.progress();
  }
},

progress:function()
{
  this.proc++;

  this.probarID.height = this.proc;

  if( this.proc == 224 )
  {
    this.photoframe.visibility = "hidden";

    this.probarrun = false;
  
    return;
  }

  setTimeout("image.progress()", 20);
}
}

var group = {

probarrun:false, photoframe:null, probarID:null, proc:0, ypos:0,

photoarray:new Array(),

grparray:new Array('ecole', 'pous', 'comp', 'loisir'),

read:function()
{
  for(var x in this.grparray)
  {
    var groupname = this.grparray[x];

    this.photoarray[groupname] = new Image();

    this.photoarray[groupname].src = 'photos/group_' + groupname + '.jpg';
  }
},

keep:function()
{
  this.photoframe = document.getElementById('groupFrame').style;

  var pos = document.body.scrollTop + 0.5 * document.body.clientHeight - 170;

  this.ypos += ( pos - this.ypos ) * 0.12;

  this.photoframe.top = this.ypos;

  setTimeout("group.keep()", 10);
},

load:function(groupname,legend)
{
  document.getElementById('photoFrame').style.visibility = "hidden";

  document.getElementById('groupPhoto').src = this.photoarray[groupname].src; 

  document.getElementById('groupLegend').innerHTML = legend;

  this.probarID = document.getElementById('groupProbar').style;

  this.photoframe.visibility = "visible";

  this.proc = 0;

  if (!this.probarrun)
  {
    this.probarrun = true;

    this.progress();
  }
},

progress:function()
{
  this.proc++;

  this.probarID.height = this.proc;

  if( this.proc == 339 )
  {
    this.photoframe.visibility = "hidden";

    this.probarrun = false;
  
    return;
  }

  setTimeout("group.progress()", 16);
}
}


// load all photos already

image.read();

group.read();
