// $Id: generic.js,v 4.13 2004/01/16 15:19:54 tzr-master Exp $
function winZoom(image,l,h,alt,mention,titre,margev) {
	inferieur = String.fromCharCode(60)
	photo=window.open("","photo", "scrollbars=no,status=no,toolbar=no,menubar=no,height="+(h)+",width="+l); 
	photo.document.open();
	photo.document.writeln("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	photo.document.writeln('<BODY MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" LINK="#FFFFFF" bgcolor="#FFFFFF" text="#ffffff" onBlur="self.close();">');
	photo.document.writeln('<CENTER><FONT FACE="Verdana,Geneva,Arial,Helvetica,sans-serif" SIZE="-1" COLOR="#696969"><IMG SRC="'+image+'" WIDTH='+l+' HEIGHT='+h+' ALT="'+alt+'" BORDER=0>');
	photo.document.writeln('</FONT>'+inferieur +'/BODY>'+inferieur +'/HTML>');
	photo.document.close();
}	

function winStream(file,l,h,titre,mime) {
        inferieur = String.fromCharCode(60)
        photo=window.open("","photo", "scrollbars=no,status=no,toolbar=no,menubar=no,resizable=yes,height="+(h)+",width="+l);
        photo.document.open();
        photo.document.writeln("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
        photo.document.writeln('<BODY MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" LINK="#FFFFFF" bgcolor="#FFFFFF" text="#ffffff" >');
        photo.document.writeln('<embed id=ii type="'+mime+'" src="'+file+'" autostart="true" controls=true loop=-1 border=0 width='+l+' height='+h+'>');
        photo.document.writeln(inferieur +'/BODY>'+inferieur +'/HTML>');
        photo.document.close();
}

// validation des formulaires
TZR_isFormOk=true;
TZR_formValidation=true;
function TZR_isShortTextValid(id,fmt,fieldlabel,color) {
  var obj = document.getElementById(id);
  var phrase = obj.value;
  var resultat = fmt.test(phrase);
  if(!resultat) {
    obj.style.backgroundColor=color;
    TZR_isFormOk=false;
    return false;
  } else {
    obj.style.backgroundColor='transparent';
    return true;
  }
}

function TZR_isFormValid(f) {
  return TZR_isFormValidWithFocus(f,false);
}
function TZR_isFormValidWithFocus(f,foc) {
  if(typeof(TZR_formValidator)=='undefined') {
    TZR_isFormOK=true;
    return true;
  }
  nb=TZR_validator.length;
  TZR_isFormOk=true;
  for(i=0;i<nb;i++) {
    var obj = document.getElementById(TZR_validator[i][0]);
    if(obj.form.name==f.name) {
      if(TZR_validator[i][4]=='XShortText') TZR_isShortTextValid(TZR_validator[i][0],TZR_validator[i][1],TZR_validator[i][2],TZR_validator[i][3]);
      if(TZR_validator[i][4]=='XPasswdDef') TZR_isShortTextValid(TZR_validator[i][0],TZR_validator[i][1],TZR_validator[i][2],TZR_validator[i][3]);
      if(foc) {
	if(!TZR_isFormOk) {
	  obj.focus();
	  return false;
	}
      }
    }
  }
  if(!TZR_isFormOk) {
    if(typeof(TZR_customValid)!='undefined')
      return TZR_customValid(f);
    else 
      return confirm('Some data are not valid. Save anyway ?');
  }
  return true;
}
function sstree_toggle(elm,iopen,iclose) {
 var newDisplay = "none";
 if(iopen=='') iopen='templates/images/folder-open.gif';
 if(iclose=='') iclose='templates/images/folder-closed.gif';
 if(iopen=='none') iopen='';
 if(iclose=='none') iclose='';
 if(iclose!='none') elm.style.backgroundImage = 'url( '+iclose+' )';
 var e = elm.nextSibling; 
 while (e != null) {
  if (e.tagName == "OL" || e.tagName == "ol" || e.tagName == "ul" || e.tagName == "UL") {
   if (e.style.display == "none") {
    newDisplay = "block";
    if(iopen!='none') elm.style.backgroundImage = 'url( '+iopen+' )';
   }
   break;
  }
  e = e.nextSibling;
 }
 while (e != null) {
  if (e.tagName == "OL" || e.tagName == "ol" || e.tagName == "ul" || e.tagName == "UL") e.style.display = newDisplay;
  e = e.nextSibling;
 }
}

function sstree_toggleBullet(elm) {
 var newDisplay = "none";
 var e = elm.nextSibling; 
 while (e != null) {
  if (e.tagName == "OL" || e.tagName == "ol" || e.tagName == "UL" || e.tagName == "ul") {
   if (e.style.display == "none") newDisplay = "block";
   break;
  }
  e = e.nextSibling;
 }
 while (e != null) {
  if (e.tagName == "OL" || e.tagName == "ol" || e.tagName == "UL" || e.tagName == "ul") e.style.display = newDisplay;
  e = e.nextSibling;
 }
}

function sstree_collapseAll() {
  var lists = document.getElementsByTagName('OL');
  for (var j = 0; j < lists.length; j++) 
   lists[j].style.display = "none";
  lists = document.getElementsByTagName('ol');
  for (var j = 0; j < lists.length; j++) 
   lists[j].style.display = "none";
  lists = document.getElementsByTagName('ul');
  for (var j = 0; j < lists.length; j++) 
   lists[j].style.display = "none";
  lists = document.getElementsByTagName('UL');
  for (var j = 0; j < lists.length; j++) 
   lists[j].style.display = "none";
  var e = document.getElementById("root");
  e.style.display = "block";
}

function writeInfo(i,s) {
  var obj = document.getElementById(i);
  obj.innerHTML=s;
}
