google.load("jquery", "1.4");
google.setOnLoadCallback(function() {
	
	$('a[href^="http://"]').attr("target", "_blank");
	
	// Rollover menu déroulant pour ie
	$('#banner li').hover(function() {
	  $(this).addClass('iehover');
	}, function() {
	  $(this).removeClass('iehover');
	});
	
	// Gestion des colonnes 
	$('#contents').css('padding','0 0 0 0');
	
	$('#leftbar .box,#leftbar .first_level').map(function(){
		var width = $('#leftbar').width();
		width = width+10;
		$('#contents').css('paddingLeft',''+width+'px');
	});
	$('#rightbar .box,#rightbar .first_level').map(function(){
		var width = $('#leftbar').width();
		width = width+10;
		$('#contents').css('paddingRight',''+width+'px');
	});	
	
	/*Masque le formulaire de commentaire */
	$('#form_add_comment form').hide().parent().click(function(){
		$(this).find('form').show();
	});
	
	/* resume à 100 lettre les descriptions*/
	$('.short_product').each(function(){
		$(this).find('p').html($(this).find('p').html().substring(0,220)+" […]");
	});
	
	/* Ajoute un bouton "Lire la suite"*/
	$('.news_event,#articles_list .chapo,.short_product').each(function(){
		var url = $(this).find('a').attr('href');
		$(this).find('p').append(" <a class='suite' href='"+url+"'>Lire la suite…</a>");
	});

	/* Style pour les boutons "Retour" */
	$("#contents").prepend($('a:contains(Retour)').addClass('btnRetour'));
	
	/* Calcul automatique de la largeur colx dans les linex dasn les #children_selector*/
	$('#children_selector>div').each(function(){
		var nouvelleLargeur = $(this).width() / $(this).children().size();
		$(this).children().width(nouvelleLargeur);
	});
	
	// Permet de placer les widget .before au dessus des contenus 
	$('#main').prepend($('.before'));

	
	// Supprimer le breadcrumb sur la page d'accueil
	$('.rubrique_sommaire_ .breadcrumb').remove();

	// Permet de rendre cliquable le logo
	$('#banner img').click(function(){
		window.open('http://'+window.location.hostname,'_self');
	}).hover().css('cursor','pointer');


// ==========
// = ACTUAL =
// ==========

/* Ajoute un bouton "Lire la suite"*/
$('.mediatheque .news_event').each(function(){
	var url = $(this).find('a').attr('href');
	$(this).find('img').wrap("<a href='"+url+"'></a>");
});


$('#main .boxlastelements .news_event:first').addClass('highlight');
$('#form_add_comment form').show();

$('#leftbar').append($('#form_add_comment,.vos_photos_du_multi50 #article .formulaire'));


$('#leftbar .formulaire,#leftbar #form_add_comment').wrap('<div class="box"></div>');


	// pagination des commentaires
	var comments = new Array();
	var compteur=0;
	$("#list_comments .comment").each(function(){
		var contenu = $(this).html();
		comments[compteur] = contenu;
		compteur++;;
	}).remove();
	
	comments.reverse();
	
	var display = "";
	for (var i=0; i < comments.length; i++) {
		display += "<div class='comment'>"+comments[i]+"</div>";
	}
	
	$("#list_comments").after(display);
	$("#list_comments").after("<div id='list_counter'></div>");
	// $(".comment").quickpaginate({ perpage: 4, showcounter: true, pager : $("#list_counter") });
	
	
	
	if($('body').attr('class') == 'rubrique_sommaire_' || $('body').attr('class') == 'actualite'){
		var urlImg = $('.rubrique_sommaire_ .boxlastelements:first img , .actualite #news img').attr('src');
		urlImg = urlImg.replace('thumbnails/','');
		$('.rubrique_sommaire_ #main').prepend('<div class="actu_photo"><img src='+urlImg+' width="610" /></div>');
		$('.actualite #main #chapo').after('<div class="actu_photo"><img src='+urlImg+' width="610" /></div>');	
	}

	
	
});






