$(function(){
    /*$("h1").html(function(){
    
      // separate the text by spaces
      var text = $(this).text().split(" ");
    
      // drop the last word and store it in a variable
      var last = text.pop();
      if (text.length > 2) last = text.pop() + " " + last;
    
      // join the text back and if it has more than 1 word add the span tag
      // to the last word
      return text.join(" ") + (text.length > 0 ? " <span>"+last+"</span>" : last);   
    
    });*/

    $('a[href="#"]').live('click',function(e){
        e.preventDefault();
    });

    //-----------------------------------------------------------------------------------
    // Carrousel Accueil
    //-----------------------------------------------------------------------------------

    function fadeCarr(){

        clearTimeout(fade_timeout);

        var $carr = $('#carr-home');
        var $cur_slide = $carr.find('.cur-slide');
        var $next_slide = $cur_slide.next().show();

        //console.log($next_slide);

        $cur_slide.fadeOut(1500, function(){
            $(this).removeClass('cur-slide').clone().appendTo($carr);
            $(this).remove();

            $next_slide.addClass('cur-slide');


            fade_timeout = setTimeout(fadeCarr, 7000);
        });

    }
    if($('#carr-home li').length > 1){
        var fade_timeout = setTimeout(fadeCarr, 7000);
    }

    
});

function loadvideoMedias(url, width, height, bgcolor, id, txt){
    window.document.getElementById("video_medias_title").innerHTML = txt;
    loadvideo(url, width, height, bgcolor, id);
}

function loadvideo(url, width, height, bgcolor, id){
    var tmpSwf = "";
    tmpSwf = tmpSwf + '<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" align="middle">';
    tmpSwf = tmpSwf + '<PARAM name="allowScriptAccess" value="sameDomain" />';
    tmpSwf = tmpSwf + '<param name="allowFullScreen" value="true" />';
    tmpSwf = tmpSwf + '<PARAM name="movie" value="'+url+'" />';
    tmpSwf = tmpSwf + '<PARAM name="quality" value="high" />'
    tmpSwf = tmpSwf + '<PARAM name="scale" value="noscale" />'
    tmpSwf = tmpSwf + '<PARAM name="salign" value="lt" />'
    tmpSwf = tmpSwf + '<PARAM name="bgcolor" value="'+bgcolor+'" />'
    tmpSwf = tmpSwf + '<PARAM name="wmode" value="transparent" />'
    tmpSwf = tmpSwf + '<EMBED src="'+url+'" wmode="transparent" quality="high" scale="noscale" salign="lt" allowFullScreen="true" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
    tmpSwf = tmpSwf + '</OBJECT>'
    window.document.getElementById(id).innerHTML = tmpSwf;
}

function openTestimonial(testimonial_id){
    document.getElementById("div_testimonial_"+testimonial_id).style.display = 'block';
    document.getElementById("a_testimonial_show_"+testimonial_id).style.display = 'none';
}

function closeTestimonial(testimonial_id){
    document.getElementById("div_testimonial_"+testimonial_id).style.display = 'none';
    document.getElementById("a_testimonial_show_"+testimonial_id).style.display = 'block';
}

function TestimonialGotoPage(page){

    postData = '';
    postData += 'langue='+$('#testimonials_langue').val();
    postData += '&page='+page;
    postData += '&tri='+$('#testimonials_tri').val();   
    
    $("#testimonial_content").html('<IMG src="img/loading.gif" width="32" height="32">');

    $.ajax({
        type: "POST",
        url: "ajax/testimonials",
        data: postData,
        success: function(html){
            $("#testimonial_content").html(html);
        }
     });

}




