/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
|		
|		Copyright (c) 2008
|		Design + HTML/CSS/DOM JavaScript : Smart Agence
|		http://www.smartagence.com/
|		
\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */


// Running jQuery in no conflict mode
var $jQ = jQuery.noConflict();


function IEPNGFix() {
	/*
 
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}

};


/* ______________________[ 03 | Lancement d’une impression pour les navigateurs compatibles ]________________________ */

function DirectPrint() {
	if (window.print) self.print();
}


/* ______________________[ 04 | Miscellaneous ]________________________ */

function OpenPopup(url,nom,option) {
	window.open(url,nom,option);
}


/* ______________________[ 08 | Lancement des scripts ]________________________ */

window.onload=function() {
	IEPNGFix();
	/* IE 5-6 background flicker fix */
	try {document.execCommand('BackgroundImageCache', false, true);}
	catch(e) { }
}




/* ______________________[ MooTools parts ]________________________ */

//	We add MooTools stuff BEFORE jQuery to avoid strange script misbehaviours

function startGallery() {
	if(window.gallery) {
		try {
			var myGallery = new gallery($('myGallery'), {
				timed:true,delay: 5000,
				showArrows: true,
				showCarousel: false,
				textShowCarousel: 'Photos',
				embedLinks:true,
				lightbox:true
			});
			var mylightbox = new Lightbox();
		} catch(error){
			window.setTimeout("startGallery();",2500);
		}
	}else{
		window.gallery=true;
		
		if(this.ie){
		window.setTimeout("startGallery();",3000);
		}else{
		window.setTimeout("startGallery();",100);
		}
	}
}

function addMultiBox() {
		var box = {};
		box = new MultiBox('multibox', {descClassName: 'multiboxDesc',
						   onOpen:function() {$jQ("#SlideShow").cycle("pause");},
						   onClose:function() {$jQ("#SlideShow").cycle("resume");}
				});
};


window.addEvent('domready',function() {
		addMultiBox();
		startGallery();
});


/* ______________________[ jQuery parts ]________________________ */

$jQ(document).ready(function(){
	// we do not support MSIE < 6
	if(!$jQ.browser.msie || $jQ.browser.msie && $jQ.browser.version >= 6) {		
		jQ_CollapsibleBanner();
		$jQ("#SlideShow").cycle({fx: "scrollLeft",timeout:4000});
	}
	else {	// non-animated version for IE < 6
		CollapsibleBanner();
	}
});
 
 
function jQ_CollapsibleBanner() {
	var bExpand = false;
	var iHeight = $jQ("#Bandeau>img").height();
 	$jQ("#Bandeau").append('<a rel="resize"><span>Replier</span></a>');
	$jQ("#Bandeau a[rel=resize]").click(function() {
		if(bExpand) {
			$jQ("#Bandeau").animate({height:iHeight},"fast");
			$jQ(this).removeClass("folded").html("<span>Replier</span>");
			bExpand = false;
		}
		else {
			$jQ("#Bandeau").animate({height:"40px"},"fast");
			$jQ(this).addClass("folded").html("<span>D&eacute;plier</span>");
			bExpand = true;
		}
	});
};

/* For IE 5.x */
function CollapsibleBanner() {
	var oBandeau = document.getElementById("Bandeau");
	oBandeau.innerHTML += '<a rel="resize"><span>Replier</span></a>';
	var oLink = oBandeau.getElementsByTagName("a")[0];
	var bExpand = false;
	oLink.onclick = function() {
		if(bExpand) {
			oBandeau.className = "";
			this.innerHTML = "<span>Replier</span>";
			bExpand = false;
		}
		else {
			oBandeau.className = "folded";
			this.innerHTML = "<span>D&eacute;plier</span>";
			bExpand = true;
		}
	};
};

