$(document).ready(function(){
	
	//Correction de styles
	if($("ul.nav-fixe")) {
		$("ul.nav-fixe li:first").css("border", "0px");
		$("ul.nav-fixe li:last").css("padding-right", "0px");
	}
	if($("ul.breadcrumb")) {
		$("ul.breadcrumb li:first").css("background", "none");
		$("ul.breadcrumb li:last a").css("text-decoration", "none");
	}
	if($("ul#quick-link")) {
		$("ul#quick-link li:last").css("border", "0px");
	}
	if($("div.content")) {
		$("div.content p + ul").css("margin-top", "-15px");
		$("div.content p + ol").css("margin-top", "-15px");
	}
	if($("div.site-map")) {
		$("div.site-map ul.colonne:first").css("margin-right", "20px");
		$("div.site-map ul.colonne:first").css("border-right", "1px solid #CCE5F3");
	}

	//Changement de la grosseur de texte
	var onepixel = 6.26;//1px in %
	$("a.bt-font-size").each(function(){		
		$(this).click(function(){
			//Get size type
			var sizeType = $(this).attr("rel");
			switch(sizeType) {
				case "grand":
					newSize = 11.5;//px
					break;
				case "moyen":
					newSize = 11;//px
					break;
				case "normal":
				default:
					newSize = 10;//px
			}
			var formattedSize = (newSize*onepixel)+"%";
			$("body").css("font-size", formattedSize);
			putcookie("font-size", formattedSize, 30);
		});
	});
	
	//Set last size
	var cookieSize = getcookie("font-size");
	//alert(cookieSize);
	if(cookieSize!=null) {
		$("body").css("font-size", cookieSize);
	}
	
});

$(window).load(function(){
	        $("a.accordeon").attr("href","javascript:void(0);");
	        $("a.accordeon").click(function(){
                if ($(this).parent().hasClass("ItemOuvert")){
                    $(this).parent().removeClass("ItemOuvert");
                    $(this).parent().addClass("ItemFerme");
                }else{
                    $(this).parent().removeClass("ItemFerme");
                    $(this).parent().addClass("ItemOuvert");
                }
                $(this).parent().children("ul").animate({height:'toggle'}, 500);
	        });
            $('#q').keypress(function(e){
	            if(e.which == 13)
	                redirectToSearchPage();
	        });
	        $('#btnRecherche').click(function(){
	            redirectToSearchPage();
	        });
        });

function putcookie(name, value, days)
{
  var expire = "";
  if(days != null) {
    expire = new Date((new Date()) + days);
    expire = "; expires=" + expire.toGMTString()+";";
  }
  document.cookie = name + "=" + escape(value) + expire + "path=/";
}
function getcookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}