<!--
// Gallimedia 2004-2005
//
// Filename	: toolkit.js
// Purpose	: site specific javascript functionality
//

// General functions
//

// Send the max value that the rand generator could possibly return
// and a random value is returned between 0 and the sent max.
//
function rnd(max) {
  var rndnum = max * Math.random()
  rndnum = Math.ceil (rndnum)
  return rndnum
} 

// Look for a link indicator on a page that points to an other language
// content version.
//	* portal pages (page de rubrique) store link data in a div "portref"
//	* content pages store link data in a div "pageref"
//
// The logic will first look for portref, then pageref structures to extract
// link data.  If neither is found then link to the root of the other site.
//
function changeto(siteref) {
  var linkref;
  var pagekey;
  var pageval='';

  linkref = document.getElementById("portref");
  if (!linkref) {
    linkref = document.getElementById("pageref");
  }
  if (linkref) {
    pagekey=linkref.getElementsByTagName("p");
    if (pagekey) {
      if (pagekey[0]) {
        var linkto=pagekey[0].childNodes[0];
        if (linkto) {
          if (linkto.nodeValue) {
            pageval= linkto.nodeValue + ".html"
          }
        }
      }
    }
  }
  document.location.href="http://www." + siteref + ".fr/" + pageval;
}

// Magnification function set
//

// Pass in the object to restore it to css defined sizes.
// Notably the definitions below must agree with the css values.
//
function stepcss_fontSize(obj) {
//  alert ("tagName: [" + obj.tagName + "], className: [" + obj.className + "], fontSize: [" + obj.style.fontSize +"]");
  if (obj.className!="txtsituation") {
    if (obj.className!="rubinterne") {
      if (obj.className!="rubbas") {
        if (obj.tagName=="SPAN") obj.style.fontSize="xx-small";
        else obj.style.fontSize="12px";
      }
    }
  }
}

// Pass in the object to increment its size
//
function stepup_fontSize(obj) {
  if (obj.className=="txtsituation" || obj.className=="rubbas" || obj.className=="rubinterne") return;
  var objSize=obj.style.fontSize;
 
  switch (objSize) {
    case "xx-small": obj.style.fontSize="x-small";	break;
    case "x-small" : obj.style.fontSize="small";	break;
    case "small"   : obj.style.fontSize="medium";	break;
    case "medium"  : obj.style.fontSize="large";	break;
    case "large"   : obj.style.fontSize="large"; 	break;	// sets magnification upper limit
    case "12px"    : obj.style.fontSize="14px";		break;
    case "14px"    : obj.style.fontSize="16px";		break;
    case "16px"    : obj.style.fontSize="18px";		break;
    case "18px"    : obj.style.fontSize="20px";		break;
    case "20px"    : obj.style.fontSize="20px";		break;  // sets magnification upper limit
    default        : obj.style.fontSize="14px";		break;
  }
}

// Pass in the object to decrement its size
//
function stepdn_fontSize(obj) {
  if (obj.className=="txtsituation" || obj.className=="rubbas" || obj.className=="rubinterne") return;
  var objSize=obj.style.fontSize;

  switch (objSize) {
    case "large"   : obj.style.fontSize="medium";	break;
    case "medium"  : obj.style.fontSize="small";	break;
    case "small"   : obj.style.fontSize="x-small";	break;
    case "x-small" : obj.style.fontSize="xx-small";	break;
    case "20px"    : obj.style.fontSize="18px";		break;
    case "18px"    : obj.style.fontSize="16px";		break;
    case "16px"    : obj.style.fontSize="14px";		break;
    case "14px"    : obj.style.fontSize="12px";		break;
  }
}

function step_fontSize(obj, step) {
  if (step=="up") {
    stepup_fontSize(obj);
  }
  else if (step=="dn") {
    stepdn_fontSize(obj);
  }
  else {
    stepcss_fontSize(obj);
  }
}

function txtsize(step) {
//  var x;
//  x = document.getElementById("vmainframe");
//  x.style.left="20px";
//  x.style.top="120px";
//  alert (x.className);

  var main = document.getElementById("document");
  var para = main.getElementsByTagName("p");
//  var link = main.getElementsByTagName("a");
  var bold = main.getElementsByTagName("strong");
  var span = main.getElementsByTagName("span");

//  var z = document.getElementsByTagName("div");
//  x.style.background= 'white url(/assets/webct95/img/background.gif)';
//  alert(y[0].childNodes[0]);

  var i;

  for (i=0; i < para.length; i++) {
    step_fontSize(para[i], step);
  }
/*
  for (i=0; i < link.length; i++) {
    step_fontSize(link[i], step);
  }
 */
  for (i=0; i < bold.length; i++) {
    step_fontSize(bold[i], step);
  }
  for (i=0; i < span.length; i++) {
    step_fontSize(span[i], step);
  }
}
//-->
