
function getElementsByClass(searchClass, node, tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}

function tailleFonte(classe, taille) {
	body = document.getElementsByTagName('body');
	cibles = getElementsByClass('mod');
	for (i=0; i < cibles.length; i++) {
		cibles[i].style.fontSize = taille+'px';
	}
	setCook("typo", taille);
	selectCLass(taille);
}
	


     function setCook(nom,valeur) {
        document.cookie = nom + "=" + escape(valeur)
        }
		
	   function selectCLass(taille) {
			$$('.fSize').each(function (s, index) {
				$(s.id).removeClassName('current');
			});
			$("size"+taille).addClassName('current');
        }	
		
		
		function getCook(nom) {
        deb = document.cookie.indexOf(nom + "=")
        if (deb >= 0) {
            deb += nom.length + 1
            fin = document.cookie.indexOf(";",deb)
            if (fin < 0) fin = document.cookie.length
            return unescape(document.cookie.substring(deb,fin))
            }
        return ""
        }
		
		
		document.observe("dom:loaded",function(){
			if(getCook('typo')!=''){
				tailleFonte("mod",getCook('typo'));
				selectCLass(getCook('typo'));
				}
			});
