// tfwa
jQuery(function( $ )
{
							 	
	$('.homelivetab li').click(function(){
									  
		if(!$(this).hasClass('act'))
		{
			$('.homelivetab li').removeClass('act');
			$(this).addClass('act');
			if($(this).hasClass('today'))
			{
				$('.homelivetab .todaycontent').show();
				$('.homelivetab .tomorrowcontent').hide();
			}
			else
			{
				$('.homelivetab .todaycontent').hide();
				$('.homelivetab .tomorrowcontent').show();
			}
			
		}
		return false;
	});
	
	$('.bt-details a').click(function(){
			
		if($(this).parent().hasClass('expand'))
		{
			$(this).parent().removeClass('expand');
			$(this).parent().addClass('retract');
			$(this).parent().next().show();
		}
		else
		{
			$(this).parent().addClass('expand');
			$(this).parent().removeClass('retract');
			$(this).parent().next().hide();
		}
		return false;
	});
	
	$('#menu ul li').hover(
		function(){
			$(this).find("div").show();
		},
		function(){
			$(this).find("div").hide();
		}
	);
	
	$(".rgtabs-menu a").click(
		function(){
			$.ajax({
   				dataType: "html",
   				url: $(this).attr('href'),
   				success: function(content){
     				$(".rgtabs-wrapper").html($(content).find(".rgtabs-wrapper").html());
					$('.bt-details a').click(function(){
						if($(this).parent().hasClass('expand'))
						{
							$(this).parent().removeClass('expand');
							$(this).parent().addClass('retract');
							$(this).parent().next().show();
						}
						else
						{
							$(this).parent().addClass('expand');
							$(this).parent().removeClass('retract');
							$(this).parent().next().hide();
						}
						return false;
						});
   					}
 			});
			$(".rgtabs-selected").removeClass("rgtabs-selected");
			$(this).parent().addClass('rgtabs-selected');
			return false;
		}
	);
	$(".rgtabs-menu li:first-child").addClass("rgtabs-selected");
	
	wemScrollers(
		'.slide-show', 
		'.slide',
		'.scroller',
		'/duty_free/fileadmin/templates/images/common/evtcover-slidebar-left.png', 
		'/duty_free/fileadmin/templates/images/common/evtcover-slidebar-right.png', 
		'/duty_free/fileadmin/templates/images/common/evtcover-slidebar-link.png', 
		'/duty_free/fileadmin/templates/images/common/evtcover-slidebar-selected.png'
	);
	
	wemScrollers(
		'.bloc-eventcov-scroll', 
		'.event',
		'.scroller',
		'/duty_free/fileadmin/templates/images/common/evt-scroll-left.png', 
		'/duty_free/fileadmin/templates/images/common/evt-scroll-right.png', 
		'/duty_free/fileadmin/templates/images/common/evt-scroll-link.png', 
		'/duty_free/fileadmin/templates/images/common/evt-scroll-activ.png'
	);
	
	wemScrollers(
		'.bloc-speakers',	
		'.speaker',
		'.scroller',
		'/duty_free/fileadmin/templates/images/common/speak-scroll-left.png', 
		'/duty_free/fileadmin/templates/images/common/speak-scroll-right.png', 
		'/duty_free/fileadmin/templates/images/common/speak-scroll-link.png', 
		'/duty_free/fileadmin/templates/images/common/speak-scroll-activ.png'
	);
	
});

function ouvrir(page,titre,param)
{

	var w = window.open(page,titre,param);

}

$(document).ready(function() {
						   
	$('.details-bg').hide();
	$('.survol').hover(
		function(){
			$(this).find(".details-bg").show();
		},
		function(){
			$(this).find(".details-bg").hide();
		}
	);

	$('#gallery a').lightBox();
        $('.stand:empty').remove();
        $('.stand').each(function(){
     		if ($(this).html()=='&nbsp;') 
	 		{
		 		$(this).parent().parent().parent().parent().find("a").hide();
		 		$(this).parent().parent().parent().remove();
	 		}
        }
	);
		
	$('#wrapper').after('<div class="overlay"></div>');
	$('.alertuser .csc-textpic-text').hide();
	$('.alertuser h2').click(
		function(){
			$(this).parent().find(".csc-textpic-text").show();
			$(".overlay").show();
		}
	);
	$('.alertuser a').click(
		function(){
			$(".alertuser .csc-textpic-text").hide();
			$(".overlay").hide(); 
			return false;
		}
	);		
	$(".alertuser .csc-textpic-text").css( "left",(($(window).width()-600)/2)+"px");
	if(screen.height<900)
		$(".alertuser .csc-textpic-text").css( "top", "10px");
	else
		$(".alertuser .csc-textpic-text").css( "top", "50px");
		
	//$('.bulle_scroll').hide();
	$('.scroll_item').hover(
		function(){
			if($(this).find(".bulle_scroll .bulle_txt").text().length)
			{
				$(this).css("z-index",100);
				$(this).find(".bulle_scroll").show();
				var position = $(this).position();
				if (position.left>600)
				{
					$(this).find(".bulle_scroll").css("right",0);
					$(this).find(".bulle_scroll").css("left","auto");
				}
			}
		},
		function(){
			$(this).find(".bulle_scroll").hide();
			$(this).css("z-index",1);
		}
	);
	$('#col_largetop .blocscroll h2 a').addClass('close');
	$('#col_largetop .blocscroll h2 a span').replaceWith('<span title="hide">hide</span>');
	
	if($('.scroll_content > *').length<5)
	{
		var width = ($('.scroll_content > *').length)*174;
		//$(this).css('width',width+'px');
		$('.scroll_content').css('width',width+'px').css("margin","0 auto");
	}
	$('.blocscroll h2 a').click(function(){	
		if($(this).hasClass('close'))
		{
			$(this).parent().parent().find('.scroll_extend').slideUp(function () {
				$(this).parent().find('h2 a').removeClass('close');
				$(this).parent().find('h2 a').addClass('open');
				$(this).parent().find('h2 a span').replaceWith('<span title="show">show</span>');
				}
			);			
		}
		else
		{
			$(this).parent().parent().find('.scroll_extend').slideDown(function(){
				$(this).parent().find('h2 a').addClass('close');
				$(this).parent().find('h2 a').removeClass('open');
				$(this).parent().find('h2 a span').replaceWith('<span title="hide">hide</span>');																	
				}
			);
		}
		return false;
	});
	
	// XITI Pour stat liens telechargement
	$(".download").each(function(){
		var taburl = $(this).attr( "href").split("/");
		$(this).attr( "onclick", "xt_med(\'C\', \'0\', \'"+escape(taburl.pop())+"\', \'T\');" ).attr( "target", "_blank");
	});
	$("#press-releases a").each(function(){
		var taburl = $(this).attr( "href").split("/");
		$(this).attr( "onclick", "xt_med(\'C\', \'0\', \'"+escape(taburl.pop())+"\', \'T\');" ).attr( "target", "_blank");
	});	
	$(".blocscroll .scroll_item a").each(function(){
		var taburl = $(this).attr( "href").split("/");
		var fichier = taburl.pop();
		if(fichier.lastIndexOf(".pdf")!=-1)
			$(this).attr( "onclick", "xt_med(\'C\', \'0\', \'"+escape(fichier)+"\', \'T\');" ).attr( "target", "_blank");
		if((fichier.lastIndexOf(".xls")!=-1) || (fichier.lastIndexOf(".xlsx")!=-1))
			$(this).attr( "onclick", "xt_med(\'C\', \'0\', \'"+escape(fichier)+"\', \'T\');" );
	});
	
}); 
