//Appel à faire quand la page est chargée
$(document).ready(function() {
	async = true ;

	//multiBlockAjax(1);
	// Handler for .ready() called.
	//Mise en style des checkbox, radio et file
	if($('#div_comparer').length > 0){
		setPopin('div_comparer');
		$('.popin_content').css('width','550px');
	}

	//BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id] = $('#content_all_id_0_tab'+click_id).contents().detach();
	//initBlock(click_id,BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id]);

	readyCommon();

	/*  if($('.multi_block_title_inner').length > 0) {
	$('.multi_block_title_inner a.active').textShadow();
	}*/
	/*  if($('.panel-welcomers-accueil span').length > 0 && $.browser.msie) {
	var option = {
	x:      0,
	y:      0,
	radius: 10,
	color:  "#000"
	}
	$('.panel-welcomers-accueil span').textShadow(option);
	//text-shadow: 0px 0px 10px #000000;
	}*/

	navigationMultiblocksAddID();

	//Menu déroulant
	menuDeroulant();

	//changement de langue
	changementPaysLangue();

	//navigation multi-blocks
	navigationMultiblocks();

	//Autocomplete
	autocomplete();

	//  if(REMOTE_USER != 'sao'){
	//    initMultiblocksId(ONGLET_MB_SPAN);
	//  }
	/*
	* JEL 10/05/2011
	* Afficher l'over layer Mon compte Thalys
	*/
	affiche_layer();
	thalysAccountLayer();

	/* Destination ambassadeurs */
	setDetailsDescriptionAmbassadeur();

	setBtnPrint();

	initNewsletterFooter();
	newsletterFooterFocus();
	newsletterFooterBlur();

	if (ie6 != '1'){
		//abe
		hideActifSelect();

		if($('#ie6-upgrade-conteneur').length > 0){
			newsUnsuscribe = $('#ie6-upgrade-conteneur');
			newsUnsuscribe.popin({id_content:'#ie6-upgrade-conteneur',default_state:'show',closeCallback: 'showActifSelect()'});
		}
	}
	$.history.init(function(block_title_name) {
		var id = BLOCKS_LINK_MULTIBLOCKS_TITLES[block_title_name];
		if (id == undefined &&  block_title_name != "" ){
			return ;
		}
		load(block_title_name == "" || (typeof(id) == 'undefined' )  ? '1' : id);
	});
	//}

	//abe
	seoAfterPageLoaded();
	//end abe
	initEvenementCIN($('#numero_the_card'),true);
});
var SEOCALL = false;

function load(num) {

	if( (inUrl('onglet') || inUrl('onglet_mb') ) && (typeof(anchor) == 'undefined' || anchor =='') ){

		var onglet ;
		if(inUrl('onglet')){
			onglet = URL_VARS['onglet'];
		}else{
			onglet = URL_VARS['onglet_mb'];
		}
		var num_onglet = BLOCKS_LINK_MULTIBLOCKS_TITLES_IDDB[onglet];

		for (var i in  BLOCKS_LINK_MULTIBLOCKS_TITLES)
		{
			if ( BLOCKS_LINK_MULTIBLOCKS_TITLES[i] == num_onglet){
				var ancre = i;
			}
		}

		var url = $(window.location).attr('href');
		url+='#'+ancre;
		$(window.location).attr('href',url);
		num = num_onglet ;
		anchor ='OK';
		return;
	}

	numero_onglet = num;
	var id_span = 'multi_block_title_span_element_'+num;
	if($('#'+id_span).length > 0){
		multiBlockAjax(num);
		//navigationMultiblocksId(id_span);
	}
}

function inUrl(param){
	for (i=0;i<URL_VARS.length;i++){
		if ( param == URL_VARS[i]){
			return true;
		}
	}
	return false;
}

function readyCommon(){
	$("select, input:checkbox, input:radio, input:file").uniform();
	if($("input:file").length > 0){
		$("input:file").uniform({
			fileBtnText: input_file_text_btn,
			fileDefaultText: input_file_text
		});
	}
	subMultiBlocksClick();
}

function uniformiserBlock(id_block){
	//log('uniformiserBlock '+ id_block);
	$("#content_all_id_0_tab"+id_block+" select, #content_all_id_0_tab"+id_block+" input:checkbox, #content_all_id_0_tab"+id_block+" input:radio, #content_all_id_0_tab"+id_block+" input:file").uniform();
	if($("#content_all_id_0_tab"+id_block+" input:file").length > 0){
		$("#content_all_id_0_tab"+id_block+" input:file").uniform({
			fileBtnText: input_file_text_btn,
			fileDefaultText: input_file_text
		});
	}
	subMultiBlocksClick();
}

function uniformiserBlockUpdate(id_block){
	//$('input').not("#content_all_id_0_tab"+id_block+" select, #content_all_id_0_tab"+id_block+" input:checkbox, #content_all_id_0_tab"+id_block+" input:radio, #content_all_id_0_tab"+id_block+" input:file").uniform();
	$.uniform.update;
	//$("select, input:checkbox, input:radio, input:file").uniform();
	//$.uniform.update(("#content_all_id_0_tab"+id_block+" select, #content_all_id_0_tab"+id_block+" input:checkbox, #content_all_id_0_tab"+id_block+" input:radio, #content_all_id_0_tab"+id_block+" input:file"));
	//  $("#content_all_id_0_tab"+id_block+" select, #content_all_id_0_tab"+id_block+" input:checkbox, #content_all_id_0_tab"+id_block+" input:radio, #content_all_id_0_tab"+id_block+" input:file").uniform();
	//  $.uniform.update("#content_all_id_0_tab"+id_block+" select, #content_all_id_0_tab"+id_block+" input:checkbox, #content_all_id_0_tab"+id_block+" input:radio, #content_all_id_0_tab"+id_block+" input:file");
	//  if($("input:file").length > 0){
	//    $("input:file").uniform({
	//      fileBtnText: input_file_text_btn,
	//      fileDefaultText: input_file_text
	//    });
	//  }
	subMultiBlocksClick();
}

function consoleLog(){
	if (typeof console == "object") {log = console.log;}
	else{
		//log = function(msg) { alert(msg); };
		//  console.log =  function(msg) { alert(msg);};
	}
}

String.prototype.noaccent = function() {
	return this.replace(/[àáâãäåæ]/g,"a").replace(/[ÀÁÂÃÄÅÆ]/g,"A").replace(/[Ç]/g,"C").replace(/[ç]/g,"c").replace(/[èéêë]/g,"e").replace(/[ÈÉÊË]/g,"E").replace(/[ÌÍÎÏ]/g,"I").replace(/[ìíîï]/g,"i").replace(/[Ð]/g,"D").replace(/[ð]/g,"d").replace(/[Ñ]/g,"N").replace(/[ñ]/g,"n").replace(/[ÒÓÔÕÖØ]/g,"O").replace(/[òóôõöø]/g,"o").replace(/[Ý]/g,"Y").replace(/[ýÿ]/g,"y").replace(/[ÙÚÛÜ]/g,"U").replace(/[ùúûü]/g,"u").replace(/[ß]/g,"ss").replace(/[Þ]/g,"Th").replace(/[þ]/g,"th");
};

String.prototype.nospecialchars = function() {
	return this.replace(/[^a-z]/gi,"");
};

String.prototype.replacewithdash = function() {
	return this.replace(/[^a-z1-9]/gi,"-");
};

function setPopin(id_block){
	oPopin = $('#'+id_block);
	oPopin.popin({id_content:'#'+id_block,id_btn:'#link_'+id_block});
}
function cleanName(nom){
	return nom.noaccent().nospecialchars().toLowerCase();
}

function cleanEmail(email){
	return $.trim(email.toLowerCase());
}

function cleanUrl(url){
	return $.trim(url.noaccent().replacewithdash().toLowerCase());
}

/*************************************************
**************************************************
*************FONCTIONS COMMUNES*******************
**************************************************
*************************************************/

function reloadPageWithHash(ancre) {
	return false;
	var initialPage = window.location.protocol+'//'+window.location.host+window.location.pathname;
	var qs = window.location.search;
	if(qs == ''){
		var hashes = window.location.hash.split('?');
		qs = (undefined == hashes[1])? '' : '?'+hashes[1];
	}
	window.location.replace(initialPage+'#/' + ancre+qs);
}

function ShowHide(id) {
	if($("#"+id).length > 0){
		$("#"+id).toggle();

		if($("#showHideAvantages").length > 0){
			if($("#"+id).css('display') == 'none'){
				$("#showHideAvantages").html(label_lire_la_suite);
			} else {
				$("#showHideAvantages").html(label_reduire);
			}
		}
	}
}


function showHideTwoElements(idshow,idhide){
	if($("#"+idhide).length > 0){
		$("#"+idhide).hide();
	}
	if($("#"+idshow).length > 0){
		$("#"+idshow).show();
	}
	$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
}

function limitTextarea(id,limite)
{
	var texte = $('#'+id).val();
	if (texte.length > limite){
		$('#'+id).val(texte.substr(0,limite));
	}
	var left = limite - texte.length;
	if (left < 0){
		left = 0;
	}
	if ($('#nb_caractere_'+id+' span.nb_caractere')){
		$('#nb_caractere_'+id+' span.nb_caractere').html(left);
	}
}

function isValidDate(dateStr, lang) {
	if(undefined == lang){
		lang = LANGUAGE;
	}
	switch(lang){
		case 'de':
		case 'fr':
		case 'nl':
		format = "DMY"
		break;
		case 'en':
		format = "YMD"
		break;
	}
	format = format.toUpperCase();
	if (format.length != 3) { format = "MDY"; }
	if ( (format.indexOf("M") == -1) || (format.indexOf("D") == -1) || (format.indexOf("Y") == -1) ) {
		format = "MDY";
	}
	if (format.substring(0, 1) == "Y") { // If the year is first
		var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
		var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
	} else if (format.substring(1, 2) == "Y") { // If the year is second
		var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
		var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
	} else { // The year must be third
		var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
		var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
	}
	// If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
	if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) { return false; }
	var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
	// Check to see if the 3 parts end up making a valid date
	if (format.substring(0, 1) == "M") { var mm = parts[0]; } else
	if (format.substring(1, 2) == "M") { var mm = parts[1]; } else { var mm = parts[2]; }
	if (format.substring(0, 1) == "D") { var dd = parts[0]; } else
	if (format.substring(1, 2) == "D") { var dd = parts[1]; } else { var dd = parts[2]; }
	if (format.substring(0, 1) == "Y") { var yy = parts[0]; } else
	if (format.substring(1, 2) == "Y") { var yy = parts[1]; } else { var yy = parts[2]; }
	if (parseFloat(yy) <= 50) { yy = (parseFloat(yy) + 2000).toString(); }
	if (parseFloat(yy) <= 99) { yy = (parseFloat(yy) + 1900).toString(); }
	var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
	if (parseFloat(dd) != dt.getDate()) { return false; }
	if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
	return true;
}

function menuDeroulant(){

	//Accordeon pour les menu déroulant
	if($(".menu_deroulant").length > 0){

		$(".menu_deroulant").accordion({
			autoHeight: false,
			active: false,
			collapsible: true
		});

		acc = 'sidemap_active';

		//Ouverture du menu correspondant
		act = 0;
		ouverture = false;
		panels = $('#menu_deroulant > li > ul');
		for (i=0; i<panels.length; i++) {
			if ( panels[i].id == acc ) {
				act = i;
				ouverture = true;
			}
		}

		if(ouverture === true || $(".menu_deroulant").hasClass('menu_deroulant_business') || $(".menu_deroulant").hasClass('menu_deroulant_tarifs') || $(".menu_deroulant").hasClass('menu_deroulant_compte')){
			if($(".menu_deroulant").hasClass('menu_deroulant_business')){

				if($('#multi_block_title_span_element_1').length > 0){
					if($('#multi_block_title_span_element_1').hasClass('active'))
					{
						$('.menu_deroulant').accordion('activate', 0);
					}
				}else{
					$('.menu_deroulant').accordion('activate', 0);
				}
				        $('.menu_deroulant').accordion( "option", "disabled", true );
				navigationOtherPage();
				return false;
			}else if($(".menu_deroulant").hasClass('menu_deroulant_tarifs') || $(".menu_deroulant").hasClass('menu_deroulant_compte')){
				$('.menu_deroulant').accordion('activate', 2);
				$('.menu_deroulant').accordion( "option", "disabled", true );
				navigationOtherPage();
			} else {
				$('.menu_deroulant').accordion('activate', act);
			}
		}
		if(window.location.hash == ''){
			$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
		}
	}
}

function navigationOtherPage(){
	$('.menu_deroulant .niveau_2 a').click(function() {
		var url = $(this).attr('href');
		$(window.location).attr('href', url );
		return false;
	})
}

function changementPaysLangue(){
	if($("#new_country_lg").length > 0){
		$('#new_country_lg').change(function(){
			var ctlg = $('#new_country_lg').val();
			var country_lg = ctlg.split('/');

			var parse_url = window.location.href.split('?');
			//parse_url[0] =  parse_url[0].split('#').shift();
			var anchor = false;
			if(parse_url[0].search('#') > 0){
				anchor = parse_url[0].split('#').pop();
			}

			var url = parse_url[0].split('#').shift()+'?do=Navigation_Base&newlg='+country_lg[1]+'&newcountry='+country_lg[0];
			if(parse_url[1] != undefined){
				qs =  parse_url[1].split('#').shift();
				if(anchor == false){
					if(parse_url[1].search('#') > 0){
						anchor = parse_url[1].split('#').pop();
					}
				}
				url = url+'&qs='+encodeURIComponent(qs);
			}
			if(anchor != false){
				if ($('#multi_block_global').length > 0){//si multi block present
					url = url+'&anchor='+encodeURIComponent(block_id_multi_block);
				}else{//si ancre pour scroller sur la page
					url = url+'&anchor='+encodeURIComponent(anchor);
				}
			}
			//alert(url);
			$(window.location).attr('href', url );
		});

	}
}

function navigationMultiblocksAddID(){
	if($('.multi_block_global').length > 0){
		$('.multi_block_global').each(function(index) {
			$(this).children('.multi_block_title').attr('id', "title_id_"+index);
			$(this).children('.multi_block_content_all').attr('id', "content_all_id_"+index);
			$(this).children('.multi_block_content_all').children('.multi_block_content').each(function(ind) {
				var id_tab = this.id;
				$(this).attr('id', "content_all_id_"+index+'_'+id_tab);
				synchronizeSubMultiBlocksId(id_tab);
			});
		});
	}
}

function navigationMultiblocks(){

	if($('.multi_block_title').length > 0){

		$('.multi_block_title').each(function(index) {
			//alert(this.id);
			if($('.multi_block_title').length == 1){
				var active_first = $(this).find('div ul li a');
			} else {
				var active_first = $(this).find('div ul li a.active');
			}
			var p_active = $(active_first).position();
			var p_active_left = p_active.left;
			var p_active_width = $(this).find('div ul li a.active span').width();
			var cursor = $(this).find('.multi_block_title_cursor span');
			var cursor_width = 46;

			var start_left = (p_active_left + (p_active_width / 2)) - (cursor_width / 2);

			$(cursor).css('left',start_left);
		});


		/*
		*  JEL 06/06/2011
		*  Afficher le carrousel a la page destinations
		*/

		if($('#contenu_page').hasClass('section_destinations'))
		{
			var carrousel_active = true;
			if($("#carrousel-visible-part #carrousel-belt").length > 0) {
				if($("div#content_all_id_0_tab1").css("display") == "block" && carrousel_active == true) {
					carrousel();
					carrousel_active = false;
				}
			}
		}
		/*FIN JEL*/


		$("div.tabs a").click(function() {

			if(true === isBot()){
				var url = $(this).attr('href');
				//log(url);
				$(window.location).attr('href', url );
				return true;
			}

			if($(this).hasClass('active') == true)
			{
				var id = this.id.split('_');
				var click_id = id[id.length-1].substr();
				var click_id = id[id.length-1];
				var id_multi_id = click_id.substring( click_id.length - 1, click_id.length);
				var id_div = 'sub_multi_block_content_'+$('#sub_multi_block_content_init_default_'+id_multi_id).html();
				subMultiBlocksId(id_multi_id,id_div)
				return false;
			}
			var parent_div = $(this).closest('.multi_block_title');
			var ancestor_div = $(this).closest('.multi_block_global');
			var id = this.id.split('_');
			var cursor_width = 46;
			var cursor = parent_div.find('.multi_block_title_cursor span');

			var click_id = id[id.length-1];
			var click_position = $(this).position();
			var click_left = click_position.left;
			var click_width = $(this).width();
			var onglet_actif = parent_div.find('div ul li a.active');
			var tab_actif = ancestor_div.find('.multi_block_content_all div.active');
			var position_left = (click_left + (click_width / 2)) - (cursor_width / 2);
			//reloadPageWithHash(cleanUrl($(this).find('span').html()));
			synchronizeSubMultiBlocksId(click_id);
			//multiBlockAjax(click_id);

			if(tab_actif.length > 0)
			{
				cursor.stop().animate(
				{
					left : position_left
				},{
					duration: 700,
					specialEasing: {
						left: 'easeOutExpo'
					}
				});

				var actif = false;

				tab_actif.fadeOut('fast',function(){
					new_tab_actif = tab_actif.attr('id').split('_');
					new_tab_actif[new_tab_actif.length-1]='tab'+click_id;
					new_tab_actif_id = new_tab_actif.join('_');
					//            alert(new_tab_actif_id);
					tab_actif.removeClass('active');
					onglet_actif.removeClass('active');
					onglet_actif.textShadowRemove('active');
					$('#'+new_tab_actif_id).addClass('active');


					parent_div.find('#multi_block_title_span_element_'+click_id).addClass('active');
					$('#'+new_tab_actif_id).fadeIn('fast');
					$('#multi_block_title_span_element_'+click_id).textShadow();

					/*
					*  JEL 06/06/2011
					*  Afficher le carrousel lorsque la page destinations recoit un paramètre
					*  exemple ==> destinations?onglet_mb=4
					*/
					if($('#contenu_page').hasClass('section_destinations'))
					{
						if($("#carrousel-visible-part #carrousel-belt").length > 0) {
							if($("div#content_all_id_0_tab1").css("display") == "block" && carrousel_active == true) {
								carrousel();
								carrousel_active = false;
							}
						}
					}
					/*FIN JEL*/
					document.title = BLOCKS_LINK_MULTIBLOCKS_SEO_TITLES[click_id];
					var meta_desc = BLOCKS_LINK_MULTIBLOCKS_SEO_DESCRIPTIONS[click_id];
					var meta_key = BLOCKS_LINK_MULTIBLOCKS_SEO_KEYWORDS[click_id];
					$('meta[name=description]').attr("content",meta_desc);
					$('meta[name=keywords]').attr("content",meta_key);

				});
			}

			//PAK referencement
			//if(REMOTE_USER == 'sao') {
			var url = $(this).attr('href');
			url = url.replace(/^.*#/, '');
			$.history.load(url);
			//}
			//PAK Fin referencement

			return false;
		});

	}

}

function multiBlockAjax(click_id){
	if(REMOTE_USER == 'moteur' || isBot() ){
		return ;
	}

	if (typeof(async) == 'undefined' || async == true ) {
		async = true ;
	}else{
		async = false ;
	}

	var block_id = BLOCKS_LINK_MULTIBLOCKS_TITLES_ID[click_id];
	var content = BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id];

	block_id_multi_block = block_id ;
	id_block_precedent = $('div.multi_block_title_inner a.active').attr('id');
	nb_id_block_precedent = id_block_precedent.split('_').pop();

	if (nb_id_block_precedent  != click_id){
		var block_id_precedent = BLOCKS_LINK_MULTIBLOCKS_TITLES_ID[nb_id_block_precedent];
		if ($.trim($('#content_all_id_0_tab'+nb_id_block_precedent).html()) != '' ){
			BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id_precedent] = $('#content_all_id_0_tab'+nb_id_block_precedent).contents().detach();
		}
	}
	if (typeof(content ) == 'undefined' || $.trim(content)  == '') {
		//  if(REMOTE_USER == 'sao'){
		ajaxDate = new Date();
		var block_id = BLOCKS_LINK_MULTIBLOCKS_TITLES_ID[click_id];
		$.ajax({
			type: "GET",
			async : async,
			url: domain_name+'?ajax=Blocks_Multi',
			data: "block_id="+block_id+'&controller='+CONTROLLER+'&lg='+LANGUAGE+'&country='+COUNTRY+'&ts='+ajaxDate.getTime(),
			success: function(msg){
				var obj = jQuery.parseJSON(msg);
				//log('JAVASCRIPT_CALL '+JAVASCRIPT_CALL);
				//log('requete ajax');
				if (obj.reponse != ''){
					FIRST_BLOCK_UNIFORM = true;
					initBlock(click_id,obj.reponse);
					uniformiserBlock(click_id);
					BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id] = $('#content_all_id_0_tab'+click_id).contents().detach();
					//initBlock(click_id,BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id]);
					initContentBlock(click_id,BLOCKS_LINK_MULTIBLOCKS_CONTENT[block_id]);
				}
				if(obj.title_seo != ''){
					document.title = obj.title_seo;
				}
				if(obj.description_seo != ''){
					$('meta[name=description]').attr("content",obj.description_seo);
				}
				if(obj.keywords_seo != ''){
					$('meta[name=keywords]').attr("content",obj.keywords_seo);
				}
				seoReportXitiAjax(click_id);
			}
		});
		//}
	}else{
		if(FIRST_BLOCK_UNIFORM === false || (BLOCK_UNIFORM_NUMBRE_ONE === false &&click_id == 1) ){
			initBlock(click_id,content);
			uniformiserBlock(click_id);

			if (click_id == 1  && FIRST_BLOCK_UNIFORM === false ){
				BLOCK_UNIFORM_NUMBRE_ONE = true ;
			}
			if (FIRST_BLOCK_UNIFORM === false){
				FIRST_BLOCK_UNIFORM = true;
			}
			seoReportXitiAjax(click_id);
		}else{
			initContentBlock(click_id,content);
			seoReportXitiAjax(click_id);
		}
	}
	async = true;
}

function seoReportXitiAjax(click_id){
	ajaxDate = new Date();
	var block_id = BLOCKS_LINK_MULTIBLOCKS_TITLES_ID[click_id];
	$.ajax({
		type: "GET",
		async : true,
		url: domain_name+'?ajax=Seoxiti',
		data: "block_id="+block_id+'&controller='+CONTROLLER+'&lg='+LANGUAGE+'&country='+COUNTRY+'&ts='+ajaxDate.getTime(),
		success: function(msg){
			var obj = jQuery.parseJSON(msg);
			if (obj.reponse != ''){
				//alert(obj.reponse);
				$('#seo-end').html(obj.reponse);
				SEOCALL = true;
			}
		}
	});
}

function setSeoReportXitiCALL(){
	SEOCALL = true;
}

function initContentBlock(click_id,content){
	$('.multi_block_content').html('');
	$('#content_all_id_0_tab'+click_id).html(content);
	navigationMultiblocksIdAnchor('multi_block_title_span_element_'+click_id);

}

function initBlock(click_id,content){

	$('.multi_block_content').html('');
	$('#content_all_id_0_tab'+click_id).html(content);
	navigationMultiblocksIdAnchor('multi_block_title_span_element_'+click_id);
	if (typeof(JAVASCRIPT_CALL ) != 'undefined' ) {
		switch(JAVASCRIPT_CALL){
			case 'services': readyServices();
			break;
			case 'destinations': readyDestinations(click_id);
			break;
			case 'business':
			case 'entreprise':
			break;
			case 'historique':
			readyHistorique();
			break;
			case 'soleil':
			readySoleil();
			break;
			case 'neige':
			readyNeige();
			break;
			case 'presse':
			readyPresse();
			break;
			case 'compensation':
			readyCompensation();
			break;
			case 'recrutement':
			readyRecrutement();
			break;
			case 'tarifs':
			readyTarifs();
			break;
			case 'wifi': readyWifi();
			break;
		}
	}
	//log($('#content_all_id_0_tab'+click_id).html());
}

function initMultiblocksId(id_span){
	if($('#'+id_span).length > 0){

		var parent_div = $('#'+id_span).closest('.multi_block_title');
		var ancestor_div = $('#'+id_span).closest('.multi_block_global');
		//      alert(this.id);
		var active_first = parent_div.find('div ul li a.active');
		var p_active = $(active_first).position();
		var p_active_left = p_active.left;
		var p_active_width = parent_div.find('div ul li a.active span').width();
		var cursor_width = 46;
		var cursor = parent_div.find('.multi_block_title_cursor span');

		var start_left = (p_active_left + (p_active_width / 2)) - (cursor_width / 2);
		$(cursor).css('left',start_left);


		var id = id_span.split('_');

		var click_id = id[id.length-1];
		var click_position = parent_div.find('#'+id_span).position();
		var click_left = click_position.left;
		var click_width = parent_div.find('#'+id_span).width();
		var onglet_actif = parent_div.find('div ul li a.active');
		var tab_actif = ancestor_div.find('.multi_block_content_all div.active');
		var position_left = (click_left + (click_width / 2)) - (cursor_width / 2);
		synchronizeSubMultiBlocksId(click_id);

		if(tab_actif.length > 0)
		{
			cursor.stop().animate(
			{
				left : position_left
			},{
				duration: 0,
				specialEasing: {
					left: 'easeOutExpo'
				}
			});

			tab_actif.hide()
			new_tab_actif = tab_actif.attr('id').split('_');
			new_tab_actif[new_tab_actif.length-1]='tab'+click_id;
			new_tab_actif_id = new_tab_actif.join('_');
			//            alert(new_tab_actif_id);
			tab_actif.removeClass('active');
			onglet_actif.removeClass('active');
			$('#'+new_tab_actif_id).addClass('active');
			parent_div.find('#multi_block_title_span_element_'+click_id).addClass('active');
			$('#'+new_tab_actif_id).show();
		}

	}
}

function navigationMultiblocksId(id_span,from){


	// OLJ 2011-07-13 evité de faire les effet si on clic sur l'element active
	// cela posai problème dans business
	if($('#'+id_span).hasClass('active'))
	{
		//	return false;
	}
	//	if ( REMOTE_USER == 'sao') {
	var id_onglet  = id_span.split('_').pop();
	for (var i in  BLOCKS_LINK_MULTIBLOCKS_TITLES)
	{
		if ( BLOCKS_LINK_MULTIBLOCKS_TITLES[i] ==  id_onglet){
			var ancre = i;
		}
	}

	var url = $(window.location).attr('href');
	url = url.split('#')[0];
	url+= '#'+ancre;
	async = false;
	$(window.location).attr('href',url);
	//multiBlockAjax(id_span.split('_').pop(),false);
	/*	}else{
	if($('#'+id_span).length > 0){


	var parent_div = $('#'+id_span).closest('.multi_block_title');
	var ancestor_div = $('#'+id_span).closest('.multi_block_global');
	//      alert(this.id);
	var active_first = parent_div.find('div ul li a.active');
	var p_active = $(active_first).position();
	var p_active_left = p_active.left;
	var p_active_width = parent_div.find('div ul li a.active span').width();
	var cursor_width = 46;
	var cursor = parent_div.find('.multi_block_title_cursor span');

	var start_left = (p_active_left + (p_active_width / 2)) - (cursor_width / 2);
	$(cursor).css('left',start_left);


	var id = id_span.split('_');

	var click_id = id[id.length-1];
	var click_position = parent_div.find('#'+id_span).position();
	var click_left = click_position.left;
	var click_width = parent_div.find('#'+id_span).width();
	var onglet_actif = parent_div.find('div ul li a.active');
	var tab_actif = ancestor_div.find('.multi_block_content_all div.active');
	var position_left = (click_left + (click_width / 2)) - (cursor_width / 2);
	synchronizeSubMultiBlocksId(click_id);

	if(tab_actif.length > 0)
	{
	cursor.stop().animate(
	{
	left : position_left
	},{
	duration: 700,
	specialEasing: {
	left: 'easeOutExpo'
	}
	});

	tab_actif.fadeOut('fast',function(){
	new_tab_actif = tab_actif.attr('id').split('_');
	new_tab_actif[new_tab_actif.length-1]='tab'+click_id;
	new_tab_actif_id = new_tab_actif.join('_');
	//            alert(new_tab_actif_id);
	tab_actif.removeClass('active');
	onglet_actif.removeClass('active');
	$('#'+new_tab_actif_id).addClass('active');
	parent_div.find('#multi_block_title_span_element_'+click_id).addClass('active');
	//multiBlockAjax(click_id);
	$('#'+new_tab_actif_id).fadeIn('fast');
	});
	}
	}
	}*/
}


function navigationMultiblocksIdAnchor(id_span,from){


	// OLJ 2011-07-13 evité de faire les effet si on clic sur l'element active
	// cela posai problème dans business
	if($('#'+id_span).hasClass('active'))
	{
		//  return false;
	}

	if($('#'+id_span).length > 0){

		var parent_div = $('#'+id_span).closest('.multi_block_title');
		var ancestor_div = $('#'+id_span).closest('.multi_block_global');
		//      alert(this.id);
		var active_first = parent_div.find('div ul li a.active');
		var p_active = $(active_first).position();
		var p_active_left = p_active.left;
		var p_active_width = parent_div.find('div ul li a.active span').width();
		var cursor_width = 46;
		var cursor = parent_div.find('.multi_block_title_cursor span');

		var start_left = (p_active_left + (p_active_width / 2)) - (cursor_width / 2);
		$(cursor).css('left',start_left);


		var id = id_span.split('_');

		var click_id = id[id.length-1];
		var click_position = parent_div.find('#'+id_span).position();
		var click_left = click_position.left;
		var click_width = parent_div.find('#'+id_span).width();
		var onglet_actif = parent_div.find('div ul li a.active');
		var tab_actif = ancestor_div.find('.multi_block_content_all div.active');
		var position_left = (click_left + (click_width / 2)) - (cursor_width / 2);
		synchronizeSubMultiBlocksId(click_id);

		if(tab_actif.length > 0)
		{
			cursor.stop().animate(
			{
				left : position_left
			},{
				duration: 700,
				specialEasing: {
					left: 'easeOutExpo'
				}
			});
			tab_actif.hide();
			new_tab_actif = tab_actif.attr('id').split('_');
			new_tab_actif[new_tab_actif.length-1]='tab'+click_id;
			new_tab_actif_id = new_tab_actif.join('_');
			//            alert(new_tab_actif_id);
			tab_actif.removeClass('active');
			onglet_actif.removeClass('active');
			$('#'+new_tab_actif_id).addClass('active');
			parent_div.find('#multi_block_title_span_element_'+click_id).addClass('active');
			//multiBlockAjax(click_id);
			//$('#'+new_tab_actif_id).fadeIn('fast');
			$('#'+new_tab_actif_id).show();

		}
	}

}

function subMultiBlocksId(id_multi_id,id_div){
	if($("#sub_multi_block_content_all_"+id_multi_id).length > 0){
		$div_child = $("#sub_multi_block_content_all_"+id_multi_id).find('.sub_multi_block_content').hide();
	}
	if($("#"+id_div+'_'+id_multi_id).length > 0){
		$("#"+id_div+'_'+id_multi_id).show();
	}
}

function subMultiBlocksClick(){

	if($(".retour_submultiblock_span").length > 0){
		$(".retour_submultiblock_span").click(function() {
			parent_div = $(this).closest('.multi_block_content');
			var id = parent_div.attr('id').split('_');
			var click_id = id[id.length-1].substr();
			var click_id = id[id.length-1];
			var id_multi_id = click_id.substring( click_id.length - 1, click_id.length);
			var id_div = 'sub_multi_block_content_'+$('#sub_multi_block_content_init_default_'+id_multi_id).html();
			subMultiBlocksId(id_multi_id,id_div)
		});
	}
}

function subMultiBlocksIdBetweenTab(id_multi_id,id_div){
	if($("#sub_multi_block_content_default_"+id_multi_id).length > 0){
		$("#sub_multi_block_content_default_"+id_multi_id).html(id_div);
		id_span = 'multi_block_title_span_element_'+id_multi_id;
		navigationMultiblocksId(id_span);
	}
}

function synchronizeSubMultiBlocksId(id_multi_id){
	if($("#sub_multi_block_content_default_"+id_multi_id).length > 0){
		if($("#sub_multi_block_content_all_"+id_multi_id).length > 0){
			$div_child = $("#sub_multi_block_content_all_"+id_multi_id).find('.sub_multi_block_content').hide();
		}
		id_div = 'sub_multi_block_content_'+$("#sub_multi_block_content_default_"+id_multi_id).html();
		if($("#"+id_div+'_'+id_multi_id).length > 0){
			$("#"+id_div+'_'+id_multi_id).show();
		}
	}
}

function autocomplete(){
	/*if($(".form_autocomplete").length > 0){
	$(".form_autocomplete").focus(function() {
	$(this).val('');
	});
	$(".form_autocomplete").autocomplete({
	source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
	});
	}*/
}

function parseDate(str) {
	if(str.indexOf("-") > 0){
		var ymd = str.split('-');
		str = ymd[2]+'/'+ymd[1]+'/'+ymd[0];
	}
	if(str.indexOf(".") > 0){
		var dmy = str.split('.');
		str = dmy[0]+'/'+dmy[1]+'/'+dmy[2];
	}
	var dmy = str.split('/');
	return new Date(dmy[2], dmy[1]-1, dmy[0]);
}

function daydiff(first, second) {
	return (second-first)/(1000*60*60*24)
}

function dateConvertFormat(date_a_convertir,lang){
	var d = date_a_convertir.getDate();
	var m = date_a_convertir.getMonth()+1;
	var y = date_a_convertir.getFullYear()
	switch(lang){
		case 'en':
		return y+'-'+padZero(m)+'-'+padZero(d);
		break;
		case 'de':
		return padZero(d)+'.'+padZero(m)+'.'+y;
		break;
		default:
		return padZero(d)+'/'+padZero(m)+'/'+y;
		break;
	}
}

function padZero(num) {
	return (num < 10) ? '0' + num : '' + num;
}





function dateAller(){
	if($("#date_aller").length > 0){

		$.datepicker.regional[LANGUAGE]['minDate'] = DATE_PREVIEW;
		$.datepicker.regional[LANGUAGE]['maxDate'] = '+3M';
		$.datepicker.regional[LANGUAGE]['onSelect'] = dateRetour;
		$.datepicker.regional[LANGUAGE]['beforeShowDay'] = excludeDatesAller;

		$("#date_aller").datepicker($.datepicker.regional[LANGUAGE]);
	}
}

function dateRetour(date){
	//alert(date);
	if($("#date_aller").length > 0){
		if($("#date_retour").length > 0){
			if($("#date_retour").val() != ''){
				var diff = daydiff(parseDate($("#date_aller").val()), parseDate($("#date_retour").val()))
				if(diff < 0){
					//alert(diff);
					$("#date_retour").val('');
				}
			}
			$("#date_retour").datepicker("destroy");
			$.datepicker.regional[LANGUAGE]['minDate'] = $("#date_aller").val();
			$.datepicker.regional[LANGUAGE]['maxDate'] = '+3M';
			$.datepicker.regional[LANGUAGE]['beforeShowDay'] = excludeDatesRetour;

			$("#date_retour").datepicker($.datepicker.regional[LANGUAGE]);
		}
	}
}

function excludeDatesAller(date){
	var day = date.getDay();
	var closed_dates = [];
	var closed_days = [];
	for (var i = 0; i < closed_days.length; i++) {
		if (day == closed_days[i]) {
			return [false];
		}

	}

	for (i = 0; i < closed_dates.length; i++) {
		if (date.getMonth() == parseInt(closed_dates[i][1],10) - 1 &&
		date.getDate() == parseInt(closed_dates[i][2],10) &&
		date.getFullYear() == parseInt(closed_dates[i][0],10)) {
			return [false];
		}
	}

	return [true];
}

function excludeDatesRetour(date){
	var day = date.getDay();
	var closed_dates = [];
	var closed_days = [];
	for (var i = 0; i < closed_days.length; i++) {
		if (day == closed_days[i]) {
			return [false];
		}

	}

	for (i = 0; i < closed_dates.length; i++) {
		if (date.getMonth() == parseInt(closed_dates[i][1],10) - 1 &&
		date.getDate() == parseInt(closed_dates[i][2],10) &&
		date.getFullYear() == parseInt(closed_dates[i][0],10)) {
			return [false];
		}
	}

	return [true];
}

function selectStationsSort(id_select,label_select){
	var option_main = [];
	var option_be = [];
	var option_fr = [];
	var option_nl = [];
	var option_de = [];
	var option_tgb = [];
	var option_other = [];
	if($("#"+id_select).length > 0){
		var str = '';
		select_station = $("#"+id_select);
		station = select_station.val();
		if(select_station.containsOption("")){
			select_station.removeOption("");
		}
		select_station.sortOptions();
		if(select_station.children('option').length > 1){
			select_station.children('option').each(function() {
				if(isMainStation($(this).val())){
					option_main.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
				}

				switch($(this).val().substr(0,2).toUpperCase()){
					case 'TG':
					case 'BE':
					if($(this).val().length > 5){
						option_tgb.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
					} else {
						option_be.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
					}
					break;
					case 'FR': option_fr.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
					break;
					case 'NL': option_nl.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
					break;
					case 'DE': option_de.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
					break;
					case '': break;
					default: option_other.push( { text: $(this).text(), value: $(this).val(), id: $(this).attr('id') } );
					break;
				}
			});

			if($("#"+id_select+" > option").length > 0){
				$("#"+id_select+" > option").remove();
			}

			if($("#"+id_select+" > optgroup").length > 0){
				$("#"+id_select+" > optgroup").remove();
			}
			if(undefined == label_select){
				label_select = label_faites_votre_choix
			}
			$("#"+id_select).append('<optgroup class="select-main">');
			$("#"+id_select).
			append($("<option></option>").
			attr("value","").
			attr("id","select_empty").
			text(label_select));
			if(option_main.length > 0){
				for( var i = 0; i < option_main.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_main[i]['value']).
					attr("id",option_main[i]['id']).
					text(option_main[i]['text']));
				}
			}
			$("#"+id_select).append('<optgroup label="-------------------"></optgroup></optgroup>');

			//Allemagne
			if(option_de.length > 0){
				$("#"+id_select).append('<optgroup class="select-de" label="'+label_pays_de+'">');
				for( var i = 0; i < option_de.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_de[i]['value']).
					attr("id",option_de[i]['id']).
					text(option_de[i]['text']));
				}
				$("#"+id_select).append('</optgroup>');
			}

			//Belgique
			if(option_be.length > 0){
				$("#"+id_select).append('<optgroup class="select-be" label="'+label_pays_be+'">');
				for( var i = 0; i < option_be.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_be[i]['value']).
					attr("id",option_be[i]['id']).
					text(option_be[i]['text']));
				}
				$("#"+id_select).append('</optgroup>');
			}

			//Autres gares Belges
			if(option_tgb.length > 0){
				$("#"+id_select).append('<optgroup class="select-tgb" label="'+label_autres_gares_belges+'">');
				for( var i = 0; i < option_tgb.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_tgb[i]['value']).
					attr("id",option_tgb[i]['id']).
					attr("class",'select-tgb-option').
					text(option_tgb[i]['text']));
				}
				$("#"+id_select).append('</optgroup>');
			}

			//France
			if(option_fr.length > 0){
				$("#"+id_select).append('<optgroup class="select-fr" label="'+label_pays_fr+'">');
				for( var i = 0; i < option_fr.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_fr[i]['value']).
					attr("id",option_fr[i]['id']).
					text(option_fr[i]['text']));
				}
				$("#"+id_select).append('</optgroup>');
			}

			//Pays-bas
			if(option_nl.length > 0){
				$("#"+id_select).append('<optgroup class="select-nl" label="'+label_pays_nl+'">');
				for( var i = 0; i < option_nl.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_nl[i]['value']).
					attr("id",option_nl[i]['id']).
					text(option_nl[i]['text']));
				}
				$("#"+id_select).append('</optgroup>');
			}

			//Autres
			if(option_other.length > 0){
				$("#"+id_select).append('<optgroup class="select-oc" label="Autres">');
				for( var i = 0; i < option_other.length; i++ ){
					$("#"+id_select).
					append($("<option></option>").
					attr("value",option_other[i]['value']).
					attr("id",option_other[i]['id']).
					text(option_other[i]['text']));
				}
				$("#"+id_select).append('</optgroup>');
			}
		}
		select_station.val(station);
		$.uniform.update("#"+id_select);
	}
}

function pushDestination(destination){
	if(destination == ''){
		destination = COUNTRIES_STATION_DESTINATION_INIT[COUNTRY];
	}
	if(destination != ''){
		$.ajax({
			type: "GET",
			url: domain_name+'?ajax=Push_Destination',
			data: "destination="+destination+'&lg='+LANGUAGE+'&ct='+COUNTRY,
			success: function(msg){
				if($('#push_destination').length > 0){
					$('#push_destination').html(msg);
				}
			}

		});
	}
}


/*************************************************
**************************************************
*************FONCTIONS COMMUNES  FICHIERS**********
**************************************************
*************************************************/


function affichePieceJointe(a){
	var next_input = $('div.piece_jointe_active').last().next('div.piece_jointe_inactive');

	$(next_input).removeClass('piece_jointe_inactive');
	$(next_input).addClass('piece_jointe_active');
}

function cachePieceJointe(a){
	var last_input = $('div.piece_jointe_active').last();
	$(last_input).removeClass('piece_jointe_active');
	$(last_input).addClass('piece_jointe_inactive');
}


/**************************************************************
***************************************************************
*************     FONCTIONS COMMUNES VERIFICATION    **********
***************************************************************
**************************************************************/

function isBot(){
	if(ISBOT == 'BOT'){
		return true;
	}
	return false;
}

function isSeasonStation(gare){
	if($.inArray(gare, SEASON_STATIONS) >= 0){
		return true;
	}
	return false;
}

function isNeigeStation(gare){
	if($.inArray(gare, NEIGE_STATIONS) >= 0){
		return true;
	}
	return false;
}

function isSoleilStation(gare){
	if($.inArray(gare, SOLEIL_STATIONS) >= 0){
		return true;
	}
	return false;
}

function isTGBAllowStation(gare){
	if($.inArray(gare, TGB_ALLOW_STATIONS) >= 0){
		return true;
	}
	return false;
}

function isTGBAllowStationWithoutSuffixe(gare){
	if($.inArray(gare, TGB_ALLOW_STATIONS_WITHOUT_SUFFIXE) >= 0){
		return true;
	}
	return false;
}

function isMainStation(gare){
	if($.inArray(gare, MAIN_STATIONS) >= 0){
		return true;
	}
	return false;
}

function isNewGermanStation(gare){
	if($.inArray(gare, NEW_GERMAN_STATIONS) >= 0){
		return true;
	}
	return false;
}

function isBxlAeroport(gare){
	if($.inArray(gare, CODE_SSIM_BXL_AEROPORT) >= 0){
		return true;
	}
	return false;
}

function setOngletMultiBlockSpan(omb){
	ONGLET_MB_SPAN = omb;
}

function setTitletMultiBlock(block_title_name,id, iddb){
	BLOCKS_LINK_MULTIBLOCKS_TITLES[block_title_name] = id;
	BLOCKS_LINK_MULTIBLOCKS_TITLES_ID[id] = iddb;
	BLOCKS_LINK_MULTIBLOCKS_TITLES_IDDB[iddb] = id;
}

function setContentMultiBlock(iddb,content){
	BLOCK_UNIFORM_NUMBRE_ONE = false ;
	BLOCKS_LINK_MULTIBLOCKS_CONTENT[iddb] = content.content;
}


function setSeoMultiBlock(id, content){
	BLOCKS_LINK_MULTIBLOCKS_SEO_TITLES[id] = content.title;
	BLOCKS_LINK_MULTIBLOCKS_SEO_DESCRIPTIONS[id] = content.description;
	BLOCKS_LINK_MULTIBLOCKS_SEO_KEYWORDS[id] = content.keywords;

	if(REMOTE_USER == 'pak'){
		//alert(id+" => "+BLOCKS_LINK_MULTIBLOCKS_SEO_TITLES[id]+" => "+BLOCKS_LINK_MULTIBLOCKS_SEO_DESCRIPTIONS[id]+" => "+BLOCKS_LINK_MULTIBLOCKS_SEO_KEYWORDS[id]);
	}
}

function navigationMultiblocksTitle(block_title_name){
	if(undefined != BLOCKS_LINK_MULTIBLOCKS_TITLES[block_title_name]){
		id_span = 'multi_block_title_span_element_'+BLOCKS_LINK_MULTIBLOCKS_TITLES[block_title_name];
		navigationMultiblocksId(id_span);
	}
}

function setTitletSubMultiBlock(sub_block_title_name,id,id_onglet){
	if(undefined == BLOCKS_LINK_SUB_MULTIBLOCKS_TITLES[id_onglet]){
		BLOCKS_LINK_SUB_MULTIBLOCKS_TITLES[id_onglet] = [];
	}
	BLOCKS_LINK_SUB_MULTIBLOCKS_TITLES[id_onglet][sub_block_title_name] = id;
}

function navigationSubMultiblocksTitle(block_title_name, sub_block_title_name){
	if(undefined != BLOCKS_LINK_MULTIBLOCKS_TITLES[block_title_name]){
		var id_multi_id = BLOCKS_LINK_MULTIBLOCKS_TITLES[block_title_name];
		if(undefined != BLOCKS_LINK_SUB_MULTIBLOCKS_TITLES[id_multi_id][sub_block_title_name]){
			var id_div = BLOCKS_LINK_SUB_MULTIBLOCKS_TITLES[id_multi_id][sub_block_title_name];
			subMultiBlocksIdBetweenTab(id_multi_id,id_div);
		}
	}
}

function thalysAccountLayer()
{
	var btn_account = $('#btn_thalys_account');
	if(btn_account.length > 0)
	{
		btn_account.click(function(){
			return showThalysAccountLayer();
		});
	}
}

function showThalysAccountLayer()
{
	var deconnexion_link = $('#div_thalys_account .mon_compte_deconnexion_label');
	var layer = $('#div_thalys_account');
	
	if(deconnexion_link.length > 0)
	{
		layer.fadeIn("fast");
		$(document).click(function(event){
			var target = event.target;
			if($(target).parents('#div_thalys_account').length == 0 && $(target).attr('id') != 'div_thalys_account')
			{
				layer.fadeOut("fast");
			}
		});
		return false;
	}
	return true;
}

function affiche_layer(){
	$("a#btn_compte_thalys").click(function () {
		var deconnexion_link = $('#div_compte_thalys .mon_compte_deconnexion_label');
		if(deconnexion_link.length > 0)
		{
			$("div#div_compte_thalys").fadeIn("fast");
			return false;
		}else{
			return true;
		}
	});
	$("div#div_compte_thalys").click(function () {
		$("div#div_compte_thalys").fadeOut("fast");
	});

	var deconnexion_link = $('#div_compte_thalys .mon_compte_deconnexion_label');

	if(deconnexion_link.length > 1){
		var deconnexion_newsletter_overlayer = $('#deconnexion_newsletter_overlayer');
		if(deconnexion_newsletter_overlayer.length > 0)
		{
			deconnexion_newsletter_overlayer.popin({id_content:'#deconnexion_newsletter_overlayer',id_btn:'#deconnexion_newsletter'});
		}

		var deconnexion_thepass_overlayer = $('#deconnexion_thepass_overlayer');
		if(deconnexion_newsletter_overlayer.length > 0)
		{
			deconnexion_thepass_overlayer.popin({id_content:'#deconnexion_thepass_overlayer',id_btn:'#deconnexion_thepass'});
		}

		var deconnexion_wifi_overlayer = $('#deconnexion_wifi_overlayer');
		if(deconnexion_wifi_overlayer.length > 0)
		{
			deconnexion_wifi_overlayer.popin({id_content:'#deconnexion_wifi_overlayer',id_btn:'#deconnexion_wifi'});
		}

		var deconnexion_business_overlayer = $('#deconnexion_business_overlayer');
		if(deconnexion_business_overlayer.length > 0)
		{
			deconnexion_business_overlayer.popin({id_content:'#deconnexion_business_overlayer',id_btn:'#deconnexion_business'});
		}

		var deconnexion_ticketless_overlayer = $('#deconnexion_ticketless_overlayer');
		if(deconnexion_ticketless_overlayer.length > 0)
		{
			deconnexion_ticketless_overlayer.popin({id_content:'#deconnexion_ticketless_overlayer',id_btn:'#deconnexion_ticketless'});
		}
	}
}

function setDetailsDescriptionAmbassadeur(){
	var short_desc = 0;
	$('.profile-welcomer #en_savoir_plus').click(function(){
		switch(short_desc){
			case 0:
			$('.profile-welcomer .contenu_shortener').hide();
			$('.profile-welcomer .desc-fin').show();
			$(this).html(label_reduire);
			short_desc++;
			break;
			case 1:
			$('.profile-welcomer .contenu_shortener').show();
			$('.profile-welcomer .desc-fin').hide();
			$(this).html(label_en_savoir_plus);
			short_desc--;
			break;
		}
	});
}

function setBtnPrint(){
	var btn_print = $('.btn_print');
	if(btn_print.length > 0)
	{
		btn_print.click(function(){
			window.print();
			return false;
		});
	}
}

function verifFormulaireNewsletterFooter(){

	$.ajax({
		type: "GET",
		url: domain_name+'?ajax=Footer_Newsletter',
		data: "email_footer="+$("#email_footer").val()+'&lg='+LANGUAGE+'&country='+COUNTRY,
		success: function(msg){
			var obj = jQuery.parseJSON(msg);
			if (obj.valide == 'non_valide'){
				$('.form_box span.error').remove();
				$('#email_footer').addClass('error');
				$('#email_footer').before(obj.reponse);
			}else{
				$(window.location).attr('href', domain_name+obj.reponse );
			}
		}
	});
	return false;
}

function initNewsletterFooter(){
	if($( "#email_footer" ).length > 0){
		if($( "#email_footer" ).val() == ''){
			$( "#email_footer" ).val(label_adresse_email);
		}
	}
}


function newsletterFooterFocus(){
	if($( "#email_footer" ).length > 0){
		$('#email_footer').focus(function() {
			if($(this).val() == label_adresse_email){
				$(this).val('');
			}
		});
	}
}


function newsletterFooterBlur(){
	if($( "#email_footer" ).length > 0){
		$('#email_footer').blur(function() {
			if($.trim($(this).val()) == ''){
				$(this).val(label_adresse_email);
			}
		});
	}
}

//abe
var tableau_select = [];
function hideActifSelect() {

	if ( $.browser.msie ) {
		if( parseInt($.browser.version,10) == 6) {
			$("select").each( function(i, elem) {

				if($(this).css('display') != 'none') {
					tableau_select.push({id: this.id} );
					$(this).css('display','none');
					//log(tableau_select[i].id);
				}

			});

		}
	}
}

function showActifSelect()  {

	for(i=0; i<tableau_select.length; i++){
		$("#"+tableau_select[i].id).css('display','');
	}

}

function seoAfterPageLoaded(){
	if(false === SEOCALL){
		$.ajax({
			type: "GET",
			url: domain_name+'?ajax=Seo',
			data: '&lg='+LANGUAGE+'&country='+COUNTRY,
			success: function(msg){
				var obj = jQuery.parseJSON(msg);
				$('#seo-end').append(obj.reponse);
			}
		});
	}

}
//end abe

function initEvenementCIN(elementCin,avec_prefixe)
{
	if (elementCin.length > 0){
		if (avec_prefixe){
			valeur_par_defaut = '';
		}else{
			valeur_par_defaut = '30840601';
		}
		elementCin.keyup( function() { synchronizeCIN(this); } );
		elementCin.blur( function() {  synchronizeCIN(this); } );
	}
}

function synchronizeCIN(elementCin)
{
	var cin = $(elementCin).val();
	nbr_occurence = 0 ;

	if (valeur_par_defaut != ''){
		position = cin.indexOf(valeur_par_defaut);
		while  (position != -1)
		{
			position = cin.indexOf(valeur_par_defaut,position + valeur_par_defaut.length);
			nbr_occurence++;
		}
	}

	if((cin !='' && nbr_occurence  > 1) || valeur_par_defaut == ''){
		var aRemplacer = /30840601/g;
		cin = cin.replace(aRemplacer, '');
		$(elementCin).val(valeur_par_defaut+cin);
	}
}

