var listChar = '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var nbLevel=10;
/*
function openNode(url,idN){
  window.top.frames.frCenter.frames.frRight.document.location=url;
  window.frames.advanced.document.location="advancedpage.php?lang=fr&idN=" + idN;
}
  */
  function adjustContextVAlign(){
	var maxHeight=0;
	$("#mainContain").each(function(){
      maxHeight=this.offsetHeight;
	});
	$("#tools").each(function(){
      if (this.offsetHeight>maxHeight){
      	maxHeight=this.offsetHeight;
      }
	});
	$("#contextual").each(function(){
      $(this).height(maxHeight + "px");
	});
  }
  
  function adjustIllustrationVAlign(){
  	var maxHeight=0;
	var booStop=false;
	while (!booStop) {
		$("#artID").each(function(){
	      newMaxHeight=this.offsetHeight - 15;
		  if (newMaxHeight == maxHeight) {
		  	booStop=true;
		  }
		  else {
		  	maxHeight=newMaxHeight;
		  }
		});
		$("#illID").each(function(){
	      $(this).height(maxHeight + "px");
		});		
	}
  }

  function displayHorizSep(){
		
	if (document.documentElement.scrollTop==0) {
		$("#horizSep").css('display', 'none');
	}
	else{	
		$("#horizSep").css('display', 'block');
	}
  }
  
  function adjustDesign(horizSep, contextVAlign){
  	if (horizSep==1){displayHorizSep();}
	if (contextVAlign==1){adjustContextVAlign();}
	
  }
  function goTop(){
  	document.documentElement.scrollTop=0;
	return false;
  }
  
  function loadImgDisplay(idSong){
  	currentImgSrc= top.frCenter.document.getElementById('i'+idSong).src;
	newImgSrc=currentImgSrc.substring(0,currentImgSrc.lastIndexOf('/')) + '/bt_listen_loading.gif';
	top.frCenter.document.getElementById('i'+idSong).src = newImgSrc;
  }

  function loadGrayedBask(idSong){
  	currentImgSrc= top.frCenter.document.getElementById('b'+idSong).src;
	newImgSrc=currentImgSrc.substring(0,currentImgSrc.lastIndexOf('/')) + '/bt_basket_grayed.gif';
	top.frCenter.document.getElementById('b'+idSong).src = newImgSrc;
  }
    
  
  function standardImgDisplay(idSong){
  	//on arrète tout les clignotement
	/*
  	currentImgSrc= top.frCenter.document.getElementById('i'+idSong).src;
	newImgSrc=currentImgSrc.substring(0,currentImgSrc.lastIndexOf('/')) + '/bt_listen.gif';
	top.frCenter.document.getElementById('i'+idSong).src = newImgSrc;
	*/
	var llistListenId = top.frCenter.listListenId;
	var length = llistListenId.length;
	for(var i=0; i<length; i++){
		current = llistListenId[i];
		currentImgSrc= top.frCenter.document.getElementById(current).src;
		newImgSrc=currentImgSrc.substring(0,currentImgSrc.lastIndexOf('/')) + '/bt_listen.gif';
		top.frCenter.document.getElementById(current).src = newImgSrc;
	}
  }   
  
  function songOperation(typeRecord,idSong,musTitle,toArchive){
	if (typeRecord==0){top.frTop.doPassVar("STOP@#@ ");}
  $.ajax({
	    url: '../multipart/songOperation_multipart.php?idSong=' + idSong + "&typeRecord=" + typeRecord + "&archive=" + toArchive,
	    type: 'GET',
	    dataType: 'html',
	    timeout: 20000,
	    error: function(err){
	        alert('Problème de chargement : ' + err);
	    },
	    success: function(composedXML){
			var regBask = new RegExp("</*bask>", "");
			baskListArr = composedXML.split(regBask);
			if (baskListArr.length>1) {$('#basketList').html(baskListArr[1]);}
			
			var regHist = new RegExp("</*hist>", "");
			histListArr = composedXML.split(regHist);
			if (histListArr.length>1) {$('#historyList').html(histListArr[1]);}

			var regStat = new RegExp("</*stat>", "");
			statListArr = composedXML.split(regStat);
			if (statListArr.length>1) {$('#statList').html(statListArr[1]);}
			
			var regResu = new RegExp("</*resu>", "");
			resuListArr = composedXML.split(regResu);
			if (resuListArr.length>1) {$('#main-rightcontain').html(resuListArr[1]);}
			if (typeRecord==0){top.frTop.doPassVar(idSong+"@#@"+musTitle);}
			
			var regBigBasket = new RegExp("</*basketList>", "");
			bigbaskListArr = composedXML.split(regBigBasket);
			if (bigbaskListArr.length>1) {$('#mainContain').html(bigbaskListArr[1]);}		
		}
	}); 
	if (0==typeRecord) {loadImgDisplay(idSong);}
	if (1==typeRecord) {loadGrayedBask(idSong);}
  }
