// JavaScript Document
// Fonctions SwapImages et Zoom Images de 40x40 à 100x100 
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 MM_ZoomPassage() { //v3.0
  // Fait un 'ZOOM' 100x100 d'une vignette.
  var i,j=0,x,a=MM_ZoomPassage.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]; x.width=100; x.height=100;}
}

function MM_ZoomRestore() { //v3.0
  // Met une image à 40x40 (utilisé avec ZoomPassage, sur onmouseout
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; x.width=40; x.height=40;
}


// Fonction Pixelate
function pixel(img)
{	
	if(img && img.filters && img.filters[0]) {
		img.filters[0].apply();
		img.filters[0].play();
	}
}


// Fonction TxTan : 2 texte se rejoignent au milieu de l'écran
 var TxTx = 45;
 var TxTplace = -1000;
 var TxTplace2 = 1000;
 
function TXTan()
	{
		if (TxTplace < TxTplace2)
			{
			t1.left = (TxTplace = TxTplace + TxTx);
			t2.left = (TxTplace2 = TxTplace2 - TxTx);
			tempoText = setTimeout('TXTan()', 25);
			}
		else
			{
			TxTx = TxTx/2;
			t1.left = (TxTplace = TxTplace - TxTx);
			t2.left = (TxTplace2 = TxTplace2 + TxTx);
			tempoText = setTimeout('TXTan()', 25);
			}
	}
	

/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=30

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

var bw=new lib_bwcheck()

function getObjectRef(name) {
  if(document.getElementById) return document.getElementById(name);
  else if(document.all) return document.all[name];
  else return null;
}

// Menu circulaires qui éclatent
// general functions to assist the script
//========================================
function show(name) {
  var el = getObjectRef(name);
  if(el) el.style.visibility = "visible";
}
function hide(name) {
  var el = getObjectRef(name);
  if(el) el.style.visibility = "hidden";
}
function getWidth(name) {
  var el = getObjectRef(name);
  return el.offsetWidth;
}
function getHeight(name) {
  var el = getObjectRef(name);
  return el.offsetHeight;
}
function moveMe(name,x,y) {
  var el = getObjectRef(name);
  if(el) { el.style.top = parseInt(y); el.style.left = parseInt(x); }  
}
function moveBy(name,x,y) {
  var el = getObjectRef(name);
  if(el) { el.style.top = parseInt(el.style.top) + parseInt(y); el.style.left = parseInt(el.style.left) + parseInt(x); }  
}

// Creates the menu objects
//==========================
var menuCount = 0;
function menuObject(name,x,y,caption, r, parent) {
  if ( (!document.getElementById&&!document.all) || navigator.userAgent.indexOf("Opera")>-1) return;
  document.write('<div id="divDot' + menuCount + '" class="dotempty" style="top: ' + y + '; left: ' + x + '"></div>');
  document.write('<div id="divCap' + menuCount + '" class="caption" style="top: 0; left: 0">' + caption + '</div>');
  
  this.name = name;
  this.parent = parent
  this.ref = "divDot" + menuCount;
  this.caption = "divCap" + menuCount
  if(r) this.radius = r;
  else this.radius = 400;
  this.subMenus = new Array();
  this.state = 0;
  this.moving = false;
  if(this.parent) this.action = "null";
  else this.action = "toggle";
  if(this.parent) this.startAngle = parent.startAngle;
  else this.startAngle = 0;

  getObjectRef(this.ref).objRef = this.name;
  
  this.show = function() { show(this.ref); }
  this.hide = function() { hide(this.ref); }
  this.moveMe = function(x,y) { if(this.parent) { x += this.parent.x(); y += this.parent.y(); } moveMe(this.ref,x,y); }
  this.moveBy = function(x,y) { moveBy(this.ref,x,y); }
  this.x = function() { return parseInt(getObjectRef(this.ref).style.left); }
  this.y = function() { return parseInt(getObjectRef(this.ref).style.top); }
  this.w = function() { return getWidth(this.ref); }
  this.h = function() { return getHeight(this.ref); }

  this.showCaption = function() {
    moveMe(this.caption, this.x() - (getWidth(this.caption)/2) + (this.w()/2), (this.y() + this.h()));
    show(this.caption);
  }
  this.hideCaption = function() {
    hide(this.caption);
  }
  this.setCaption = function(c) { getObjectRef(this.caption).innerHTML = c;}
 
  this.addItem = function(c,action,r) {
    if (this.parent) 
		getObjectRef(this.ref).className = "dot";
	else
		getObjectRef(this.ref).className = "centerdot";
    if(!r) r = this.radius/2;
    var sub = new menuObject(this.name + ".subMenus[" + this.subMenus.length + "]",0,0,c,r,this);
    sub.parent = this;
    sub.action = action;
    sub.moveMe(0,0);
    this.subMenus[this.subMenus.length] = sub;
    return sub;
  }
  
  this.expand = function() {
    if(this.subMenus.length > 0) {
      var p = true;
      if(this.parent) {
        p = !this.parent.moving;
        for(var i=0; i<this.parent.subMenus.length;i++)
          p = p && ((this.parent.subMenus[i].state==0) || (this.parent.subMenus[i].state==this.parent.subMenus[i].subMenus.length)) && (this.parent.subMenus[i].moving==false);
      } else var o = false;
      

      if((!this.parent || this.parent.state == this.parent.subMenus.length) && p) {
        if(this.parent) this.collapseAll(this.name);
        
        var diff = 360 / this.subMenus.length;
        for(var i=0;i<this.subMenus.length;i++){
          this.subMenus[i].moveMe(0,0);
          this.subMenus[i].show();
          this.moving = true;
          this.subMenus[i].slide(this.subMenus[i].radius * cos(degToRad((diff*i)+this.startAngle)), this.subMenus[i].radius * sin(degToRad((diff*i)+this.startAngle)), this.name + ".subMenus[" + i + "].showCaption();" + this.name + ".moving=false;" + this.name + ".state+=1;");
        }
        if(this.parent){
          getObjectRef(this.parent.ref).style.filter = "alpha (opacity=33)";
          getObjectRef(this.parent.ref).style.MozOpacity = "33%";

          getObjectRef(this.parent.ref).className = "dotoff";
          getObjectRef(this.parent.caption).style.filter = "alpha (opacity=33)";
          getObjectRef(this.parent.caption).style.MozOpacity = "33%";
          for(i=0;i<this.parent.subMenus.length;i++) {
              getObjectRef(this.parent.subMenus[i].ref).style.filter = "alpha (opacity=66)";
              getObjectRef(this.parent.subMenus[i].ref).style.MozOpacity = "66%";
              getObjectRef(this.parent.subMenus[i].caption).style.filter = "alpha (opacity=66)";
              getObjectRef(this.parent.subMenus[i].caption).style.MozOpacity = "66%";        
          }
          if(this.parent.parent) {
            for(i=0;i<this.parent.parent.subMenus.length;i++) {
              getObjectRef(this.parent.parent.subMenus[i].ref).style.filter = "alpha (opacity=33)";
              getObjectRef(this.parent.parent.subMenus[i].ref).style.MozOpacity = "33%";
              getObjectRef(this.parent.parent.subMenus[i].ref).className = "dotoff";
              getObjectRef(this.parent.parent.subMenus[i].caption).style.filter = "alpha (opacity=33)";        
              getObjectRef(this.parent.parent.subMenus[i].caption).style.MozOpacity = "33%";
            }
            getObjectRef(this.parent.parent.ref).style.MozOpacity = "33%";
            getObjectRef(this.parent.parent.ref).style.MozOpacity = "33%";
            getObjectRef(this.parent.parent.ref).className = "dotoff";
          }
        }
        getObjectRef(this.ref).style.filter = "alpha (opacity=66)";
        getObjectRef(this.caption).style.filter = "alpha (opacity=66)";  
        getObjectRef(this.ref).style.MozOpacity = "66%";
        getObjectRef(this.caption).style.MozOpacity = "66%"; 
      }
    }  
  }

  this.collapse = function() {
    var p = true;
    p = !this.moving;
    for(var i=0; i<this.subMenus.length;i++)
      p = p && (this.subMenus[i].state==0)  && (this.subMenus[i].moving==false);
    
    if(p && this.subMenus.length > 0) {
      for(var i=0;i<this.subMenus.length;i++){
        this.subMenus[i].hideCaption();
        this.moving = true;
        this.subMenus[i].slide(0, 0, this.name + ".subMenus[" + i + "].hide();" + this.name + ".moving=false;" + this.name + ".state-=1;");
      }
      if(this.parent){
        getObjectRef(this.parent.ref).style.filter = "alpha (opacity=66)";
        getObjectRef(this.parent.ref).style.MozOpacity = "66%";
        if(this.parent.subMenus.length != 0)
          getObjectRef(this.parent.ref).className = "centerdot";
        else
          getObjectRef(this.parent.ref).className = "dotempty";
        getObjectRef(this.parent.caption).style.filter = "alpha (opacity=66)";
        getObjectRef(this.parent.caption).style.MozOpacity = "66%";
        for(i=0;i<this.parent.subMenus.length;i++) {
          getObjectRef(this.parent.subMenus[i].ref).style.filter = "alpha (opacity=100)";
          getObjectRef(this.parent.subMenus[i].ref).style.MozOpacity = "100%";
          if(this.parent.subMenus[i].subMenus.length != 0) 
            getObjectRef(this.parent.subMenus[i].ref).className = "dot";
          else
            getObjectRef(this.parent.subMenus[i].ref).className = "dotempty";
          getObjectRef(this.parent.subMenus[i].caption).style.filter = "alpha (opacity=100)";        
          getObjectRef(this.parent.subMenus[i].caption).style.MozOpacity = "100%";
        }
        if(this.parent.parent) {
          for(i=0;i<this.parent.parent.subMenus.length;i++) {
            getObjectRef(this.parent.parent.subMenus[i].ref).style.filter = "alpha (opacity=66)";
            getObjectRef(this.parent.parent.subMenus[i].ref).style.MozOpacity = "66%";
            if(this.parent.parent.subMenus[i].subMenus.length != 0)
              getObjectRef(this.parent.parent.subMenus[i].ref).className = "dot";
            else
              getObjectRef(this.parent.parent.subMenus[i].ref).className = "dotempty";
            getObjectRef(this.parent.parent.subMenus[i].caption).style.filter = "alpha (opacity=66)";        
            getObjectRef(this.parent.parent.subMenus[i].caption).style.MozOpacity = "66%";
          }
        }
      }
      getObjectRef(this.ref).style.filter = "alpha (opacity=100)";
      getObjectRef(this.caption).style.filter = "alpha (opacity=100)";       
      getObjectRef(this.ref).style.MozOpacity = "100%";
      getObjectRef(this.caption).style.MozOpacity = "100%";
    }
  }

  this.collapseAll = function(except) {
    for(var i=0;i<this.parent.subMenus.length;i++) {
      if(this.parent.subMenus[i].name!=except && this.parent.subMenus[i].state==this.parent.subMenus[i].subMenus.length) {
        this.parent.subMenus[i].collapse();
      }    
    }
  }
  
  this.toggle = function(e) {
    if(document.all) id = window.event.srcElement;
    else id = e.target;
    var dot = eval(id.objRef);
    
    if(dot.state==0 && !dot.moving) dot.expand();
    else if(dot.state==dot.subMenus.length && !dot.moving) dot.collapse()
  }
  
  this.doAction = function(e) {
    if(document.all) id = window.event.srcElement;
    else id = e.target;
    var dot = eval(id.objRef);
    
    if(dot.action == "toggle") dot.toggle(e);
    else eval(dot.action);
  }
  
  //change these if you want to change the events that trigger the actions
  //========================================================================
  //getObjectRef(this.ref).onmousemove = this.toggle;
  getObjectRef(this.ref).onmouseup = this.doAction;
  
  this.slide = function(xx,yy,func) {
    if(!func) func = "";
    var px = this.parent.x();
    var py = this.parent.y();
    
    var x = xx - this.x() + px;
    var y = yy - this.y() + py;
    
    var d = sqrt(square(xx-this.x() + px) + square(yy-this.y() + py));
    
    var v = d/8;
    if(v<1) v = 1;
        
    if( (Math.abs(x) < v) && (Math.abs(y) < v) ) {
      moveMe(this.ref,xx + px,yy + py);      
      if(func != "") eval(func);
    } else {    
      var a = round(atan(x,y));
      dx = round(v * cos(degToRad(a)));
      dy = round(v * sin(degToRad(a)));
   
      this.moveBy(dx,dy);
      setTimeout(this.name + ".slide(" + xx + "," + yy + ", '" + func + "');",10);    
    }
  }
  // Preoading the windows filters.
  if (menuCount==0 && document.all) document.all[this.ref].style.filter = "alpha (opacity=100)";
  menuCount++;
  return this;
}


// Math functions
//================
var pi = Math.PI;
function square(x) { return (x*x); }
function sqrt(x) { return Math.sqrt(x); }
function round(x) { return Math.round(x); }
function rand(x,y) { return (round(Math.random()*(y-x)) + x); }

function cos(x) { return Math.cos(x) }
function sin(x) { return Math.sin(x) }
	
function degToRad(x) { return ( x/(360/(2*pi)) ); }
function radToDeg(x) { return ( x*(360/(2*pi)) ); }


function atan(s,t) {
  if( s == 0.0 && t > 0.0)
    angle = 90.0;
  else if(s == 0.0 && t < 0.0) 
    angle = 270.0;
  else if (s < 0.0 ) 
    angle = 180.0 + radToDeg(Math.atan(t/s));
  else if (s > 0.0 && t < 0.0)
    angle = 360.0 + radToDeg(Math.atan(t/s));
  else {
    if(s==0.0) s=0.00001;
    angle = radToDeg(Math.atan(t/s));
  }
  if(angle < 0.0) angle += 360.0;
  return angle;
}

// Waqui : c''est le truc qui secoue un message publicitaire
var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"
var cr_top = 200;

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("waqui").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-cr_top+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
 if (parseInt(crossobj.top)<scroll_top)
	crossobj.top=parseInt(crossobj.top)+40+calunits
 else{
	clearInterval(dropstart)
	bouncestart=setInterval("bouncein()",50)
 }
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function redo(){
bouncelimit=32
direction="up"
initbox()
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
// Waqui : c''est le truc qui secoue // FIN


// Pour suivre les variation de taille écran
function redraw_menu() {
Chargement();
 if(document.all) pageWidth = document.body.offsetWidth-40;
	else pageWidth = innerWidth;
 if(document.all) pageHeight = document.body.offsetHeight-4;
	else pageHeight = innerHeight;
 	newx=(pageWidth/2);
	xx=aq_menu.x();
	dx=newx-xx  
	aq_menu.moveBy(dx,0);
	for(var i=0;i<aq_menu.subMenus.length;i++){
     	aq_menu.subMenus[i].hideCaption();
        aq_menu.subMenus[i].moveBy(dx,0);
		for(var j=0;j<aq_menu.subMenus[i].subMenus.length;j++){
			 vis = aq_menu.subMenus[i].state;
     		 aq_menu.subMenus[i].subMenus[j].hideCaption();
             aq_menu.subMenus[i].subMenus[j].moveBy(dx,0);
			 if (vis) aq_menu.subMenus[i].subMenus[j].showCaption();
			 //aq_menu.subMenus[i].subMenus[j].caption.style.visibility = vis;
     	}
		aq_menu.subMenus[i].showCaption();
    }
	// Pour les menus du haut...
	    
}



// Blur
// Placer une balise DIV nommée blurthis
// Remplir le tableau blurcolor (pour le texte), et blurmsg (images, text, etc...)
// Blurtime contient le temps d'annimation, qui ne joue qu'une fois.... (voir fin du script !)


var blursize=11
var blurfont="Verdana"

var blurcolor= new Array()
blurcolor[0]="000000"
var blurmsg = new Array()
//blurmsg[0]="<img border=0 src=themes/bien_vu/images/mouvement.gif>"
var i_blurstrength=10
var i_blurmsg=0
var i_blurcolor=0
var blurtime=60

function blurdiv() {		
if(document.all) {
 if (i_blurstrength >=-2) {
	if (i_blurcolor >=blurcolor.length-1) {i_blurcolor=blurcolor.length-1}
	blurthis.innerHTML="<span id='blurpit1' style='position:absolute;visibility:visible;width:600px;top:5px;left:5px;filter:blur(add=0,strength="+i_blurstrength+",direction=90);font-family:"+blurfont+";font-size:"+blursize+"pt;color:"+blurcolor[i_blurcolor]+"'>"+blurmsg[i_blurmsg]+"</span>";
	document.close()
	i_blurstrength=i_blurstrength-2
	i_blurcolor++
	var timer=setTimeout("blurdiv()",blurtime)
	}
else {
	if (i_blurcolor >=blurcolor.length-1) {i_blurcolor=blurcolor.length-1}
	blurthis.innerHTML="<span id='blurit1' style='position:absolute;visibility:visible;width:600px; top:5px;left:5px;filter:blendTrans(duration=4.2);font-family:"+blurfont+";font-size:"+blursize+"pt;color:000000'>"+blurmsg[i_blurmsg]+"</span>";
	i_blurmsg++
	if (i_blurmsg>=blurmsg.length){i_blurmsg=0}
	i_blurstrength=20
	i_blurcolor=0
	clearTimeout(timer)
//var timer=setTimeout("blurtext()",2000)
	}
 }	
}

function initbox_blurdiv() {
initbox();
blurdiv();
libinit();
}

// Empêcher le click droit
var click_msg = "Ce document est protégé !";
if(document.layers) window.captureEvents(Event.MOUSEDOWN);

function aq_no_click(e){
if (navigator.appName == 'Netscape' && ( e.which == 2 || e.which == 3))
 {
  alert(click_msg);return false;
 }
 if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
 {
   alert(click_msg);return false;
 }
}

window.onmousedown=aq_no_click;
document.onmousedown=aq_no_click;
