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+40, dh+20);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('UL');
  for (var j = 0; j < lists.length; j++)
   lists[j].style.display = "none";
  var e = document.getElementById("root");
  e.style.display = "block";
}
function sstree_open(tag) {
  var lists = document.getElementsByTagName('A');
  for (var j = 0; j < lists.length; j++)
   if(lists[j].id==tag) sstree_toggle(lists[j],'','');
}


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

if(typeof(TZR)=="undefined") TZR=new Object();
if(typeof(TZR._sharescripts)=="undefined") TZR._sharescripts="/tzr/scripts/";
TZR.isFormOk=true;
TZR.formValidation=true;
TZR.validator=new Array();
TZR.dependency=new Object();
TZR.onsubmit=new Array();
// validation des formulaires
TZR.isShortTextValid = function (id,fmt,fieldlabel,color,linktext,listid) {
  var o = document.getElementById(id);
  var phrase = o.value;
  var resultat = fmt.test(phrase);
  if(linktext){
    o=document.getElementById(linktext);
  }
  if(!resultat) {
    if(o.isValid!==false){
      if(color.charAt(0)=='#') {
	o.obackgroundColor=o.style.backgroundColor;
	o.style.backgroundColor=color;
      } else {
	o.oclassName=o.className;
	o.className=color;
      }
    }
    o.isValid=false;
    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;
    }
    o.isValid=true;
    return true;
  }
}

// validation des formulaires
TZR.isLinkValid = function (id,fmt,fieldlabel,color,linktext,listid) {
  var o = document.getElementById(id);
  var typ=o.type;
  // Cas "radio" ou "checkbox"
  if(typ=="radio" || typ=="checkbox"){
    return TZR.isRadioValid(id,fmt,fieldlabel,color,linktext,listid);
  }else{
    var resultat = true;
    // Cas "un select"
    if(fmt=='compselect'){
      resultat = false;
      for(var i=0;i<o.options.length;i++){
	if(o.options[i]!=null && o.options[i].selected && o.options[i].value!=''){
	  resultat=true;
	  break;
	}
      }
    }else if(fmt=='') { // Cas "2 select non obligatoire"
      for(var i=0;i<o.options.length;i++) if(o.options[i]!=null) o.options[i].selected=true;
    } else if(fmt=='/(.+)/') { // Cas "2 select obligatoire"
      if(o.options.length==0) resultat=false;
      else for(var i=0;i<o.options.length;i++) if(o.options[i]!=null) o.options[i].selected=true;
    } else if(document.getElementById("table"+id)!=undefined){ // Cas autocomplete multiple
      if(document.getElementById("table"+id).tBodies[0].rows.length<2) resultat=false;
      o=document.getElementById(linktext);
    } else { // Autre cas : autocomplete, lien base doc...
      var phrase = o.value;
      var resultat = fmt.test(phrase);
      if(linktext){
	o=document.getElementById(linktext);
      }
    }
    if(!resultat) {
      if(o.isValid!==false){
	if(color.charAt(0)=='#') {
	  o.obackgroundColor=o.style.backgroundColor;
	  o.style.backgroundColor=color;
	} else {
	  o.oclassName=o.className;
	  o.className=color;
	}
      }
      o.isValid=false;
      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;
      }
      o.isValid=true;
      return true;
    }
  }
}
TZR.isRadioValid = function (id,fmt,fieldlabel,color,linktext,listid) {
  var resultat=false;
  var o=document.getElementById(id);
  var l=listid.length;
  for(var i=0;i<l;i++){
    if(document.getElementById(listid[i]).checked){
      resultat=true;
      break;
    }
  }
  var tab=TZR.getParent(o,'TABLE');
  if(!resultat){
    if(o.isValid!==false){
      if(color.charAt(0)=='#') {
	tab.obackgroundColor=tab.style.backgroundColor;
	tab.style.backgroundColor=color;
      } else {
	tab.oclassName=tab.className;
	tab.className=color;
      }
    }
    o.isValid=false;
    TZR.isFormOk=false;
    return false;
  } else {
    if(color.charAt(0)=='#') {
      if(tab.obackgroundColor) tab.style.backgroundColor=tab.obackgroundColor;
      else tab.style.backgroundColor='';
    } else {
      if(tab.oclassName) tab.className=tab.oclassName;
    }
    o.isValid=true;
    return true;
  }
}
TZR.isThesaurusValid=function(id,fmt,fieldlabel,color){
  var o=document.getElementById("div"+id);
  var ok=false;
  jQuery('#table'+id+" input").each(function(i){
    if(this.value!=''){
      ok=true;
      return false;
    }
  });
  if(!ok){
    if(o.isValid!==false){
      if(color.charAt(0)=='#') {
	o.obackgroundColor=o.style.backgroundColor;
	o.style.backgroundColor=color;
      } else {
	o.oclassName=o.className;
	o.className=color;
      }
    }
    o.isValid=false;
    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;
    }
    o.isValid=true;
    return true;
  }
}
TZR.isCaptchaValid = function(id,fmt,fieldlabel,color){
  var response=0;
  o=document.getElementById(id);
  jQuery.ajax({async:false,
	       url:TZR._sharescripts+"ajax8.php?class=XModTable&function=xmodtable_captcha",
	       cache:false,
	       data:{value:o.value,id:id},
	       success:function(resp){response=resp;}
  });
  if(response=='0') response=false;
  else response=true;
  if(!response) {
    document.getElementById("ca"+id).onclick();
    document.getElementById(id).value="";
    if(o.isValid!==false){
      if(color.charAt(0)=='#') {
	o.obackgroundColor=o.style.backgroundColor;
	o.style.backgroundColor=color;
      } else {
	o.oclassName=o.className;
	o.className=color;
      }
    }
    o.isValid=false;
    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;
    }
    o.isValid=true;
    TZR.isFormOk=true;
    return true;
  }
}
TZR.isFolderValid = function (id,fmt,fieldlabel,color) {
  var o=document.getElementById(id.replace('hidden','Queue'));
  var nb=jQuery(o).find('>div>div.cancel').length;
  var tocol=jQuery(o).find('>div.uploadifyQueueItem');
  if(nb>0) {
    if(o.isValid!==false){
      o.obackgroundColor=tocol[0].style.backgroundColor;
      tocol.css('background-color',color);
    }
    o.isValid=false;
    TZR.isFormOk=false;
    return false;
  } else {
    if(o.obackgroundColor) tocol.css('background-color',o.obackgroundColor);
    else tocol.css('background-color','');
    o.isValid=true;
    return true;
  }
}
TZR.isFileValid = function (id,fmt,fieldlabel,color,browsemods,allow_externalfile) {
  var o = document.getElementById(id);
  o.style.backgroundColor='';
  o.isValid = false;
  if (o.value != '' || document.getElementById(id+'-old').value != '')
    o.isValid = true;
  else if (browsemods && document.getElementById(id+'-from').value != '')
    o.isValid = true;
  else if (allow_externalfile && document.getElementById(id+'-external').value != '')
    o.isValid = true;
  if (!o.isValid) {
    o.style.backgroundColor = color;
    TZR.isFormOk = false;
  }
  return o.isValid;
}
TZR.actualizeCaptcha=function(url,id){
  document.getElementById('cimg'+id).src=url+"?id="+id+"&"+(new Date()).getTime();
}
TZR.getUrlTitle=function(url,color){
  var urlu=document.getElementById("url"+url);
  var urll=document.getElementById("label"+url);
  urlu.style.backgroundImage="url('/tzr/templates/ico/general/indicator.gif')";
  urlu.style.backgroundPosition="right center";
  urlu.style.backgroundRepeat="no-repeat";
  var reg=/^(((?!mailto)(?!\[)).+)$/;
  if(!reg.test(urlu.value)){
    urlu.obackgroundColor=urlu.style.backgroundColor;
    urlu.style.backgroundColor=color;
  }else{
    var title=TZR.file_get_contents(TZR._sharescripts+'ajax8.php?function=xurldef_getPageTitle&class=XUrlDef&url='+escape(urlu.value));
    if(title=="error"){
      urlu.obackgroundColor=urlu.style.backgroundColor;
      urlu.style.backgroundColor=color;
    }else{
      if(urlu.obackgroundColor) urlu.style.backgroundColor=urlu.obackgroundColor;
      else urlu.style.backgroundColor='';
      urll.value=title;
    }
  }
  urlu.style.backgroundImage="";
  urlu.style.backgroundPosition="";
  urlu.style.backgroundRepeat="";
}
TZR.openPopup = function(url){
  window.open(url,'','menubar=no,status=no,resizable=1,scrollbars=1,width=700,height=500');
  return false;
}
TZR.validFormInPopup = function(f){
  var ret=TZR.isFormValidWithFocus(f,true);
  if(ret){
    window.opener.name=TZR.uniqid('TZR');
    document.editform.target=window.opener.name;
    f.submit();
    self.close();
    return false;
  }else{
    return false;
  }
}
TZR.isFormValid = function (f) {
  return TZR.isFormValidWithFocus(f,false);
}
TZR.isFormValidWithFocus=function(f,foc) {
  TZR.isFormOk=true;
  for(var i=0;i<TZR.validator.length;i++){
    var o=document.getElementById(TZR.validator[i][0]);
    if(o!=null && o.form.name==f.name) {
      if(TZR.validator[i][99]){
	TZR.isIdxValid(i);
	if(foc) {
	  if(!TZR.isFormOk) {
	    if(TZR.validator[i][5])
	      o=document.getElementById(TZR.validator[i][5]);
	    jQuery(o).parents('fieldset.fieldsetAccordionClose').find('>legend').click();
	    o.focus();
	    return false;
	  }
	}
      }
    }else{
      TZR.validator.splice(i,1);
      i--;
    }
  }
  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;
   var val=TZR.validator[i];
   if(val[4]=='XShortTextDef')
      isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3]);
   else if(val[4]=='XRealDef')
      isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3]);
   else if(val[4]=='XPasswdDef'){
      isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3]);
      if(isValid && document.getElementById(val[0]+'_HID')){
	isValid=TZR.isShortTextValid(val[0]+'_HID',new RegExp('^'+document.getElementById(val[0]).value+'$'),val[2],val[3]);
      }
   }else if(val[4]=='XDocumentDef')
      isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3],val[5]);
   else if(val[4]=='XLinkDef')
      isValid=TZR.isLinkValid(val[0],val[1],val[2],val[3],val[5],val[6]);
   else if(val[4]=='XStringSetDef')
      isValid=TZR.isLinkValid(val[0],val[1],val[2],val[3],val[5],val[6]);
   else if(val[4]=='XThesaurusDef')
      isValid=TZR.isThesaurusValid(val[0],val[1],val[2],val[3]);
   else if(val[4]=='Captcha')
      isValid=TZR.isCaptchaValid(val[0],val[1],val[2],val[3]);
   else if(val[4]=='XFolderDef')
      isValid=TZR.isFolderValid(val[0],val[1],val[2],val[3]);
   else if(val[4]=='XFileDef')
      isValid=TZR.isFileValid(val[0],val[1],val[2],val[3],val[6],val[7]);
   return isValid;
}

TZR.addAutoComplete=function(url,id,moid,table,field,target_fields,callback){
  var hiddenf=document.getElementById(id);
  jQuery("#_INPUT"+id).keydown(function(event){
    if(event.keyCode!=13 && event.keyCode!=9 && hiddenf) hiddenf.value="";
  }).autocomplete(url, {
    extraParams:{moid:moid,table:table,field:field,target_fields:target_fields},
    width:300,
    delay:500,
    mustMatch:true,
    minChars:2,
    multiple:false,
    multipleSeparator:'__none__',
    max:999
  }).result(function(event, data, formatted) {
    if(data!=undefined){
      if(!data[1]){
	this.value="";
	if(hiddenf) hiddenf.value='';
      }else{
	if(hiddenf) hiddenf.value=data[1];
	if(callback) callback(id,data[1],data[0]);
      }
      jQuery(hiddenf).change();
    }
  });
}
TZR.autoCompleteMultipleValue=function(id,oid,v){
  if(jQuery('#table'+id).find('input[value="'+oid+'"]').length>0) return;
  var tr=TZR.addTableLine("table"+id,[undefined,v],0,false);
  jQuery('input',tr.cells[0]).val(oid);
  jQuery(tr).show();
  jQuery('#_INPUT'+id).val('');
}
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){
  var o=document.getElementById(src[0]);
  if(!o) return false;
  if(src[99]===undefined) src[99]=true;
  var v=jQuery(o).data('validators');
  if(!v) v=[src];
  else v.push(src);
  jQuery(o).data('validators',v);
  TZR.validator.push(src);
  return true;
}
TZR.changeValidatorsState=function(id,active){
  if(!active) active=false;
  var vs=jQuery('#'+id).data('validators');
  if(vs){
    for(var i in vs){
      vs[i][99]=active;
    }
  }
}
TZR.editSec=function (selfu, moid, oid) {
  window.open(selfu+'&function=secEdit&template=xmodule/edit-sec.html&moid='+moid+'&tplentry=br&oid='+oid,
	      'SecBrowser','width=600,height=320,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);
  }
}

// Inverse la coche de toutes les checkbox d'un formulaire
TZR.toggleCheckBoxes = function(src,startn,endn) {
  if(!startn) startn='selectstart';
  var start=false;
  for(var i=0;i<src.elements.length;i++) {
    if(endn){
      if(src.elements[i].value==endn) break;
    }
    if(start) src.elements[i].checked = !src.elements[i].checked;
    if(src.elements[i].value==startn) start=true;
  }
}
// Coche ou decoche toutes les checkbox d'un formulaire
TZR.checkBoxes = function(src,value,startn,endn) {
  if(!startn) startn='selectstart';
  var start=false;
  for(var i=0;i<src.elements.length;i++) {
    if(endn){
      if(src.elements[i].value==endn) break;
    }
    if(start && (src.elements[i].type=='checkbox')) src.elements[i].checked=value;
    if(src.elements[i].value==startn) start=true;
  }
}
// Retourne vrai si au moins une checkbox est coché dans le formulaire
TZR.checkBoxesIsChecked = function(src,startn,endn) {
  if(!startn) startn='selectstart';
  var start=false;
  for(var i=0;i<src.elements.length;i++) {
    if(endn){
      if(src.elements[i].value==endn) break;
    }
    if(start && src.elements[i].checked) return true;
    if(src.elements[i].value==startn) start=true;
  }
  return false;
}

TZR.referer = function(markers,lang) {
 var maintenant = new Date();
 var msg=maintenant.toLocaleString();
 var n1=new Image();
 n1.src=TZR._sharescripts+'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._sharescripts+'marker.php?_marks='+markers+'&_lang='+lang+'&_total='+totalon+'&alea='+msg;
}

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

TZR.selectDocument=function(selfu,moid,id,showfiles){
  if(typeof(showfiles)=='undefined') showfiles=1;
  var w=window.open(selfu+'&function=index2Light&nosess=1&template=xmoddocmgt/poptree.html&moid='+moid+
		'&tplentry=br&showfiles='+showfiles+'&_raw=1&_silent=1&action=selectDoc&target='+id,
	      	'DocumentBrowser','width=400,height=600,resizable=yes,scrollbars=yes,dependent=yes');
}

TZR.setDocumentEmpty = function(id) {
  document.getElementById("id_"+id).value='';
  document.getElementById("id_INPUT"+id).value='';
  return false;
}

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

TZR.applySelected=function(func,form,message,template,tplentry,noselect) {
   if(TZR.checkBoxesIsChecked(form)){
     form.target='_self';
     form._function.value=func;
     form.message.value=message;
     if(template!==false){
       form.template.value=template;
       form._next.value="";
     }
     if(tplentry!==false) form.tplentry.value=tplentry;
     if(!form.onsubmit || form.onsubmit()) form.submit();
   }else{
     alert(noselect);
     return;
   }
}

TZR.doubleAdd = function(src,dst,morder) {
  var i=0;
  if(morder) {
    if (jQuery(dst).find('optgroup').length > 0) { // grouped options
      for (i=0; i<src.options.length; i++) {
        if (src.options[i].selected) {
          order = parseInt(jQuery(src.options[i]).attr('order'));
          groupId = src.options[i].parentNode.id.replace(/(unselected_)?(.*)/, "$2");
          dstGroup = jQuery(dst).find('optgroup[id$="'+groupId+'"]');
          opts = jQuery(dstGroup).find('option');
          for (j=0; j<opts.length; j++) {
            if (parseInt(jQuery(opts[j]).attr('order')) > order)
              break;
          }
          if (opts[j])
            jQuery(opts[j]).before(src.options[i]);
          else
            jQuery(dstGroup).append(src.options[i]);
          i--;
        }
      }
    } else { // non grouped options
      for (i=0; i<src.options.length; i++) {
        if (src.options[i].selected) {
          order = parseInt(jQuery(src.options[i]).attr('order'));
          for (j=0; j<dst.options.length; j++) {
            if (parseInt(jQuery(dst.options[j]).attr('order')) > order)
              break;
          }
          if (dst.options[j])
            jQuery(dst.options[j]).before(src.options[i]);
          else
            jQuery(dst).append(src.options[i]);
          i--;
        }
      }
    }
  } else {
    for (i=src.options.length-1; i>=0; i--) {
      if (src.options[i].selected) {
        dst.options[dst.options.length] = src.options[i];
//         src.options[i]=null;
      }
    }
  }
  jQuery(src).val('');
  jQuery(dst).val('');
  // trigger the change event for additionnal control (FO usage)
  jQuery(dst).change();
}

TZR.idxidx=10;
TZR.addTableLine = function(tableid,td,trtoclone,del) {
  if(td[1]=='--') return;
  if(typeof(trtoclone)=='undefined') trtoclone=0;
  if(typeof(del)=='undefined') del=true;
  var table = document.getElementById(tableid);
  var tbody = table.tBodies[0];
  var tr = tbody.rows[trtoclone].cloneNode(true);
  if(del){
    for(i=0;i<tr.cells.length; i++) {
      tr.cells[i].innerHTML="";
    }
  }
  table.tBodies[0].appendChild(tr);
  var td3;
  for(i=0;i<td.length; i++) {
    if(td[i]!=undefined){
      td3=td[i].replace(/xidxid/g,'xid'+TZR.idxidx);
      jQuery(tr.cells[i]).html(td3);
    }
  }
  TZR.idxidx++;
  return tr;
}

/* ajout d'une valeur a partir d'une combo */
TZR.addValueToShortText = function(text, multi, sep) {
   var text1 = document.getElementById(text);
   var combo1 = document.getElementById(text+'_H');
   if(combo1.selectedIndex==0) return;
   if(multi) {
     if(text1.value=='') sep='';
     text1.value+=sep+combo1.options[combo1.selectedIndex].text;
   } else {
     text1.value=combo1.options[combo1.selectedIndex].text;
   }
   return;
}

/* trouve le tag "parentTagName" parent de "element" */
TZR.getParent = function(element, parentTagName) {
  if ( ! element ) return null;
  else if ( element.nodeType == 1 && element.tagName.toLowerCase() == parentTagName.toLowerCase() ) return element;
  else return TZR.getParent(element.parentNode, parentTagName);
}

/* supprimer une ligne dans un tableau */
TZR.delLine = function(link) {
  var td = link.parentNode;
  var table = TZR.getParent(td, 'TABLE');
  var tbody = table.tBodies[0];
  tbody.removeChild(TZR.getParent(td, 'TR'));
}

// Recupere le contenu d'une url via ajax en synchrone
TZR.file_get_contents=function(url,nocache){
    var req = null;
    try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
        try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
            try { req = new XMLHttpRequest(); } catch(e) {}
        }
    }
    if (req == null) throw new Error('XMLHttpRequest not supported');
    if(typeof(nocache)!='undefined'){
	url+="&uniqid="+TZR.uniqid();
    }
    req.open("GET", url, false);
    req.send(null);
    return req.responseText;
}
TZR.winEditor = null;
TZR.openhtmlfileeditor = function(options){
  var url = options.url+'&formid='+options.uniqid+'&editflag='+escape(options.editflag)+'&uploader='+escape(options.uploader)+'&downloader='+escape(options.downloader);
  try{
    if(TZR.winEditor.closed) throw "Closed";
    TZR.winEditor.location = url;
    TZR.winEditor.focus();
  } catch(e){
    TZR.winEditor = window.open(url, 'file editor', 'width=800px,height=700px;')
  }
}
// Génére un identifiant unique avec un prefix eventuel
TZR.uniqid=function(prefix){
  if(typeof(prefix)=='undefined') prefix="";
  var alea=Math.random()*1000000000;
  return prefix+alea.toString();
}
TZR.addDependency=function(ftype,fd,f,vd,v,op,s,nochange){
  if(typeof(TZR.dependency[fd])=='undefined'){
    TZR.dependency[fd]=new Object();
    TZR.dependency[fd]['_depfields']=new Object();
    TZR.dependency[fd]['_!=']=new Object();
  }
  if(vd=='') vd='_empty';
  if(op=='='){
    if(typeof(TZR.dependency[fd][vd])=='undefined') TZR.dependency[fd][vd]=new Object();
  }else{
    if(typeof(TZR.dependency[fd]['_!='][vd])=='undefined') TZR.dependency[fd]['_!='][vd]=new Object();
  }
  TZR.dependency[fd]['_depfields'][f]=1;
  if(op=='=') TZR.dependency[fd][vd][f]={field:f,ftype:ftype,value:v,style:s,op:op,nochange:nochange};
  else TZR.dependency[fd]['_!='][vd][f]={field:f,ftype:ftype,value:v,style:s,op:op,nochange:nochange};
}
TZR.activeDependency=function(f){
  jQuery(f).find('select').bind('change',{form:f},TZR.checkDependency);
  jQuery(f).find(':checkbox,:radio').bind("click",{form:f},TZR.checkDependency);
  var els=jQuery(f).find('select');
  for(var i=0;i<els.length;i++){
    jQuery(els[i]).triggerHandler("change");
  }
  var oks=new Object();
  var els=jQuery(f).find(':checkbox:checked,:radio:checked');
  for(var i=0;i<els.length;i++){
    jQuery(els[i]).triggerHandler("click");
    oks[els[i].name]=1;
  }
  var els=jQuery(f).find(':checkbox,:radio');
  for(var i=0;i<els.length;i++){
    if(els[i].checked || oks[els[i].name]==1) continue;
    jQuery(els[i]).triggerHandler("click");
    oks[els[i].name]=1;
  }
}
// Dependance uniquement sur select simple, radio et checkbox de booleen
TZR.checkDependency=function(e){
  var t=e.target;
  var n=t.name;
  var v=t.value;
  if(typeof(n)=='undefined' || n=="") return;
  if(t.type=="hidden") return;
  if(t.type=="radio" && !t.checked) v="";
  if(t.type=="checkbox"){
    n=n.replace(/(\[.+\])$/g,"");
    n=n.replace(/(_HID)$/g,"");
    if(t.checked) v=1;
    else v=2;
  }
  if(v=='') v='_empty';
  if(typeof(TZR.dependency[n])=='undefined') return;
  if(typeof(TZR.dependency[n][v])!='undefined'){
    for(var i in TZR.dependency[n][v]){
      var dep=TZR.dependency[n][v][i];
      TZR.setDependencyValue(e.data.form,dep.field,dep.ftype,dep.value,dep.nochange);
      if(!e.data.nostyle) TZR.setDependencyStyle(dep.field,dep.style);
    }
  }
  for(var v2 in TZR.dependency[n]['_!=']){
    if(v==v2) continue;
    for(var i in TZR.dependency[n]['_!='][v2]){
      if(typeof(TZR.dependency[n][v])!="undefined" && typeof(TZR.dependency[n][v][i])!="undefined") continue;
      var dep=TZR.dependency[n]['_!='][v2][i];
      TZR.setDependencyValue(e.data.form,dep.field,dep.ftype,dep.value,dep.nochange);
      if(!e.data.nostyle){
        TZR.setDependencyStyle(dep.field,dep.style);
      }
    }
  }
}

TZR.setDependencyStyle=function(field,style){
  var toStyle=document.getElementById('cont-'+field);
  if(typeof(toStyle)=='undefined' || !toStyle){
      toStyle=document.getElementById('cv8d-displayobj-field-'+field);
  }
  if(typeof(toStyle)!='undefined' && toStyle){
    if(style=='hidden'){
      toStyle.style.display='none';
    }else if(style=="invalid"){
      jQuery(toStyle).find(":input").attr('disabled',true);
    }else{
      jQuery(toStyle).find(":input").attr('disabled',false);
      toStyle.style.display='';
    }
  }
}
TZR.setDependencyValue=function(form,field,ftype,value,nochange){
  if(!nochange || nochange=="0"){
    TZR.setValue(form,field,ftype,value);
    if(typeof(TZR.dependency[field])=='undefined') return;
    TZR.checkDependency({target:{name:field,value:value},data:{nostyle:false,form:form}});
  }
}
TZR.setValue=function(form,field,ftype,value){
  if(typeof(field)=='string' && !form){
    fid=document.getElementById(field);
    field=fid.name;
    form=fid.form;
  }else if(typeof(field)=='string' && typeof(form)=='string'){
    form=jQuery('form[name='+form+']').get(0);
  }

  if(ftype=="XLinkDef") TZR.setLinkValue(form,field,value);
  else TZR.setTextValue(form,field,value);
}
// form (objet), field (string)
TZR.setLinkValue=function(form,field,value){
  var cont=document.getElementById('cont-'+field);
  if(typeof(cont)=='undefined' || !cont){
      cont=document.getElementById('cv8d-displayobj-field-'+field);
  }

  var ret=jQuery(cont).find(":radio[name='"+field+"']").val([value]);
  if(ret.length==0) var ret=jQuery(cont).find("select[name='"+field+"']").val(value);
  if(ret.length==0) var ret=jQuery(cont).find("select[name='"+field+"[]']").val(value);
  if(ret.length==0) var ret=jQuery(cont).find(":checkbox[name^='"+field+"[']").val([value]);
}
TZR.setTextValue=function(form,field,value){
  form.elements[field].value=value;
}

// Affiche du contenu centré dans l'écran avec une div d'arriere plan pleine page
// content est soit du texte, soit l'id d'un objet deja existant
TZR.dispFullScreenContent=function(content,color,op){
  if(!color) color="#000000";
  if(!op) op=0.2;

  var div=document.getElementById('fsoverlay');
  if(!div){
    jQuery("body").append('<div id="fsoverlay"></div>');
    jQuery("#fsoverlay").css({position:"absolute", zIndex:99998, padding:0, margin:0, top:0, left:0, background:color,
	  	              opacity:op, width:"100%", height:jQuery(document).height()});
  }
  if(content.substr(0,1)!="#"){
    jQuery("#fscontent").remove();
    jQuery("body").append('<div id="fscontent"></div>');
    jQuery("#fscontent").css({position:"absolute", zIndex:99999, padding:0, margin:0, top:0, left:0});
    jQuery("#fscontent").html(content);
    jQuery("#fscontent").css({top:(jQuery(window).height()-jQuery("#fscontent").outerHeight())/2+jQuery(window).scrollTop(),
    				    left:(jQuery(window).width()-jQuery("#fscontent").outerWidth())/2, visibility:"visible"});
  }else{
    jQuery(content).css({visibility:"visible", display:"block"});
    jQuery(content).css({position:"absolute", zIndex:99999, padding:0, margin:0,
				    top:(jQuery(window).height()-jQuery(content).outerHeight())/2+jQuery(window).scrollTop(),
				    left:(jQuery(window).width()-jQuery(content).outerWidth())/2});
  }
}
TZR.hideFullScreenContent=function(content){
  jQuery("#fsoverlay").remove();
  if(content!=undefined && content.substr(0,1)=="#"){
    jQuery(content).css('display','none');
  }else{
    jQuery("#fscontent").remove();
  }
}

/* Fonctions pour faciliter la gestion des champs préremplis avec leur libellé */
// Initialise les différentes propiétés du champ (o=objet, l=libellé)
function inputInit(o,l,cpltblur){
  if(cpltblur==undefined) cpltblur=true;
  if(typeof o=="string") { o=document.getElementById(o); }
  if(o.type=="text" || o.type=="textarea" || o.type=="password"){
    o.cpltblur=cpltblur;
    o.ovalue=l;
    if(o.value=="") o.value=l;
    o.onfocus=delValue;
    o.onblur=retablishValue;
    o.onchange=function(){};
  }else if(o.type=="select-one"){
    o.options[0].text=l;
  }
}
// Efface le contenu d'un champ (o=objet (se renseigne automatiquement sur un onfocus))
function delValue(o){
  if(o==undefined || o.type=="focus") o=this;
  if(o.value==o.ovalue){
    o.value="";
  }else{
    var r=new RegExp("^"+o.ovalue+" : ","");
    o.value=o.value.replace(r,"");
  }
}
// Rétabli le libellé si necessaire lors de la perte du focus (o=objet (se renseigne automatiquement sur un onblur))
function retablishValue(o){
  if(o==undefined || o.type=="blur") o=this;
  if(o.value==""){
    o.value=o.ovalue;
  }else if(o.cpltblur){
    o.value=o.ovalue+" : "+o.value;
  }
}
// A appeller sur le submit pour vider les champs non saisis
function checkFields(f){
  l=f.elements.length;
  for(i=0;i<l;i++){
    if((f.elements[i].type=="text" || f.elements[i].type=="textarea")){
      if(f.elements[i].value==f.elements[i].ovalue){
	f.elements[i].value="";
      }else{
	var r=new RegExp("^"+f.elements[i].ovalue+" : ","");
	f.elements[i].value=f.elements[i].value.replace(r,"");
      }
    }
  }
}

/* Fonctions pour formater les champs date et heure/durée (besoin de jquery.ui.datepicker)*/
TZR.formatDate=function(obj,fmt){
  if(obj.value[0]=='=') return;
  if(fmt==undefined) fmt=jQuery(obj).datepicker('option','dateFormat');
  var val=obj.value;
  if(val=='') return false;
  // traitement interval
  fmt_re = fmt.replace(new RegExp('dd|mm|y','g'), '\\d{1,2}').replace(new RegExp('\/','g'),'[\/.-]');
  range_pattern = new RegExp('('+fmt_re+')\\s*\<\>\\s*('+fmt_re+')');
  matches = val.match(range_pattern);
  try {
    if (matches != null && matches.length == 3)
      obj.value = jQuery.datepicker.formatDate(fmt, jQuery.datepicker.parseDate(fmt,matches[1]))+' <> '+jQuery.datepicker.formatDate(fmt, jQuery.datepicker.parseDate(fmt,matches[3]));
    else
      obj.value = jQuery.datepicker.formatDate(fmt, jQuery.datepicker.parseDate(fmt,val));
  } catch(e) {
    obj.value = '';
  }
}
TZR.format2dates=function(obj,b,e,fmt){
  if(fmt==undefined) fmt=jQuery.datepicker._defaults.dateFormat;
  var form=obj.form;
  var b=form.elements[b];
  var e=form.elements[e];
  TZR.formatDate(obj);
  var begindate=jQuery.datepicker.parseDate(fmt,b.value);
  var enddate=jQuery.datepicker.parseDate(fmt,e.value);
  if(obj==b && begindate>enddate) e.value=b.value;
  else if(obj==e && begindate>enddate) b.value=e.value;
}
TZR.formatHour=function(obj,n){
  val=obj.value;
  tab=val.split(":");
  var rtab=new Array();

  if(/^[0-9]$/.test(tab[0])) {
    rtab[0]="0"+tab[0];
  }else if(/^[0-9]{2}$/.test(tab[0])) {
    rtab[0]=tab[0];
  }else{
    return;
  }
  if(n>1){
   if(!tab[1]){
     rtab[1]="00";
   }else if(/^[0-9]$/.test(tab[1])){
     rtab[1]="0"+tab[1];
   }else if(/^[0-9]{2}$/.test(tab[1])) {
     rtab[1]=tab[1];
   }else{
     return;
   }
  }
  if(n>2){
   if(!tab[2]){
     rtab[2]="00";
   }else if(/^[0-9]$/.test(tab[2])){
     rtab[2]="0"+tab[2];
   }else if(/^[0-9]{2}$/.test(tab[2])) {
     rtab[2]=tab[2];
   }else{
     return;
   }
  }
  obj.value=rtab.join(":");
}

TZR.format2hours=function(obj,n,b,e,bd,ed){
  var form=obj.form;
  b=form.elements[b];
  e=form.elements[e];
  if(bd!=undefined) bd=form.elements[bd];
  if(ed!=undefined) ed=form.elements[ed];
  TZR.formatHour(obj,n);
  var reg=/^[0-9]{2}(:[0-9]{2})?(:[0-9]{2})?$/;
  var tab=obj.value.split(":");
  if(obj.value==""){
    b.value="";
    e.value="";
  }else if(obj==b && b.value>e.value && (bd==undefined || ed==undefined || bd.value==ed.value) && reg.test(b.value)){
    var hour=parseFloat(tab[0]);
    var minute=parseFloat(tab[1]);
    if(hour==23) e.value="23:59";
    else e.value=(hour+1)+":"+minute;
    TZR.formatHour(e,n);
  }else if(obj==e && b.value>e.value && (bd==undefined || ed==undefined || bd.value==ed.value) && reg.test(e.value)){
    var hour=parseFloat(tab[0]);
    var minute=parseFloat(tab[1]);
    if(hour==0) b.value="00:00";
    else b.value=(hour-1)+":"+minute;
    TZR.formatHour(b,n);
  }
}


/* Fonction du champ couleur */
function colourPickerCallback(acolor){
  TZR.ColourPicker.setFieldColor(acolor);
}
function colourPickerClose(acolor){
  TZR.ColourPicker.hide();
}

TZR.ColourPicker = {
  parent:null,
  target:null,
  control:null,
  lastColor:'#7f7f7f',
  myAppName:'ColourPicker',
  myfield:null,
  init:function(target){
    if(!this.target){
      this.target=target;
      this.parent=document.getElementById(target).parentNode;
      swfobject.embedSWF('/tzr/templates/flash/Colourpicker.swf',target,"435","220","8.0.0",null,{},{menu:false,allowScriptAccess:"sameDomain"},{name:this.myAppName,id:this.myAppName});
    }
  },
  initField:function(field){
    var value;
    if(field) this.myField = field;
    else field=this.myField;
    TZR.ColourPicker.show(field);
    var swf=this.getMyApp();
    if(swf.setColour){
      if(field.value) value=field.value;
      else value=this.lastColor;
      swf.setColour(value, field.name);
    }else{
      setTimeout("TZR.ColourPicker.initField()", 250);
    }
  },
  show:function(field){
    coor=jQuery(field).offset();
    this.parent.style.left = (coor.left+field.clientWidth+10)+"px";
    this.parent.style.top = coor.top+"px";
    if(this.control) clearInterval(this.control);
    this.control=setInterval("if(!document.getElementById('"+field.id+"')) TZR.ColourPicker.hide();",1000);
  },
  hide:function(){
    this.parent.style.top = '-500px';
    clearInterval(this.control);
    this.control=null;
  },
  setFieldColor:function(acolor){
    TZR.ColourPicker.hide();
    this.lastColor=acolor;
    document.getElementById('col'+this.myField.id).style.backgroundColor=acolor;
    this.myField.value=acolor;
  },
  getMyApp:function () {
    if (navigator.appName.indexOf ("Microsoft") !=-1) {
      return window[this.myAppName];
    } else {
      return document[this.myAppName];
    }
  }
}
// fonctions des champs de geodesiccoordinates
TZR.geodesic = {
  geoSearch:null,
  dms2dd:function(inid, outid){
    var dms = document.getElementById(inid).value;
    var exp = new RegExp(/[ ]*([0-9]{1,2})° ([0-9]{1,2})' ([0-9]{1,2}\.[0-9]{0,3})'' ([NS]{1})[ ]+([0-9]{1,3})° ([0-9]{1,2})' ([0-9]{1,2}\.[0-9]{0,3})'' ([WOE]{1})/);
    if (exp.test(dms)){
      var dd = document.getElementById(outid);
      var dlng = RegExp.$5;
      var mlng = RegExp.$6;
      var slng = RegExp.$7;
      var lng = RegExp.$8;
      var dlat = RegExp.$1;
      var mlat = RegExp.$2;
      var slat = RegExp.$3;
      var lat = RegExp.$4;
      if (lat == 'S'){
	lat = '-';
      } else {
	lat = '';
      }
      if (lng == 'W' || lng == 'O'){
	lng = '-';
      } else {
	lng = '';
      }
      var ddlat = parseInt(dlat) + parseFloat(mlat/60) + parseFloat(slat/3600);
      var ddlng = parseInt(dlng) + parseFloat(mlng/60) + parseFloat(slng/3600);
      dd.value = lat+ddlat+';'+lng+ddlng;
    }else{
      //      var dd = document.getElementById('dd').value='####';
    }
  },
  setPointCoordinates:function(field, rawvalue, dmsvalue){
    document.getElementById(field.fid).value = rawvalue;
    document.getElementById('dms'+field.fid).value = dmsvalue;
    document.getElementById(field.fid+'_autogc').checked = false;
    this.geocodeauto(document.getElementById(field.fid+'_autogc'), field.fid);
  },
  geocodeauto:function(cb, fid){
    if (cb.checked){
      document.getElementById(fid+'_b1').style.display='block';
      document.getElementById(fid+'_b2').style.display='block';
    } else {
      document.getElementById(fid+'_b1').style.display='none';
      document.getElementById(fid+'_b2').style.display='none';
      document.getElementById(fid+'_unchanged').value = '0';
      document.getElementById(fid+'_accuracy1').innerHTML = '';
      document.getElementById(fid+'_upd').innerHTML = '';
      document.getElementById(fid+'_accuracy2').value = 'N/A';
    }

  },
  openGeoSearch:function( url, fname, fid, ftable){
    var v = document.getElementById(fid).value;
    if (v != ';'){
      var c = v.split(';');
      var newp = false;
      var lat = c[0];
      var lng = c[1];
    } else {
      var newp = true;
      var lat = 0;
      var lng = 0;
    }
    try{
      TZR.geodesic.geoSearch.setPoint({table:ftable, name:fname, id:fid, newpoint:newp, lat:lat, lng:lng});
      TZR.geodesic.geoSearch.focus();
    }catch(e){
      TZR.geodesic.geoSearch = window.open(url+'&fid='+fid+'&ftable='+ftable+'&fname='+fname+'&flatlng='+escape(v), 'GeoSearch',"resizable=no,width=700,height=530,left=100,top=100");
    TZR.geodesic.geoSearch.focus();
    }
  },
  clear:function(fid){
    document.getElementById(fid).value='';
    document.getElementById('dms'+fid).value='';
    document.getElementById(fid).value='';
    document.getElementById(fid+'_accuracy1').innerHTML = '';
    document.getElementById(fid+'_upd').innerHTML = '';
    document.getElementById(fid+'_accuracy2').value = 'N/A';
  },
  openGeoView:function(coordstring, url, fname, fid, ftable){
    var v = coordstring;
    if (v != ';'){
      var c = v.split(';');
      var newp = false;
      var lat = c[0];
      var lng = c[1];
    } else {
      var newp = true;
      var lat = 0;
      var lng = 0;
    }
    try{
      TZR.geoSearch.setPoint({table:ftable, name:fname, id:fid, newpoint:newp, lat:lat, lng:lng});
      TZR.geoSearch.focus();
    }catch(e){
      TZR.geoSearch = window.open(url+'&fid='+fid+'&ftable='+ftable+'&fname='+fname+'&flatlng='+escape(v), 'GeoView',"resizable=no,width=700,height=530,left=100,top=100");
    TZR.geoSearch.focus();
    }
  }
};

// Applique une popup a des objets (obj est un objet jQuery)
TZR.applyHottip=function(obj,param){
  param=jQuery.extend(true,{fill:'#F9F9F9',strokeStyle:'#4b4b4b',spikeLength:10,spikeGirth:10,padding:8,cornerRadius:0,
			    cssStyles:{fontFamily:'"lucida grande",tahoma,verdana,arial,sans-serif',fontSize:'11px'},
			    closeWhenOthersOpen:true,closeButton:0,ajaxPath:["$(this).attr('bt-xpath')"]},param);
  obj.bt(param);
  return obj;
}

function showObj(objid){
  var o = document.getElementById(objid);
  if(o){
    o.style.visibility = "visible";
    o.style.position = "relative";
  }
}
function hideObj(objid){
  var o = document.getElementById(objid);
  if(o){
    o.style.visibility = "hidden";
    o.style.position = "absolute";
  }
}
function showHide(objid){
  var o = document.getElementById(objid);
  if(o){
    if(o.style.visibility == "hidden"){
      o.style.visibility = "visible";
      o.style.position = "relative";
    }else{
      o.style.visibility = "hidden";
      o.style.position = "absolute";
    }
  }
}

// Function appelé à la fin du chargment de la page
function onLoadComplete(){
  // Correction des PNG sous IE
	  if(window.attachEvent && window.correctPNG) correctPNG();
}

window.onload=onLoadComplete;

