
var timerID = null;
var headerPictures = new Array('/jflauze/voyer001.jpg','/jflauze/voyer002.jpg','/jflauze/voyer003.jpg','/jflauze/voyer004.jpg','/jflauze/voyer005.jpg','/jflauze/voyer006.jpg','/jflauze/voyer007.jpg','/jflauze/voyer008.jpg','/jflauze/voyer009.jpg','/jflauze/voyer010.jpg','/jflauze/voyer011.jpg','/jflauze/voyer012.jpg');
var headerPictureIndex = Math.floor(Math.random()*headerPictures.length);

for(var x=0; x< headerPictures.length; x++){
  var newpic = new Image();
  newpic.src = headerPictures[x];
}

$(document).ready(function(){

  //firstHeaderPicture();

  $('.sub').hide();

  $('#mask').animate({width:'0px',opacity:0.7},400);

  $('.first').mouseover(function(){$('.sub').hide();$(this).parent().children(".sub").each(function(){$(this).fadeIn(300);});});

  $('.menuitem').mouseout(function(){timerID=setTimeout(function(){ $('.sub').hide();$('#mask').animate({opacity:1},200,function(){nextHeaderPicture();$('#mask').animate({opacity:0.7,width:'0px'},200);});},1000);});

  $('.menuitem').mouseover(function(){clearTimeout(timerID);$('#mask').animate({width:'760px'},200);});


});


function setAttachementLinks(){
  $('.attachementLink').hover(
      function () {
        $(this).append($("<span>" + $(this).attr("title") + "</span>"));
      },
      function () {
        $(this).find("span:last").remove();
      }
    );
}


function firstHeaderPicture(){
  $('#headerphoto').css("background-image", "url("+headerPictures[headerPictureIndex]+")");
}


function nextHeaderPicture(){
  headerPictureIndex++ ;
  if(headerPictureIndex >= headerPictures.length) headerPictureIndex = 0;
  $('#headerphoto').css("background-image", "url("+headerPictures[headerPictureIndex]+")");
}

function bookmarksite(){
  title = document.title;
  url = location.href;
  if (window.sidebar){
    window.sidebar.addPanel(title, url, "");
  } else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
  }
  else if(document.all){
    window.external.AddFavorite(url, title);
  }
}

function addBookmark(){
  bookmarksite();
}


function sendPageToAFriend(lang,siteRoot){
	$('#utilityPane').html('<iframe frameborder="0" src="'+siteRoot+'/pages/sendToAFriendForm.php?url=' + window.location.href + '" width="650" height="150"></iframe>').toggle('slow');

}
