var lastid = "";


//Parametres Des Outils
var currentTool = 1;
var numTool = 5;
var lastTool = numTool;
var speedTool = 500;
var widthTool = 300;
var heightTool = 90;
var autoscrollTool = 1;
var autoslideToolSpeed = 10000;
var CanscrollTool = true;
//var lastTool = 3;
//////////////////////

//Parametres Des Commanditaire
var currentCommanditaire = 1;
var numCommanditaire = 6;
var lastCommanditaire = numTool;
var speedCommanditaire = 400;
var widthCommanditaire = 300;
var heightCommanditaire = 50;
var autoscrollCommanditaire = 1;
var autoslideCommanditaireSpeed = 11000; //11000
var CanscrollCommanditaire = true;
//var lastCommanditaire = 3;
///////////////////////////////


//Parametres Des Conseils
var currentConseilPro = 1;
var showConseil = 0;
var topConseil = 174;
var heightConseil = 309;
var widthConseil = 163;
///////////////////////////////


//Parametres Des Conseils
var showBlog = 0;
var topBlog = 174;
var heightBlog = 309;
var widthBlog = 163;
///////////////////////////////


function getInternetExplorerVersion() 
	{
    var rv = -1; 
	// Return value assumes failure.    
	if (navigator.appName == 'Microsoft Internet Explorer') 
		{
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
			rv = parseFloat(RegExp.$1);
		} 
   return rv;
   }

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_showHideLayers() 
	{ //v6.0
  	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3)
		if ((obj=MM_findObj(args[i]))!=null) 
			{ 
			v=args[i+2];
		    if (obj.style) 
				{ 
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
				}
		    obj.visibility=v; 
			}
	}

function hideElement(id,hide)
{
    var elt = document.getElementById(id);
    
    if (hide)
    {
        elt.style.visibility = "hidden";
    }
    else
    {
        elt.style.visibility = "visible";    
    }
}
    
function HideLayer(l)
	{
	MM_showHideLayers(l,'','hide');
	}

function ShowLayer(l)
	{
	MM_showHideLayers(l,'','show');	
	}
	
function FadeLayerIn(id, millisec)
	{
	//speed for each frame
	//Show
	var speed = Math.round(millisec / 100);
	var timer = 0;

	var lyer = document.getElementById(id).style;
	if (lyer.visibility != 'visible')
		{
		changeOpac(1,id); 
		MM_showHideLayers(id,'','show');
		//determine the direction for the blending, if start and end are the same nothing happens
		for(i = 0; i <= 100; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
			}
		}
	}

function FadeLayerOut(id, millisec) 
	{
	//speed for each frame
	//Hide
	var speed = Math.round(millisec / 100);
	var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
	for(i = 100; i >= 0; i--) 
		{
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
		timer++;
		}
	setTimeout("MM_showHideLayers('" + id + "','','hide')",(timer * speed));
	}

//change the opacity for different browsers
function changeOpac(opacity, id) 
	{
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	
	}

function SlideToolRight(millisec)
	{
	var speed = Math.round(millisec / 100);
	var timer = 0;

	lastId = "tool" + lastTool;
	currentId = "tool" + currentTool;

//    alert('L=' + lastId + ' C=' + currentId);
    
	var fromlyer = GetLayer(lastId);
	var tolyer = GetLayer(currentId);

//	SetZ('99', lastId);				//placer en ordre
//	SetZ('77', currentId);
	
	SetW(widthTool,currentId);
	SetW(0,currentId);
	SetX(0,currentId);
	
	ShowLayer(currentId);	//currentID
    //hideElement(currentId);
    
    //tolyer.style.direction = "rtl";
    tolyer.style.direction = "ltr";
	
    //fromlyer.style.direction = "ltr";
	
	c = 1;
	for(i = widthTool; i >= 0; i--)
		{
		x = widthTool - i;
		c++;
//		setTimeout("SetW(" + i + ",'" + lastId + "'); SetX(" + x + ",'" + lastId + "');",(timer * speed)); //STYLE CARTES
		setTimeout("SetW(" + i + ",'" + lastId + "'); SetX(" + x + ",'" + lastId + "'); SetW(" + c + ",'" + currentId + "');",(timer * speed));
		timer++;
		}
	}

function SlideToolLeft(millisec)
	{
	var speed = Math.round(millisec / 100);
	var timer = 0;

	lastId = "tool" + lastTool;
	currentId = "tool" + currentTool;

//    alert('L=' + lastId + ' C=' + currentId);

    
	var fromlyer = GetLayer(lastId);
	var tolyer = GetLayer(currentId);

	SetW(widthTool,currentId);
	SetW(0,currentId);
	SetX(0,currentId);
	
	ShowLayer(currentId);	//currentID
    //hideElement(currentId);   
    
	tolyer.style.direction = "ltr";
	fromlyer.style.direction = "rtl";
	
	c = 1;
	for(i = 0; i <= widthTool; i++)
		{
		x = widthTool - i;
		c++;
		setTimeout("SetW(" + x + ",'" + lastId + "'); SetX(" + x + ",'" + currentId + "'); SetW(" + i + ",'" + currentId + "');",(timer * speed));
		timer++;
		}
	}

function SlideCommanditaireRight(millisec)
	{
	var speed = Math.round(millisec / 100);
	var timer = 0;

	lastId = "commanditaire" + lastCommanditaire;
	currentId = "commanditaire" + currentCommanditaire;

	var fromlyer = GetLayer(lastId);
	var tolyer = GetLayer(currentId);

	
	SetW(widthCommanditaire,currentId);
	SetW(0,currentId);
	SetX(0,currentId);
	
	ShowLayer(currentId);	//currentID

	tolyer.style.direction = "rtl";
	
	fromlyer.style.direction = "ltr";
	
	
	c = 1;
	for(i = widthCommanditaire; i >= 0; i--)
		{
		x = widthCommanditaire - i;
		c++;
		setTimeout("SetW(" + i + ",'" + lastId + "'); SetX(" + x + ",'" + lastId + "'); SetW(" + c + ",'" + currentId + "');",(timer * speed));
		timer++;
		}
	}

function SlideCommanditaireLeft(millisec)
	{
	var speed = Math.round(millisec / 100);
	var timer = 0;

	lastId = "commanditaire" + lastCommanditaire;
	currentId = "commanditaire" + currentCommanditaire;

	var fromlyer = GetLayer(lastId);
	var tolyer = GetLayer(currentId);

	
	SetW(widthCommanditaire,currentId);
	SetW(0,currentId);
	SetX(0,currentId);
	
	ShowLayer(currentId);	//currentID

	tolyer.style.direction = "ltr";
	fromlyer.style.direction = "rtl";
	
	c = 1;
	for(i = 0; i <= widthCommanditaire; i++)
		{
		x = widthCommanditaire - i;
		c++;
		setTimeout("SetW(" + x + ",'" + lastId + "'); SetX(" + x + ",'" + currentId + "'); SetW(" + i + ",'" + currentId + "');",(timer * speed));
		timer++;
		}
	}



//Change les outils
function nextTool()
	{
	if (CanscrollTool)
		{
		CanscrollTool = false;

		setTimeout("CanscrollTool = true;",(speedTool*4));

		autoscrollTool = 0;
		if (currentTool >= numTool)
			{
			lastTool = currentTool;
			currentTool = 1;
			SlideToolRight(speedTool);
			}
		else
			{
			lastTool = currentTool;
			currentTool = currentTool + 1;
			SlideToolRight(speedTool);        				
			}
		}
	}

function prevTool()
	{
	if (CanscrollTool)
		{
		CanscrollTool = false;

		setTimeout("CanscrollTool = true;",(speedTool*4));

		autoscrollTool = 0;
		if (currentTool <= 1)
			{
			lastTool = currentTool;
			currentTool = numTool;
			SlideToolLeft(speedTool);
			}
		else
			{
			lastTool = currentTool;
			currentTool = currentTool - 1;
			SlideToolLeft(speedTool);
			}
		}
	}
	

//Change les commanditaire
function nextCommanditaire()
	{
	if (CanscrollCommanditaire)
		{
		CanscrollCommanditaire = false;

		setTimeout("CanscrollCommanditaire = true;",(speedCommanditaire*4));

		autoscrollCommanditaire = 0;
		if (currentCommanditaire >= numCommanditaire)
			{
			lastCommanditaire = currentCommanditaire;
			currentCommanditaire = 1;
			SlideCommanditaireRight(speedCommanditaire);
			}
		else
			{
			lastCommanditaire = currentCommanditaire;
			currentCommanditaire = currentCommanditaire + 1;
			SlideCommanditaireRight(speedCommanditaire);
			}
		}
	}

function prevCommanditaire()
	{
	//alert(lastCommanditaire + ' ' + currentCommanditaire);
	if (CanscrollCommanditaire)
		{
		CanscrollCommanditaire = false;

		setTimeout("CanscrollCommanditaire = true;",(speedCommanditaire*4));

		autoscrollCommanditaire = 0;
		if (currentCommanditaire <= 1)
			{
			lastCommanditaire = currentCommanditaire;
			currentCommanditaire = numCommanditaire;
			SlideCommanditaireLeft(speedCommanditaire);
			}
		else
			{
			lastCommanditaire = currentCommanditaire;
			currentCommanditaire = currentCommanditaire - 1;
			SlideCommanditaireLeft(speedCommanditaire);
			}
		}
	}


function autoslideCommanditaire1()
	{
	//nextCommanditaire();
	//setTimeout("autoslideCommanditaire1();",autoslideCommanditaireSpeed);
	
	if (autoscrollCommanditaire == 1)
		{
		lastCommanditaire = currentCommanditaire;
		currentCommanditaire++;
		if (currentCommanditaire >= numCommanditaire) currentCommanditaire = 1;
		SlideCommanditaireRight(speedCommanditaire);
		setTimeout("autoslideCommanditaire1();",autoslideCommanditaireSpeed);
		}
	else
		{
		autoscrollCommanditaire = 1;
		setTimeout("autoslideCommanditaire1();",(autoslideCommanditaireSpeed/2));
		}
	}

function autoslideTool1()
	{
	//nextTool();
	//setTimeout("autoslideTool1();",autoslideToolSpeed);
	
	if (autoscrollTool == 1)
		{
		lastTool = currentTool;
		currentTool++;
		if (currentTool >= numTool) currentTool = 1;
		SlideToolRight(speedTool);
		setTimeout("autoslideTool1();",autoslideToolSpeed);
		}
	else
		{
		autoscrollTool = 1;
		setTimeout("autoslideTool1();",(autoslideToolSpeed/2));
		}
	
	}


function GetLayer(layer)
         {
         var ReturnLayer = null;
		 
		 //if(layer == 'myassistant') alert('debug');
		 
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              ReturnLayer = document.getElementById(layer);
           else
              eval('ReturnLayer = document.' + layer + ';');
           }
         else
           {
           eval('ReturnLayer = document.all.' + layer + ';');
           }
         return ReturnLayer; 
         }

         
function Visible(layer)         
         {
         var Visible = true
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              if(layer.style.visibility == 'hidden') Visible = false;               
           else
              if(layer.visibility == 'hide') Visible = false;                          
           }
         else
           {
           if(layer.style.visibility == 'hidden') Visible = false;           
           }
         return Visible;
         }

function SetZ(z, id)
         {
			// alert(id + "=" + z);
		 var layer = GetLayer(id);
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              layer.style.zIndex = z;
           if(parseInt(navigator.appVersion) == 4)
              layer.zIndex = z;
           }
         else
           {
           layer.style.zIndex = z;
           }
         }

function SetX(x, id)
         {
			// alert(id + "=" + z);
		 var layer = GetLayer(id);
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              layer.style.left = x + "px";
           if(parseInt(navigator.appVersion) == 4)
              layer.left = x + "px";
           }
         else
           {
           layer.style.left = x + "px";
           }
         }

function SetY(y, id)
         {
		 var layer = GetLayer(id);
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              layer.style.top = y + "px";
           if(parseInt(navigator.appVersion) == 4)
              layer.top = y + "px";
           }
         else
           {
           layer.style.top = y + "px";
           }
         }

function SetMX(x, id)
         {
		 var layer = GetLayer(id);
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              layer.style.marginLeft = x + "px";
           if(parseInt(navigator.appVersion) == 4)
              layer.marginLeft = x + "px";
           }
         else
           {
           layer.style.marginLeft = x + "px";
           }
         }

function SetW(x, id)
         {         
		 var layer = GetLayer(id);
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)
              layer.style.width = x + "px";  
           if(parseInt(navigator.appVersion) == 4)
              layer.clip.width = x + "px";                    
           }
         else
           {           
           if(navigator.appVersion.indexOf('MSIE 4') > 0)
              layer.style.pixelWidth = x + "px";
			else
			  layer.style.width = x + "px";  
           }
         }  
                  
function SetH(y, id)         
         {
		 var layer = GetLayer(id);
		 
         if(navigator.appName == 'Netscape')
           {
           if(parseInt(navigator.appVersion) == 5)             
              layer.style.height = y + "px";               
           if(parseInt(navigator.appVersion) == 4)
              layer.clip.height = y + "px";  
           }
         else
           {           
           if(navigator.appVersion.indexOf('MSIE 4') > 0)		  
              layer.style.pixelHeight = y + "px";  
			else
			  layer.style.height = y + "px";  
           }
         }
                
function Show_Conseils(millisec)
    {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    currentId = "ContainerConseilsPro" + currentConseilPro;
    wrapId = "ContainerConseilsProWrap";
    
    var tolyer = GetLayer(currentId);
    var wraplyer = GetLayer(wrapId);

    //SetY(topConseil,wrapId);
    //SetH(heightConseil,wrapId);
    
    //SetW(0,wrapId);
    SetH(0,wrapId);
    
    ShowLayer(wrapId);    //currentID
    ShowLayer(currentId);    //currentID

    wraplyer.style.direction = "ltr";

    for(i = 0; i <= heightConseil; i++)
        {
        setTimeout("SetH(" + i + ",'" + wrapId + "'); ",(timer * speed));
        timer++;
        }
    }

function Hide_Conseils(millisec)
    { 
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    currentId = "ContainerConseilsPro" + currentConseilPro;
    wrapId = "ContainerConseilsProWrap";
    
    var tolyer = GetLayer(currentId);
    var wraplyer = GetLayer(wrapId);
    
    for(i = heightConseil; i >= 1; i--)
        {
        setTimeout("SetH(" + i + ",'" + wrapId + "'); ",(timer * speed));
        timer++;
        }
    setTimeout("MM_showHideLayers('" + wrapId + "','','hide')",(heightConseil * speed)+1);        
    setTimeout("MM_showHideLayers('" + currentId + "','','hide')",(heightConseil * speed)+1);        
    
    }

function ShowHide_Conseils(millisec)
    {
    if (showConseil == 1)
        {
        Hide_Conseils(millisec);
        showConseil = 0;
        }
    else
        {
        Show_Conseils(millisec);
        showConseil = 1;
        }
    }

                
function Show_Blog(millisec)
    {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    wrapId = "ContainerBlogWrap";
    
    var wraplyer = GetLayer(wrapId);
    
    SetH(0,wrapId);
    
    ShowLayer(wrapId);    //currentID
    
    wraplyer.style.direction = "ltr";

    for(i = 0; i <= heightBlog; i++)
        {
        setTimeout("SetH(" + i + ",'" + wrapId + "'); ",(timer * speed));
        timer++;
        }
    setTimeout("MM_showHideLayers('" + wrapId + "','','hide')",(heightBlog * speed)+1);       
    setTimeout("MM_showHideLayers('" + wrapId + "','','show')",(heightBlog * speed)+1);       
    
    }

function Hide_Blog(millisec)
    { 
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    wrapId = "ContainerBlogWrap";
    
    var wraplyer = GetLayer(wrapId);
    
    for(i = heightBlog; i >= 1; i--)
        {
        setTimeout("SetH(" + i + ",'" + wrapId + "'); ",(timer * speed));
        timer++;
        }
    setTimeout("MM_showHideLayers('" + wrapId + "','','hide')",(heightBlog * speed)+1);        
    
    }

function ShowHide_Blog(millisec)
    {
    if (showBlog == 1)
        {
        Hide_Blog(millisec);
        showBlog = 0;
        }
    else
        {
        Show_Blog(millisec);
        showBlog = 1;
        }
    }

function SwitchTabPro(t)
	{
	oldTab = "ContainerConseilsPro" + currentConseilPro;
	newTab = "ContainerConseilsPro" + t;
	currentConseilPro = t;
	
	HideLayer(oldTab);
	ShowLayer(newTab);
	
	}

    
function initialisation() 
	{
    var url = location.href;  // entire url including querystring - also: window.location.href;
    if (url.search("http://www.dlvdm.com/forum/") == -1)    //Tout sauf forum
        {
	    nextTool();
        nextCommanditaire();
        }
//	autoslideCommanditaire1();
//	autoslideTool1();

//FIX FORUM BOX TEMPORRAIRE
	if (getInternetExplorerVersion() == -1)
		{
		SetZ(999,"get-myassistant");
		SetY(-400, "get-myassistant");
		}
	
	
	}
    
    
    
    //fonctions pour arcencoeur
    
function showdiv( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function hidediv( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  if (elem!=null)
{
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = 'none';
  vis.display = 'none';
}
}

