function FixExternalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i = 0; i < anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("rev")) {
      anchor.target = anchor.getAttribute("rev");
    }
    
    //*** legacy for sites using rel
    else if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "external") {
      anchor.target = "external";
    }
    else if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "blank") {
      anchor.target = "_blank";
    }
    //***

  }
}


function disableEnterKey(e) {
  var key;     
  if(window.event)
    key = window.event.keyCode; //IE
  else
    key = e.which; //firefox     
  return (key != 13)
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
 //addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
//addLoadEvent(function() {
  /* more code to run on page load */ 
//});
function addUnloadEvent(func) {
  var oldonunload = window.onunload;
  if (typeof window.onunload != 'function') {
    window.onunload = func;
  } else {
    window.onunload = function() {
      if (oldonunload) {
        oldonunload();
      }
      func();
    }
  }
}
function addResizeEvent(func) {
  var oldonresize = window.onresize;
  if (typeof window.onresize != 'function') {
    window.onresize = func;
  } else {
    window.onresize = function() {
      if (oldonresize) {
        oldonresize();
      }
      func();
    }
  }
}
function addReloadEvent(func) {
  var oldonreload = window.onreload;
  if (typeof window.onreload != 'function') {
    window.onreload = func;
  } else {
    window.onreload = function() {
      if (oldonreload) {
        oldonreload();
      }
      func();
    }
  }
}
function addKeypressEvent(func) {
  var oldonkeypress = window.onkeypress;
  if (typeof window.onkeypress != 'function') {
    window.onkeypress = func;
  } else {
    window.onkeypress = function() {
      if (oldonkeypress) {
        oldonkeypress();
      }
      func();
    }
  }
}

// PreloadImages( '01.gif', '02.gif' ); 
function PreloadImages()
{ 
  var args = PreloadImages.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
function ViewportHeight() {
var y = 0;
if (self.innerHeight) {
  y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight) {
  y = document.documentElement.clientHeight;
}
else if (document.body) {
  y = document.body.clientHeight;
}
return y;
}

function ViewportWidth() {
var x = 0;
if (self.innerWidth) {
  x = self.innerWidth;
}
else if (document.documentElement && document.documentElement.clientWidth) {
  x = document.documentElement.clientWidth;
}
else if (document.body) {
  x = document.body.clientWidth;
}
return x;
}

function DocumentHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function ValidEmailAddress(address) {
var atpos=address.indexOf("@");
var dotpos=address.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=address.length) return false;
else return true; 
}

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-T (Opera) or CTRL-D (Netscape) to bookmark");
  }
}

function AutoCheckboxes(key,box){
//alert(box.name+" "+box.checked)
  var arr = new Array;
  arr = eval("arrTicks"+key);
  // if box is Any
  if (box.name==key+"Any") {
    if (box.checked) {
    // if Any is checked, go through all boxes and uncheck them
      for (i=1;i<arr.length;i++) {
        document.getElementById(arr[i]).checked = false;
      }
    }
    else /* (!box.checked) */ {
    // else go through all boxes and check Any if all other boxes are unchecked
      var allOtherBoxesAreUnchecked = true;
      for (i=1;i<arr.length;i++) {
        if (document.getElementById(arr[i]).checked) allOtherBoxesAreUnchecked = false;
      }
      if (allOtherBoxesAreUnchecked) document.getElementById(key+"Any").checked = true;
    }
  }
  // else box is not Any
  else /* (box.name!=key+"Any") */ {
    // uncheck Any if another box gets checked
    if (box.checked) {
      document.getElementById(key+"Any").checked = false;
    }
    // else go through all boxes and check Any if all other boxes are unchecked
    else /* (!box.checked) */ {
      var allOtherBoxesAreUnchecked = true;
      for (i=1;i<arr.length;i++) {
        if (document.getElementById(arr[i]).checked) allOtherBoxesAreUnchecked = false;
      }
      if (allOtherBoxesAreUnchecked) document.getElementById(key+"Any").checked = true;
    }
  }
}

function QueryString(qvar) {
  hu = window.location.search.substring(1);
  gy = hu.split("&");
  for (i=0;i<gy.length;i++) {
    ft = gy[i].split("=");
    if (ft[0] == qvar) {
      return ft[1];
    }
  }
}

function QueryStringDecode(qs) {
qs = qs.replace(/%20/g, " ")
qs = qs.replace(/%E9/g, "é")
qs = qs.replace(/%E0/g, "à")
return qs
}

function IsNumeric(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

function PostToLocation(locationhref,postdata) {
  var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = locationhref ;
  for (var k in postdata) {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", postdata[k]);
    myForm.appendChild(myInput) ;
  }
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;
}


