function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function updateTweet(){
	jQtsara.get("/index.php?id=133&no_cache=1", function(data){
		jQtsara('div#tweetUpdate').html('');
		jQtsara('div#tweetUpdate').html( data );		
		jQtsara('div#tweetUpdate').fadeIn();
		
		
		
	});
	
	setTimeout("updateTweet();","18000");
}


// When the document loads do everything inside here ...
	   var jQtsara = jQuery.noConflict();

	  jQtsara(document).ready(function(){
	  
		if( jQtsara('form.form_jqtransform') && jQtsara('form.form_jqtransform').length > 0 ){
			jQtsara('form.form_jqtransform').jqTransform({imgPath:'jqtransformplugin/img/'});
		}
		
		if( jQtsara('a.inframe').length > 0 ){
			jQtsara('a.inframe').click(function() {
				var e=jQtsara(this);
				var iframe=e.next('iframe');

				if (!e.data('state')) {	//if state is undefined

					e.data('state','open'); //set the state to 'open'

					// Extract the frame height from the rel attribute
					var frameHeight=e.attr('rel');
					var pat1 = new RegExp('height:');
					pat1.test(frameHeight);
					frameHeight=RegExp.rightContext;
					var pat2 = new RegExp('px');
					pat2.test(frameHeight);
					frameHeight = RegExp.leftContext;
					if ( !frameHeight || (Math.ceil(frameHeight)!=Math.floor(frameHeight)) ) {
						//if it's null or not an integer
						frameHeight = '550'; //default frame height, in case none is specified
					};
					frameHeight += 'px';

					frameWidth = '100%';

					// Insert the iframe just after the link
					e.after('<iframe style="width:'+frameWidth+'; height:'+frameHeight+'; border:solid 1px #ccc; margin-bottom:1em; background:#fff;" src=' + e.attr('href') + ' frameborder="0" ></iframe>');

					iframe.css('display', 'none');
					// Insert the "loading..." text
					iframe.before(' <small class="quiet"> Loading...</small>')
					iframe.load(function(){	//once content was loaded
						iframe.slideDown(500);	//slide it down
						iframe.prev('small').remove();	//remove the 'loading...'
					});
					e.attr('title','Hide');	//set the link title to 'Hide'
				}
				else if(e.data('state')=='closed') { //if state is 'closed'
					e.data('state', 'open');
					e.next('iframe').slideDown(500);
					e.attr('title','Hide');
				}
				else if(e.data('state')=='open') { //if state is 'open'
					e.data('state', 'closed');
					e.next('iframe').slideUp(500);
					e.attr('title','Show');
				}
				return false;
			});
		}
		
		
		if( jQtsara('.item_partenaires').length > 0 ){
			//move the image in pixel
			var move = -15;
			
			//zoom percentage, 1.2 =120%
			var zoom = 1.2;

			//On mouse over those thumbnail
			jQtsara('.item_partenaires').hover(function() {
				
				//Set the width and height according to the zoom percentage
				width = jQtsara('.item_partenaires').width() * zoom;
				height = jQtsara('.item_partenaires').height() * zoom;
				
				//Move and zoom the image
				jQtsara(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
				
				//Display the caption
				jQtsara(this).find('div.caption_partenaires').stop(false,true).fadeIn(200);
			},
			function() {
				//Reset the image
				jQtsara(this).find('img').stop(false,true).animate({'width':jQtsara('.item').width(), 'height':jQtsara('.item').height(), 'top':'0', 'left':'0'}, {duration:100});	

				//Hide the caption
				jQtsara(this).find('div.caption_partenaires').stop(false,true).fadeOut(200);
			});
		}
		
		if( jQtsara('#topnav').length > 0 ) {
			jQtsara("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag
		
			jQtsara("#topnav li").each(function() { //For each list item...
				var linkText = jQtsara(this).find("a").html(); //Find the text inside of the a tag
				jQtsara(this).find("span").show().html(linkText); //Add the text in the span tag
			}); 
			
			jQtsara("#topnav li").hover(function() {	//On hover...
				jQtsara(this).find("span").stop().animate({ 
					marginTop: "-40" //Find the span tag and move it up 40 pixels
				}, 250);
			} , function() { //On hover out...
				jQtsara(this).find("span").stop().animate({
					marginTop: "0" //Move the span back to its original state (0px)
				}, 250);
			});
		}
	
		

      
        //UPDATE HTML RSS via AJAX
        if( jQtsara('div#ajaxRss').length > 0 ) {
            jQtsara.get("/index.php?id=171&no_cache=1", function(data){
                //alert("Data Loaded: "+   data);
                jQtsara('div#ajaxRss').html( data );
                jQtsara('div#ajaxRss').removeClass();            
                jQtsara('div#ajaxRss #rsswidget').accordion({ 
                    active: 0, 
                    header: 'h4', 
                    navigation: true,   
                    autoheight: false
                });
            });
        }
		
		/*if( jQtsara('div#tweetUpdate').length > 0 ){
		
			updateTweet();
		
		}*/
		
		if( jQtsara(':text[@name="tx_ablinklist_pi1[label]"]').length > 0 ) {
            jQtsara(':text[@name="tx_ablinklist_pi1[label]"]').focus();
        }
        
        //Update Picasa via AJax
        if( jQtsara('div#ajaxPicasaAlbum').length > 0 ){
            jQtsara.get("/index.php?id=132&no_cache=1", function(data){
                //alert("Data Loaded: "+   data);
                jQtsara('div#ajaxPicasaAlbum').html( data );
                jQtsara('div#ajaxPicasaAlbum').removeClass();            
                jQtsara("div#ajaxPicasaAlbum div.scrollable").scrollable({
                    size: 3,
                    items: '#thumbs',  
                    hoverClass: 'hover'
                });
            });
        }
        
        //Update twitter via AJax
        /*if( jQtsara('div#ajaxTwitter')  ) {
            jQtsara.get("/index.php?id=133&no_cache=1", function(data){
                //alert("Data Loaded: "+   data);
                jQtsara('div#ajaxTwitter').html( data );
                jQtsara('div#ajaxTwitter').removeClass();            
            });
        }*/
        
        //Clic sur Moteur de recherche
        jQtsara('#bt_moteur_recherche_google').click( function( i ) {
            
                
               
                
                var actionGoogle = jQtsara('#ACTIONGOOGLE').val();
                var data = '?id='+actionGoogle+'&cx=partner-pub-0184608766708661:hq1dc6-hd28&cof=FORID:10&ie=ISO-8859-1&q='+escape(jQtsara('#text_mr').val())+'&sa=Rechercher';
                jQtsara('#moteur_recherche').attr('action',data);
                jQtsara('#moteur_recherche').submit(); 
                
                return false;                
            
        } );
        
        //Clic sur Moteur de recherche
        jQtsara('#form_google').submit( function( i ) {
            
                
               
                
                var actionGoogle = jQtsara(this).find('#ACTIONGOOGLE').val();
                var data = '?id='+actionGoogle+'&cx=partner-pub-0184608766708661:hq1dc6-hd28&cof=FORID:10&ie=ISO-8859-1&q='+escape(jQtsara('#text_mr').val())+'&sa=Rechercher';
                /*jQtsara('#moteur_recherche').attr('action',data);
                jQtsara('#moteur_recherche').submit(); */
                
                window.location.href = data;
                
                return false;                
            
        } );
        
        //GET PARAM URL
        if( jQtsara('#text_mr').length > 0 && jQtsara.url.param("q") ) jQtsara('#text_mr').val( jQuery.url.param("q") );
        
        
       
        
        //Clic sur relatedvideo
        jQtsara('.ytv a.videoThumb').click( function( i ) {
            
			if( player ){
				player.sendEvent('STOP');
				player.sendEvent('LOAD','http://www.youtube.com/watch?v='+jQtsara(this).attr('rel'));
				
				//Mettre à jour le titre
				jQtsara('#col1_content').find('h3:first').text(jQtsara(this).parent().find('p:first').text());
document.title = jQtsara(this).parent().find('p:first').text()+' | Madatsara';
				//Supprimer le bloc Commentaire
				if( jQuery('#comments_yt') ) jQuery('#comments_yt').remove();
			}
			else {
				loadNewVideo( jQtsara(this).attr('rel'),0);
			}
            return false;
        });
        
      
        if( jQtsara("#featured > ul").length > 0 ) jQtsara("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 7000, true);

      
        if( jQtsara('#fontsize1').length > 0 ){
            fontSize("#fontsize1", "#col1", 9, 12, 20);
        }
	    //fontSize("#holder2", "#content2", 15, 20, 30);
      
        //jQtsara("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
        jQtsara("a[href*='http://']:not([href*='madatsara.com'])").attr("target","_blank");
        
        jQtsara('a.btsubmit').click( function() {
            jQtsara(this).parents('form').submit();
            return false;
        });
        
        
        //Si le lien bouton ne contient pas de span, ajouter ce span
        if( jQtsara('a.button').find('span').text() == '' ) {
            jQtsara('a.button').wrapInner( document.createElement('span') );
        }
		
		// tabs
		if( jQtsara('div.tabbed_area > ul').length > 0 ) jQtsara('div.tabbed_area > ul').tabs({ fx: { opacity: 'toggle' } }).tabs();

        // tabs
        
        //Accordion
        
        if( jQtsara('#accordion1, #accordion2,#rsswidget, #rsswidget2, #event_bloc').length > 0 ){
            jQtsara('#accordion1, #accordion2 ').accordion(); 
            jQtsara('#rsswidget, #rsswidget2, #event_bloc').accordion({ 
                active: false, 
                header: 'h4', 
                navigation: true,   
                autoheight: false
            });
        }
              
        
        //Feed Menu
        if( jQtsara('#jquery_feed_menu_example_1') ) var fm = new FeedMenu();fm.write('#jquery_feed_menu_example_1');
        
        //Partenaires
        if( jQtsara('#partenairesSpecial a').length > 0 ) {
            jQtsara('#partenairesSpecial a').click( function(){
                window.open( jQtsara(this).attr('href') );
                return false;
            });
        }
        if( jQtsara('#JeuneAfrique') ) jQtsara('#JeuneAfrique').attr('target','_blank');
        
        
        // initialize scrollable 
        if( jQtsara("div.scrollable").length > 0 ) {
            jQtsara("div.scrollable").scrollable({
                size: 3,
                items: '#thumbs',  
                hoverClass: 'hover'
            });
        }
        
        //FORMULAIRE
        if( jQtsara('input[title!=""]').length > 0 ) jQtsara('input[title!=""]').hint();
        if( jQtsara('textarea[title!=""]').length > 0 ) jQtsara('textarea[title!=""]').hint();
        
        //Autogrow
        if( jQtsara('textarea.ata').length > 0 ) jQtsara('textarea.ata').ata();
    
        //BTN
        /*if( jQtsara('.btn') ) {
            jQtsara('.btn').each(function(){
                var b = jQtsara(this);
                var tt = b.text() || b.val();
                if (jQtsara(':submit,:button',this)) {
                    b = jQtsara('<a>').insertAfter(this). addClass(this.className).attr('id',this.id);
                    jQtsara(this).remove();
                }
                b.text('').css({cursor:'pointer'}). prepend('<i></i>').append(jQtsara('<span>').
                text(tt).append('<i></i><span></span>'));
            });
        }*/
        
        //Fil d'ariane
        //if( jQtsara("#breadCrumb0") ) jQtsara("#breadCrumb0").jBreadCrumb();
        
        //superfish
        //if( jQtsara("ul.sf-menu") ) jQtsara("ul.sf-menu").superfish();
        
        
        
       
        
        
        jQtsara('div.thumbnail').find('img').each( function (i) {
        
            var lien = jQtsara(this).parent().attr('href').toLowerCase();
            
            //alert( jQtsara.trim( lien.substring(lien.lastIndexOf('.')+1) ) );
            
            //Table des extensions
            var arrExtensions = ['jpg','jpeg','png','gif'];
            
           //Si l'extension du fichier se trouve dans la liste
           if( !jQtsara.inArray( jQtsara.trim( lien.substring(lien.lastIndexOf('.')+1) ) , arrExtensions )) {
                
                jQtsara(this).parent().fancybox();
                //jQtsara(this).parent().parent().addClass('fancy');
                
                
                
           }
		   if(jQtsara.inArray( jQtsara.trim( lien.substring(lien.lastIndexOf('.')+1) ) , arrExtensions ) && jQtsara(this).parent().parent().parent().parent().attr('id') == 'homeThumb' ){
				jQtsara(this).parent().addClass('fancyIframe');
				//alert(jQtsara(this).parent().parent().parent().parent().attr('class'));
		   }
           
           
	    });
        
        //fancy
        if( jQtsara(".fancy, .fancyIframe").length > 0 ) {
			var largeur = 400;
			var hauteur = 300;
			var tabSplit;
			var relw;
			
			//Regarder si un attribut rel existe
			if( jQtsara(".fancy, .fancyIframe").find('img').attr('rel') != ''){
				relw = jQtsara(".fancy, .fancyIframe").find('img').attr('rel');
				if( relw ){
					tabSplit = relw.split(';');
					largeur = tabSplit[0];
					hauteur = tabSplit[1];
				}
			}
			
            jQtsara(".fancy").fancybox();
			//alert(largeur+'/'+hauteur);
            jQtsara(".fancyIframe").fancybox({frameWidth:largeur,frameHeight:hauteur});
        };
		
		//colorbox
        if( jQtsara(".colorbox").length > 0 ) {
            jQtsara(".colorbox").colorbox(
				{
					opacity: "0.4",
					close: "FERMER (X)"
				}
				/*,function(){
						alert(jQtsara(this).attr('href'));
				}*/
				);
        };
		
		//lazyload
		if( jQtsara("#galleryPicasa").length > 0 ) {
			if( jQtsara("#galleryPicasa").find('img') ) {
				jQtsara("#galleryPicasa").find('img').lazyload({ 
					placeholder : "lazyload/grey.gif",
					effect : "fadeIn" 
				});
			}
		}
        
        ///LOCALSCROLL
       // jQtsara.localScroll();
        
        //treeview sitemap
        if( jQtsara("#sitemap").length > 0 ) {
            jQtsara("#sitemap").treeview({
				collapsed: true,
				animated: "medium",
				control:"#sidetreecontrol"
			});
        }
        
        //Star rating
        if( jQtsara('input.star').html()!=null ) {
            
            jQtsara('input.star').rating(); 
        }
        
        
        
        
        //newsticker
        
        //newsticker

        if( jQtsara("#newsticker").html()!=null ) {
            //jQtsara("#newsticker").newsTicker();
            jQtsara('#newsticker').innerfade(
                { 
                animationtype: 'slide', 
                speed: 2000, 
                timeout: 2000, 
                type: 'random', 
                containerheight: '1em' 
                }
            ); 
            
        }
        
        
        if( jQtsara("a.send") ) {
            jQtsara("a.send").click( function(){
                if( !jQtsara('div#testube22').is(':hidden') ) jQtsara('div#testube22').slideUp();
                else jQtsara('div#testube22').slideDown();
                return false;
            });
        }




    



        });
      



