﻿/*jquery*/
$(document).ready(function () {
	
	$(".box").each(function () {
		var div = $("div", this);
		$("h2 a", this).toggle(function () {
			div.hide(250);//removeClass("none");
		}, function () {
			div.show(250);//addClass("none");
		});
	});
	
	/*
	// with custom options
	$("#image_rubrique").before('<div id="slide_nav">').cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    next: '#image_rubrique',
	    pager: '#slide_nav',
	    after: function () {
	    	$("#image_rubrique").animate({"height":$(this).height()+"px"});
	    }
	});
	*/
		
	if (!!$("#image_rubrique img").length) {
		
		$("#image_rubrique").css("background-image","url("+ $("#image_rubrique img").attr("src") +")");
		
		if ($("#image_rubrique img").length != 1) {
			$("#image_rubrique").append('<p id="slide_nav">');
			$("#image_rubrique img").each(function () {
				$(this).appendTo("#slide_nav");
				
				$(this).click(function () {
					$("#image_rubrique").css("background-image","url("+ $(this).attr("src") +")");
				});
			});
		}
		else {
			$("#image_rubrique img").remove();
		}
	}
	else {
		$("#image_rubrique").css("display","none");
		var g = $("#gauche_rubrique");
		if(g.height() > 800) { 
			g.attr("style","width:600px!important");
		}
	}
	
	
	if($("#gauche_rubrique").height() > 800) {
		$("#gauche_rubrique h3 + div").css("display","none");
		$("#gauche_rubrique h3").css("cursor","pointer");
		$("#gauche_rubrique h3").toggle(function () {
			$(this).next("div").css("display","block");
			return false;
		},function () {
			$(this).next("div").css("display","none");
			return false;
		});
	}
	
	// ouverture externe des pdfs
	$("a[href$=pdf]").attr("target","_blank");
	
	
	/**
	 *	FIX pour IE6
	 */
	if ($.browser.msie && !window.JSON) {
	
		function mouseenter () {
			this.className = this.className.replace("hover","") + " hover";
		}
		
		function mouseleave () {
			this.className = this.className.replace("hover","");
		}
	
		var ul = document.getElementById("menu"),
			li = [], liTmp = ul.getElementsByTagName("li");
			
		for (var i = 0, il = liTmp.length; i < il; i++) {
			if (liTmp[i].id) {
				li.push(liTmp[i]);
			}
		}
		
		for (var n = 0, nl = li.length; n < nl; n++) {
			//li[n].onmouseover = mouseenter;
			li[n].onmouseenter = mouseenter;
			li[n].onmouseleave = mouseleave;
		}
	}
});

