jQuery(document).ready(function (){
	jQuery("div._langage").mouseenter( function() { jQuery("._langage ul li").stop(true,true).slideDown("slow") });
	jQuery("div._langage").mouseleave( function() { jQuery("._langage ul li:not(li#active_language)").stop(true,true).slideUp("slow") });

	if (jQuery("#rt-sidebar-a ._domVideo p.video").length > 0){
		jQuery("#rt-sidebar-a ._domVideo p.video").css('background','url('+jQuery('#rt-sidebar-a ._domVideo p.video a img').attr("src").match(/[^\.]+/)+'_hover.png) no-repeat scroll top left #000000');
	}
	if(jQuery("#rt-sidebar-a ._actuVideo p.video").length > 0) {
		jQuery("#rt-sidebar-a ._actuVideo p.video").css('background','url('+jQuery('#rt-sidebar-a ._actuVideo p.video a img').attr("src").match(/[^\.]+/)+'_hover.png) no-repeat scroll top left #000000');
	}
	jQuery("a#gantry-totop").fadeTo("fast", 0.6);
	jQuery("a#gantry-totop").hide();
	
	jQuery(document).scroll(function() {
		if(jQuery(document).scrollTop() > (jQuery(window).height()/7))
		{
			jQuery("a#gantry-totop").fadeTo("slow",0.6);
		}
		else {
			jQuery("a#gantry-totop").fadeTo("slow",0);
		}
	});
	
	if(jQuery(".wi_k2readmore").length>0) {
		jQuery(".wi_k2readmore").corner("3px");
	}
	
	jQuery("#rt-sidebar-a p.video a img").hover(
		function () {
			jQuery(this).fadeTo("slow", 0);
		},
		function () {
			jQuery(this).fadeTo("slow",1);
	});
	
	jQuery("a#gantry-totop").hover(
		function () {
			jQuery(this).fadeTo(400, 1);
		},
		function () {
			jQuery(this).fadeTo(400,0.6);
	});
	
	
	if(jQuery("div.categories").length>0) {
		jQuery("div.categories ul.event_legend_list li a").tooltip({ effect: 'slide', tipClass: 'cycleTooltip'});
	}
	jQuery("#rt-footer div.conteneur a").tooltip({ effect: 'slide', tipClass: 'tooltip'});
	
	//textShadow
	jQuery("div#rt-main #rt-sidebar-a div.rt-block div.module-title h2").textShadow({x:1,y:1,radius:0,color:"#424242"});
	jQuery("#rt-menu ul.menu li a span").textShadow({x:1,y:1,radius:0,color:"#000000"});
	//jQuery(".sidebarMenu ul li#current a").textShadow({x:1,y:1,radius:0,color:"#333333"});
	jQuery("div#rt-main #rt-sidebar-a div._actuVideo p.buttons a").textShadow({x:1,y:1,radius:0,color:"#ffffff"});
	if(jQuery("div#spectacle div#droite div#infosSpectacle div#typologie").length>0) { jQuery("div#spectacle div#droite div#infosSpectacle div#typologie").textShadow({x:-1,y:-1,radius:0,color:"#131313"}); }
	if(jQuery("td.ev_td_left").length>0) { jQuery("td.ev_td_left").textShadow({x:1,y:1,radius:0,color:"#ffffff"}); }
	
	// Page spectacle : diaporama photos
	jQuery('#slideshowHolder').jqFancyTransitions({
		width: 620,
		height: 349,
		effect: 'zipper', // wave, zipper, curtain
		strips: 1, // number of strips
		delay: 3000, // delay between images in ms
		stripDelay: 100, // delay beetwen strips in ms
		titleOpacity: 0, // opacity of title
		titleSpeed: 0, // speed of title appereance in ms
		position: 'left', // top, bottom, alternate, curtain
		direction: 'left', // left, right, alternate, random, fountain, fountainAlternate
		navigation: false, // prev and next navigation buttons
		links: false // show images as links
	});

	if(jQuery('div#listeGenerique').text().length <1) { jQuery("div#listeGenerique").hide(); }
	else
	{
		if(jQuery('div#listeGenerique div.inner').height() > 120)
		{
			jQuery('div#listeGenerique').css("height","120px");
			jQuery("div#listeGenerique_plus").show();
			var listeGenerique_cpt=true;
			jQuery("div#listeGenerique_plus").click(function(){
				if(listeGenerique_cpt)
				{
					jQuery('div#listeGenerique').animate({ height: jQuery("div#listeGenerique div.inner").height() }, 500).css('overflow','normal');
					jQuery("div#listeGenerique_plus").html("&and; Masquer");
					listeGenerique_cpt = false;
				}
				else
				{
					jQuery('div#listeGenerique').animate({ height: "120px" }, 500).css('overflow','hidden');
					jQuery("div#listeGenerique_plus").html("&or; Afficher la suite");
					listeGenerique_cpt = true;
				}
			});
		}
	}
	
	if(jQuery('div#programmeSpectacle').text().length <1) { jQuery("div#programmeSpectacle").hide(); }
	else
	{
		if(jQuery('div#programmeSpectacle div.inner').height() > 120)
		{
			jQuery('div#programmeSpectacle').css("height","120px");
			jQuery("div#programmeSpectacle_plus").show();
			var programmeSpectacle_cpt=true;
			jQuery("div#programmeSpectacle_plus").click(function(){
				if(programmeSpectacle_cpt)
				{
					jQuery('div#programmeSpectacle').animate({ height: jQuery("div#programmeSpectacle div.inner").height() }, 500).css('overflow','normal');
					jQuery("div#programmeSpectacle_plus").html("&and; Masquer");
					programmeSpectacle_cpt = false;
				}
				else
				{
					jQuery('div#programmeSpectacle').animate({ height: "120px" }, 500).css('overflow','hidden');
					jQuery("div#programmeSpectacle_plus").html("&or; Afficher la suite");
					programmeSpectacle_cpt = true;
				}
			});
		}
	}
	
	if (jQuery("div#spectacle").length > 0){
		jQuery("div.rt-grid-3").hide();
		jQuery("div.rt-grid-9").css('width','930px');
	}
	
	if(jQuery("td.mod_events_latest_first").length>0) {
		jQuery("td.mod_events_latest_first div.description p:not(:first-child), td.mod_events_latest div.description p:not(:first-child)").hide();
	}
	if(jQuery("div.actuSpectacles div.actuS_infos div.moreInfo a").length>0) {
		jQuery("div.actuSpectacles div.actuS_infos div.moreInfo a").corner("3px");
	}
	if(jQuery("span#autreLieuLieu").html() == '') {
		jQuery("div#autreLieu").hide();
	}
	if(jQuery("div#autreLieuTransport").html() == '') {
		jQuery("div#autreLieuTransport").hide();
	}
	if(jQuery("div#partenaires").html() == '') {
		jQuery("div#partenaires").hide();
	}
	
	if(jQuery("div#presse div#listePresse").html() == '') {
		jQuery("div#presse").hide();
	}

	if(jQuery("div#spectacle div#video a").length<1) {
		jQuery("div#spectacle div#video").hide();
	}

	if((jQuery("div#spectacle div#infosSpectacle span#trancheTarifaire span#tarif").text()) == 'Tarif différent') {
		jQuery("div#spectacle div#infosSpectacle span#trancheTarifaire").hide();
	}
	if((jQuery("div#spectacle div#infosSpectacle span#trancheTarifaire span#tarif").text()) != 'Tarif différent') {
		jQuery("div#spectacle div#infosSpectacle span#tarifLibre").hide();
	}
	
	if(jQuery("div#spectacle div#infosSpectacle span#specStatut").text() == '') {
		jQuery("div#spectacle div#infosSpectacle span#specStatut").hide();
	}
	else {
		jQuery("div#spectacle div#infosSpectacle div#divBoutonAchat").hide();
		jQuery("a.reservixlink").hide();
		jQuery("a.fnaclink").hide();
	}
	
	
	if(jQuery("table.ev_table").length>0)
	{
		var nbSpec = jQuery("#countSpect").text();
		for (var i=0; i<nbSpec; i++)
		{
			
			/*listDateLargeur = jQuery(".listSpec"+i+" .listDate").width();
			jQuery(".listSpec"+i+" .listSpecTitle").css("margin-left",listDateLargeur+10+"px");	
			h3Hauteur = jQuery(".listSpec"+i+" .listSpecTitle").height();
			//jQuery(".listSpec"+i+" h3").css("height",h3Hauteur+20+"px");
			jQuery(".listSpec"+i+" .listDate").css("height",h3Hauteur+"px");*/
			jQuery(".listSpec"+i+" span.listTheDate").html(jQuery(".listSpec"+i+" .initListTheDate").html());
			
			if(jQuery("body.cssstyle-style_archives").length>0)
			{
				// CHERCHER IMG
				if(jQuery(".listSpec"+i+" div.listSpecDescInfos img").length<1)
				{
					var htmlTemp1 = jQuery(".listSpec"+i+" div.listSpecDescInfos").html();
					jQuery(".listSpec"+i+" div.listSpecDescInfos").html('<img src="images/archive_no_image.jpg" alt="" style="width:111px;float:left;border: 1px solid #5A0535;margin-right: 10px;" />'+htmlTemp1);
				}
			}
		}
		
		jQuery("li.ev_td_li div.listSpecTitle").click(function() {
			if(!jQuery(this).hasClass("active"))
			{
				jQuery(this).addClass("active");
				//jQuery("td.listVisitor", this).css("color","#5a0535");
				jQuery(this).parent("li").children("div.listSpecDesc").slideDown("slow");
			}
			else
			{
				jQuery(this).removeClass("active");
				//jQuery("td.listVisitor", this).css("color","#55055A");
				jQuery(this).parent("li").children("div.listSpecDesc").slideUp("slow");
			}
		});
		
		jQuery(".ev_td_li div.listBouton a").corner("3px");
		
	}
	jQuery("a#gantry-totop").corner("5px");
	jQuery("div#rt-footer div._menu ul li a, div#rt-footer div._menuAnnexes ul li a").corner("5px");
	
	if(jQuery("div#pictos").length>0) {
		if(jQuery("div#pictos").html()!="aucun")
		{
			var myPictos = jQuery("#pictos").html().split(", ");
			var imagePictos="";
			for(var j=0; j < myPictos.length; j++)
			{
				if(myPictos[j]!="aucun") {
					imagePictos+='<img src="images/pictos/'+myPictos[j]+'.png" alt="'+myPictos[j]+'" />';
				}
			}
			
			jQuery("#pictos").html("");
			jQuery("#pictos").html(imagePictos);
			jQuery("#pictos img").fadeTo("fast",0.5);
			jQuery("#pictos img").mouseenter(function(){ 
				jQuery(this).fadeTo(500, 1);
			}).mouseleave(function(){
				jQuery(this).fadeTo("slow", 0.5);
			});
		}
		else { jQuery("div#pictos").hide(); }

	}
	if(jQuery("a#boutonAchat").attr("href") != "" && jQuery("a#boutonAchat").attr("href") != "#" )
	{
		//jQuery("a#boutonAchat").css("height",jQuery("div#infos").height()-3+"px");
		jQuery("a#boutonAchat").corner("3px");
		if(jQuery("a.reservixlink").attr("href") != "" && jQuery("a#boutonAchat").attr("href") != "#" )
		{
			jQuery("a#boutonAchat").attr("href",jQuery("a.reservixlink").attr("href"))
			jQuery("a#boutonAchat").attr("target","_blank")
		}
	}
	else { jQuery("a#boutonAchat").hide(); }
	
	if(jQuery("div.componentheading").length>0) {
		var str=jQuery("div.componentheading").html();
		if(str.search(/<h2/i)==-1) {
			var tempTitle = jQuery("div.componentheading").html();
			jQuery("div.componentheading").html("<h2>"+tempTitle+"</h2>");
		}
	}
	
	if(jQuery("select#year").length>0) { jQuery("select#year").corner("3px"); }
	
	if(jQuery("body.cssstyle-style_archives div#titreSpectacle").length>0)
	{
		jQuery("body.cssstyle-style_archives div.ev_navigation").hide();
		jQuery("body.cssstyle-style_archives div#divBoutonAchat").hide();
		jQuery("body.cssstyle-style_archives a.covoiturage").hide();
		jQuery("body.cssstyle-style_archives a.icallink").hide();
		jQuery("body.cssstyle-style_archives span#trancheTarifaire").hide();
		if(jQuery("body.cssstyle-style_archives div#ft-title-slideshowHolder").html()=="undefined")
		{
			jQuery("body.cssstyle-style_archives div#slideshowHolder").hide();
			var htmlTemp = jQuery("body.cssstyle-style_archives div#texte").html();
			jQuery("body.cssstyle-style_archives div#texte").html('<img src="images/archive_no_image.jpg" alt="" style="margin-bottom:10px;border: 1px solid #55055A;" />'+htmlTemp);
		}
	}

	header_user_login_cant_close = false;
	
	// Fermeture et ouverture de la div de login
	jQuery("._connexion div.logButton span").mouseenter(function(){
		if(header_user_login_cant_close == false)
		{
			jQuery("._connexion #form-login").show();
			jQuery("._connexion div.logButton span").addClass('active');
		}
	}).mouseleave(function(){
		if(header_user_login_cant_close == false)
		{
			jQuery("._connexion #form-login").hide();
			jQuery("._connexion div.logButton span").removeClass('active');
		}
	});
	
	jQuery("._connexion #form-login").mouseenter(function(){
		if(header_user_login_cant_close == false)
		{
			jQuery(this).show();
			jQuery("._connexion div.logButton span").addClass('active');
		}
	}).mouseleave(function(){
		if(header_user_login_cant_close == false)
		{
			jQuery(this).hide();
			jQuery("._connexion div.logButton span").removeClass('active');
		}
	});
	
	jQuery('._connexion #form-login input').focus(function(){
		header_user_login_cant_close = true;
	});
	jQuery('._connexion #form-login input').blur(function(){
		header_user_login_cant_close = false;
	});
	
	

	setTimeout("test()",450);
	
});

	function test() {
		jQuery("#rt-menu ul.menu").css("display", "inline-block");
		jQuery("#rt-menu ul.menu").css("width", jQuery("#rt-menu ul.menu").width()+40);
		jQuery("#rt-menu ul.menu").css("display", "block").css("margin-left", "auto").css("margin-right", "auto");
	}
