
function winZoom(image,l,h,alt,mention,titre,margev) {
	inferieur = String.fromCharCode(60)
	ph=window.open("","ph", "scrollbars=no,status=no,toolbar=no,menubar=no,height="+(h)+",width="+l); 
	ph.document.open();
	ph.document.writeln("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	ph.document.writeln('<BODY MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" LINK="#FFFFFF" bgcolor="#FFFFFF" text="#ffffff" onBlur="self.close();">');
	ph.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>');
	ph.document.writeln('</FONT>'+inferieur +'/BODY>'+inferieur +'/HTML>');
	ph.document.close();
}	
function winZoom2(image,titre) {
inferieur = String.fromCharCode(60);
titre=escape(titre);
ph=window.open("","ph", "scrollbars=no,status=no,toolbar=no,menubar=no,width=100,height=100");
ph.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
ph.document.writeln("<html><head>");
       ph.document.writeln(inferieur +'title>'+unescape(titre)+inferieur +'/title>'+inferieur +'/head>');
       ph.document.writeln('<body style="padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-color:black;color:#ffffff;text-align:center" onBlur="self.close();" >');
ph.document.writeln("<script language=\"javascript\" type=\"text/javascript\">var i=new Image();i.src='"+image+"';function setSize(W, H) {window.resizeTo(W, H);var cp = document.createElement(\"div\");cp.style.position = \"absolute\";cp.style.width = \"0px\";cp.style.height = \"0px\";cp.style.right = \"0px\";cp.style.bottom = \"0px\";cp.style.margin=\"0px 0px 0px 0px\";cp.style.padding=\"0px 0px 0px 0px\";document.body.appendChild(cp);var current_width = cp.offsetLeft;var current_height = cp.offsetTop;var dw = W + document.body.clientWidth - current_width;var dh = H + document.body.clientHeight - current_height;window.resizeTo(dw+10, dh);document.body.removeChild(cp);return { missed_width: dw, missed_height: dh };}function f(){setSize(i.width,i.height);window.defaultStatus='"+escape(titre)+"';}");
       ph.document.writeln(inferieur +'/script>');
       ph.document.writeln('<img onload="f();" style=\"margin:0px\" src="'+image+'" name="image" border="0" alt="'+unescape(titre)+'"  />');
       ph.document.writeln(inferieur +'/body>'+inferieur +'/html>');
       ph.document.close();

}
function winZoom3(image,titre) {
       inferieur = String.fromCharCode(60)
       ph=window.open("","ph", "scrollbars=no,status=no,toolbar=no,menubar=no,width=100,height=100");
       ph.document.writeln("<HTML><HEAD><script language=javascript>var i=new Image();i.src='"+image+"';function f(){window.resizeTo(i.width+10,i.height+25);/*window.innerHeight=i.height;window.innerWidth=i.width;alert(i.height);alert(i.width);*/window.defaultStatus='"+titre+"';}</script><TITLE>"+titre+"</TITLE></HEAD>");
       ph.document.writeln('<BODY MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" LINK="#FFFFFF" bgcolor="black" text="#ffffff" onBlur="self.close();" onload="f();">');
       ph.document.writeln('<CENTER><IMG SRC="'+image+'" name=image BORDER=0>');
       ph.document.writeln(inferieur +'/BODY>'+inferieur +'/HTML>');
       ph.document.close();
}


function winStream(file,l,h,titre,mime) {
        inferieur = String.fromCharCode(60)
        ph=window.open("","ph", "scrollbars=no,status=no,toolbar=no,menubar=no,resizable=yes,height="+(h)+",width="+l);
        ph.document.open();
        ph.document.writeln("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
        ph.document.writeln('<BODY MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" LINK="#FFFFFF" bgcolor="#FFFFFF" text="#ffffff" >');
        ph.document.writeln('<embed id=ii type="'+mime+'" src="'+file+'" autostart="true" controls=true loop=-1 border=0 width='+l+' height='+h+'>');
        ph.document.writeln(inferieur +'/BODY>'+inferieur +'/HTML>');
        ph.document.close();
}
function winAction(url){
  var w = window.open('','action','width=400,height=400,scrollbars=yes,location=no,resizable=yes');
  w.location = url;
}
function sstree_toggle(elm,iopen,iclose) {
 var newDisplay = "none";
 if(iopen=='') iopen='/tzr/templates/images/folder-open.gif';
 if(iclose=='') iclose='/tzr/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;
}

TZR = new Object();
TZR.isFormOk=true;
TZR.formValidation=true;
TZR.validator=new Array();
TZR.onsubmit=new Array();
//
TZR.selectAll = function (f,value) {
  start=false;
  for(i=0;i< f.elements.length; i++) {
    if(start && (f.elements[i].type=='checkbox')) f.elements[i].checked = value;
    if(f.elements[i].value=='selectstart') start=true;
  }
}
// validation des formulaires
TZR.isShortTextValid = function (id,fmt,fieldlabel,color) {
  var o = document.getElementById(id);
  var phrase = o.value;
  var resultat = fmt.test(phrase);
  if(!resultat) {
    if(color.charAt(0)=='#') {
      o.obackgroundColor=o.style.backgroundColor;
      o.style.backgroundColor=color;
    } else {
      o.oclassName=o.className;
      o.className=color;
    }
    TZR.isFormOk=false;
    return false;
  } else {
    if(color.charAt(0)=='#') {
      if(o.obackgroundColor) o.style.backgroundColor=o.obackgroundColor;
      else o.style.backgroundColor='';
    } else {
      if(o.oclassName) o.className=o.oclassName;
    }
    return true;
  }
}

TZR.isFormValid = function (f) {
  return TZR.isFormValidWithFocus(f,false);
}
TZR.isFormValidWithFocus = function (f,foc) {
  TZR.isFormOk=true;
  nb=TZR.validator.length;
  for(i=0;i<nb;i++) {
    var o = document.getElementById(TZR.validator[i][0]);
    if(o.form.name==f.name) {
      TZR.isIdxValid(i);
      if(foc) {
	if(!TZR.isFormOk) {
	  o.focus();
	  return false;
	}
      }
    }
  }
  nb=TZR.onsubmit.length;
  for(i=0; i<nb; i++) {
    eval(TZR.onsubmit[i]);
  }
  if(!TZR.isFormOk) {
    if(typeof(TZR.customValid)!='undefined')
      return TZR.customValid(f);
    else 
      return confirm('Some data are not valid. Save anyway ?');
  }
  return true;
}
TZR.isIdxValid = function (i) {
   var isValid=false;
   if(TZR.validator[i][4]=='XShortTextDef') 
      isValid=TZR.isShortTextValid(TZR.validator[i][0],TZR.validator[i][1],TZR.validator[i][2],TZR.validator[i][3]);
   else if(TZR.validator[i][4]=='XRealDef') 
      isValid=TZR.isShortTextValid(TZR.validator[i][0],TZR.validator[i][1],TZR.validator[i][2],TZR.validator[i][3]);
   else if(TZR.validator[i][4]=='XPasswdDef') 
      isValid=TZR.isShortTextValid(TZR.validator[i][0],TZR.validator[i][1],TZR.validator[i][2],TZR.validator[i][3]);
   return isValid;
}
TZR.isIdValid = function (id) {
  found=false;
  nb=TZR.validator.length;
  for(i=0;i<nb;i++) {
    if(id==TZR.validator[i][0]) {
      if(!TZR.isIdxValid(i)) return false;
    }
  }
  if(typeof(TZR.customOnBlur)!='undefined')
    return TZR.customOnBlur(id);
  return true;
}
TZR.copyDivToHidden = function (idsrc, iddst) {
  var objsrc = document.getElementById(idsrc);
  var objdst = document.getElementById(iddst);
  if(objsrc.innerHTML=="...") objdst.value="";
  else objdst.value = objsrc.innerHTML;
  return true;
}

TZR.addOnSubmit = function (src) {
  nb=TZR.onsubmit.length;  
  TZR.onsubmit[nb]=src;
}
TZR.addValidator = function (src) {
  nb=TZR.validator.length;  
  TZR.validator[nb]=src;
}

TZR.editSec = function (selfu, moid, oid) {
   window.open(selfu+'&function=secEdit&template=xmodule/edit-sec.html&moid='+moid+'&tplentry=br&oid='+oid,
   'SecBrowser','width=500,height=300,resizable=yes,scrollbars=yes,dependent=yes');
  return false;
}
<!-- -->
TZR.autocomplete_cb = function (suggestion) {     
  if ( suggestion ) {
    var inp = TZR.autocomplete_field;
    var inp_enc = TZR.autocomplete_encoded_field;
    inp_enc.value=suggestion[0];
    // IE
    if ( document.selection ) {
      var sel = document.selection.createRange();
      sel.text = suggestion[1];            
      sel.move( 'character', -suggestion[1].length );
      sel.findText( suggestion[1] );
      sel.select();
    } else {
      var preLength = inp.value.length;
      inp.value += suggestion[1];
      inp.selectionStart = preLength;
      inp.selectionEnd   = inp.value.length;
    } 
  }
}

TZR.autocomplete_running=false;
TZR.autocomplete_precheck = function ( tab, field, myform, e ) {
  // Check for alpha numeric keys
  TZR.autocomplete_field = myform.elements[field+'_HID'];
  TZR.autocomplete_encoded_field = myform.elements[field];
  if ( ( e.keyCode >= 48 && e.keyCode <= 57 ) || ( e.keyCode >= 65 && e.keyCode <= 90 ) ) {
    x_xlinkdef_autocomplete( tab, field, TZR.autocomplete_field.value, TZR.autocomplete_cb);
  }
}
      
TZR.toggleCheckBoxes = function(src) {
  start=false;
  for(i=0;i< src.elements.length; i++) {
    if(start) src.elements[i].checked = !src.elements[i].checked;
    if(src.elements[i].value=='selectstart') start=true;
  }
}
TZR.checkBoxes = function(src, value) {
  start=false;
  for(i=0;i< src.elements.length; i++) {
    if(start) src.elements[i].checked=value;
    if(src.elements[i].value=='selectstart') {
      start=true;
    }
  }
}
TZR.referer = function(markers,lang) {
 var maintenant = new Date();
 var msg=maintenant.toLocaleString();
 var n1=new Image();
 n1.src='/tzr/scripts/marker.php?_marks='+markers+'&_lang='+lang+'&alea='+msg;
}
TZR.refererWithTotalOn = function(markers,lang,totalon) {
 var maintenant = new Date();
 var msg=maintenant.toLocaleString();
 var n1=new Image();
 n1.src='/tzr/scripts/marker.php?_marks='+markers+'&_lang='+lang+'&_total='+totalon+'&alea='+msg;
}

TZR.setDateEmpty = function(id) {
  document.getElementById(id).value='0000-00-00';
  return false;
}

var selectedtopic;
var selectedtopics_title;
TZR.selectTopic = function(selfu, moid, t1,t2) {
  selectedtopic=t1;
  selectedtopic_title=t2;
  w=window.open(selfu+'&class=XModInfoTree&function=home&template=xmodinfotree/pop2.html&moid='+
		moid+'&tplentry=mit&do=showtree',
	      	'TreeBrowser','width=400,height=300,resizable=yes,scrollbars=yes,dependent=yes');
}

