var format = "ft";
var offre = "ot";
var duree = "dt";
var zone = "zt";
var profil = "pt";
var offre_abo = $("#abo li:hidden").size(); 

$(function(){
	$("#abo li").hide();
    $("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
	
    $('.format').each(function() {
        $(this).click(function() {
			// alert ($(this).attr("name"));
			format = $(this).val();
			$("#abo li").hide();
			if ( $(".profil").is(':checked')) {
                profil="pt";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            } else {
                profil="pa";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            }
			offre_abo = $("#abo li:hidden").size();
            if($("#abo li").size()-offre_abo<1){
                $("#abo li.not").show();
            }else{
                $("#abo li.not").hide();
            }
        })
    });
	$('.zone').each(function() {
        $(this).click(function() {
			zone = $(this).val();
			$("#abo li").hide();
			if ( $(".profil").is(':checked')) {
                profil="pt";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            } else {
                profil="pa";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            }
			offre_abo = $("#abo li:hidden").size();
            if($("#abo li").size()-offre_abo<1){
                $("#abo li.not").show();
            }else{
                $("#abo li.not").hide();
            }
        })
    });
	$('.offre').each(function() {
        $(this).click(function() {
			offre = $(this).val();
			$("#abo li").hide();
			if ( $(".profil").is(':checked')) {
                profil="pt";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            } else {
                profil="pa";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            }
			offre_abo = $("#abo li:hidden").size();
            if($("#abo li").size()-offre_abo<1){
                $("#abo li.not").show();
            }else{
                $("#abo li.not").hide();
            }
        })
    });
	$('.duree').each(function() {
        $(this).click(function() {
			duree = $(this).val();
			$("#abo li").hide();
			if ( $(".profil").is(':checked')) {
                profil="pt";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            } else {
                profil="pa";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            }
			offre_abo = $("#abo li:hidden").size();
            if($("#abo li").size()-offre_abo<1){
                $("#abo li.not").show();
            }else{
                $("#abo li.not").hide();
            }
        })
    });
	$('.profil').each(function() {
        $(this).click(function() {
			
			$("#abo li").hide();
			if ( $(".profil").is(':checked')) {
                profil="pt";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            } else {
                profil="pa";
				$("#abo li."+format+"."+offre+"."+duree+"."+zone+"."+profil).show();
            }
			offre_abo = $("#abo li:hidden").size();
            if($("#abo li").size()-offre_abo<1){
                $("#abo li.not").show();
            }else{
                $("#abo li.not").hide();
            }
        })
    });

    
    if($('#carousel-en-image').length){
		$('#carousel-en-image').jcarousel({'scroll':2});
	}
	
	if($('#slider').length){
	    $('#slider').s3Slider({
	        timeOut: 3000
	    });
	}

	if($('#gallery').length){
	    $('#gallery a').lightBox({
		imageLoading: 'http://www.magazine-litteraire.com/images/lightbox-0.5/lightbox-ico-loading.gif',
		imageBtnClose: 'http://www.magazine-litteraire.com/images/lightbox-0.5/lightbox-btn-close.gif',
		imageBtnPrev: 'http://www.magazine-litteraire.com/images/lightbox-0.5/lightbox-btn-prev.gif',
		imageBtnNext: 'http://www.magazine-litteraire.com/images/lightbox-0.5/lightbox-btn-next.gif',
		containerResizeSpeed: 350,
		txtImage: 'Image',
		txtOf: 'sur'
	    });
	}
});


$(document).ready(function() {
	$(".nav3").hide();
	$(".nav3#connexion").show();
    $(".nav31").click(function(){
    	$(".nav3").hide();
    	$(".nav3#recherche").show();
    });
    $(".nav32").click(function(){
    	$(".nav3").hide();
    	$(".nav3#connexion").show();
    });
    $(".form_con31").click(function(){
    	$(".con").hide();
    	$(".con31").show();
    });
    $(".form_con32").click(function(){
    	$(".con").hide();
    	$(".con32").show();
    });
    $(".form_con33").click(function(){
    	$(".con").hide();
    	$(".con33").show();
    });
    $(".nav33").click(function(){
    	$(".nav3").hide();
    	$(".nav3#aide").show();
   	});
   	
    $(".accordion").accordion();
    
	$('#diaporama').anythingSlider({
		width : 464,
		autoPlay : false,
		resizeContents : false
	});
	if(!$('.nopager').length){
		if($('#content .box').length){
	   		$('#content .box').pager('li').not('.banniere').not('.une');
		}
    }
    /*if (topicId != null && topicId!=""){
    	$("#content ul.box").append('<li><a id="comment" href="http://www.facebook.com/topic.php?uid=17405595782&topic='+topicId+'" target="_blank" rel="nofollow">Proposer un'+typeContenu+'</a></li>');
    }*/
});
