// LAHOVARY.RO AVIZIER.JS
// (C) Dan Mirescu

/*var poze = new Array();
poze[0] = 'back_to_school.jpg';
poze[1] = 'masquerade.jpg';
poze[2] = 'av_parteneriat.jpg';
poze[3] = 'av_curte.jpg';*/
//poze[3] = 'av_npaun.gif';
//poze[3] = 'in_constructie.jpg';
poze[4]='pinguin.jpg';
var img;

for(i=0;i<poze.length;i++)
{
  img = document.createElement('img');
  img.style.display = 'none';
  img.src = 'poze/' + poze[i];
  img.id = 'img' + i;
  document.body.appendChild(img);
}

var avizier = document.getElementById('avizier');
var av_img = avizier.getElementsByTagName('div')[0];
var a = avizier.getElementsByTagName('a');
var i;


function av_select()
{
  this.getElementsByTagName('span')[0].style.display = 'inline';
  this.style.backgroundColor = '#d7cab4';
  this.style.borderLeft = '2px solid gray';
  this.style.paddingLeft = '18px';
  av_img.style.backgroundImage = "url('poze/" + poze[this.nr] + "')";
}
function av_unselect()
{
  this.getElementsByTagName('span')[0].style.display = 'none';
  this.style.background = 'none';
  this.style.border = 'none';
  this.style.paddingLeft = '20px';
  av_img.style.backgroundImage = "url('poze/av0.jpg')";
}

var msover = false;
var handler;

for(i=0;i<a.length;i++)
{
  a[i].nr = i;
  a[i].select = av_select;
  a[i].onmouseover = function() { msover = true; clearTimeout(handler); av_unselect_all(); this.select(); }; 
  //a[i].onmouseout = function() { msover = false; /*av_seq_select(this.nr); /*this.unselect();*/ };
  a[i].unselect = av_unselect;
}

//a[1].select = av_select;

//a[1].select();

function av_unselect_all()
{
  for(i=0;i<a.length;i++)
  {
    a[i].unselect();
  }
}

function av_seq_select(id)
{
  if(id<a.length && !msover)
  {
    if(id-1>=0) a[id-1].unselect();
    else a[a.length-1].unselect();
    a[id].select();
    if(id+1 == a.length) id = 0;
    else id++
    handler = setTimeout('av_seq_select(' + id + ');',4000);
    return true;
  }
  else return false;
}

av_seq_select(0);

