volet_class = function () {
	this.volet = document.getElementById('volet');
	this.content = document.getElementById('volet_content');
	
	this.btnOpen = document.getElementById('btn_open_volet');
	this.btnClose = document.getElementById('btn_close_volet');
	
	this.width = parseInt(this.content.offsetWidth);
	this.height = parseInt(this.content.offsetHeight);
	
	this.flag;	
	this.pos;	
	this.vitesse = 40;		
	var fadeSpeed = 20;
	
	this.amt;
	
	var obj = this;
	
	var putSession = function(value) {
		var xhr=null;
		
		if (window.XMLHttpRequest) { 
			xhr = new XMLHttpRequest();
			}
		else if (window.ActiveXObject) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
		
		xhr.onreadystatechange = function() {
												if (xhr.readyState==4) {													
													return true;
													}
											} 
		xhr.open("GET", "message/volet_session_put.asp?flag="+value+"&RANDOM="+Math.random()+String.fromCharCode(34), true); 
		xhr.send(null);
		}
		
	var getSession = function() {
		var xhr=null;
		
		 if(window.XMLHttpRequest) // FIREFOX
          xhr = new XMLHttpRequest(); 
		 else if(window.ActiveXObject) // IE
			  xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
		 else 
          return(false);
		  
		xhr.open("GET", "message/volet_session_get.asp?RANDOM="+Math.random()+String.fromCharCode(34), false); 
		xhr.send(null);
		
		if (xhr.readyState==4) {
			value = xhr.responseText;
			return value;
			}
		}
	
	var session = getSession();
	
	if (session!='') {
		this.flag=parseInt(session);
		}
		else {
			this.flag=1;
			}	
		
	this.initClass = function () {
		this.positionBtn(this.btnClose,this.btnOpen);
		this.style_volet();
		}	
	
	this.change_flag = function (flag) {
		this.flag = flag;		
		putSession(flag);
		this.initClass();
		}
	
	this.style_volet = function () {
		this.volet.style.overflow = 'hidden';
		switch (this.flag) {
			case 0:
				this.volet.style.height = '0px';
				this.pos = 0;
				lnk_hide(this.btnClose);
				lnk_show(this.btnOpen);
				this.amt = 0;
				this.setFade(this.amt,this.volet);
				break;
			case 1:
				this.volet.style.height = this.height+'px';
				this.pos = this.height;
				lnk_hide(this.btnOpen);
				lnk_show(this.btnClose);
				this.amt = 100;
				this.setFade(this.amt,this.volet);
				break;
			}
		}
	
	var lnk_hide = function (box) {
		box.style.display = 'none';
		}
	var lnk_show = function (box) {
		box.style.display = 'block';		
		}
	
	this.btnOpen.onclick = function() {
		clearTimeout(fadeOutTime);
		obj.fadeIn(100,obj.volet);
		obj.openVolet();
		menu_fix.scrollToTop();
		}
	this.btnClose.onclick = function() {
		clearTimeout(fadeInTime);
		obj.fadeOut(0,obj.volet);
		obj.closeVolet();
		menu_fix.scrollToTop();
		}
		
	var timerCloseVolet;
	this.closeVolet = function() {
		clearTimeout(timerOpenVolet);
		if (this.pos>0) {
			if (this.pos-this.vitesse<=0) {
				this.pos = 0;
				}
				else {
					this.pos = this.pos-this.vitesse;
					}
			
			this.volet.style.height = this.pos+'px';
			timerCloseVolet = setTimeout(function () {obj.closeVolet();},80);
			}
			else {
				clearTimeout(timerCloseVolet);
				this.change_flag(0);
				}
		}
	var timerOpenVolet;
	this.openVolet = function() {
		clearTimeout(timerCloseVolet);
		if (this.pos<this.height) {
			if (this.pos+this.vitesse>=this.height) {
				this.pos = this.height;
				}
				else {
					this.pos = this.pos+this.vitesse;
					}
			
			this.volet.style.height = this.pos+'px';
			timerOpenVolet = setTimeout(function () {obj.openVolet();},80);
			}
			else {
				clearTimeout(timerOpenVolet);
				this.change_flag(1);
				}
		}
		
	this.positionBtn = function () {
		for (var i=0; i < this.positionBtn.arguments.length; i++) {
			if (window.XMLHttpRequest) {
				this.positionBtn.arguments[i].style.position = 'fixed';
				} 
				else {
					this.positionBtn.arguments[i].style.top = '164px';
					}
			document.getElementById('breadcrumbs').appendChild(this.positionBtn.arguments[i]);
			}
				
		}
		
	var fadeOutTime;
	this.fadeOut = function (to,box) {
		clearTimeout(fadeInTime);
		
		if(this.amt >= to) {
			this.setFade(this.amt,box);
			this.amt -= fadeSpeed;
			fadeTime = setTimeout(function () {obj.fadeOut(to,box);}, 60);
		}
		else {
			clearTimeout(fadeOutTime);			
			}
		}
	var fadeInTime;
	this.fadeIn = function (to,box) {
		clearTimeout(fadeOutTime);
		
		if(this.amt <= to) {
			this.setFade(this.amt,box);
			this.amt += fadeSpeed;
			fadeTime = setTimeout(function () {obj.fadeIn(to,box);}, 60);
		}
		else {
			clearTimeout(fadeInTime);			
			}
		}
		
	
	this.setFade = function (amt,obj) {		
		amt = (amt == 100)?99.999:amt;
	  
		// IE
		obj.style.filter = "alpha(opacity:"+amt+")";	  
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = amt/100;	  
		// Mozilla and Firefox
		obj.style.MozOpacity = amt/100;	  
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = amt/100;
		}
		
	return this.initClass();
	}
