function goIndex(idIndex)
{
goPage(idIndex, 1) ;
}

function goPage(idIndex, idPage)
{
location.href = ('audio.php?idIndex=' + idIndex + '&idPage=' + idPage) ;
}

function goItem(idIndex, idContent)
{
   if(idContent != 0)
location.href = ('audio.php?idIndex=' + idIndex + '&idContent=' + idContent) ;
}

function PopupImage(img)
{
   titre="View";

   w=open("",'image','width=40,height=40,toolbar=no,scrollbars=no,resizable=yes');
   w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
   w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
   w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
   w.document.write("");
   w.document.write("</BODY></HTML>");
   w.document.close();
}
function OptionList(value, text, action, name, other) {
this.value = value;
this.text = text;
this.action = action;
this.name = name;
this.other = other;

this.ch = "";
this.selected = false;
}

// les objets OptionList sélectionnées
var selectOptionListObjects = Array();

// les objets select enchaînés dans chaque liste
var selectObjects = Array();

// les objets contenaires select enchaînés dans chaque liste
var selectContainerObjects = Array();

// les contenaires dans lesquelles on place les optionlists
var optionListContainer = Array();

// le mode d'affichage
// "" = pas d'html supplémentaire à côté des selects
// "img" = image (p.ex flèche) à côté des selects
// "txt" = txt (p.ex >>) à côté des selects
var displayMode = "txt";

// le contenu selon le displayMode en dessus
// displayMode = "": n/a
// displayMode = "img": chemin de l'image
// displayMode = "txt": chaîne de caractères
//var displayContent = "http://<?= ALLINONE_HTTP_HOST ?>/system/images/fleche_path.gif";
var displayContent = " Go ";

// true pour un unique bouton de validation à droite des listbox
var uniqSubmit = true ;

function selectValue(optionListObject, value) {
var i;

for (i = 0; i < optionListObject.ch.length; i++) {
if (optionListObject.ch[i].value == value) {
optionListObject.ch[i].selected = true;
return true;
} else if (selectValue(optionListObject.ch[i], value)) {
optionListObject.ch[i].selected = true;
return true;
}
}

return false;
}

function destroyChildren(selectObject, optionListId) {
var i;

for (i = selectObjects[optionListId].length; selectObjects[optionListId][i] != selectObject; --i) {
if (selectObjects[optionListId][i]) {
optionListContainer[optionListId].removeChild(selectContainerObjects[optionListId][i]);
selectObjects[optionListId].pop();
selectContainerObjects[optionListId].pop();
selectOptionListObjects[optionListId].pop();
}
}
}

function appendOptionList(parentObject, list) {
var i;
var newOption;
var newAttribute;
var newText;

var selection = -1;

for (i = 0; i < list.length; i++) {
newOption = document.createElement("option");
newOption.value = list[i].value;

newText = document.createTextNode(list[i].text);
newOption.appendChild(newText);

parentObject.appendChild(newOption);

if (list[i].selected) {
list[i].selected = false;
parentObject.selectedIndex = i;
selection = i;
}
}

return selection;
}

function changeSelect(selectObject, optionListId) {
var optionObject;
var i;

for (i = 0; selectObjects[optionListId][i] != selectObject; i++);

optionObject = selectOptionListObjects[optionListId][i].ch[selectObject.selectedIndex];
optionListObject = selectOptionListObjects[optionListId][i];

if (optionObject.action && (displayMode == "")) {
eval(optionObject.action);
}

destroyChildren(selectObject, optionListId);
selectLevel = selectOptionListObjects[optionListId].length - 1;

if (optionObject.ch != "")
createSelect(optionObject, optionListId);

changeDisplayContentHref(optionListObject, optionListId, selectLevel, selectContainerObjects[optionListId][i]);
}

function changeDisplayContentHref(optionListObject, optionListId, selectLevel, newSpan) {
var newA;
var newDisplayContent;

if (displayMode != "") {
spanChildren = newSpan.childNodes;

for (i = 0; i < spanChildren.length; i++) {
newA = spanChildren[i];
 
if ((newA.tagName == "A") || (newA.tagName == "a"))
newSpan.removeChild(newA);
}

newA = document.createElement("a");

var breakExecuted = false;

for (i = 0; i < optionListObject.ch.length; i++) {
if (optionListObject.ch[i].selected || (selectObjects[optionListId][selectLevel].selectedIndex == i)) {
action = optionListObject.ch[i].action;
newA.href = "javascript:changeSelect(selectObjects["+optionListId+"]["+selectLevel+"], "+optionListId+"); "+action;
breakExecuted = true;
break;
}
}

if (!breakExecuted) {
newA.href = "javascript:changeSelect(selectObjects["+optionListId+"]["+selectLevel+"], "+optionListId+");";
}

if(uniqSubmit != true 
|| (uniqSubmit == true && (optionListObject.ch[i] == null 
|| (optionListObject.ch[i]) && (optionListObject.ch[i].ch == '')))) {

if (displayMode == "txt") {
newDisplayContent = document.createTextNode(displayContent);
} else if (displayMode == "img") {
newDisplayContent = document.createElement("img");
newDisplayContent.src = displayContent;
newDisplayContent.hspace = "5";
newDisplayContent.border = "0";
newDisplayContent.align = "middle";
}

newA.appendChild(newDisplayContent);
newSpan.appendChild(newA);
}
}
}

function createSelect(optionListObject, optionListId) {
var newSpan;
var newSelect;
var newAttribute;
var selection;
var selectLevel = selectOptionListObjects[optionListId].length;

newSpan = document.createElement("span");
newSelect = document.createElement("select");
newSelect.style.marginRight = "5px" ;

selectOptionListObjects[optionListId][selectLevel] = optionListObject;
selectObjects[optionListId][selectLevel] = newSelect;
selectContainerObjects[optionListId][selectLevel] = newSpan;

newSelect.onchange = new Function("changeSelect(this, "+optionListId+")");
newSelect.name = optionListObject.name;

newSpan.appendChild(newSelect);

changeDisplayContentHref(optionListObject, optionListId, selectLevel, newSpan);

selection = appendOptionList(newSelect, optionListObject.ch);
optionListContainer[optionListId].appendChild(newSpan);

if (selection != -1) {
if (optionListObject.ch[selection].ch != "") {
createSelect(optionListObject.ch[selection], optionListId);
}
}
}

function addOptionListContainer(optionListContainerObject, optionListId) {
selectOptionListObjects[optionListId] = Array();
selectObjects[optionListId] = Array();
selectContainerObjects[optionListId] = Array();
optionListContainer[optionListId] = optionListContainerObject;
}
