/*************************************************************************
  tooltipcustom.js
  version date: May 2004
  requires tooltipgeneral.js
This code has been extended after merging several codes from
Dynamic Web Coding, available at http://www.dyn-web.com/.
The extension of the code has been made at University of Savoie in France by P. Febvre. 

This code allows to display different kinds of tooltips on the same Webpage:
moving tooltips without links, fixed tooltips with possibilities of links, and menu tooltips.
Moreover it is possible to individually customize the background color and offset position of each tooltip.

If you want some tooltips in a Webpage, the following commands need to be included 
in  the HEAD section of the corresponding Webpage (Customize style and script file paths if necessary):

<LINK href="../Styles/styletiptool.css" rel="stylesheet" type="text/css">
<script src="../Scripts/tooltipcustom.js" type="text/javascript"></script>

You also need to include the following command just before the </BODY> argument.
(Customize script file path if necessary):

<script src="../Scripts/tooltipgeneral.js" type="text/javascript"></script>


For including a tooltip to appear when you browse your mouse on a blabla text,
the general syntax to be used in the WebPage is the following:

FOR MOVING TOOLTIP without links INSIDE the tooltip:
<a href="choose the link (# if you do not want any link)" class="choose the style of your blabla" onmouseover="doTooltip(event,1,8,12)" onmouseout="hideTip()"> blabla on which the mouse will show the tooltip</a>
First number (1 here) corresponds to the tooltip to be shown. This is the argument
of the variable messages[i] (i=1 here) to be customized down below in this file.
8 and 12 are respectively the offset X and Y positions of the tooltip with respect to the position
of the mouse (when it is browsed on the blabla text associated to the tooltip). You can change these values.

FOR FIXED TOOLTIPS, possibly containing links INSIDE the tooltip:
<a href="choose the link (# if you do not want any link)" class="choose the style of your blabla" onmouseover="doToolLink(event,1,8,12)" onmouseout="hideLink()"> blabla on which the mouse will show the tooltip</a>

To see how to customize the content of the Tooltip itself, see the customization part below in this file.

    See Terms of Use at http://www.dyn-web.com/bus/terms.html
    regarding conditions under which you may use this code.
    This notice must be retained in the code as is!
*************************************************************************/

var dw_event = {
  
  add: function(obj, etype, fp, cap) {
    cap = cap || false;
    if (obj.addEventListener) obj.addEventListener(etype, fp, cap);
    else if (obj.attachEvent) obj.attachEvent("on" + etype, fp);
  }, 

  remove: function(obj, etype, fp, cap) {
    cap = cap || false;
    if (obj.removeEventListener) obj.removeEventListener(etype, fp, cap);
    else if (obj.detachEvent) obj.detachEvent("on" + etype, fp);
  }, 

  DOMit: function(e) { 
    e = e? e: window.event;
    e.tgt = e.srcElement? e.srcElement: e.target;
    
    if (!e.preventDefault) e.preventDefault = function () { return false; }
    if (!e.stopPropagation) e.stopPropagation = function () { if (window.event) window.event.cancelBubble = true; }
        
    return e;
  }
  
}

/*************************************************************************
  dw_viewport.js  version date Nov 2003 from Dynamic Web Coding
*************************************************************************/  
  
viewport = {
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}
  
/*************************************************************************
  Tooltip customization start here
*************************************************************************/
 
var messages = new Array();
// array elements: image file name, image width, image height, optional text, width of tooltip (optional),
// tip background color (optional)
// If no width passed, tooltip width is as set in style sheet named styletiptool.css, or width of previous 
// If no background color passed, tooltip background color is as set in style sheet named styletiptool.css
// So, if you going to specify the width (using the 5th array element) specify them for all
// NOTE: Be sure width you specify is at least image width + 2 X border-width + 2 X padding-width !
// The array values need be defined by INCREASING order
messages[0] = ['',0,0, '<div style="text-align:center; font-size:9px; font-weight:bolder; font-style:italic">These pages are for LAHC members only.</div>', 120,'lightyellow'];
messages[1] = ['',0,0, '<div style="text-align:center; font-weight:bolder; font-style:italic; color:#000000">Overview of research activities</div>',100,'lightyellow'];
messages[2] = ['',0,0, '<div style="text-align:center; font-weight:bolder; font-style:italic; color:#000000">Interconnects in advanced integrated circuits and Tunable Microwave Circuits</div>',140,'lightyellow'];
messages[3] = ['',0,0, '<div style="text-align:center; font-weight:bolder; font-style:italic; color:#000000">THz spectroscopy, EO sampling & more ...</div>',100,'lightyellow'];
messages[4] = ['',0,0, '<div style="text-align:center; font-weight:bolder; font-style:italic; color:#000000">Josephson junctions used in digital RSFQ mode</div>',100,'lightyellow'];
messages[5] = ['pictures/ga.jpg', 126, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Gilbert Angénieux</div><ul><li><a href="mailto:gilbert.angenieux@univ-savoie.fr">send an email</a></li><li><a href="Angenieux/Ens_Angenieux/index.html" target="_blank">visit education page</a></li></ul>', 136,'lightyellow'];
messages[6] = ['pictures/sbauzac.jpg', 177, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Stéphane Bauzac</div><ul><li><a href="mailto:stephane.bauzac@univ-savoie.fr">send an email</a></li></ul>', 187,'lightyellow'];
messages[7] = ['pictures/cb.jpg', 162, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Cédric Bermond</div><ul><li><a href="mailto:cedric.bermond@univ-savoie.fr">send an email</a></li></ul>', 172,'lightyellow'];
messages[8] = ['pictures/sc.jpg', 111, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Stéphane Capraro</div><ul><li><a href="mailto:stephane.capraro@univ-savoie.fr">send an email</a></li></ul>', 126,'lightyellow'];
messages[9] = ['pictures/jlc.jpg', 135, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Jean-Louis Coutaz</div><ul><li><a href="mailto:coutaz@univ-savoie.fr">send an email</a></li></ul>', 145,'lightyellow'];
messages[10] = ['pictures/ad.jpg', 122, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Agnès Dominjon</div><ul><li><a href="mailto:agnes.dominjon@univ-savoie.fr">send an email</a></li></ul>', 132,'lightyellow'];
messages[11] = ['pictures/pf.jpg', 112, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Pascal Febvre</div><ul><li><a href="mailto:pascal.febvre@univ-savoie.fr">send an email</a></li></ul>', 122,'lightyellow'];
messages[12] = ['pictures/bf.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Bernard Fléchet</div><ul><li><a href="mailto:bernard.flechet@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];
messages[13] = ['pictures/fg.jpg', 123, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Frédéric Garet</div><ul><li><a href="mailto:frederic.garet@univ-savoie.fr">send an email</a></li></ul>', 133,'lightyellow'];
messages[14] = ['', 139, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">*******</div><ul><li><a href="#">send an email</a></li></ul>', 149,'lightyellow'];
messages[15] = ['pictures/jfr.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Jean-François Roux</div><ul><li><a href="mailto:jean-francois.roux@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];
messages[16] = ['pictures/sbadi.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Siham Badi</div><ul><li><a href="mailto:siham.badi@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];
messages[17] = ['pictures/bblampey.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Benjamin Blampey</div><ul><li><a href="mailto:benjamin.blampey@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];
messages[18] = ['pictures/jmdelord.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Jean-Marie Delord</div><ul><li><a href="mailto:jean-marie.delord@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];
messages[19] = ['pictures/mgallitre.jpg', 200, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Michel Gallitre</div><ul><li><a href="mailto:michel.gallitre@univ-savoie.fr">send an email</a></li></ul>', 210,'lightyellow'];
messages[20] = ['pictures/ylaamiri.jpg', 200, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Youness Laamiri</div><ul><li><a href="mailto:youness.laamiri@univ-savoie.fr">send an email</a></li></ul>', 210,'lightyellow'];
messages[21] = ['pictures/jpiquet.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Jérôme Piquet</div><ul><li><a href="mailto:jerome.piquet@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];
messages[22] = ['pictures/epistono.jpg', 170, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Emmanuel Pistono</div><ul><li><a href="mailto:emmanuel.pistono@univ-savoie.fr">send an email</a></li></ul>', 180,'lightyellow'];
messages[23] = ['pictures/trangvo.jpg', 145, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Thu-Trang Vo</div><ul><li><a href="mailto:thu-trang.vo@univ-savoie.fr">send an email</a></li></ul>', 155,'lightyellow'];
messages[24] = ['pictures/ggaborit.jpg', 182, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Gwenaël Gaborit</div><ul><li><a href="mailto:gwenael.gaborit@univ-savoie.fr">send an email</a></li><li><a href="Gaborit/perso_gaborit/indexgaborit.html" target="_blank">visit personal pages</a></li></ul>', 192,'lightyellow'];
messages[25] = ['pictures/tlacrevaz.jpg', 127, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Thierry Lacrevaz</div><ul><li><a href="mailto:thierry.lacrevaz@univ-savoie.fr">send an email</a></li></ul>', 137,'lightyellow'];
messages[26] = ['pictures/darmand.jpg', 190, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Damien Armand</div><ul><li><a href="mailto:damien.armand@univ-savoie.fr">send an email</a></li></ul>', 200,'lightyellow'];
messages[27] = ['pictures/alondiche.jpg', 142, 142,'<div style="text-align:center; font-weight:bolder; font-style:italic">Anne Londiche</div><ul><li><a href="mailto:anne.londiche@univ-savoie.fr">send an email</a></li></ul>', 152,'lightyellow'];
messages[28] = ['pictures/friscado.jpg', 142, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Fernanda Riscado</div><ul><li><a href="mailto:fernanda.riscado@univ-savoie.fr">send an email</a></li></ul>', 152,'lightyellow'];
messages[29] = ['peoplepages/pictures/jlc.jpg', 126, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Jean-Louis Coutaz</div><ul><li><a href="mailto:coutaz@univ-savoie.fr">send an email</a></li></ul>', 136,'lightyellow'];
messages[30] = ['pictures/treich.jpg', 107, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Torsten Reich</div><ul><li><a href="mailto:Torsten.Reich@tu-ilmenau.de">send an email</a></li></ul>', 117,'lightyellow'];
messages[31] = ['pictures/invisible.jpg', 170, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">David Bouis</div><ul><li><a href="mailto: ">send an email</a></li></ul>', 180,'lightyellow'];
messages[32] = ['pictures/invisible.jpg', 170, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Alexis Farcy</div><ul><li><a href="mailto: alexis.farcy@univ-savoie.fr">send an email</a></li></ul>', 180,'lightyellow'];
messages[33] = ['pictures/vsbrugnera.jpg', 127, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Vanessa Sbrugnera</div><ul><li><a href="mailto: vanessa.sbrugnera@univ-savoie.fr">send an email</a></li></ul>', 137,'lightyellow'];
messages[34] = ['pictures/invisible.jpg', 170, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Anna Triantafyllou</div><ul><li><a href="mailto: Anna.Triantafyllou@univ-savoie.fr">send an email</a></li></ul>', 180,'lightyellow'];
messages[35] = ['pictures/smoreau.jpg', 144, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Sébastien Moreau</div><ul><li><a href="mailto: sebastien.moreau@univ-savoie.fr">send an email</a></li></ul>', 154,'lightyellow'];
messages[36] = ['peoplepages/pictures/pf.jpg', 112, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Pascal Febvre</div><ul><li><a href="mailto:pascal.febvre@univ-savoie.fr">send an email</a></li></ul>', 122,'lightyellow'];
messages[37] = ['peoplepages/pictures/bf.jpg', 131, 150,'<div style="text-align:center; font-weight:bolder; font-style:italic">Bernard Fléchet</div><ul><li><a href="mailto:bernard.flechet@univ-savoie.fr">send an email</a></li></ul>', 141,'lightyellow'];

/*messages[5] = ['pictures/ga.jpg', 126, 150, '<div style="text-align:center; font-weight:bolder; font-style:italic">Gilbert Angénieux <span class="comicblack">&#8217;</span>Optique 2005 et JNOG 2005 - Chambéry</div>',160,'lightyellow'];
messages[4] = ['', 0,0,'Pour commander ce CD, envoyer un mél à <a href="mailto:Pascal.Febvre@univ-savoie.fr">Pascal Febvre</a>, en précisant vos corrdonnées et votre fonction.', 120];

messages[3] = ['',0,0, '<div style="text-align:center; font-weight:bolder; font-style:italic">under construction</div>',100,'lightblue'];
messages[4] = ['',0,0, '<div style="text-align:center; font-weight:bolder; font-style:italic">Not yet! Sorry...</div>',100,'lightblue'];
messages[6] = ['images/smile.gif', 88, 88, 'See the complete list of <a href="http://www.dyn-web.com/dhtml/tooltips/">tooltips</a> currently available at <a href="http://www.dyn-web.com/">www.dyn-web.com</a>, along with a brief description.', 120,'lightblue'];
messages[7] = ['images/balloon.gif', 106, 131, , 120];
*/
// other examples:
//messages[1] = ['images/dot-com-btn.gif', 176, 30, 'The regular tooltip can display images too.', 190,'yellow'];
//messages[2] = ['', 0, 0, 'You are here!',75,'lightblue'];
// an example with no text
//messages[3] = ['images/balloon.gif', 106, 131, , 120];
//////////////////////////////////////////////////////////////////////////////////////////////////
// Code for preloading images
// If you don't want to preload your images you can remove or comment out this section
// or just put all your messages arrays below it

if (document.images) {
	var image_list = new Array();
  for (var message_counter=0; message_counter < messages.length; message_counter++) {
  	image_list[message_counter] = new Image(); 
		image_list[message_counter].src = messages[message_counter][0];
  }
}

// end preload code
////////////////////////////////////////////////////////////////////////////////////////////////////////
  
// since this comes after the preload algorithm, the image here won't be preloaded
//messages[8] = ['images/smile.gif', 88, 88, 'This image was not preloaded.', 120,'blue'];

/*************************************************************************
  Tooltip customization ends here
*************************************************************************/

// Function doTooptip used for (a priori) moving tips without links
function doTooltip(e, num, offsetx , offsety) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  var cntnt = wrapTipContent(num);
  var tip = document.getElementById( Tooltip.tipID );
  if ( messages[num][4] ) tip.style.width = messages[num][4] + "px";
  if ( messages[num][5] ) tip.style.backgroundColor = messages[num][5]; else tip.style.backgroundColor ="";
  Tooltip.show(e, cntnt, offsetx, offsety);
}

// Function doToopLink used for fixed tips with links
function doToolLink(e, num, offsetx , offsety) {
  if ( typeof ToolLink == "undefined" || !ToolLink.ready ) return;
  var cntnt = wrapTipContent(num);
  var tip = document.getElementById( ToolLink.tipID );
  if ( messages[num][4] ) tip.style.width = messages[num][4] + "px";
  if ( messages[num][5] ) tip.style.backgroundColor = messages[num][5]; else tip.style.backgroundColor ="";
  ToolLink.clearTimer();
  ToolLink.show(e, cntnt, offsetx, offsety);
}


function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}

function hideLink() {
  if ( typeof ToolLink == "undefined" || !ToolLink.ready ) return;
  ToolLink.timerId = setTimeout("ToolLink.hide()", 300); 
}


function wrapTipContent(num) {
  var cntnt = '<div class="img"><img src="' + messages[num][0] + '" width="' + 
    messages[num][1] + '" height="' + messages[num][2] + '" border="0"></div>';
  if ( messages[num][3] ) cntnt += '<div class="msg">' + messages[num][3] + '</div>';
	return cntnt;
}

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset 
  offY: 6,   // vertical offset 
  show: function(id, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    this.position(mnu,e);
  },
  
  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById) 
      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
  },
  
  position: function(mnu, e) {
    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
    
    if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - mnu.offsetWidth - this.offX;
    else x = x + this.offX;
  
    if ( y + mnu.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? y - mnu.offsetHeight - this.offY : viewport.height + viewport.scrollY - mnu.offsetHeight;
    else y = y + this.offY;
    
    mnu.style.left = x + "px"; mnu.style.top = y + "px";
    this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
  },
  
  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },
  
  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode ) 
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  }
  
}

