(function($) {
$(document).ready(function(){
	/* Masquage add_block */
	if(document.getElementById('addBlockContainer')){
		$("#sorter").before('<p id="addBlockLink" class="addLink"><a href="#TB_inline?height=100&amp;width=250&amp;inlineId=addBlockContainer" class="button thickbox">Ajouter un bloc de contenu</a></p><br/>');
	};
	$("#addBlockContainer").css('position','absolute');
	$("#addBlockContainer").css('visibility','hidden');
	
	var browsercap = navigator.userAgent;

	/* fix ie < 7 hr decoration bug*/
	$("hr").wrap('<div class="hr"></div>');

	/* css 2.1 pseudo class for ie */
	$("#page #nav li:last-child span").css('position','absolute');
	$("#page #nav li:last-child span").css('left','-5000px');

	$("#breadcrumb li:last-child a").css('color','#fff');
	$("#breadcrumb li:last-child a").css('text-decoration','none');
  
  /* Recherche commercant label date*/
	/*$("#annuaire p.date input").each(function(){
	  if(!$(this).val())
		{
		  $(this).attr('value',$(this).next().html());
		}
		$(this).next().css('display','none');
		$(this).click(function() {
	      if ($(this).val() == $(this).next().html()){
	        $(this).val('');
	      }
	    });
	    $(this).blur(function() {
	      if ($(this).val() == '')
	      {
	        $(this).val($(this).next().html());
	      }
	    });
	});*/
	/*---------------------------------------------------------*/  

	/*init sliding div*/
	$(".expand").prev().each(function(){
		$(".expand").css("display","none");
		$(".expand").prev().css('cursor','pointer');
	});

	/*sliding actions*/
	$(".expand").prev().toggle(
		function(){$(this).next().show(100);},
		function(){$(this).next().hide(100);}
	);

	$(".expand:first").show();
	

	/* ajoute un target _blank au lien avec une classe external */
	$("a[rel='external'], a[rel='document']")
		.attr({ title: "s'ouvre dans une nouvelle fen\u00EAtre" })
		.click(function() { window.open($(this).attr('href')); return false; });
	/*--------------------*/
	
	//try{$(document).pngFix();}catch(err){}
  
  /* animation flash annuaire*/
  if(document.getElementById($("#home #annuaire").attr('id'))){
    $("#home #annuaire form").attr('class', 'js-enabled');
    $("#home #annuaire h2").attr('id', 'anim-annuaire');
    var so = new SWFObject("/flash/annuaire.swf", "swf-annuaire", "315px", "115px", "8", "#FFFFFF");
		so.addParam("scale", "noscale");
    so.addParam("wmode", "transparent");
		so.write("anim-annuaire");
  }
  /*--------------------------*/
  
  
   /* gestion message ovpi */
	if(document.getElementById('ovpi')){
    $('#ovpi').focus();
		$('#ovpi').attr('class', 'js-enabled');
		$('#ovpi').prepend('<p id="js-close-ovpi"><a href="#" class="close">Fermer</a></p>');
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		  $("body","html").css({height: "100%", width: "98%"});
		  if (document.getElementById("HideSelect") === null) {//iframe to hide select elements in ie6
      $("html").css("overflow","hidden");
			$("body").append("<iframe id='HideSelect'></iframe><div id='trame'></div>");
		  }
		}else{//all others
		  if(document.getElementById("TB_overlay") === null){
			$("body").append("<div id='trame'></div>");
		  }
		}
    $('a.close, #trame').click(function(){
			if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
				$('#HideSelect').hide();
        $("html").css("overflow","auto");
			}
			$('#ovpi').fadeOut(300);
			$('#trame').fadeOut(300);
		});
    
	}
	/*--------------------------*/
  
  /* animation flash annuaire*/
  if($("#home").length == 1){
    $('body').prepend('<div id="cheque-kdo"></a>')
    var so = new SWFObject("/flash/cheque-kdo.swf", "cheque-kdo", "470px", "300px", "10", "#FFFFFF");
		so.addParam("scale", "noscale");
    so.addParam("wmode", "transparent");
		so.write("cheque-kdo");
  }
  /*--------------------------*/
  
   /* gestion tooltips  */
  if($('.adhesion').length != 0)
  {
    $('.adhesion ul').attr('class', 'tooltip');
    $('.adhesion li').tooltip({
  		track: true,
      showURL: false,  
      bodyHandler: function() { 
          return $(this).html(); 
      },
      fade: '250'
  	});
  }  
  
	
});
})(jQuery);