var slideCount = 0;
var slideIndex = 0;
var slideWidth = 445;
var slideDelay = 6000;
var slideStopped = false;
        
var J = jQuery.noConflict();
J(document).ready(function(){

	J('#menu li').hoverIntent({
		sensitivity: 15,
		interval: 10,
		over: addHoverClass,
		timeout: 20,
		out: removeHoverClass
	});
	
	J('#menu li ul li').hover(addHoverClass, removeHoverClass);

 20    // J('#q').DefaultValue('Rechercher...');
    var debut=true;
    J('#q').focus(function(){
        if (debut==true){
        J('#q').val('');
         debut=false;
        }
    });
    J('#email').DefaultValue('Adresse email...');
    
    if(J('#page').hasClass('homepage'))
    {
        slideCount = J('#slides-text').children().length;
  
        J('#slide-control-back').click(function(){
            stopSlideShow();
            slideLeft();
            return false;
        });
    
        J('#slide-control-foreward').click(function(){
            stopSlideShow();
            slideRight();
            return false;
        });
    
        startSlideShow();
    }
    
    J('#themes li').click(function(){
        window.location = '/' + J(this).find('a').attr('href');
    });
    
    J('#slides-text li').click(function(){
        window.location = J(this).find('a').attr('href');
    });
     J('div.temoignage').click(function(){
        window.location = J(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--;
        
    J('.slides').animate({
        left: - slideIndex * slideWidth
    }, 500);

}

function slideRight()
{
    if(slideIndex == (slideCount - 1))
        slideIndex = 0;
    else
        slideIndex++;

    J('.slides').animate({
        left: - slideIndex * slideWidth
    }, 500);
}

function addHoverClass()
{
	J(this).addClass('hover');
}

function removeHoverClass()
{
	J(this).removeClass('hover');
}



Cufon.replace('h2,h3', {
    fontFamily: 'DIN Next LT Pro'
});
Cufon.replace('#baseline', {
    fontFamily: 'DINmedium'
});
/*
Cufon.replace('#slideshow h3', {
    fontFamily: 'vectora'
});
Cufon.replace('#content-header div, #content-header p', {
    fontFamily: 'helvetica',
    fontSize: '12px'
});
*/


