/**
 * justcorners.js 1.81 (21-Mar-2009)
 * (c) by Christian Effenberger 
 * All Rights Reserved
 * Source: corner.netzgesta.de
 * Distributed under Netzgestade Software License Agreement
 * http://www.netzgesta.de/cvi/LICENSE.txt
 * License permits free of charge
 * use on non-commercial and 
 * private web sites only 
**/

var tmp = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
if(tmp) var isIE = document.namespaces && !window.opera ? 1 : 0;

if(isIE) {
	if(document.namespaces['v']==null) {
		var e=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","roundrect","oval","rect","arc","image"],s=document.createStyleSheet(); 
		for(var i=0; i<e.length; i++) {s.addRule("v\\:"+e[i],"behavior: url(#default#VML);");} document.namespaces.add("v","urn:schemas-microsoft-com:vml");
	} 
}

function roundedCorners(ctx,width,height,radius,lt,rt,lb,rb){
	ctx.beginPath(); ctx.moveTo(0,radius);
	if(lb==1) {ctx.lineTo(0,height-radius); ctx.quadraticCurveTo(0,height,radius,height); }else {ctx.lineTo(0,height); }
	if(rb==1) {ctx.lineTo(width-radius,height); ctx.quadraticCurveTo(width,height,width,height-radius); }else {ctx.lineTo(width,height); }
	if(rt==1) {ctx.lineTo(width,radius); ctx.quadraticCurveTo(width,0,width-radius,0); }else {ctx.lineTo(width,0); }		
	if(lt==1) {ctx.lineTo(radius,0); ctx.quadraticCurveTo(0,0,0,radius); }else {ctx.lineTo(0,0); }		
	ctx.closePath();
}

function addRoundedIECorners() {
	var image, object, vml, classNames, data, classes = ''; 
	var iradius = 0, iborder = 0, icolor = '', newClasses = ''; 
	var maxdim = 0, mindim = 0, i, j, child, tmp = '';
	var radius = null, display = "", flt = "", color = '';
	var tl = 1, tr = 1, bl = 1, br = 1; 
	var children = document.getElementsByTagName('img'); 
	var theimages = new Array(); 
	for(i=0;i<children.length;i++) {
		child = children[i];
		classNames = child.className.split(' ');
		for(j=0;j<classNames.length; j++) {
			if(classNames[j] == 'corners') {theimages.push(child); break; }
		}
	}	
	for(i=0;i<theimages.length;i++) {	
		image = theimages[i]; iradius = 16; color = '0000ff';
		tl = 1;	tr = 1; bl = 1; br = 1; iborder = 0;
		object = image.parentNode; 
		classes = image.className.split(' ');
		for(j=0;j<classes.length;j++) {
			if(classes[j].indexOf("iradius") == 0) {
				iradius = classes[j].substring(7);
			}else if(classes[j].indexOf("iborder") == 0) {
				iborder = classes[j].substring(7);
			}else if(classes[j].indexOf("icolor") == 0) {
				icolor = classes[j].substring(6);
			}else if(classes[j].indexOf("iradiae") == 0) {
				tmp = classes[j].substring(7);
				tl = (tmp.substr(0,1)!="1"?0:1);
				tr = (tmp.substr(1,1)!="1"?0:1);
				bl = (tmp.substr(2,1)!="1"?0:1);
				br = (tmp.substr(3,1)!="1"?0:1);
			}
		} newClasses = '';
		for(j=0;j<classes.length;j++) {
			if(classes[j] != "corners") {
				if(newClasses) { newClasses += ' '; }
				newClasses += classes[j];
			}
		}
		maxdim = Math.min(image.width,image.height)/2;
		mindim = (iradius==0?16:iradius);
		radius = Math.min(maxdim,mindim);
		iborder = Math.min(iborder,2);
		color = (icolor.match(/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)?icolor:color);
		display = (image.currentStyle.display.toLowerCase()=='block')?'block':'inline-block';        
		vml = document.createElement(['<var style="zoom:1;overflow:hidden;display:' + display + ';width:' + image.width + 'px;height:' + image.height + 'px;padding:0;">'].join(''));
		flt =  image.currentStyle.styleFloat.toLowerCase();
		display = (flt=='left'||flt=='right')?'inline':display;
		var path = "m 0," + radius; 
		if(bl==1) {path += " l 0," + (image.height-radius) + " qy " + radius + "," + image.height;}else {path += " l 0," + image.height;}
		if(br==1) {path += " l " + (image.width-radius) + "," + image.height + " qx " + image.width + "," + (image.height-radius);}else {path += " l " + image.width + "," + image.height;}
		if(tr==1) {path += " l " + image.width + "," + radius + " qy " + (image.width-radius) + ",0";}else {path += " l " + image.width + ",0";}	
		if(tl==1) {path += " l " + radius + ",0 qx 0," + radius;}else {path += " l 0,0";}	
		path += " x e"; data = '<v:shape strokeweight="'+iborder+'px" stroked="'+(iborder>0?"t":"f")+'" strokecolor="#'+color+'" filled="t" fillcolor="#ffffff" coordorigin="0,0" coordsize="' + image.width + ',' + image.height + '" path="' + path + '" style="zoom:1;margin:-1px 0 0 -1px;padding: 0;display:' + display + ';width:' + image.width + 'px;height:' + image.height + 'px;"><v:fill src="' + image.src + '" type="frame" /></v:shape>';
		vml.innerHTML = [data ].join('');
		vml.className = newClasses;
		vml.style.cssText = image.style.cssText;
		vml.style.visibility = 'visible';
		vml.src = image.src; vml.alt = image.alt;
		if(image.id!='') vml.id = image.id;
		if(image.title!='') vml.title = image.title;
		if(image.getAttribute('onclick')!='') vml.setAttribute('onclick',image.getAttribute('onclick'));
		image.insertAdjacentElement('BeforeBegin',vml); 
		if(image.getAttribute("usemap")) {
			object.style.position = 'relative';
			object.style.height = image.height+'px';
			object.style.width = image.width+'px';
			image.left = 0; image.top = 0;
			image.style.position = 'absolute';
			image.style.height = image.height+'px';
			image.style.width = image.width+'px';
			image.style.left = 0 + 'px';
			image.style.top = 0 + 'px';
			image.style.filter = "Alpha(opacity=0)";
		}else {
			image.style.display = 'none'; 
		}
	}
}

function addRoundedCorners() {
	var image, object, canvas, context, classNames, classes = '';
	var iradius = 0, iborder = 0, icolor = '', newClasses = ''; 
	var maxdim = 0, mindim = 0, i, j, child, tmp = '';
	var tl = 1, tr = 1, bl = 1, br = 1, color = '';
	var children = document.getElementsByTagName('img'); 
	var theimages = new Array(); 
	for(i=0;i<children.length;i++) {
		child = children[i];
		classNames = child.className.split(' ');
		for(j=0;j<classNames.length; j++) {
			if (classNames[j] == 'corners') {theimages.push(child); break; }
		}
	}	
	for(i=0;i<theimages.length;i++) {	
		image = theimages[i]; iradius = 16; color = '0000ff';
		tl = 1;	tr = 1; bl = 1; br = 1; iborder = 0;
		object = image.parentNode; 
		canvas = document.createElement('canvas');
		if(canvas.getContext) {
			classes = image.className.split(' ');  
			for(j=0;j<classes.length;j++) {
				if(classes[j].indexOf("iradius") == 0) {
					iradius = classes[j].substring(7);				
				}else if(classes[j].indexOf("iborder") == 0) {
					iborder = classes[j].substring(7);
				}else if(classes[j].indexOf("icolor") == 0) {
					icolor = classes[j].substring(6);
				}else if(classes[j].indexOf("iradiae") == 0) {
					tmp = classes[j].substring(7);
					tl = (tmp.substr(0,1)!="1"?0:1);
					tr = (tmp.substr(1,1)!="1"?0:1);
					bl = (tmp.substr(2,1)!="1"?0:1);
					br = (tmp.substr(3,1)!="1"?0:1);
				}
			} newClasses = '';
			for(j=0;j<classes.length;j++) {
				if(classes[j] != "corners") {
					if(newClasses) { newClasses += ' '; }
					newClasses += classes[j];
				}
			}
			canvas.className = newClasses;
			canvas.style.cssText = image.style.cssText;
			canvas.style.height = image.height+'px';
			canvas.style.width = image.width+'px';
			canvas.height = image.height;
			canvas.width = image.width;
			canvas.src = image.src; canvas.alt = image.alt;
			if(image.id!='') canvas.id = image.id;
			if(image.title!='') canvas.title = image.title;
			if(image.getAttribute('onclick')!='') canvas.setAttribute('onclick',image.getAttribute('onclick'));
			maxdim = Math.min(canvas.width,canvas.height)/2;
			mindim = (iradius==0?16:iradius);
			iradius = Math.min(maxdim,mindim);
			iborder = Math.min(iborder*2,iradius);
			color = (icolor.match(/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)?icolor:color);
			context = canvas.getContext("2d");
			if(image.getAttribute("usemap")) {
				object.style.position = 'relative';
				object.style.height = image.height+'px';
				object.style.width = image.width+'px';
				canvas.left = 0; canvas.top = 0;
				canvas.style.position = 'absolute';
				canvas.style.left = 0 + 'px';
				canvas.style.top = 0 + 'px';
				image.left = 0; image.top = 0;
				image.style.position = 'absolute';
				image.style.height = image.height+'px';
				image.style.width = image.width+'px';
				image.style.left = 0 + 'px';
				image.style.top = 0 + 'px';
				image.style.opacity = 0;
				object.insertBefore(canvas,image);
			}else {
				object.replaceChild(canvas,image);
			}
			context.clearRect(0,0,canvas.width,canvas.height);
			globalCompositeOperation = "source-in";
			roundedCorners(context,canvas.width,canvas.height,iradius,tl,tr,bl,br);
			context.clip();
			context.fillStyle = 'rgba(0,0,0,0)';
			context.fillRect(0,0,canvas.width,canvas.height);
			context.drawImage(image,0,0,canvas.width,canvas.height);
			if(iborder>0) {
				roundedCorners(context,canvas.width,canvas.height,iradius,tl,tr,bl,br);
				context.strokeStyle = '#'+color;
				context.lineWidth = iborder;
				context.stroke(); 
			}
			canvas.style.visibility = 'visible';
		}
	}
}

var cornersOnload = window.onload;
window.onload = function () { if(cornersOnload) cornersOnload(); if(isIE){addRoundedIECorners(); }else {addRoundedCorners();}}



function GetId(id)
{
return document.getElementById(id);
}
var i=false; // La variable i nous dit si la bulle est visible ou non
var ondiapo=0;
function move(e) {
  if(i) {  // Si la bulle est visible, on calcul en temps reel sa position ideale
    /*if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
    
    
    GetId("curseur").style.left=e.pageX + 5+"px";
    GetId("curseur").style.top=e.pageY + 10+"px";
    }
    else {*/ // Modif proposé par TeDeum, merci à lui
    //if(document.documentElement.clientWidth>0) {
	/*GetId("curseur").style.left=20+event.x+document.documentElement.scrollLeft+"px";
	GetId("curseur").style.top=10+event.y+document.documentElement.scrollTop+"px";*/
    if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
    
    if(navigator.userAgent.indexOf("WebKit") > -1){
    if(ondiapo==1){
    GetId("curseur").style.left=(((e.pageX + 5)-(Math.round((document.documentElement.clientWidth-983)/2)))-330)+"px";
    }else{
     GetId("curseur").style.left=((e.pageX + 5)-(Math.round((document.documentElement.clientWidth-983)/2)))+"px";
   
    }
    }else{
      if(ondiapo==1){
       GetId("curseur").style.left=(e.pageX - 330) +"px";
      }else{
       GetId("curseur").style.left=e.pageX + 5 +"px";
      }
    
    
   
    }
    
    GetId("curseur").style.top=e.pageY + 15+"px";
    }else{ 
    //GetId("corps").innerHTML= event.y;
      if(ondiapo==1){
    GetId("curseur").style.left=510+event.x+"px";
	GetId("curseur").style.top=170+event.y+"px";
    }else{
     GetId("curseur").style.left=20+event.x+"px";
	GetId("curseur").style.top=10+event.y+"px";
    }
}
    /*} else {
	GetId("curseur").style.left=20+event.x+document.body.scrollLeft+"px";
	GetId("curseur").style.top=10+event.y+document.body.scrollTop+"px";*/
    /*GetId("curseur").style.left=20+event.x+"px";
	GetId("curseur").style.top=10+event.y+"px";*/
	    // }
    //}
  }
}


  function mousemove(e) {
    var DocRef;
    //-- On traque les hybrides
    if( e && e.target){
      Mouse_X = e.pageX;
      Mouse_Y = e.pageY;
    }
    else{
      if( document.documentElement && document.documentElement.clientWidth)
        DocRef = document.documentElement;
      else
        DocRef = document.body; 

      Mouse_X = event.clientX +DocRef.scrollLeft;
      Mouse_Y = event.clientY +DocRef.scrollTop;
    }
  /*
    if (navigator.appName.indexOf("Explorer") > -1) {
      var mouseX=event.x; var mouseY=event.y;
    }
    else {var mouseX=e.pageX; var mouseY=e.pageY;}
  */
    var Obj =  document.getElementById("curseur");
    with( Obj){
      style.top  = Mouse_Y +20 +"px";
      style.left = Mouse_X +20 +"px";
      style.visibility = voir;
      style.display = display;
    }
  }



function montre(text) {
  if(i==false) {
  if(text!=""){
  GetId("curseur").style.visibility="visible"; // Si il est caché (la verif n'est qu'une securité) on le rend visible.
  GetId("curseur").innerHTML = text; // Cette fonction est a améliorer, il parait qu'elle n'est pas valide (mais elle marche)
  i=true;}
  }
}
function cache() {
if(i==true) {
GetId("curseur").style.visibility="hidden"; // Si la bulle etais visible on la cache
i=false;
}
}
document.onmousemove=move; // des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.
//-->




