function isFirstVisit() {

  if(document.cookie.indexOf("firstVisit") > -1){
    return false;
  } else {
    document.cookie = "firstVisit";
    return true;
  }
  
}


function popup_news(lang) {
  if(!isFirstVisit()) {  
    return; 
  }
  window.open("news.php?lang=" + lang,"News", "toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=310,height=360");
}

function mover(pagename) {
  getEl("img_" + pagename).src="images/frame/menu_" + pagename + "_on.gif";
}

function mout(pagename) {
  
  getEl("img_" + pagename).src="images/frame/menu_" + pagename + ".gif";
}

var bioPopup;
function popup_bio(name, lang) {
  var url = "bio_popup.php?name=" + name + "&lang=" + lang;
  bioPopup = window.open(url,"Bio", "toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=405,height=530");
  bioPopup.focus();
}


var lyricsPopup;
function popup_lyrics(name, lang) {
  var url = "lyrics_popup.php?song=" + name + "&lang=" + lang;
  lyricsPopup = window.open(url,"Lyrics", "toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=600");
  lyricsPopup.focus();
}

function getEl(id) {
  return document.getElementById(id);
}

var lastLink = "";
function mo_bio(name) {
  getEl("bio_img").src="images/bio_" + name + ".jpg";
  getEl("a_" + name).style.textDecoration = "underline";
  if(lastLink) {
    getEl(lastLink).style.textDecoration = "";
  }
  lastLink = "a_" + name;
}

function openImageWin(sImgPath){
  window.open("image_popup.php?img=" + sImgPath,"Image", "toolbar=no,directories=no,menubar=no,scrollbars=auto,resizable=yes,width=500,height=450");
}

var names = ["ralph", "ludo", "marco", "davide", "patrick", "serge"];

var arrBioImages = new Array(names.length);
function preloadBioImages() {
  for(i=0; i< names.length; i++) {
    arrBioImages[i]=new Image(); 
    arrBioImages[i].src="images/bio_" + names[i] + ".jpg"; 
   }
   mo_bio(names[ranimage()]);
   //setTimeout("cycleImg();", 500);
}

function cycleImg() {
  iTime = 200;
  for(i=0; i< names.length; i++) {
  	 setTimeout("mo_bio(names[" + i + "]);", i*iTime);
  }
	setTimeout("mo_bio(names[ranimage()]);", i*iTime);
}


function ex_ranimage() {
  return Math.floor(Math.random() *  images.length);
}

var ran = 60/names.length;
function ranimage() {
  currentdate = new Date()
  core = currentdate.getSeconds()
  core = Math.floor(core/ran)
  return core;
}

function showImg(path) {
	document.getElementById("photoBig").src=path;
}