// JavaScript Document
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) { if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';} }
	if (d) {d.style.display='block';}
}
function hover(obj){
	 obj.style.zindex = 1000;
	 if(document.all){
		 UL = obj.getElementsByTagName('ul');
		 if(UL.length > 0){
			 sousMenu = UL[0].style;
			 if(sousMenu.display == 'none' || sousMenu.display == ''){ sousMenu.display = 'block'; } else { sousMenu.display = 'none';
			 }
		 }
	 }
}
function setHover(id){
	 LI = document.getElementById(id).getElementsByTagName('li');
	 nLI = LI.length;
	 for(i=0; i < nLI; i++){
		 LI[i].onmouseover = function(){
			 hover(this);
		 }
		 LI[i].onmouseout = function(){
			 hover(this);
		 }
	 }
}
function sfHover(id) {
	 var sfEls = document.getElementById(id).getElementsByTagName('li');
	 for (var i=0; i<sfEls.length; i++) {
		 sfEls[i].onmouseover=function() {
			 this.className+=" sfhover"; this.style.zindex = 1000;
		 }
		 sfEls[i].onmouseout=function() {
			 this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		 }
	 }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function sendajax(param, page, contenu) {
if(document.all && !window.opera) { var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ; } else { var XhrObj = new XMLHttpRequest(); }
var content = document.getElementById(contenu);
XhrObj.open("POST", page);
XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200) { content.innerHTML = XhrObj.responseText ; } }
XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XhrObj.send(param);
}
function VerticalInfiniteScroller(containerId,normalSlideSpeed,buttonSlideSpeed,delay,div_size)
{
	//this.slideTimeBetweenSteps = 30;	// General speed variable (Lower = slower)
	
	var scrollingContainer = document.getElementById(containerId);
	scrollingContainer.vertical_infinite_scroller=this;
	var scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];
		
	scrollingContainer.style.position = 'relative';
	scrollingContainer.style.overflow = 'hidden';
	scrollingContent.style.position = 'relative';
	scrollingContent.style.top = '0px';
	
	this.slidelock=0;
	this.autoslidelock=0;
	
	this.products=new Array();
	var content=scrollingContent.getElementsByTagName('DIV');
	for (var i=0; i<content.length; i++)
	{
		if (content[i].className=='element_div')
		{
			this.products.push(content[i]);
			content[i].style.position = 'relative';
			content[i].style.height = div_size + 'px';
		}
	}
	
	var ctop=0;		
	/*
	for (var i=0; i< this.products.length; i++)
		{
			cleft+=this.products[i].offsetWidth;
		}
	*/
	ctop=this.products.length * div_size;
	//scrollingContent.style.width = ctop+'px';

	
	this.containerId=containerId;
	this.objRef = scrollingContent;
	this.contentHeight = scrollingContent.offsetHeight;
	this.containerHeight = scrollingContainer.clientHeight;
	this.slideSpeed = normalSlideSpeed;
	this.originalSlideSpeed = normalSlideSpeed;
	this.buttonSlideSpeed = buttonSlideSpeed;
	this.divSize=div_size;
	this.delay=delay;
	this.autosliding=false;
	this.currentProductIndex=0;
	
	if (this.products.length < 2 || this.containerHeight >= this.contentHeight)
	{
		this.originalSlideSpeed=0;
		this.buttonSlideSpeed=0;
		this.slideSpeed=0;
	}
	else
	{
		this.autoSlideStart();
	}
}

VerticalInfiniteScroller.prototype.autoSlideStart = function()
{
	this.autosliding=true;
	
	this.autoslidelock++;
	
	if (this.autoslidelock == 1 && this.delay > 0)
	{
		setTimeout('document.getElementById("'+this.containerId+'").vertical_infinite_scroller.autoSlideContinue()',this.delay*1000);
	}
	else
	{
		this.autoslidelock--;
	}
}

VerticalInfiniteScroller.prototype.autoSlideStop = function()
{
	this.autosliding=false;
}

VerticalInfiniteScroller.prototype.autoSlideContinue = function()
{
	this.autoslidelock--;

	if (this.autosliding)
	{
		this.restartSliding(-1,true);
	}
}

VerticalInfiniteScroller.prototype.slideContent = function()
	{
		if (this.slidelock ==0)

		{
		this.slidelock++;
		
		var topPos = this.objRef.style.top.replace(/[^\-0-9]/g,'');
		topPos = topPos - this.slideSpeed;
		var reordered=false;
		
		if (this.slideSpeed != 0)
		{
		
		while (topPos < -this.products[this.currentProductIndex].offsetHeight)
		{
			topPos+=this.products[this.currentProductIndex].offsetHeight;
			this.currentProductIndex++;
			
			if (this.currentProductIndex >= this.products.length)
			{
				this.currentProductIndex=0;
			}
			
			reordered=true;
		}
		
		while (topPos > 0)
		{
			topPos-=this.products[this.currentProductIndex].offsetHeight;
			this.currentProductIndex--;
			
			if (this.currentProductIndex < 0)
			{
				this.currentProductIndex=this.products.length-1;
			}
			
			reordered=true;
		}
		
		}
		
		if (reordered)
		{
			var ctop=0;
			var cbottom=0;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i < this.currentProductIndex)
				{
					ctop+=this.products[i].offsetHeight;
				}
				else
				{
					cbottom+=this.products[i].offsetHeight;
				}
			}
			
			var ctotal=ctop+cbottom;
			ctop=ctop%ctotal;
			cbottom=cbottom%ctotal;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i >= this.currentProductIndex)
				{
					this.products[i].style.top=(-ctop)+'px';
				}
				else
				{
					this.products[i].style.top=cbottom+'px';
				}
			}
			
		}
		
		if (this.autosliding && reordered)
		{
			topPos=0;
			this.stopSliding();
		}
		
		if(topPos/1 + this.contentHeight/1<0 && this.slideSpeed != 0)
		{
			topPos = this.containerHeight;
			
		}
		this.objRef.style.top = topPos + 'px';

		if (this.slideSpeed != 0)
		{
			var cdelay=this.buttonSlideSpeed;
			if (this.autosliding)
			{
				cdelay=this.normalSlideSpeed;
			}
			setTimeout('document.getElementById("'+this.containerId+'").vertical_infinite_scroller.slideContinue()',cdelay);
		}
		else
		{
			this.slidelock--;
		}
		}
	}
	
VerticalInfiniteScroller.prototype.slideContinue = function()
{

	this.slidelock--;
	this.slideContent();

}
	
VerticalInfiniteScroller.prototype.stopSliding = function()
	{
		this.slideSpeed = 0;
		this.autoSlideStart();
	}
	
VerticalInfiniteScroller.prototype.mouseStopSliding = function()
    {
        this.slideSpeed = 0;
        this.autoSlideStop();
    }

	
VerticalInfiniteScroller.prototype.restartSliding = function(direction,autospeed)
	{
		if (this.products.length > 1)
		{
			this.slideSpeed = -direction * this.originalSlideSpeed; //this.divSize;
			this.slideContent();
		}
	}
	
VerticalInfiniteScroller.prototype.startSliding = function(direction)
	{
		this.autoSlideStop();
		this.restartSliding(direction);
	}