/******* eServices JS ***********/

plusImgUrl = '/Style Library/Images/plus.gif';
minusImgUrl = '/Style Library/Images/minus.gif';

//function used in the header of the webcontrols
//in order to hide and display it
//also changes the collapse/expand picture
function webcontrolHeaderCollapse(imgid, elementid)
{
	var element = document.getElementById(elementid);
	var img = document.getElementById(imgid);
	if (element.style.display == 'none')
	{
		img.src = minusImgUrl;
		element.style.display = '';
	}
	else
	{
		element.style.display = 'none';
		img.src = plusImgUrl;
	}
}

/*
Functionnality to change the font size of the current page.
Used by the Tools WebControl
*/
//****** Begin Change Font Size functionnality ******
/*
 * Utility function for changeFontSize()
 *
 */

 

function getElementsByClassName(nomClasse, element) {
  var resultat = new Array();
  if(nomClasse!="" || typeof element == 'object'){
    var children = element.getElementsByTagName('*');
    var exp_reg = new RegExp("(^|\\s|-)" + nomClasse + "(\\s|$)");
    for (var i = 0; i < children.length; i++) {
      var laClasse = (children[i].className)? children[i].className : "";
      if(laClasse != "" && (laClasse == nomClasse || laClasse.match(exp_reg))){
        resultat.push(children[i])
      }
    }
  }
  return resultat;
}
/*
 * Change these values to adapt font size amplitude
 *
 */
var min=8;
var max=36;
function increaseFontSize(modif) {

   var tab = getElementsByClassName("MainColumn", document);
      
   if(tab.length != 0)
   {
		var p = tab[0].getElementsByTagName('*');
		
		for(i=0;i<p.length;i++) {
			if (p[i].style.fontSize && p[i].style.fontSize.indexOf("px")>=0) {
				var s = parseInt(p[i].style.fontSize.replace("px",""));
			}
			else {
				s = 12;
			}
			if(s+modif<max && s+modif>min) {
				s += modif;
			}
			p[i].style.fontSize = s+"px";
		}
	}
}

 

/*
 * Legacy Call
 *
 */
function changeFontSize(modif)
{
 if (modif > 0){
   increaseFontSize(2);
 }
 else {
   increaseFontSize(-2);
 }
}
//****** End Change Font Size functionnality ******

//******** Begin link behind the top left logo ***************
function redirectLogo() {

    var href = window.location.href;
    var tmpArray = href.split('/');
    var lang = tmpArray[3];

    window.location.href = tmpArray[0] + "/" + tmpArray[1] + "/" + tmpArray[2] + "/" + tmpArray[3];


}

//*********** End link behind the top left logo ***************