$(document).ready(function() {
	
    $('.one-classifield').hover(function() {
        $(this).addClass("class-over");
    },
    function() {
        $(this).removeClass("class-over");
    });
	
    $('.one-classifield  > *:not(.bloc-mini-img)').click(function() {
		
        url = $(this).children('tbody').children('tr').children('td.td-right').children('strong').children('a').attr('href');
		
        document.location = url;
    });
	
    $('#vivalur-last-classified h2').text("Dernières "+$('#vivalur-last-classified h2').text());
	
    //$('.hidden-classifield').hide();
	
    $('.bloc-mini-img > img').click(
        function(e) {
			
            elt = $(this);
            div = $(elt).parents('div').parents('div').children('table').children('tbody').children('tr').children('td');
			
            ulPhoto = $(div).children('ul.liPhoto');// on selection l'element ul qui correspond
			
            switch ($(elt).attr('class')) {
                case 'next':
				
                    liVisible = $(ulPhoto).children('li:visible');
                    nextLi = $(liVisible).next('li');
				
                    $(liVisible).hide();
                    $(nextLi).show(50);
				
                    if(!$(nextLi).next('li:hidden').html()) {
                        $(elt).parents('div').children('img.next-disable').show();
                        $(elt).parents('div').children('img.next').hide();
                    }
				
                    if($(nextLi).prev('li:hidden').html() != null) {
                        $(elt).parents('div').children('img.prev').show();
                        $(elt).parents('div').children('img.prev-disable').hide();
                    }
				
                    break;
                case 'prev':
				
                    liVisible = $(ulPhoto).children('li:visible');
                    prevLi = $(liVisible).prev('li');
				
                    $(liVisible).hide();
                    $(prevLi).show(50);
				
                    if(!$(prevLi).prev('li:hidden').html()) {
                        $(elt).parents('div').children('img.prev-disable').show();
                        $(elt).parents('div').children('img.prev').hide();
                    }
				
                    if($(prevLi).next('li:hidden').html() != null) {
                        $(elt).parents('div').children('img.next').show();
                        $(elt).parents('div').children('img.next-disable').hide();
                    }
				
                    break;
            }// end of switch
			
        }// end of function
		
        );//end of click

    // On charge les maps
    $.get('/home/map?idMap=franceMap', function(data) {$('#content-annonce-france').append(data);});
    $.get('/home/map?idMap=idfMap', function(data) {$('#content-annonce-france').append(data);});
    $.get('/home/map?idMap=corseMap', function(data) {$('#content-annonce-france').append(data);});

});


    
    
/*
function voirClassified(){
	
	// le nombre d'annonce affichee
	nbElt = $('.one-classifield:visible').size();
	
	lastVisibleElt = $('.one-classifield:visible:last');
	firstHiddenElt = lastVisibleElt.next(".hidden-classifield"); 
	
	nbEltShowed = 0;
	EltToShow = firstHiddenElt;
	for(i=0;i<=nbElt;i++)
	{
		if(EltToShow.text() != "") {
			EltToShow.show();
			EltToShow = EltToShow.next(".hidden-classifield");
			nbEltShowed++;
		} else {
			break;
		}
	}
	
	var nbEltHidded = 0;
	$('.one-classifield:visible').each(function(){
		
		
		if(nbEltHidded < nbEltShowed) {
			$(this).hide();
		}
		
		nbEltHidded++;
	});
	
};*/

