/**
 * Actions that are executed right after the DOM loads
 */
$(document).ready
(
		function()
	{
		/*
		** Encart developpement durable (box)
		*/
		bindColorBox (
			'#lien_podcast',
			this.href,
			585,
			650
		);
		
		/*
		** Boutons Newsletters (box)
		*/
		bindColorBox (
			'.newsletter button',
			'/newsletter.html,1,1',
			398,
			164
		);
		bindColorBox (
			'.news-affaires button',
			'/newsletter.html,1,0',
			398,
			164
		);
		bindColorBox (
			'.news-evasion button',
			'/newsletter.html,0,1',
			398,
			164
		);
		
		/*
		** Lien Intranet (box)
		*/
		bindColorBox (
			'#lien_intranet',
			this.href,
			450,
			185,
			true // no-iframe
		);
		
		/*
		** Liens Newsletter (box)
		*/
		bindColorBox (
			'.lien_newsletter',
			this.href,
			398,
			164
		);
		
		/*
		** Bouton encart Rngagements Planete
		*/
		$('#encart_planete button').click (function ()
		{
			$(location).attr('href','/nos-engagements-pour-la-planete.html');
		});
		
		/*
		** Bouton encart Engagements Planete
		*/
		$('#encart_recrutement button').click (function ()
		{
			$(location).attr('href','/offres-emploi/page/1.html');
		});
		
		/*
		** Liens Agences Loisirs : plus d'infos (box)
		*/
		bindColorBox (
			'a.plus-infos',
			this.href,
			750,
			452
		);
		
		/*
		** Liens Toutes les Infos Flash : (box)
		*/
		bindColorBox (
			'.fin_info_flash a',
			this.href,
			600,
			352
		);
		
		/*
		** Encart actualites
		*/
		$('#encart_actualites button').click (function ()
		{
			$(location).attr('href','/actualites/page/1.html');
		});
		
		/*
		** Reve de voyage
		*/
		$('.reve_voyage button').click (function ()
		{
			$(location).attr('href','/vacances-loisirs/votre-reve-de-voyages.html');
		});
		$('.devis').click (function (e)
		{
			e.preventDefault ();
			parent.location = this.href;
		});
		
		/*
		** Offre coup de coeur
		*/
		$('.offre_cdc button').click (function ()
		{
			$(location).attr('href','http://bleu.selectour.com');
		});
		
		/*
		** Reservation en ligne
		*/
		$('.encart_resa button').click (function ()
		{
			$(location).attr ('href','http://resa.bleu-voyages.fr/BLEU_VOYAGES_WEB/includes/bleu-voyages/index.html');
		});
		
		/*
		** Menus de navigation gauches
		*/
		/*
		$('#menu_deplacements_professionnels').click (function ()
		{
			$('.sous_menu_principal1').animate (
				{
					height: 'toggle'
				},
				500
			);
			return false;
		});
		$('#menu_vacances_loisirs').click (function ()
		{
			$('.sous_menu_principal2').animate (
				{
					height: 'toggle'
				},
				500
			);
			return false;
		});
		$('#menu_groupes_loisirs').click (function ()
		{
			$('.sous_menu_principal3').animate (
				{
					height: 'toggle'
				},
				500
			);
			return false;
		});
		*/
		
		/*
		** Filtre de departements (pour les agences)
		*/
		$('#filtre #departement').change (function ()
		{
			$('#filtre').submit ();
		});
		
		/*
		** Carousel Infos Flash
		*/
		$(window).load(function(){
			$("#texte_info_flash").icecarousel ({
				speed : 1000,
				rotate : true,
				rotate_speed : 6000
			});
		});
		
		/*
		** Carousel Liens Utiles
		*/
		$(window).load(function(){
			$(".scrolling").icecarousel({
				btnNext: ".fleche_droite",
				btnPrev: ".fleche_gauche",
				speed : 500,
				rotate : false
			});
		});
		
		/*
		**
		*/
		var go = false;
		$('#esmile_connecter').click(function(e)
		{
			var mylogin = $('#T_Login').val();
			var mymdp = $('#T_Password').val();
			if (mylogin.substr(0,4) == 'kds/' || mylogin.substr(0,4) == 'KDS/')
			{
				e.preventDefault();
				$.ajax({
					type: "POST",
					url: "/kds/ajaxLogin.php",
					data: "login="+mylogin+"&mdp="+mymdp,
					success: function(msg)
					{	
						if (msg != 'x')
						{
							document.location.href = msg;
						}
						else
						{
							var cb_h = 168;
							var cb_w = 450; 
							
							cb_h = cb_h+34; // ...because of the absence of title bar
							var nav = navigator.appVersion, h;
							if (nav.indexOf('MSIE 7.0') != -1)
							cb_h = cb_h+70; // ...because IE sucks 
							
							$.fn.colorbox
							({
								iframe: true,
								width: cb_w,
								height: cb_h,
								close: 'Fermer',
								scrolling: false,
								opacity: 0.6,
								href: '/kds/login-incorrect.html'
							}); 
						}
					}
				});
			}
		});
	}
);
