function mycarousel_initCallback(carousel){
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
$(document).ready(function() {
 	$('.cat_select').animate({paddingBottom: "5"},250);
 	$('div#categories a').click(function(){
		$(this).removeClass().animate({marginBottom: "-50"},500,function(){
			$(this).addClass('cat_select').animate({paddingBottom: "5" , marginBottom: "0"},500);
		});
		$('div#categories a.cat_select').animate({marginBottom: "-50"},500,function(){
			$(this).removeClass().animate({paddingBottom: "0" , marginBottom: "0" },250);
		});
		$("div#liste_videos").empty().append('<div id="videos_top"></div><div id="videos_milieu"><div id="videos_fond"><div id="load">Chargement Des Videos En Cours, veuillez patienter quelques instants.</div></div></div><div id="videos_bottom"></div><style>div#videos_bottom{margin-bottom: 25px;}</style>');
		var ok = $(this).attr('id');
		$.ajax({
			url: "http://www.southindiescrew.com/?page=loading_video_categorie&cat="+ok,
			cache:false,
			success:function(html){
				afficher_2(html);
			},
			error:function(XMLHttpRequest,textStatus, errorThrown){
				afficher_2("erreur lors du chagement de la page");
			}
		});
	});
	$('div#categories a').hover(function(){
		$(this).animate({paddingBottom: "5"},200);
	},function(){
		$(this).animate({paddingBottom: "0"},0);
		$('a.cat_select').animate({paddingBottom: "5"},0);
	});
	jQuery('#categories ul#liste_categories').jcarousel({
		scroll: 6,
		wrap: 'both',
        initCallback: mycarousel_initCallback
    });
	$('a#menu_5').addClass('soirees_select');
	$('div.fragment').each($.blocpagination);
	$(".pagination a.lien_pagination").append('<img class="shadow" src="http://www.southindiescrew.com/squelettes/2010/images/icons-shadow.png" width="81" height="27" alt="" />');
	$("span.on").append('<img class="shadow" src="http://www.southindiescrew.com/squelettes/2010/images/icons-shadow.png" width="81" height="27" alt="" />');
	$(".pagination a.lien_pagination span").hover(function() {
		var ey = this;
	    $(ey).stop().animate({ marginTop: "-14px" }, 250, function() {
	    	$(ey).animate({ marginTop: "-10px" }, 250);
	    });
	    $(ey).parent('a').find("img.shadow").stop().animate({ width: "65", height: "20px", marginLeft: "8px" }, 250);
	},function(){
		var ey = this;
	    $(ey).stop().animate({ marginTop: "4px" }, 250, function() {
	    	$(ey).animate({ marginTop: "0px" }, 250);
	    });
	    $(ey).parent('a').find("img.shadow").stop().animate({ width: "81", height: "27px", marginLeft: "0"}, 250);
	});
	var total = $('div.pagination a').size();
	$('div.pagination').width(81 * total);
});

	function afficher_2(data){
		$('div#liste_videos').empty().append(data);
		$('a.moderer').hide();$('a.modifier').hide();
		$(".pagination a.lien_pagination").append('<img class="shadow" src="http://www.southindiescrew.com/squelettes/2010/images/icons-shadow.png" width="81" height="27" alt="" />');
		$("span.on").append('<img class="shadow" src="http://www.southindiescrew.com/squelettes/2010/images/icons-shadow.png" width="81" height="27" alt="" />');
		$(".pagination a.lien_pagination span").hover(function() {
			var ey = this;
			$(ey).stop().animate({ marginTop: "-14px" }, 250, function() {
				$(ey).animate({ marginTop: "-10px" }, 250);
			});
			$(ey).parent('a').find("img.shadow").stop().animate({ width: "65", height: "20px", marginLeft: "8px" }, 250);
		},function(){
			var ey = this;
			$(ey).stop().animate({ marginTop: "4px" }, 250, function() {
				$(ey).animate({ marginTop: "0px" }, 250);
			});
			$(ey).parent('a').find("img.shadow").stop().animate({ width: "81", height: "27px", marginLeft: "0"}, 250);
		});	
		$('div.fragment').each($.blocpagination);
		var total = $('div.pagination a').size();
		$('div.pagination').width(81 * total);	
	}
	$.addFade = function() {		$('a.moderer').hide();$('a.modifier').hide();

		$(".pagination a.lien_pagination").append('<img class="shadow" src="http://www.southindiescrew.com/squelettes/2010/images/icons-shadow.png" width="81" height="27" alt="" />');
		$("span.on").append('<img class="shadow" src="http://www.southindiescrew.com/squelettes/2010/images/icons-shadow.png" width="81" height="27" alt="" />');
		$(".pagination a.lien_pagination span").hover(function() {
			var ey = this;
			$(ey).stop().animate({ marginTop: "-14px" }, 250, function() {
				$(ey).animate({ marginTop: "-10px" }, 250);
			});
			$(ey).parent('a').find("img.shadow").stop().animate({ width: "65", height: "20px", marginLeft: "8px" }, 250);
		},function(){
			var ey = this;
			$(ey).stop().animate({ marginTop: "4px" }, 250, function() {
				$(ey).animate({ marginTop: "0px" }, 250);
			});
			$(ey).parent('a').find("img.shadow").stop().animate({ width: "81", height: "27px", marginLeft: "0"}, 250);
		});
		var total = $('div.pagination a').size();
		$('div.pagination').width(81 * total);
	}

$.blocpagination = function() {
		var blocfrag = this;
		$('.pagination',this).each(function(){
			var divpagi=this;
			$('a.lien_pagination',this).each(function(){
				var url = this.href.split('#');
				url[0] += (url[0].indexOf("?")>0 ? '&':'?')+'var_fragment='+blocfrag.id;
				$(this).click(function(){
					var placeholder=$('.searching_placeholder',blocfrag);
					if (placeholder.length) placeholder.prepend('');
					else $('div#videos_fond ').empty().append('<div id="load">Chargement Des Videos En Cours, veuillez patienter quelques instants.</div>');
					$(blocfrag).load(url[0],null,function(){
						$.addFade.apply(blocfrag);
						window.location.hash = url[1];
						$.blocpagination.apply(blocfrag);
					});
					
					return false;
				});
			});
		});
};
