//
// Routines Javascript diverses
// (c) JL.ATX APR-2010
//

function isblank(s) {                   // Check input exists
 for(var i=0; i<s.length; i++) {
  var c=s.charAt(i);
  if((c!=' ')&&(c!='\n')&&(c!='\r')&&(c!='\t'))
   return(false); }
 return(true); }

 function ltrim(s) {
  while(s.charAt(0)==' ') s=s.substr(1);
  return s; }

 function rtrim(s) {
  while(s.charAt(s.length-1)==' ') s=s.substr(0,s.length-1);
  return s; }

function toggleWindowSize() {           // Changement taille fenêtre qualibré
 var i=document.body.clientWidth;
 if(window.screen) { x=window.screen.availWidth; y=window.screen.availHeight; }
 else { x=1024; y=768; }
 if(i>(x-15)) i=784;
 if(i<1265) { w=1280; h=1024; }
 if(i<1137) { w=1152; h=864; }
 if(i<1009) { w=1024; h=768; }
 if(i<785)  { w=800;  h=600; }
 w=Math.min(w,x);
 h=Math.min(h,y);
// window.moveTo(0,0);
 window.resizeTo(w,h); }

function changeInnerHTML(id,val) {      // Changement du contenu d'un div à la volée
 if(document.getElementById) {
  document.getElementById(id).innerHTML=val; }
 else if(document.all) {
  document.all[id].innerHTML=val; } }

function hideAbsById() {                // Cacher complètement un ID (décalage des autres ID)
 for(var i=0;i<hideAbsById.arguments.length;i++) {
  if(document.getElementById) {
   var j=document.getElementById(hideAbsById.arguments[i]);
   j.style.visibility="hidden";
   j.style.position="absolute"; }
  else if(document.all) {
   document.all[hideAbsById.arguments[i]].style.visibility="hidden";
   document.all[hideAbsById.arguments[i]].style.position="absolute"; }
  else if(document.layers) {
   document.hideAbsById.arguments[i].visibility="hide";
   document.hideAbsById.arguments[i].position="absolute"; } } }

function showAbsById() {                // Afficher complètement un ID (décalage des autres ID)
 for(var i=0;i<showAbsById.arguments.length;i++) {
  if(document.getElementById) {
   var j=document.getElementById(showAbsById.arguments[i]);
   j.style.visibility="visible";
   j.style.position="relative"; }
  else if(document.all) {
   document.all[showAbsById.arguments[i]].style.visibility="visible";
   document.all[showAbsById.arguments[i]].style.position="relative"; }
  else if(document.layers) {
   document.showAbsById.arguments[i].visibility="show";
   document.showAbsById.arguments[i].position="relative"; } } }

function getVisibilityById(e) {         // Dit si un ID est visible (boolean)
 var v=e.parentNode.style.visibility;
 if((v==null)||(v=="")||(v=="visible")||(v=="show")) return true;
 return false; }

function showProperties(obj) { // Debugging function to see what's in an object
 y=0;
 nam='';
 for(z in obj) {
  y++;
  nam+=z+'='+obj[z]+'\\n';
  if((y%10)==0) { alert(nam); nam=''; } }
 if(nam.length>0) alert(nam); }
