// JavaScript Document
var btnSelected;
var imgSelected="";
var thumbSelected="";
var nbrPhotos;
var idxPhotoDiapo=1;
var intervalID=0;
function getFlashMovie() {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  if (isIE){
	  return window.jukeBox;
	  }else{
		return   window.document.jukeBox;
		  }
}
 
function jouePiece(albumEtpiste,btnSelect) {
    var swf=getFlashMovie();
		if(swf.sendTextToFlash){
 swf.sendTextToFlash(albumEtpiste);
 setBtnSelected(btnSelect);
		}
	}

function  setBtnSelected(btnSelect){	
	if(btnSelected){
 		btnSelected.className="noIcone";
 	}
 var btn=document.getElementById(btnSelect);
 if(btn){
 btn.className="selected";
 btnSelected=btn;
 }
}
function stopJukeBox(){
	var swf=getFlashMovie();
	swf.stopSoundForJukeBox();
	}
	
	function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}
function setJukeBoxWithPiece(piece){
		if(piece=="9"){
			jouePiece('DufresneJorane_2.mp3', 'btn8');
			}
		
	}
	
	function onInitFinished(){
		if(getURLParam("snd") !=""){
		if(getURLParam("snd")=="9"){
jouePiece('montrealJazzClubSession_9.mp3', 'btn9');
window.location.hash="MontrealJazzClubSession";
		}else if(getURLParam("snd")=="7"){
			jouePiece('DufresneJorane_9.mp3', 'btn7');
window.location.hash="Jorane";

			}
		}
		}
// JavaScript Document
function changeLanguage(){
var txt=window.location.href;
if(txt.lastIndexOf('en/')==-1){
var dernierChar=txt.lastIndexOf('fr/')+3;
var debutAdresse='../en/';
}else{
var dernierChar=txt.lastIndexOf('en/')+3;
var debutAdresse='../fr/';
}
var finAdresse=txt.substring(dernierChar);
window.location.href=debutAdresse+finAdresse;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function showPhoto(nbr){
	if(imgSelected !=""){
		imgSelected.style.display="none";
	}
	if(thumbSelected !=""){
		thumbSelected.className="";
	}	
	
	var obj=document.getElementById("photo"+nbr);
	
	obj.style.position="relative";
	obj.style.top="0px"
	obj.style.left="0px";
	obj.style.display="block";
	imgSelected=obj;
	
	var thumb=document.getElementById("th"+nbr);
	thumb.className="selected";
	thumbSelected=thumb;
	
	idxPhotoDiapo=nbr+1;
	}
	
function countPhoto(){
	var i=1;
	var count=0;
	while(document.getElementById("th"+i)){
		count++;
		i++;
		}
	nbrPhotos=count;
}
function startDiapo(){
	var obj=document.getElementById("arretDiaporama");
	var obj2=document.getElementById("diaporama");
	obj.style.display="block";
	obj2.style.display="none";
	countPhoto();
	intervalID=setInterval("showPhotoDiapo()",3000);
	}

function showPhotoDiapo(){
	if(idxPhotoDiapo>nbrPhotos){
	idxPhotoDiapo=1;
	}
	showPhoto(idxPhotoDiapo);	
}
		
function stopDiaporama(){
	clearInterval(intervalID);
		var obj=document.getElementById("arretDiaporama");
	var obj2=document.getElementById("diaporama");
	obj.style.display="none";
	obj2.style.display="block";
}
function rewindPhoto(){
	stopDiaporama();
	countPhoto();
	if(idxPhotoDiapo<=2	){
		showPhoto(nbrPhotos);
		}else{
	showPhoto(idxPhotoDiapo-2);
		}
	}
	
	function forwardPhoto(){
		stopDiaporama()
	countPhoto();

	showPhotoDiapo(idxPhotoDiapo);
	}
	
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}