/* objet */
function getOb(ob) { return (document.all)?eval('document.all.'+ob):(document.getElementById)?eval('document.getElementById("'+ob+'")'):null }

/*----------------------------------------------------------------------- proprietes -------------------------------------------------------------*/
/* hauteur */
function getHt(ob) { return ob.offsetHeight }
/* largeur */
function getLg(ob) { return ob.offsetWidth }
/* position y */
function getx(ob) { return (document.all)?ob.style.pixelLeft:parseInt(ob.style.left) }
/* position x */
function gety(ob) { return (document.all)?ob.style.pixelTop:parseInt(ob.style.top) }
/* hauteur zone affichage */
function htZoneAffichage() {if(browser.isIE55){return document.body.clientHeight} if(browser.isIE6up){return document.documentElement.clientHeight} if(browser.isAutre || browser.isFirefox || browser.isMac){return document.documentElement.clientHeight}}
/*----------------------------------------------------------------------- /proprietes -------------------------------------------------------------*/


/*------------------------------------------------------------------------ methodes ---------------------------------------------------------------*/
/* visible */
function show(ob) { ob.style.visibility = "visible" }
/* invisible */
function hide(ob) { ob.style.visibility = "hidden" }
/* affiche */
function d_block(ob) { ob.style.display = "block" }
/* desaffiche */
function d_none(ob) { ob.style.display = "none" }
/* definit hauteur */
function laht(ob,px) { ob.style.height = px+'px' }
/* definit largeur */
function lalg(ob,px) { ob.style.width = px+'px' }
/* positionne en x */
function enx(ob,px) { if (document.all) ob.style.pixelLeft = px; else ob.style.left = px+'px'; }
/* positionne en y */
function eny(ob,px) { if (document.all) ob.style.pixelTop = px; else ob.style.top = px+'px'; }
/* clip */
function clp(ob,htm,lgd,htp,lgg) { ob.style.clip = eval("'rect("+htm+"px, "+lgd+"px, "+htp+"px, "+lgg+"px)'") }
/* proportion */
function prop(mn,mx,bi,ind,bs) { return (((mx-mn)*ind)/(bs-bi)) }
/* definit contenu */
function inner(ob,contenu){ ob.innerHTML = contenu; }
/* change source image */
function swimg(im,src) { eval( 'document.'+im+'.src = "'+src+'"' ) }
/* definit hauteur image */
function iht(im,px) { eval('document.'+im+'.style.height = '+px+'px') }
/* definit largueur image */
function ilg(im,px) { eval('document.'+im+'.style.width = '+px+'px') }

function getOffsetPosition(inID, inTYPE){var iVal = 0;var oObj = document.getElementById(inID);var sType = 'oObj.offset' + inTYPE;while (oObj && oObj.tagName != 'BODY') {iVal += eval(sType);oObj = oObj.offsetParent;}return iVal;}
/*----------------------------------------------------------------------------- /methodes -----------------------------------------------------------------*/

/*----------------------------------------------------------------------------- browser --------------------------------------------------------------------*/
/* detection du navigateur */
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 
   
   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   this.isFirefox   = (ua.indexOf('firefox') != -1);
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE55up = (this.isIE && this.versionMajor >= 5.5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
   
   this.isAutre   = !(this.isIE || this.isFirefox || this.isSafari);
}
browser = new BrowserDetectLite();
/*----------------------------------------------------------------------------- /browser --------------------------------------------------------------------*/

/*---------------------------------------------------------------------------- popup ------------------------------------------------------------------------*/
// ouvre une popup qui se centre; url=url de la page ; nom_fenetre = nom de la fenetre ; hauteur et largeur en chaine et sans unité
// pour une popup fixe : hauteur=hauteur du contenu(<=534px) ; largueur=largueur du contenu(<=790px)
// pour une popup plein écran : hauteur='max' ; largueur='max';
// pour une popup de hauteur 'max' , le scroll est automatique mis avec la fenetre ; le contenu de la popup <= 771px;
// prend en compte les navigateurs IE5.5, IE6, Firefox et Safari +  l'interface du système d'exploitation (barre des taches)
// si besoin d'avoir un scroll, il faut le créer à l'intérieur de la page appelée

function popup(url,nom_fenetre,largeur,hauteur,scrollbar)
{
	// ecran
	var hauteurEcran = screen.height;
	var largeurEcran = screen.width;
	if (browser.isIE)
	{
		hauteurEcran = screen.availHeight;
		largeurEcran = screen.availWidth;
	}
	
	// dimension fenetre 
	var hauteurFenetre = null;
	var largeurFenetre = null;
	
	// resolution 800 * 600
	//if(largeur!="max" && parseInt(largeur)>790){largeur=790;alert('Le contenu de la popup ne dois pas dépassé 790px en largeur pour s\'afficher correctement en 800 * 600')}
	//if(hauteur!="max" && parseInt(hauteur)>534){hauteur=534;alert('Le contenu de la popup ne dois pas dépassé 534px en hauteur pour s\'afficher correctement en 800 * 600')}
	
	// largeur fenetre
	if(largeur=='max')
	{
		if(browser.isIE){largeurFenetre = largeurEcran-10;}
		if(browser.isFirefox || browser.isAutre){largeurFenetre = largeurEcran-6}
		if(browser.isSafari){largeurFenetre = largeurEcran;}
	} 
	else
	{largeurFenetre =  parseInt(largeur)}
	
	// hauteur fenetre
	if(hauteur=='max')
	{
		if(browser.isIE){hauteurFenetre = hauteurEcran-36;}
		if(browser.isFirefox || browser.isAutre){hauteurFenetre = hauteurEcran;}
		if(browser.isSafari){hauteurFenetre = hauteurEcran-48}
	} 
	else
	{ 
		if(browser.isIE){hauteurFenetre = parseInt(hauteur)}
		if(browser.isFirefox || browser.isAutre){hauteurFenetre = parseInt(hauteur)}
		if(browser.isSafari){hauteurFenetre = parseInt(hauteur)+1}
	}
	
	// largueur effective fenetre
	var largeurFenetreEffective = null;
	if(browser.isIE){largeurFenetreEffective=parseInt(largeurFenetre)+10;}
	if(browser.isFirefox || browser.isAutre){largeurFenetreEffective=parseInt(largeurFenetre)+6}
	if(browser.isSafari){largeurFenetreEffective=parseInt(largeurFenetre)}
	
	// hauteur effective fenetre
	var hauteurFenetreEffective = null;
	if(browser.isIE){hauteurFenetreEffective=parseInt(hauteurFenetre)+36;}
	if(browser.isFirefox || browser.isAutre){hauteurFenetreEffective=parseInt(hauteurFenetre)+36;}
	if(browser.isSafari){hauteurFenetreEffective=parseInt(hauteurFenetre)}
	
	// position fenetre
	var top = (hauteurEcran-hauteurFenetreEffective)/2;	
	var left = (largeurEcran-largeurFenetreEffective)/2;

	// bug safari
	if(browser.isSafari && left==0){left=1}
	// fenetre
	var nouvelleFenetre=open(url,nom_fenetre,"width="+largeurFenetre+"px,height="+hauteurFenetre+"px,top="+top+"px,left="+left+"px,menubar=no,resizable=no,scrollbars="+scrollbar);
	nouvelleFenetre.focus();
}
/*--------------------------------------------------------------------------- /popup ------------------------------------------------------------------------*/
/*--------------------------------------------------------------------- preload rollover --------------------------------------------------------------------*/
function preload_rollover()
{
	var imgs_roll = document.getElementsByClassName("rollover_img");
	for(var i=0 ; i<imgs_roll.length ; i++)
	{
		new Img_rollover(imgs_roll[i]);
	}
}
/*--------------------------------------------------------------------- /preload rollover --------------------------------------------------------------------*/
/*--------------------------------------------------------------------- contour_image --------------------------------------------------------------------*/
function contour_image()
{
	var imgs_contour = document.getElementsByClassName("contour_image");
	for(var i=0 ; i<imgs_contour.length ; i++)
	{
		new Img_contour(imgs_contour[i]);
	}
}

Img_contour = Class.create();
Img_contour.prototype = {
	   initialize: function(img) {
			this.image = img;
			if(browser.isIE55)
			{
				this.width = this.image.width;
				this.height = this.image.height;
			}
			if(!browser.isIE55)
			{
				this.width = this.image.width-12;
				this.height = this.image.height-12;
			}
			this.rendu='<div class="rel"><div class="contour" style="width:'+ppx(this.width)+';height:'+ppx(this.height)+';"></div></div>';
			new Insertion.Before(this.image,this.rendu)
	   }
	};

/*--------------------------------------------------------------------- /contour_image --------------------------------------------------------------------*/
/*--------------------------------------------------------------------- toggle --------------------------------------------------------------------*/

var Toogle_anim = false

Toggle = Class.create();
Toggle.prototype = {
	   initialize: function(id_image,id_conteneur) {
			this.image = $(id_image);
			this.source = this.image.src;
			this.url = this.source.substring(0,this.source.lastIndexOf('/'));

			this.source_fermer = this.url+"/bt_fermer.gif";
			this.source_ouvrir = this.url+"/bt_ouvrir.gif";
			//alert(this.url)

			this.conteneur = $(id_conteneur);
			//this.anim = false;
			//Element.fixeElement(this.conteneur);
			if(!Element.hasClassName(this.conteneur,"ouvert"))
			{
				Element.setStyle(this.conteneur,{display:'none'});
			}
			this.etat_initial = Element.hasClassName(this.conteneur,"ouvert") ? true : false;// true ouvert, false ferme
			this.image.onclick = this.onclick.bindAsEventListener(this);
	   },
	  onclick: function(evt) {
		if(!Toogle_anim)
		 {
			 if(this.etat_initial)
			 {
				this.ferme()
				}
			 else
			 {
				 this.ouvre()
			}
		}
	   },
	   ouvre: function() {
		 this.image.src = this.source_fermer;
		if(browser.isMac)
		{
			Effect.BlindDown(this.conteneur,{duration:0.7, beforeStart:function() {Toogle_anim=true;}, afterFinish:function(){Toogle_anim=false;}});
		}
		else
		{
			new Rico.Effect.FadeTo(this.conteneur, 1.0, 800, 10);
			Effect.BlindDown(this.conteneur,{duration:0.7, beforeStart:function() {Toogle_anim=true;}, afterFinish:function(){Toogle_anim=false;}});
		}
		 this.etat_initial = true;
		  
	   },
	   ferme: function() {
		this.image.src = this.source_ouvrir;
		if(browser.isMac)
		{
			Effect.BlindUp(this.conteneur,{duration:0.7, beforeStart:function() {Toogle_anim=true;}, afterFinish:function(){Toogle_anim=false}});
		}
		else
		{
			new Rico.Effect.FadeTo(this.conteneur, 0.0, 600, 10);
			Effect.BlindUp(this.conteneur,{duration:0.7, beforeStart:function() {Toogle_anim=true;}, afterFinish:function(){Toogle_anim=false}});
		}
		this.etat_initial = false;
	   }
	};

/*--------------------------------------------------------------------- /toggle --------------------------------------------------------------------*/
/*--------------------------------------------------------------------- impression --------------------------------------------------------------------*/
var impression = new Array()
function imprimer()
{
	impression_prete = false;
	//alert(impression.length)
	if(impression.length > 0)
	{
		impression.each(function(objet){
			//alert(objet)
			if(objet.type == 'Toggle')
			{
				objet.each(function(toogle){
					toogle.ouvre()
				});
			}
			if(objet.type == 'Moox_2')
			{
				objet.each(function(moox_2){
					moox_2.impression()
				});
			}
		});
	}
	// 1000 car 800 pour anim bloc
	window.setTimeout("window.print()",1000)
}
/*--------------------------------------------------------------------- /impression --------------------------------------------------------------------*/

/*----- retour_accueil -----*/
// retour_accueil (flash)
function retour_accueil()
{
	document.location.href = '/public/'
}


/*---- css ----*/
function css(chemin,media)
{
	document.write('<link href="'+chemin+'" rel="stylesheet" type="text/css" media="'+media+'"/>')
}


/*--- parametre flash ---*/
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

/*--------------------------------------------------------------------------- CMS image ------------------------------------------------------------------------*/
// Test des images de visuels push liés aux articles

function loadImageIf (cont, type, id, lang) {
	pars = 'type='+type+'&id='+id+'&lang='+lang;
	Ag = new Ajax.Updater(
		cont,
		'/public/boatiful/html/transversal/test_image.php',
		{
			method : 'get',
			parameters : pars
		}
	);
}

/*--------------------------------------------------------------------------- loading ------------------------------------------------------------------------*/
// loading utilisé sur chaque page
function loading()
{
	preload_rollover();
	contour_image();
}

Event.observe(window,"load",loading,false)
/*--------------------------------------------------------------------------- /loading ------------------------------------------------------------------------*/