// démarrer les scripts
window.onload = function() {
	fileLinks();
	alternateRows();
}



// pour changer la langue

function changeLangue() {
    var path = document.location.href;
    var pathTraduction = path;

	if (path.indexOf('index_fr.php') > 0) pathTraduction = 'index_en.php';
	else if (path.indexOf('index_en.php') > 0) pathTraduction = 'index_fr.php';
	else { 
	    var pos = path.indexOf('_fr.php');
	
    	if (pos > 0) pathTraduction = path.replace('_fr.php', '_en.php');
   		 else {
    	    pos = path.indexOf('_en.php');
        	if (pos > 0) pathTraduction = path.replace('_en.php', '_fr.php');
   		 }
	}
    document.location=pathTraduction;
}


// ajouter automatiquement des icons au liens

function fileLinks() {
    var fileLink;
    if (document.getElementsByTagName('a')) {
        for (var i = 0; (fileLink = document.getElementsByTagName('a')[i]); i++) {
            if (fileLink.href.indexOf('.pdf') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'pdfLink';
            }
            if (fileLink.href.indexOf('.doc') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'docLink';
            }
            if (fileLink.href.indexOf('.zip') != -1) {
                fileLink.setAttribute('target', '_blank');
                fileLink.className = 'zipLink';
            }
        }
    }
}

// alternate row

function alternateRows() {
el = document.getElementsByTagName("table");
  for (i=0; i<el.length; i++)
    if (el[i].className == "alterne") {
      rows = el[i].getElementsByTagName("tr");
    for (j=0; j<rows.length; j++)
      rows[j].className = "row" + (j % 2);
  }
}



