/* Image w/ description tooltip v2.0
* Created: April 23rd, 2010. This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/


var ddimgtooltip={

	tiparray:function(){
		var tooltips=[]
		//define each tooltip below: tooltip[inc]=['path_to_image', 'optional desc', optional_CSS_object]
		//For desc parameter, backslash any special characters inside your text such as apotrophes ('). Example: "I\'m the king of the world"
		//For CSS object, follow the syntax: {property1:"cssvalue1", property2:"cssvalue2", etc}

		tooltips[1]=["./Location/01_loc_Ain.gif", "Département Ain"];
		tooltips[2]=["./Location/02_loc_Aisne.gif", "Département Aisne"];
		tooltips[3]=["./Location/03_loc_Allier.gif", "Département Allier"];
		tooltips[4]=["./Location/04_loc_Alpes-de-Haute-Provence.gif", "Département Alpes-de-Haute-Provence"];
		tooltips[5]=["./Location/05_loc_Hautes-Alpes.gif", "Département Hautes-Alpes"];
		tooltips[6]=["./Location/06_loc_Alpes-Maritimes.gif", "Département Alpes-Maritimes"];
		tooltips[7]=["./Location/07_loc_Ardèche.gif", "Département Ardèche"];
		tooltips[8]=["./Location/08_loc_Ardennes.gif", "Département Ardennes"];
		tooltips[9]=["./Location/09_loc_Ariège.gif", "Département Ariège"];
		tooltips[10]=["./Location/10_loc_Aube.gif", "Département Aube"];
		tooltips[11]=["./Location/11_loc_Aude.gif", "Département Aude"];
		tooltips[12]=["./Location/12_loc_Aveyron.gif", "Département Aveyron"];
		tooltips[13]=["./Location/13_loc_Bouches-du-Rhône.gif", "Département Bouches-du-Rhône"];
		tooltips[14]=["./Location/14_loc_Calvados.gif", "Département Calvados"];
		tooltips[15]=["./Location/15_loc_Cantal.gif", "Département Cantal"];
		tooltips[16]=["./Location/16_loc_Charente.gif", "Département Charente"];
		tooltips[17]=["./Location/17_loc_Charente-Maritime.gif", "Département Charente-Maritime"];
		tooltips[18]=["./Location/18_loc_Cher.gif", "Département Cher"];
		tooltips[19]=["./Location/19_loc_Corrèze.gif", "Département Corrèze"];
		tooltips[20]=["./Location/20_loc_Corse-du-Sud.gif", "Département Corse-du-Sud"];
		tooltips[20]=["./Location/20_loc_Haute-Corse.gif", "Département Haute-Corse"];
		tooltips[21]=["./Location/21_loc_Côte-d'Or.gif", "Département Côte-d'Or"];
		tooltips[22]=["./Location/22_loc_Côtes-d'Armor.gif", "Département Côtes-d'Armor"];
		tooltips[23]=["./Location/23_loc_Creuse.gif", "Département Creuse"];
		tooltips[24]=["./Location/24_loc_Dordogne.gif", "Département Dordogne"];
		tooltips[25]=["./Location/25_loc_Doubs.gif", "Département Doubs"];
		tooltips[26]=["./Location/26_loc_Drôme.gif", "Département Drôme"];
		tooltips[27]=["./Location/27_loc_Eure.gif", "Département Eure"];
		tooltips[28]=["./Location/28_loc_Eure-et-Loir.gif", "Département Eure-et-Loir"];
		tooltips[29]=["./Location/29_loc_Finistère.gif", "Département Finistère"];
		tooltips[30]=["./Location/30_loc_Gard.gif", "Département Gard"];
		tooltips[31]=["./Location/31_loc_Haute-Garonne.gif", "Département Haute-Garonne"];
		tooltips[32]=["./Location/32_loc_Gers.gif", "Département Gers"];
		tooltips[33]=["./Location/33_loc_Gironde.gif", "Département Gironde"];
		tooltips[34]=["./Location/34_loc_Hérault.gif", "Département Hérault"];
		tooltips[35]=["./Location/35_loc_Ille-et-Vilaine.gif", "Département Ille-et-Vilaine"];
		tooltips[36]=["./Location/36_loc_Indre.gif", "Département Indre"];
		tooltips[37]=["./Location/37_loc_Indre-et-Loire.gif", "Département Indre-et-Loire"];
		tooltips[38]=["./Location/38_loc_Isère.gif", "Département Isère"];
		tooltips[39]=["./Location/39_loc_Jura.gif", "Département Jura"];
		tooltips[40]=["./Location/40_loc_Landes.gif", "Département Landes"];
		tooltips[41]=["./Location/41_loc_Loir-et-Cher.gif", "Département Loir-et-Cher"];
		tooltips[42]=["./Location/42_loc_Loire.gif", "Département Loire"];
		tooltips[43]=["./Location/43_loc_Haute-Loire.gif", "Département Haute-Loire"];
		tooltips[44]=["./Location/44_loc_Loire-Atlantique.gif", "Département Loire-Atlantique"];
		tooltips[45]=["./Location/45_loc_Loiret.gif", "Département Loiret"];
		tooltips[46]=["./Location/46_loc_Lot.gif", "Département Lot"];
		tooltips[47]=["./Location/47_loc_Lot-et-Garonne.gif", "Département Lot-et-Garonne"];
		tooltips[48]=["./Location/48_loc_Lozère.gif", "Département Lozère"];
		tooltips[49]=["./Location/49_loc_Maine-et-Loire.gif", "Département Maine-et-Loire"];
		tooltips[50]=["./Location/50_loc_Manche.gif", "Département Manche"];
		tooltips[51]=["./Location/51_loc_Marne.gif", "Département Marne"];
		tooltips[52]=["./Location/52_loc_Haute-Marne.gif", "Département Haute-Marne"];
		tooltips[53]=["./Location/53_loc_Mayenne.gif", "Département Mayenne"];
		tooltips[54]=["./Location/54_loc_Meurthe-et-Moselle.gif", "Département Meurthe-et-Moselle"];
		tooltips[55]=["./Location/55_loc_Meuse.gif", "Département Meuse"];
		tooltips[56]=["./Location/56_loc_Morbihan.gif", "Département Morbihan"];
		tooltips[57]=["./Location/57_loc_Moselle.gif", "Département Moselle"];
		tooltips[58]=["./Location/58_loc_Nièvre.gif", "Département Nièvre"];
		tooltips[59]=["./Location/59_loc_Nord.gif", "Département Nord"];
		tooltips[60]=["./Location/60_loc_Oise.gif", "Département Oise"];
		tooltips[61]=["./Location/61_loc_Orne.gif", "Département Orne"];
		tooltips[62]=["./Location/62_loc_Pas-de-Calais.gif", "Département Pas-de-Calais"];
		tooltips[63]=["./Location/63_loc_Puy-de-Dôme.gif", "Département Puy-de-Dôme"];
		tooltips[64]=["./Location/64_loc_Pyrénées-Atlantiques.gif", "Département Pyrénées-Atlantiques"];
		tooltips[65]=["./Location/65_loc_Hautes-Pyrénées.gif", "Département Hautes-Pyrénées"];
		tooltips[66]=["./Location/66_loc_Pyrénées-Orientales.gif", "Département Pyrénées-Orientales"];
		tooltips[67]=["./Location/67_loc_Bas-Rhin.gif", "Département Bas-Rhin"];
		tooltips[68]=["./Location/68_loc_Haut-Rhin.gif", "Département Haut-Rhin"];
		tooltips[69]=["./Location/69_loc_Rhône.gif", "Département Rhône"];
		tooltips[70]=["./Location/70_loc_Haute-Saône.gif", "Département Haute-Saône"];
		tooltips[71]=["./Location/71_loc_Saône-et-Loire.gif", "Département Saône-et-Loire"];
		tooltips[72]=["./Location/72_loc_Sarthe.gif", "Département Sarthe"];
		tooltips[73]=["./Location/73_loc_Savoie.gif", "Département Savoie"];
		tooltips[74]=["./Location/74_loc_Haute-Savoie.gif", "Département Haute-Savoie"];
		tooltips[76]=["./Location/76_loc_Seine-Maritime.gif", "Département Seine-Maritime"];
		tooltips[77]=["./Location/77_loc_Seine-et-Marne.gif", "Département Seine-et-Marne"];
		tooltips[78]=["./Location/78_loc_Yvelines.gif", "Département Yvelines"];
		tooltips[79]=["./Location/79_loc_Deux-Sèvres.gif", "Département Deux-Sèvres"];
		tooltips[80]=["./Location/80_loc_Somme.gif", "Département Somme"];
		tooltips[81]=["./Location/81_loc_Tarn.gif", "Département Tarn"];
		tooltips[82]=["./Location/82_loc_Tarn-et-Garonne.gif", "Département Tarn-et-Garonne"];
		tooltips[83]=["./Location/83_loc_Var.gif", "Département Var"];
		tooltips[84]=["./Location/84_loc_Vaucluse.gif", "Département Vaucluse"];
		tooltips[85]=["./Location/85_loc_Vendée.gif", "Département Vendée"];
		tooltips[86]=["./Location/86_loc_Vienne.gif", "Département Vienne"];
		tooltips[87]=["./Location/87_loc_Haute-Vienne.gif", "Département Haute-Vienne"];
		tooltips[88]=["./Location/88_loc_Vosges.gif", "Département Vosges"];
		tooltips[89]=["./Location/89_loc_Yonne.gif", "Département Yonne"];
		tooltips[90]=["./Location/90_loc_Territoire_de_Belfort.gif", "Département Territoire de Belfort"];
		tooltips[91]=["./Location/91_loc_Essonne.gif", "Département Essonne"];
		tooltips[92]=["./Location/92_loc_Hauts-de-Seine.gif", "Département Hauts-de-Seine"];
		tooltips[93]=["./Location/93_loc_Seine-Saint-Denis.gif", "Département Seine-Saint-Denis"];
		tooltips[94]=["./Location/94_loc_Val-de-Marne.gif", "Département Val-de-Marne"];
		tooltips[95]=["./Location/95_loc_Val-d'Oise.gif", "Département Val-d'Oise"];

		return tooltips //do not remove/change this line
	}(),

	tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips

	//***** NO NEED TO EDIT BEYOND HERE

	tipprefix: 'imgtip', //tooltip ID prefixes

	createtip:function($, tipid, tipinfo){
		if ($('#'+tipid).length==0){ //if this tooltip doesn't exist yet
			return $('<div id="' + tipid + '" class="ddimgtooltip" />').html(
				'<div style="text-align:center"><img src="' + tipinfo[0] + '" /></div>'
				+ ((tipinfo[1])? '<div style="text-align:left; margin-top:5px">'+tipinfo[1]+'</div>' : '')
				)
			.css(tipinfo[2] || {})
			.appendTo(document.body)
		}
		return null
	},

	positiontooltip:function($, $tooltip, e){
		var x=e.pageX+this.tooltipoffsets[0], y=e.pageY+this.tooltipoffsets[1]
		var tipw=$tooltip.outerWidth(), tiph=$tooltip.outerHeight(), 
		x=(x+tipw>$(document).scrollLeft()+$(window).width())? x-tipw-(ddimgtooltip.tooltipoffsets[0]*2) : x
		y=(y+tiph>$(document).scrollTop()+$(window).height())? $(document).scrollTop()+$(window).height()-tiph-10 : y
		$tooltip.css({left:x, top:y})
	},
	
	showbox:function($, $tooltip, e){
		$tooltip.show()
		this.positiontooltip($, $tooltip, e)
	},

	hidebox:function($, $tooltip){
		$tooltip.hide()
	},


	init:function(targetselector){
		jQuery(document).ready(function($){
			var tiparray=ddimgtooltip.tiparray
			var $targets=$(targetselector)
			if ($targets.length==0)
				return
			var tipids=[]
			$targets.each(function(){
				var $target=$(this)
				$target.attr('rel').match(/\[(\d+)\]/) //match d of attribute rel="imgtip[d]"
				var tipsuffix=parseInt(RegExp.$1) //get d as integer
				var tipid=this._tipid=ddimgtooltip.tipprefix+tipsuffix //construct this tip's ID value and remember it
				var $tooltip=ddimgtooltip.createtip($, tipid, tiparray[tipsuffix])
				$target.mouseenter(function(e){
					var $tooltip=$("#"+this._tipid)
					ddimgtooltip.showbox($, $tooltip, e)
				})
				$target.mouseleave(function(e){
					var $tooltip=$("#"+this._tipid)
					ddimgtooltip.hidebox($, $tooltip)
				})
				$target.mousemove(function(e){
					var $tooltip=$("#"+this._tipid)
					ddimgtooltip.positiontooltip($, $tooltip, e)
				})
				if ($tooltip){ //add mouseenter to this tooltip (only if event hasn't already been added)
					$tooltip.mouseenter(function(){
						ddimgtooltip.hidebox($, $(this))
					})
				}
			})

		}) //end dom ready
	}
}

//ddimgtooltip.init("targetElementSelector")
ddimgtooltip.init("*[rel^=imgtip]")
