
//------------------ INFO BULLE -----------------------------//

this.tooltip = function(){
  /* CONFIG */     
    xOffset = 10;
    yOffset = 20;
    var title;
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result    
  /* END CONFIG */    

  $("a.info-bulle").hover(function(e){
    //this.title = "";                    
    $("body").append("<p id='tooltip'>"+ this.title +"</p>");
    title = this.title;
    $(this).removeAttr("title");
    $("#tooltip")
      .css("top",(e.pageY - xOffset) + "px")
      .css("left",(e.pageX + yOffset) + "px")
      .fadeIn("fast");    
    },

  function(){
    $(this).attr("title", title);
    $("#tooltip").remove();
    });  
  $("a.info-bulle").mousemove(function(e){
      
    $("#tooltip")
      .css("top",(e.pageY - xOffset) + "px")
      .css("left",(e.pageX + yOffset) + "px");
    
  });     
  
};
//---------------------------------------------------------------//



jQuery(document).ready(function($) {

//------- CALL FUNCTION INFO-BULLE -------------------------------//
tooltip();


//---COMPATIBILITY PLACEHOLDER  ALL NAIVIGATOR -------------------//

$('[placeholder]').focus(function() {
  var input = $(this);
  if (input.val() == input.attr('placeholder')) {
    input.val('');
    input.removeClass('placeholder');
  }
}).blur(function() {
  var input = $(this);
  if (input.val() == '' || input.val() == input.attr('placeholder')) {
    input.addClass('placeholder');
    input.val(input.attr('placeholder'));
  }
}).blur().parents('form').submit(function() {
  $(this).find('[placeholder]').each(function() {
    var input = $(this);
    if (input.val() == input.attr('placeholder')) {
      input.val('');
    }
  })
});
//---------------------------------------------------------------//


//-------------------- LIGHT-BOX(fancybox) ------------------------//
    
    
    $(".various").fancybox({
		maxWidth	: 800,
		maxHeight	: 600,
                                        padding       : '2',
		fitToView	: false,
		width		: '70%',
		height		: '70%',
		autoSize	: false,
		closeClick	: false,
		openEffect	: 'elastic',
		closeEffect	: 'elastic'
	});
    
   //lightbox for the gallery sidebar
    $(".fancybox-thumb").fancybox({
        openEffect                :'elastic',
        closeEffect                :'elastic',
        prevEffect	: 'none',
        nextEffect	: 'none',
        padding                  : '2',
        helpers	: {
            title	: {
                type: 'outside'
            },
            overlay	: {
                opacity : 0.8,
                css : {
                    'background-color' : '#000'
                }
            },
            thumbs	: {
                width	: 50,
                height	: 50
            }
        }
    });
    
  //Zoombox lightbox pour la video
    $('a.zoombox').zoombox({
        theme       : 'zoombox',        //available themes : zoombox,lightbox, prettyphoto, darkprettyphoto, simple
        opacity     : 0.8,              // Black overlay opacity
        duration    : 400,              // Animation duration
        animation   : false,             // Do we have to animate the box ?
        autoplay : true                // Autoplay for video
        
   
    });
//---------------------------------------------------------------//
    
    
//------------------ CAROUSEL BANNER ---------------------------//

     $(function() {

        $('#content-banner').after('<div id="nav" class="nav">').cycle({
            fx:     'fade',
            speed:  '1000',
            timeout: 6000,
            pager:  '#nav',
            slideExpr: 'img',
            before: onBefore
        });

            function onBefore() {
            
            var name = $(this).attr('alt');
            if(name == ""){
                $('#title').fadeOut();
            }else{
                $("#title").fadeIn();
                $('#title').html(name);
            }
           
        }
    });
    
//---------------------------------------------------------------//


//------------------ HOME EVENT EFFECT HOVER --------------------//

    var heightOriginal, heightText; 
    
    //affichage description evenements sur page d'accueil
    $(".article-subcontent, .box").mouseenter(function(){
        var titleBox = $(".date-article, .title-box", this);
        var textDescription = $(".description-article, .description-box", this);
        
        heightOriginal = titleBox.height();
        heightText = textDescription.outerHeight();
        if($(this).attr("class") == "article-subcontent"){heightText = heightText+30}
        
        //alert(heightText);
      $(".date-article, .title-box",this).stop().animate({height: heightText},250,function(){
                    textDescription.fadeIn(200);
                });
      
    });

    $(".article-subcontent, .box").mouseleave(function(){
        var textDescription = $(".description-article, .description-box", this);
        textDescription.hide();
        $(".date-article, .title-box", this).stop().animate({height:heightOriginal});
      
    })
    
 //---------------------------------------------------------------//
 
});

/*Function popUp*/

function popUp(URL) {
	var day = new Date();
	var id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=720,height=630,left = 370,top = 247');");
}
