/* ACTU PRESSE : Gestion affichage archives */
		
var archivePresse = {
	tagA:[],
	divAnnees:[],
	divMois:[],

	set : function(get_Month,get_Year) {
		this.tagA = $('listArchives').getElementsByTagName('A');

		var m=0;
		var u=0;
		for(var i=0;i<this.tagA.length;i++) {
			if($(this.tagA[i]).hasClass('dateArchiveoff')) {
				u = this.tagA[i].innerHTML;	

				this.tagA[i].saveVarI = m;
				this.tagA[i].saveVarI2 = i;
				m++;
				if(get_Year!=u) {
					$('divYear'+u).setStyle('opacity', 0);
				}
				this.tagA[i].onclick = function(){
					archivePresse.openCloseAnnee(this.saveVarI,this.saveVarI2);
					return false;
				}
			} else if(this.tagA[i].hasClass('aMonth')) {
				if (this.tagA[i].hasClass('on')) {

					this.tagA[i].saveVarI = i;

					var positionDiez = window.location.href.lastIndexOf("#");
				
					if (positionDiez>=0) {
						var replaceDiezUrl = window.location.href.substr(positionDiez, 8);
						var thisHref = window.location.href.replace(replaceDiezUrl,'');	
					} else {
						var thisHref = window.location.href;	
					}

					//var divId = u+(this.tagA[i].href.replace('http://'+window.location.hostname+'/',''));
					var divId = (this.tagA[i].href.replace(thisHref+'#',''));
					if (divId.indexOf("#")>=0) {
					}
	

//alert(u+" --- "+this.tagA[i].href+"\n"+window.location.href+"\n"+divId);
					this.divMois[i] = document.getElementById(divId);

					if(get_Year+''+get_Month!=divId) {
						$(this.divMois[i]).setStyle('opacity', 0);
					}

					this.tagA[i].onclick = function(){
						archivePresse.openCloseMonth(this.saveVarI);
						return false;
					}
				} else {
						this.tagA[i].removeAttribute('href')
				}
			}
		}

		var tempDiv = $('listArchives').getElementsByTagName('DIV');

		for(var i=0;i<tempDiv.length;i++) {
			if($(tempDiv[i]).hasClass('presseYear')) {
				this.divAnnees[this.divAnnees.length] = tempDiv[i];
			}
		}
	},

	openCloseAnnee : function(n,startA) {

		if(this.divAnnees[n].style.display=='none')
			this.divAnnees[n].style.display='';
		else
			this.divAnnees[n].style.display='none';

		var flagOpenDiv = false;
		for(var i=startA;i<this.tagA.length;i++) {
			if(this.tagA[i].hasClass('aMonth') && this.tagA[i].hasClass('on') && !flagOpenDiv) {
				this.tagA[i].addClass('activ');
				archivePresse.openCloseMonth(i);
				flagOpenDiv = true;
			}
		}
		this.divAnnees[n].fade(1);
		for(var i=0;i<this.divAnnees.length;i++) {
			if(i!=n) this.divAnnees[i].style.display='none';
		}
	},

	openCloseMonth : function(n) {
		for(var i=0;i<this.tagA.length;i++) {
			if(this.tagA[i].hasClass('aMonth') && this.tagA[i].hasClass('on')) {
				this.tagA[i].removeClass('activ');
				this.divMois[i].style.display = 'none';
				this.divMois[i].fade(0);
			}
		}
		this.tagA[n].addClass('activ');
		this.divMois[n].style.display = '';
		this.divMois[n].fade(1);
	}
}
