﻿function right(str, n) {
   if (n <= 0)
      return "";
   else if (n > String(str).length)
      return str;
   else {
      var iLen = String(str).length;
      return String(str).substring(iLen, iLen - n);
   }
}

function increaseFontSize() {

   var p = document.getElementsByTagName('*');
   var indexPx
   
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
      
         var indexPx = p[i].style.fontSize.toLowerCase().indexOf('px');
         var s = parseInt(p[i].style.fontSize.replace('px',""));
         
      } else {
         var s = 11;
         var indexPx = 1;
      }
      if(s!=13 && indexPx > 0) {
         s += 1;
         p[i].style.fontSize = s+'px'
      }      
   }
}

function decreaseFontSize() {
   var p = document.getElementsByTagName('*');
   var indexPx
   
   for(i=0;i<p.length;i++) {
   
      if(p[i].style.fontSize) {
      
         var indexPx = p[i].style.fontSize.toLowerCase().indexOf('px');
         var s = parseInt(p[i].style.fontSize.replace('px',""));
      } else {
         var s = 11;
         var indexPx = 1;
      }
      if(s!=9 && indexPx > 0) {
         s -= 1;
         p[i].style.fontSize = s+'px';
      }      
   }   
}

function getRandomFlashMovie() {

   var theMovies = new Array();
   theMovies[0] = 'caxton_flashSlidesShow01.swf'
   theMovies[1] = 'caxton_flashSlidesShow02.swf'
   theMovies[2] = 'caxton_flashSlidesShow03.swf'
   theMovies[3] = 'caxton_flashSlidesShow04.swf'

   var p = theMovies.length;

   var whichMovie = Math.round(Math.random()*(p-1));
   
   return theMovies[whichMovie];
}

function openLinksInNewWindow() {

   var theLinks = document.getElementsByTagName("a");

   for (var x=0; x<theLinks.length; x++) {

      if (theLinks[x].href.indexOf('#openinnewwindow') > 0) {      
         theLinks[x].target = '_blank';         
      }
  }
}

function changeCalendarLabels(tag) {

   var p = document.getElementsByTagName(tag);
   var labelsToSearch = new Array();
   var labelsToReplace = new Array();
   
   labelsToSearch[0] = "Calendar";
   labelsToReplace[0] = "Calendrier";
   labelsToSearch[1] = "Go to the previous month";
   labelsToReplace[1] = "Afficher le mois précédent";
   labelsToSearch[2] = "Go to the next month";
   labelsToReplace[2] = "Afficher le mois suivant";
   
   for(i=0;i<p.length;i++) {
   
      for(j=0;j<labelsToSearch.length;j++) {

         if(p[i].title.toUpperCase() == labelsToSearch[j].toUpperCase()) {
            p[i].title = labelsToReplace[j];
         }
      }
   }
}

function loadingPleaseWait() {

   document.body.scroll="yes";

   if (document.getElementById){
      document.getElementById('loadingPleaseWait').style.visibility='hidden';
      document.getElementById('wrapperExternal').style.visibility='visible';
      loadingFlash();
      
   } else {
      if (document.layers){ //NS4
         document.loadingPleaseWait.visibility = 'hidden';
         document.wrapperExternal.visibility = 'visible';
         loadingFlash();
      } else { //IE4
         document.all.loadingPleaseWait.style.visibility = 'hidden';
         document.all.wrapperExternal.style.visibility = 'visible';
         loadingFlash();
      }
   }
}

function loadingFlash() { 

   var randomFlashSlideShow = getRandomFlashMovie();
   if (document.getElementById) {
      document.getElementById('flashObjectSlideShow').setAttribute('movie', urlFlashPath + randomFlashSlideShow ); // IE
   }
   if (document.embeds && document.embeds["flashEmbedSlideShow"]) {
      document.embeds["flashEmbedSlideShow"].src = urlFlashPath + randomFlashSlideShow; // FF	
   } 				
}
					 