//---< Accordion jQuery >---\\
/* ---- moved
jQuery().ready(function(){
	if(document.getElementById('menuNexto')){
		jQuery('#menuNexto').accordion({
			header: '.headNexto',
			active: false,
			alwaysOpen: true,
			navigation: true,
			event: 'mouseover',
			autoheight: false,
			speed: 1000,
			animated: 'slide'
		});
	}
});
---- moved ---- */

/*jQuery().ready(function(){
	if(document.getElementById('accordionNexto')){
		jQuery('#accordionNexto').accordionUp({
			header: '.title_content',
			active: false,
			alwaysOpen: true,
			navigation: true,
			event: 'mouseover',
			autoheight: true,
			speed: 250,
			animated: 'slide',
			selectedClass: 'title_content_on'
		});
	}
});*/

var ele_opened;
var myIndex;
var new_myIndex;
var radi1 = true;
var radi2 = true;
var height_content = new Array();
var height_title_content;
var height_hide_content;
var isActive = false;

function init_height_content(index)
{
    var i=0;
   
    if(radi1&&radi2){
    $(".title_content").each(function(){
            height_content[i] = height_title_content*i+height_hide_content;
            i++;
        });       
    }                                           
}


function slideAccordion(){
	if(!isActive){

		isActive = true;
	    var i = 0;
	    new_myIndex = $(".title_content").index($(this)[0]);
	   
		//---< Suppression des class RollOver >---\\
		$(".title_content").each(function(){
			$(this).removeClass("title_content_on");
		});
		
		//---< Application de la class Hover a la balise courante >---\\
		$(".title_content:eq("+new_myIndex+")").addClass("title_content_on");
		
	    offsetElement = new_myIndex;
	    if(new_myIndex < myIndex)
	    	offsetElement = myIndex;
	    if((myIndex != new_myIndex) && radi1 && radi2){
	        radi1 = false; //état fermeture
	        radi2 = false; //état ouverture
	           
	        $(".title_content:gt("+(offsetElement-1)+")").each(function(){
	        	$(this).css({position: "absolute",top: height_content[offsetElement+i]+"px"});
	            i++;
			});   
	        ele_opened.animate({height: "hide"}, 250, function(){
	        	radi1=true;
			}); //text hidden
	        ele_opened = $(this).siblings(".hide_content");
	        ele_opened.animate({height: "show"}, 250, function(){                                                   
				$(".title_content:gt("+(offsetElement-1)+")").each(function(){
					$(this).css("position","");
	                $(this).css("top","");
					});
				radi2=true;
				myIndex = new_myIndex;                                               
			});
		}
		isActive = false;
	}
}

$(document).ready(function(){
	ele_opened = $(".hide_content:eq(0)");
    height_title_content = $(".title_content:eq(0)").height();
    height_hide_content = $(".hide_content:eq(0)").height();

    $(".hide_content").hide();
    ele_opened.show();
    $(".title_content:eq(0)").addClass("title_content_on");
    myIndex = $(".title_content").index($(".title_content:eq(0)")[0]);

    init_height_content(myIndex);
   
    $(".title_content").hoverIntent({
        sensitivity: 20,
        interval: 250, 
        over: slideAccordion,
        out: function(){}
     });
});

