function enfr(lang){
  var oldlang='';
  if(lang.toLowerCase()=='en'){oldlang='fr';}else{oldlang='en';}
  var u = document.URL.replace('\/'+oldlang+'\/','\/'+lang+'\/');
  if (u.indexOf('lang=') != 0){
    u = u.replace('lang='+oldlang,'lang='+lang);
  }
  document.location = u;
};
function showBlock(d){
  var e = document.getElementById(d);
  e.style.display=(e.style.display=='none')?e.style.display='':e.style.display='none';
};
function showBlockEx(d,v){
  var e = document.getElementById(d);
  e.style.display=(v)?e.style.display='':e.style.display='none';
};
function clearInnerHTML(d){
  var fd = document.getElementById(d);
  fd.innerHTML = '';  
};
function setHidden(e,h){
  h.value=e.value;
};
function setFromCheckbox(cb,h,v){
  if (cb.checked){h.value=v};
};
function setFromCheckboxEx(cb,h,v1,v2){
  h.value=(cb.checked)?h.value=v1:h.value=v2;
};
function setFromRadio(rb,h,v){
  if (rb.checked){h.value=v};
};
function setFromRadioEx(rb,h,v1,v2){
  h.value=(rb.checked)?h.value=v1:h.value=v2;
};
function trim(s){
  while(''+s.charAt(0)==' ')
    s=s.substring(1,s.length);
  while(''+s.charAt(s.length-1)==' ')
    s=s.substring(0,s.length-1);
  return s;
};
function isEmpty(s){
 return ((trim(s)=='')||(trim(s)=="")||(s==null));
};
function stripChar(s,c,r){
  var result = new String("");
  for (var i = 0; i < s.length; i++){
    (s.charAt(i) == c)?result+=r:result+=s.charAt(i); 
  }
  return result;
};
function replaceUnderscores(s){
  return stripChar(s,"_"," ");
};
function setReadOnly(e){
  e.readOnly = true;
  e.style.backgroundColor='#C0C0C0';
};
function setReadOnlyEx(cb,e){
  e.readOnly = cb.checked;
  (e.readOnly)?e.style.backgroundColor='#C0C0C0':e.style.backgroundColor='';
  if (e.readOnly){e.value=''};
};
function selectValue(sl,value){
  for (var i=0; i < sl.length;  i++){
    if (sl.options[i].value.toLowerCase() == value.toLowerCase()){
      sl.selectedIndex = i;
      break;
    }
  }
};
function selectRadio(rb,value){
  for (var i=0; i < rb.length; i++){
    if (rb[i].value.toLowerCase() == value.toLowerCase()){
      rb[i].checked = true;
      break;
    }
  }
};
//  selectCheckBox(f.cbChair,f.CPS_Chair.value,'yes');
function selectCheckBox(cb,h,value){
  cb.checked = (h.value == value);
};
function writePopup(title,content,width,height){
  var page = new String('');
  var params = new String();
  params += "height=" + height + ",";
  params += "width=" + width + ",";
  params += "menubar=0,";
  params += "resizable=1,";
  params += "scrollbars=1,";
  params += "status=0,";
  params += "titlebar=1,";
  params += "toolbar=0,";
  params += "left=0,";
  params += "top=0";
  page += '<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\">\n\n';
  page += '<html>\n';
  page += '<head>\n';
  page += '<title>' + title + '<\/title>\n';
  page += '<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=iso-8859-1\">\n';
  page += '</head>\n\n';
  page += '<body style=\"padding:24px;\">\n';
  page += content;
  page += '<\/body>\n';
  page += '<\/html>\n';
  var win = window.open('','',params);
  win.document.write(page);
  win.document.close;
};
