var slideCount = 0;
var slideIndex = 0;
var slideWidth = 445;
var slideDelay = 6000;
var slideStopped = false;

$(document).ready(function(){

	$('#menu li').hoverIntent({
		sensitivity: 15,
		interval: 10,
		over: addHoverClass,
		timeout: 20,
		out: removeHoverClass
	});
	
	$('#menu li ul li').hover(addHoverClass, removeHoverClass);

    $('#q').DefaultValue('Rechercher...');
    $('#email').DefaultValue('Adresse email...');
    
    if($('#page').hasClass('homepage'))
    {
        slideCount = $('#slides-text').children().length;
  
        $('#slide-control-back').click(function(){
            stopSlideShow();
            slideLeft();
            return false;
        });
    
        $('#slide-control-foreward').click(function(){
            stopSlideShow();
            slideRight();
            return false;
        });
    
        startSlideShow();
    }
    
    $('#themes li').click(function(){
        window.location = '/' + $(this).find('a').attr('href');
    });
    
    $('#slides-text li').click(function(){
        window.location = $(this).find('a').attr('href');
    });

    
    
});

function stopSlideShow()
{
    slideStopped = true;
}

function startSlideShow()
{
    setTimeout(slideNext, slideDelay);
}

function slideNext()
{
    if(!slideStopped)
    {
        slideRight();
        setTimeout(slideNext, slideDelay);
    }
}

function slideLeft()
{
    if(slideIndex == 0)
        slideIndex = slideCount - 1;
    else
        slideIndex--;
        
    $('.slides').animate({
        left: - slideIndex * slideWidth
    }, 500);

}

function slideRight()
{
    if(slideIndex == (slideCount - 1))
        slideIndex = 0;
    else
        slideIndex++;

    $('.slides').animate({
        left: - slideIndex * slideWidth
    }, 500);
}

function addHoverClass()
{
	$(this).addClass('hover');
}

function removeHoverClass()
{
	$(this).removeClass('hover');
}



Cufon.replace('h2,h3', {
    fontFamily: 'helvetica'
});
Cufon.replace('#baseline', {
    fontFamily: 'vectora'
});
Cufon.replace('#slideshow h3', {
    fontFamily: 'vectora'
});


/*
Cufon.replace('#content-header div, #content-header p', {
    fontFamily: 'helvetica',
    fontSize: '12px'
});
*/

