/* ======================================== DREAMWEAVER */

	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

/* ======================================== COMMUN */

	function decorateList(list_id)
	{
		list = $('#'+ list_id);

		list.children(':even').addClass('even');
		list.children(':odd').addClass('odd');
		list.children(':first').addClass('first');
		list.children(':last').addClass('last');
	}

	function adjustListItemsMargins(list_id, children_filter)
	{
		list = $('#'+ list_id);
		items = list.children();

        itemsWidth = 0;
        items.each(function() {
        	itemsWidth += $(this).outerWidth();
        });

        emptyWidth = list.width() - itemsWidth;

        if (0 < emptyWidth) {
            distWidth = Math.floor(emptyWidth / items.length);

            paddLeft = distWidth / 2;
            if (1 == distWidth%2) paddLeft = Math.ceil(paddLeft);
            paddRight = distWidth - paddLeft;

            remainingWidth = emptyWidth - (paddLeft + paddRight) * items.length;

            children = items;
            if (undefined != children_filter) children = items.find(children_filter);

            children.each(function(i) {
                left    = parseInt($(this).css('padding-left')) + paddLeft;
                right   = parseInt($(this).css('padding-right')) + paddRight;

                if (0 < remainingWidth) {
                    if (left > right) right++;
                    else left++;
                    remainingWidth--;
                }

                $(this).css('padding-left', left +'px');
                $(this).css('padding-right', right +'px');
            });
        }

        // certains navigateurs ont du mal avec les modèles de boîtes
        // le dernier élément peut passer à la ligne
        // si c'est le cas, on va rogner sur les marges qu'on vient de calculer

        first_item_offset = children.filter(':first').offset();
        last_item_offest = children.filter(':last').offset();

        if (last_item_offest.top != first_item_offset.top)
        {
            i = 0;

            while (last_item_offest.top > first_item_offset.top)
            {
                // IE bugge si on passe par children.eq(i) !!
                children.each(function(j) {
                    if (i == j)
                    {
                        $(this).css('padding-left', (parseInt($(this).css('padding-left')) - 1) + 'px');
                    }
                });

                last_item_offest = children.filter(':last').offset();

                i = (i+1)%children.length;
            }
        }
	}

	function focusInput(input)
	{
		$(input).css('background-position', '0 -16px');
	}

	function blurInput(input)
	{
		$(input).css('background-position', '0 0');
	}

	function survolBloc(bloc)
	{
		$(bloc).toggleClass('hover');
	}

/* ======================================== SUPRABAR */

	/* newsletter */

	function focusNewsletter(input, default_text)
	{
		if ($(input).val() == default_text) $(input).val('');
	}

	function blurNewsletter(input, default_text)
	{
		if ($(input).val() == '') $(input).val(default_text);
	}

	function submitNewsletter(form, error_message)
	{
		value = $(form).find('input[type="text"]').val();
		result = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
		if (!result) alert(error_message);
		return result;
	}

/* ======================================== METEO */

	function meteoChangeContent()
	{
		divs_ids = new Array();
		div_i = undefined;

		$('#meteo-bandeau').children('div').each(function(i) {
			div = $(this);

			divs_ids.push(div.attr('id'));

			if (div.is(':visible')) {
				div.hide();
				div_i = i;
			}
		});

		div_i = (div_i + 1) % divs_ids.length;

		$('#'+ divs_ids[div_i]).show();
	}

	function meteoAnimate()
	{
		setInterval("meteoChangeContent()", 5000);
	}

/* ======================================== PLAN DE SITE */

	function decorateSitemapList(list_id)
	{
		list = $('#'+ list_id);
		items = list.children();
		items_count = items.length;

		items.each(function(i) {
			classe = '';

			if ((4 == i%5) || (i == (items_count - 1))) classe = 'line-last';

			if ('' != classe) $(this).addClass(classe);
		});
	}

/* ======================================== LANDING PAGE */

	/* pages statiques */

	function decorateStaticPagesList(list_id)
	{
		list = $('#'+ list_id);
		items = list.children();

		items.each(function(i) {
			classe = '';

			if (0 == i%3) classe = 'line-first';
			else if (1 == i%3) classe = 'line-middle';
			else if (2 == i%3) classe = 'line-last';

			if ('' != classe) $(this).addClass(classe);
		});
	}



/* ------------------- fin refonte par Aurélien ------------------- */



// ================================== HOME AGENDA
	function equilibreLesColonnes(colonneGauche,colonneDroite,lienTamponGauche,lienTamponDroite)
	{
		hauteurGauche = document.getElementById(colonneGauche).offsetHeight;
		hauteurDroite = document.getElementById(colonneDroite).offsetHeight;

		if(hauteurDroite > hauteurGauche)
		{
			difference = (hauteurDroite - hauteurGauche) + 20;
			document.getElementById(lienTamponGauche).style.height = difference + "px";
		}

		else if(hauteurGauche > hauteurDroite)
		{
			difference = (hauteurGauche - hauteurDroite) + 20;
			document.getElementById(lienTamponDroite).style.height = difference + "px";
		}
	}
// ================================== HOME AGENDA


// ================================== SURVOL BLOCS DROITE
	function equilibreLesColonnes2(colonneGauche,colonneDroite,lienTamponGauche,lienTamponDroite)
	{
		hauteurGauche = document.getElementById(colonneGauche).offsetHeight;
		hauteurDroite = 0;
		if(document.getElementById(colonneDroite)){
			hauteurDroite = document.getElementById(colonneDroite).offsetHeight;
		}

		if(hauteurDroite > hauteurGauche)
		{
			difference = (hauteurDroite - hauteurGauche) + 10;
			document.getElementById(lienTamponGauche).style.height = difference + "px";
		}

		else if(hauteurGauche > hauteurDroite)
		{
			if(document.getElementById(lienTamponDroite)){
				difference = (hauteurGauche - hauteurDroite) + 10;
				document.getElementById(lienTamponDroite).style.height = difference + "px";
			}
		}
	}
// ================================== SURVOL BLOCS DROITE


// ================================== SURVOL OUVERTURE FERMETURE ACCORDEONS
	function survolAccordeonOn(element)
	{
		element.style.backgroundColor = "#e3e3e3";
	}

	function survolAccordeonOff(element)
	{
		element.style.backgroundColor = "#f2f2f2";
	}

	function survolAccordeonAnnuaireOn(element)
	{
		element.style.backgroundColor = "#e3e3e3";
		element.style.backgroundPosition = "0 -700px";
	}

	function survolAccordeonAnnuaireOff(element,fond)
	{
		if(fond == "fond1")
		{
			element.style.backgroundColor = "#f2f2f2";
		}
		else
		{
			element.style.backgroundColor = "#fff";
		}
		element.style.backgroundPosition = "0 0";
	}

	function ouvrirFermerAccordeon(accordeon,lienAccordeon,intitule1,intitule2)
	{
		if(document.getElementById(accordeon).className == "invisible")
		{
			for (i=0; i<blocsAccordeonsTab.length; i++)
			{
				if(accordeon == blocsAccordeonsTab[i])
				{
					document.getElementById(blocsAccordeonsTab[i]).className = "visible";
					document.getElementById(liensAccordeonsTab[i]).innerHTML = intitule2;
				}
				else
				{
					document.getElementById(blocsAccordeonsTab[i]).className = "invisible";
					document.getElementById(liensAccordeonsTab[i]).innerHTML = intitule1;
				}
			}
		}
		else
		{
			document.getElementById(accordeon).className = "invisible";
			document.getElementById(lienAccordeon).innerHTML = intitule1;
		}
	}
// ================================== SURVOL OUVERTURE FERMETURE ACCORDEONS


// ================================== COMBO ANNUAIRE
	function ouvrirFermerCombo(combo)
	{
		$("ul").each(function() {
			if ( $(this).hasClass("visible") ){
				$(this).toggleClass("invisible");
			}
		});

		if(document.getElementById(combo).className == "invisible")
		{
			document.getElementById(combo).className = "visible";
			if(combo != 'listemeetingSpaceRequired'){
				if(document.getElementById('comboListe6')){
					document.getElementById('comboListe6').style.position = "static";
				}
			}
		}
		else
		{
			document.getElementById(combo).className = "invisible";
			if(combo != 'listemeetingSpaceRequired'){
				if(document.getElementById('comboListe6')){
					document.getElementById('comboListe6').style.position = "relative";
				}
			}
		}
	}

	function ouvrirFermerCombo2(combo,combo2,combo3)
	{
		$("ul").each(function() {
			if ( $(this).hasClass("visible") ){
				$(this).toggleClass("invisible");
			}
		});

		if(document.getElementById(combo).className == "invisible")
		{
			document.getElementById(combo).className = "visible";
			if(document.getElementById(combo2)){
				document.getElementById(combo2).style.position = "static";
			}
			if(document.getElementById(combo3)){
				document.getElementById(combo3).style.position = "static";
			}
			if(document.getElementById('comboListe3')){
				document.getElementById('comboListe3').style.position = "static";
			}
			if(document.getElementById('comboListe4')){
				document.getElementById('comboListe4').style.position = "static";
			}
			if(document.getElementById('comboListe5')){
				document.getElementById('comboListe5').style.position = "static";
			}
		}
		else
		{
			document.getElementById(combo).className = "invisible";
			if(document.getElementById(combo2)){
				document.getElementById(combo2).style.position = "relative";
			}
			if(document.getElementById(combo3)){
				document.getElementById(combo3).style.position = "relative";
			}
			if(document.getElementById('comboListe3')){
				document.getElementById('comboListe3').style.position = "relative";
			}
			if(document.getElementById('comboListe4')){
				document.getElementById('comboListe4').style.position = "relative";
			}
			if(document.getElementById('comboListe5')){
				document.getElementById('comboListe5').style.position = "relative";
			}
		}
	}

	function ouvrirFermerCombo3(combo,combo2)
	{
		$("ul").each(function() {
			if ( $(this).hasClass("visible") ){
				$(this).toggleClass("invisible");
			}
		});

		if(document.getElementById(combo).className == "invisible")
		{
			document.getElementById(combo).className = "visible";
			if(document.getElementById(combo2)){
				document.getElementById(combo2).style.position = "static";
			}
		}
		else
		{
			document.getElementById(combo).className = "invisible";
			if(document.getElementById(combo2)){
				document.getElementById(combo2).style.position = "relative";
			}
		}
	}

	function majSelected(valeur,elSelected)
	{
		nouveauSelected = valeur.innerHTML;
		document.getElementById(elSelected).innerHTML = nouveauSelected;
	}

	function majSelectedContact(valeur,elSelected,indice)
	{
		nouveauSelected = valeur.innerHTML;
		document.getElementById(elSelected).innerHTML = nouveauSelected;
		document.getElementById("contactObjet").value = indice;
	}

	function majHidden(valeur,champHidden)
	{
		document.getElementById(champHidden).value = valeur;

		if(champHidden == 'hiddennbpersonne'){
			// affiche les sous-formulaires des personnes correspondants
			var reg = new RegExp("[|]+", "g");
			var nbPersonne = valeur.split(reg);

			// on les cache tous
			for(var i=1; i<=100; i++){
				if(document.getElementById('personne_'+i)){
					document.getElementById('personne_'+i).className = "invisible";
					// vidage des champs
					document.getElementById('nom_'+i).value = '';
					document.getElementById('prenom_'+i).value = '';
					document.getElementById('email_'+i).value = '';
					document.getElementById('portable_'+i).value = '';
					document.getElementById('hiddenfonction_'+i).value = '';
					//document.getElementById('cartepresse_'+i).value = '';
					document.getElementById('hiddenarrivee_'+i).value = '';
					document.getElementById('hiddendepart_'+i).value = '';
				}
			}
			for(var i=1; i<=nbPersonne[0]; i++){
				document.getElementById('personne_'+i).className = "visible";
			}
		}

		if(champHidden == 'resaParkingParking'){
			// il faut afficher la hauteur du parking, les navettes et le bon visuel
			$.ajax({
				dataType: 'xml',
				type: 'POST',
				data: 'idparking='+valeur,
				url: '/ajax/getparking/',
				success: function(reponse){
					var type = 0;
	                var errortxt = '';
				    $(reponse).find('error').each(
				    	function(){
							type = $(this).attr('type');
							errortxt = $(this).text();
						}
					);
				    appendHtml = "";
	                if(type == 0 && errortxt == ''){
	                	var parking = $(reponse).find('parking');
			    		var title = parking.find('title').text();
			    		var locatorX = parking.find('locatorX').text();
			    		var locatorY = parking.find('locatorY').text();
			    		var locatorRadius = parking.find('locatorRadius').text();
			    		var map = parking.find('map').text();
			    		var hauteur = parking.find('hauteur').text();
			    		var nbPlaceDefault = parking.find('nbPlaceDefault').text();
			    		var navette = parking.find('navette').text();

			    		if(document.getElementById("type").value == 'auto'){
				    		$("#hauteurMaxParking").empty();
				    		$("#hauteurMaxParking").append(hauteur);
				    		document.getElementById("hauteurParking").value = hauteur;

				    		$("#horairesNavettes").empty();
				    		$("#horairesNavettes").append(navette);
			    		}

			    		// met a jour la localisation
			    		if(locatorX != '' && locatorY != '' && locatorRadius != '' && map != ''){
				    		var localisation = '';
				    		localisation += '<div id="localiserFlash"></div>';
				    		localisation += '<script type="text/javascript">';
				    		localisation += 'var so = new SWFObject("/swf/mapExplorer.swf", "main", "400", "240", "8", "#2E2E2E");';
				    		localisation += 'so.useExpressInstall("/swf/expressInstall.swf");';
				    		localisation += 'so.setAttribute("xiRedirectUrl", document.URL); ';
				    		localisation += 'so.addParam("scale","noscale");';
				    		localisation += 'so.addParam("wmode", "transparent");';
				    		localisation += 'so.addParam("allowFullscreen","true");';
				    		localisation += 'so.addVariable("modeEdit", false);';
				    		localisation += 'so.addVariable("urlMap", "'+map+'");';
				    		localisation += 'so.addVariable("urlScript", "");';
				    		localisation += 'so.addVariable("locator", "true");';
				    		localisation += 'so.addVariable("locatorX", "'+locatorX+'");';
				    		localisation += 'so.addVariable("locatorY", "'+locatorY+'");';
				    		localisation += 'so.addVariable("locatorRadius", "'+locatorRadius+'");';
				    		localisation += 'so.addVariable("urlMapList","Station,/swf/map/mapStation.swf;Le Villaret,/swf/map/mapStationVillaret.swf;Les Boisses,/swf/map/mapStationBoisses.swf;Les Brévières,/swf/map/mapStationBrevieres.swf;Le Franchet,/swf/map/mapStationFranchet.swf;La Reculaz,/swf/map/mapStationReculaz.swf");';
				    		localisation += 'so.addVariable("urlRoot", "");';
				    		localisation += 'so.addVariable("locatorName", "'+title+'");';
				    		localisation += 'so.write("localiserFlash");';
				    		localisation += '</script>';
				    		$("#resaParkingLocalisation").empty();
				    		$("#resaParkingLocalisation").append(localisation);
			    		}else{
			    			var localisation = '';
				    		localisation += '<div id="localiserFlash"></div>';
				    		localisation += '<script type="text/javascript">';
				    		localisation += 'var so = new SWFObject("/swf/mapExplorer.swf", "main", "400", "240", "8", "#2E2E2E");';
				    		localisation += 'so.useExpressInstall("/swf/expressInstall.swf");';
				    		localisation += 'so.setAttribute("xiRedirectUrl", document.URL); ';
				    		localisation += 'so.addParam("scale","noscale");';
				    		localisation += 'so.addParam("wmode", "transparent");';
				    		localisation += 'so.addParam("allowFullscreen","true");';
				    		localisation += 'so.addVariable("modeEdit", false);';
				    		localisation += 'so.addVariable("urlMap", "/swf/map/mapStation.swf");';
				    		localisation += 'so.addVariable("urlScript", "");';
				    		localisation += 'so.addVariable("locator", "false");';
				    		localisation += 'so.addVariable("locatorX", "");';
				    		localisation += 'so.addVariable("locatorY", "");';
				    		localisation += 'so.addVariable("locatorRadius", "");';
				    		localisation += 'so.addVariable("urlMapList","Station,/swf/map/mapStation.swf;Le Villaret,/swf/map/mapStationVillaret.swf;Les Boisses,/swf/map/mapStationBoisses.swf;Les Brévières,/swf/map/mapStationBrevieres.swf;Le Franchet,/swf/map/mapStationFranchet.swf;La Reculaz,/swf/map/mapStationReculaz.swf");';
				    		localisation += 'so.addVariable("urlRoot", "");';
				    		localisation += 'so.addVariable("locatorName", "");';
				    		localisation += 'so.write("localiserFlash");';
				    		localisation += '</script>';
				    		$("#resaParkingLocalisation").empty();
				    		$("#resaParkingLocalisation").append(localisation);
			    		}
				    }
				}
			});

			// verifie la hauteur parking/vehicule
			checkHauteur();

			// recalcul du tarif
			calculerTarif();
		}
	}

	function changeVisuelDroite()
	{
		// fonction a completer pour modifier le flash localisation parking dans le div resaParkingLocalisation, ajouter parametres si necessaires ici et dans l'appel de la fonction sur les liens de la combo parking
	}
// ================================== COMBO ANNUAIRE


// ================================== OUVERTURE - FERMETURE ANIMATIONS
	function ouvertureFermetureAgenda(bloc,lien)
	{
		if(document.getElementById(bloc).className == "contenuAnimationInvisible")
		{
			for (i=0; i<blocsAgendaTab.length; i++)
			{
				if(bloc == blocsAgendaTab[i])
				{
					document.getElementById(blocsAgendaTab[i]).className = "contenuAnimationVisible";
					document.getElementById(liensAgendaTab[i]).style.fontWeight = "bold";
				}
				else
				{
					if(document.getElementById(blocsAgendaTab[i])){
						document.getElementById(blocsAgendaTab[i]).className = "contenuAnimationInvisible";
						document.getElementById(liensAgendaTab[i]).style.fontWeight = "normal";
					}
				}
			}
		}
		else
		{
			document.getElementById(bloc).className = "contenuAnimationInvisible";
			document.getElementById(lien).style.fontWeight = "normal";
		}
	}
// ================================== OUVERTURE - FERMETURE ANIMATIONS


// ======================================= VERIFICATION FORM CONTACT
	function statutCheckbox(checkbox,champHidden)
	{
		if(document.getElementById(checkbox).src.indexOf("case-a-cocher-off") != -1)
		{
			document.getElementById(checkbox).src = "/img/case-a-cocher-on.gif";
			document.getElementById(champHidden).value = true;
		}
		else
		{
			document.getElementById(checkbox).src = "/img/case-a-cocher-off.gif";
			document.getElementById(champHidden).value = false;
		}
	}

	function contactCheckEmail(fieldId)
	{
		$('#contactChampEmail').css('border-color', '#3e3e3e');
		$('#contactLabel1').css('color', '#'+site_color);

		reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
		val = $.trim($('#contactChampEmail').val());

		if (('' != val) && reg_email.test(val)) {
			$.ajax({
				beforeSend: function (xhr) {
					$('body').prepend('<div id="grey-bkg"></div>');
					$('body').prepend('<div id="masque-contact"></div>');
				},
				complete:   function (xhr) {
					$('#masque-contact').remove();
					$('#grey-bkg').remove();
				},
				data:		'email='+ val,
				dataType:	'json',
				success:	function (data) {
					if ('' != data) {
						if ('' != data.langue) {
							$('#contactLangue').val(data.langue);
							$('#contactChampLangue').text(data.langue_title);
						}
						if ('' != data.nom) $('#contactChampNom').val(data.nom);
						if ('' != data.prenom) $('#contactChampPrenom').val(data.prenom);
						if ('' != data.pays) {
							$('#contactPays').val(data.pays);
							$('#contactChampPays').text(data.pays_title);
						}
						if ('' != data.cp) {
							$('#contactChampCP').val(data.cp);
						}
						if ('' != data.saison) {
							$('#contactSaison').val(data.saison);
							$('#contactChampSaison').text(data.saison_title);
						}
						if ('' != data.vacances) {
							$('#contactVacances').val(data.vacances);
							$('#contactChampVacances').text(data.vacances_title);
						}
						if (!$('#contact-texte-nl').length) {
							if (0 == data.optin) statutCheckbox('contactCheckbox','contactNewsletter');
							if (0 == data.partenaire) statutCheckbox('contactCheckboxPartenaire','contactPartenaire');
						}
					}
				},
				type:		'POST',
				url:		'/ajax/get-email-infos'
			});
		} else {
			$('#contactChampEmail').css('border-color', '#f00');
			$('#contactLabel1').css('color', '#f00');
		}
	}

	function validationContact()
	{
		requiredFields = new Array('contactChampEmail', 'contactLangue',      'contactChampNom', 'contactChampPrenom', 'contactChampCP', 'contactPays',	    'contactSaison'/*,	  'contactVacances'*/);
        requiredBoxes  = new Array('contactChampEmail', 'contactChampLangue', 'contactChampNom', 'contactChampPrenom', 'contactChampCP', 'contactChampPays', 'contactChampSaison'/*, 'contactChampVacances'*/);
        requiredLabels = new Array('contactLabel1',     'contactLabel2',      'contactLabel9',   'contactLabel10',	   'contactLabel3',  'contactLabel4',	'contactLabel5'/*,	  'contactLabel6'*/);

		if ($('#contactObjet').length) {
			requiredFields.push('contactObjet', 'contactChampMessage');
			requiredBoxes.push('contactChampObjet', 'contactChampMessage');
			requiredLabels.push('contactLabel7', 'contactLabel8');
		}

		$.each(requiredBoxes, function() {
			$('#'+this).css('border-color', '#3e3e3e');
		});

		$.each(requiredLabels, function() {
			$('#'+this).css('color', '#'+site_color);
		});

		var nErreur = new Array();

		reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;

		for (i = 0; i < requiredFields.length; i++) {
			val = $.trim($('#'+requiredFields[i]).val());
			ok  = false;

			switch (requiredFields[i]) {
				case 'contactChampEmail':
					ok = (('' != val) && reg_email.test(val));
					break;
				case 'contactObjet':
					ok = (('' != val) && ('1|-------------|' != val));
					break;
				default:
					ok = ('' != val);
					break;
			}

			if (!ok) {
				nErreur.push(i);
				$('#'+requiredBoxes[i]).css('border-color', '#f00');
				$('#'+requiredLabels[i]).css('color', '#f00');
			}
		}

		return (0 == nErreur.length);
	}
// ======================================= VERIFICATION FORM CONTACT


// ======================================= VERIFICATION CONNEXION MEDIATHEQUE
	function validationConnexionMedia()
	{
		monform = document.connexionMediaForm;
		document.getElementById("connexionLogin").style.border = "2px solid #3e3e3e";
		document.getElementById("connexionLabel1").style.color = "#000";
		document.getElementById("connexionMdp").style.border = "2px solid #3e3e3e";
		document.getElementById("connexionLabel2").style.color = "#000";


		var erreurs;
		var nErreur = new Array();

		if (monform.connexionLogin.value=='')
		{
			nErreur.push(0);
			document.getElementById("connexionIdentifiant").style.border = "2px solid #ff0000";
			document.getElementById("connexionLabel1").style.color = "#ff0000";
		}

		if (monform.connexionMdp.value=='')
		{
			nErreur.push(1);
			document.getElementById("connexionMdp").style.border = "2px solid #ff0000";
			document.getElementById("connexionLabel2").style.color = "#ff0000";
		}

		erreurs = nErreur.length;
		if(erreurs>0)
		{
			return false;
		}
		return true;
	}
// ======================================= VERIFICATION CONNEXION MEDIATHEQUE


// ======================================= VERIFICATION CONDITIONS MEDIATHEQUE
	function validationConditionsMedia()
	{
		monform = document.conditionsMediaForm;
		document.getElementById("conditionsLienCheckbox").style.color = "#474747";

		var erreurs;
		var nErreur = new Array();

		if (monform.conditionAccepte.value == false)
		{
			nErreur.push(0);
			document.getElementById("conditionsLienCheckbox").style.color = "#ff0000";
		}

		erreurs = nErreur.length;
		if(erreurs>0)
		{
			return false;
		}
		return true;
	}
// ======================================= VERIFICATION CONDITIONS MEDIATHEQUE


// ======================================= GESTION DES BOUTONS RADIO
	function statutRadio(radio1,champHidden,radio2,valeur)
	{
		if(document.getElementById(radio1).src.indexOf("radio-bouton-off.gif") != -1)
		{
			document.getElementById(radio1).src = "/img/radio-bouton-on.gif";
			document.getElementById(radio2).src = "/img/radio-bouton-off.gif";
			document.getElementById(champHidden).value = valeur;
		}
		else
		{
			document.getElementById(radio1).src = "/img/radio-bouton-off.gif";
			document.getElementById(champHidden).value = "";
		}

		if(valeur == 0){
			$('.forfaitN').hide();
		}else if(valeur == 1){
			$('.forfaitN').show();
		}
	}

	function majRadio(image, images, hidden, value)
	{
		image = $('#'+ image);

		if(-1 != image.attr('src').indexOf("radio-bouton-off.gif"))
		{
			majHidden(value, hidden);

			image.attr('src', "/img/radio-bouton-on.gif");

			$.each($.makeArray(images), function() {
				$('#'+ this).attr('src', "/img/radio-bouton-off.gif");
			});
		}
		else
		{
			majHidden(' ', hidden);
			image.attr('src', "/img/radio-bouton-off.gif");
		}
	}
// ======================================= GESTION DES BOUTONS RADIO


// ======================================= OUVERTURE / FERMETURE FENETRE MODALE
	function ouvrirModale(nb)
	{
		hauteurLigne = 189;
		if(nb == 1)
		{
			posY = -250;
		}
		else
		{
			posY = -250 + (hauteurLigne*(nb-1));
		}
		document.getElementById('rechercheFenetreModale').style.top = posY+"px";
		document.getElementById('rechercheFenetreModale').className = "visible";

	}

	function fermerModale()
	{
		document.getElementById('rechercheFenetreModale').className = "invisible";
	}
// ======================================= OUVERTURE / FERMETURE FENETRE MODALE


// ======================================= LISTE HOTELS
	function changeSaison(ongletActif,ongletInactif,tableauVisible,tableauInvisible)
	{
		document.getElementById(ongletActif).className = "accordeonLienSaisonActif";
		if(document.getElementById(ongletInactif)){
			document.getElementById(ongletInactif).className = "accordeonLienSaison";
		}
		document.getElementById(tableauVisible).className = "visible";
		if(document.getElementById(tableauInvisible)){
			document.getElementById(tableauInvisible).className = "invisible";
		}
	}
// ======================================= LISTE HOTELS


// ======================================= PAGINATION MEDIATHEQUE
	function paginationMediatheque(link)
	{
		document.getElementById('rechercheMedia').action = link;
		document.getElementById('rechercheMedia').submit();
	}

// ======================================= PAGINATION MEDIATHEQUE


// ======================================= VALIDATION RESA PARKING
	function validationResaParking(message, type)
	{
		//monform = document.resaParkingForm;@
		monform = document.getElementById("resaParkingForm");

		if(type == 'auto'){
			document.getElementById("resaParkingLabel0a").style.color = '#'+site_color;
			document.getElementById("resaParkingLabel0b").style.color = "#000";
			document.getElementById("resaParkingLabel0c").style.color = "#000";
			document.getElementById("nForfait1").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait2").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait3").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait4").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait5").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait6").style.border = "2px solid #3e3e3e";
			document.getElementById("resaParkingLabel1").style.color = '#'+site_color;
			document.getElementById("nForfait1Conf").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait2Conf").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait3Conf").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait4Conf").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait5Conf").style.border = "2px solid #3e3e3e";
			document.getElementById("nForfait6Conf").style.border = "2px solid #3e3e3e";
			document.getElementById("resaParkingLabel1Conf").style.color = '#'+site_color;
			document.getElementById("resaParkingNom").style.border = "2px solid #3e3e3e";
			document.getElementById("resaParkingLabel2").style.color = '#'+site_color;
			document.getElementById("resaParkingPrenom").style.border = "2px solid #3e3e3e";
			document.getElementById("resaParkingLabel3").style.color = '#'+site_color;
		}
		if(type == 'bus'){
			document.getElementById("raisonSociale").style.border = "2px solid #3e3e3e";
			document.getElementById("resaParkingLabel2").style.color = '#'+site_color;
		}
		document.getElementById("resaParkingEmail").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel4").style.color = '#'+site_color;
		document.getElementById("resaParkingConfirmEmail").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel5").style.color = '#'+site_color;
		document.getElementById("resaParkingAdresse").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel6").style.color = '#'+site_color;
		document.getElementById("resaParkingCP").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel7").style.color = '#'+site_color;
		document.getElementById("resaParkingVille").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel8").style.color = '#'+site_color;
		document.getElementById("resaParkingTel").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel9").style.color = '#'+site_color;
		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel10").style.color = '#'+site_color;
		document.getElementById("resaParkingDateDepart").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel11").style.color = '#'+site_color;
		document.getElementById("resaParkingParking").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel12").style.color = '#'+site_color;
		document.getElementById("resaParkingImmatriculation").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel13").style.color = '#'+site_color;
		if(type == 'auto'){
			document.getElementById("resaParkingHauteurVehicule").style.border = "2px solid #3e3e3e";
			document.getElementById("resaParkingLabel14").style.color = '#'+site_color;
		}

		document.getElementById("resaParkingLabel15").style.color = "#474747";
		document.getElementById("resaParkingLabel16").style.color = "#474747";
		document.getElementById("resaParkingLabel17").style.color = "#474747";
		$("#errorFormGeneral").empty();
	  	$("#errorFormGeneral").append('');


		var erreurs;
		var nErreur = new Array();

		var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
		var reg_hauteur = /^[1-2]{1}[m][0-9]{2}$/;

		if(type == 'auto'){
			if (monform.resaParkingForfaitOuiNon.value=='')
			{
				nErreur.push(0);
				document.getElementById("resaParkingLabel0a").style.color = "#ff0000";
				document.getElementById("resaParkingLabel0b").style.color = "#ff0000";
				document.getElementById("resaParkingLabel0c").style.color = "#ff0000";
			}

			if (monform.resaParkingForfaitOuiNon.value=='1'){
				if (monform.nForfait1.value=='' || monform.nForfait2.value=='' || monform.nForfait3.value=='' || monform.nForfait4.value=='' || monform.nForfait5.value=='' || monform.nForfait6.value=='')
				{
					nErreur.push(1);
					document.getElementById("nForfait1").style.border = "2px solid #ff0000";
					document.getElementById("nForfait2").style.border = "2px solid #ff0000";
					document.getElementById("nForfait3").style.border = "2px solid #ff0000";
					document.getElementById("nForfait4").style.border = "2px solid #ff0000";
					document.getElementById("nForfait5").style.border = "2px solid #ff0000";
					document.getElementById("nForfait6").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait1.value.length != 2)
				{
					nErreur.push(1);
					document.getElementById("nForfait1").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait2.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait2").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait3.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait3").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait4.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait4").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait5.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait5").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait6.value.length != 1)
				{
					nErreur.push(1);
					document.getElementById("nForfait6").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1").style.color = "#ff0000";
				}
				if (monform.nForfait1Conf.value=='' || monform.nForfait2Conf.value=='' || monform.nForfait3Conf.value=='' || monform.nForfait4Conf.value=='' || monform.nForfait5Conf.value=='' || monform.nForfait6Conf.value=='')
				{
					nErreur.push(1);
					document.getElementById("nForfait1Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait2Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait3Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait4Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait5Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait6Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait1Conf.value.length != 2)
				{
					nErreur.push(1);
					document.getElementById("nForfait1Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait2Conf.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait2Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait3Conf.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait3Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait4Conf.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait4Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait5Conf.value.length != 5)
				{
					nErreur.push(1);
					document.getElementById("nForfait5Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait6Conf.value.length != 1)
				{
					nErreur.push(1);
					document.getElementById("nForfait6Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
				if (monform.nForfait1.value!=monform.nForfait1Conf.value || monform.nForfait2.value!=monform.nForfait2Conf.value || monform.nForfait3.value!=monform.nForfait3Conf.value || monform.nForfait4.value!=monform.nForfait4Conf.value || monform.nForfait5.value!=monform.nForfait5Conf.value || monform.nForfait6.value!=monform.nForfait6.value)
				{
					nErreur.push(1);
					document.getElementById("nForfait1Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait2Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait3Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait4Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait5Conf").style.border = "2px solid #ff0000";
					document.getElementById("nForfait6Conf").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel1Conf").style.color = "#ff0000";
				}
			}

			if (monform.resaParkingNom.value=='')
			{
				nErreur.push(2);
				document.getElementById("resaParkingNom").style.border = "2px solid #ff0000";
				document.getElementById("resaParkingLabel2").style.color = "#ff0000";
			}

			if (monform.resaParkingPrenom.value=='')
			{
				nErreur.push(3);
				document.getElementById("resaParkingPrenom").style.border = "2px solid #ff0000";
				document.getElementById("resaParkingLabel3").style.color = "#ff0000";
			}
		}
		if(type == 'bus'){
			if (monform.raisonSociale.value=='')
			{
				nErreur.push(3);
				document.getElementById("raisonSociale").style.border = "2px solid #ff0000";
				document.getElementById("resaParkingLabel2").style.color = "#ff0000";
			}
		}

		if (monform.resaParkingEmail.value=='' || !reg_email.test(monform.resaParkingEmail.value))
		{
			nErreur.push(4);
			document.getElementById("resaParkingEmail").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel4").style.color = "#ff0000";
		}

		if (monform.resaParkingConfirmEmail.value=='' || !reg_email.test(monform.resaParkingConfirmEmail.value))
		{
			nErreur.push(5);
			document.getElementById("resaParkingConfirmEmail").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel5").style.color = "#ff0000";
		}

		if (monform.resaParkingEmail.value != monform.resaParkingConfirmEmail.value)
		{
			nErreur.push(6);
			document.getElementById("resaParkingEmail").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel4").style.color = "#ff0000";
			document.getElementById("resaParkingConfirmEmail").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel5").style.color = "#ff0000";
		}

		if (monform.resaParkingAdresse.value=='')
		{
			nErreur.push(7);
			document.getElementById("resaParkingAdresse").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel6").style.color = "#ff0000";
		}

		if (monform.resaParkingCP.value=='')
		{
			nErreur.push(8);
			document.getElementById("resaParkingCP").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel7").style.color = "#ff0000";
		}

		if (monform.resaParkingVille.value=='')
		{
			nErreur.push(9);
			document.getElementById("resaParkingVille").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel8").style.color = "#ff0000";
		}

		if (monform.resaParkingTel.value=='')
		{
			nErreur.push(10);
			document.getElementById("resaParkingTel").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel9").style.color = "#ff0000";
		}

		if (monform.resaParkingDateArrivee.value=='')
		{
			nErreur.push(11);
			document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel10").style.color = "#ff0000";
		}

		if (monform.resaParkingDateDepart.value=='')
		{
			nErreur.push(12);
			document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel11").style.color = "#ff0000";
		}

		if (monform.resaParkingParking.value=='')
		{
			nErreur.push(13);
			document.getElementById("resaParkingParking").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel12").style.color = "#ff0000";
		}

		if(type == 'auto'){
			if (monform.resaParkingHauteurVehicule.value=='' || !reg_hauteur.test(monform.resaParkingHauteurVehicule.value))
			{
				nErreur.push(15);
				document.getElementById("resaParkingHauteurVehicule").style.border = "2px solid #ff0000";
				document.getElementById("resaParkingLabel14").style.color = "#ff0000";
			}
		}

		if (monform.resaParkingAccepteConditions.value=='' || monform.resaParkingAccepteConditions.value=='false')
		{
			nErreur.push(16);
			document.getElementById("resaParkingLabel15").style.color = "#ff0000";
			document.getElementById("resaParkingLabel16").style.color = "#ff0000";
			document.getElementById("resaParkingLabel17").style.color = "#ff0000";
		}

		if(type == 'auto'){
			if(-1 == nErreur.indexOf(15) && document.getElementById("hauteurParking").value != '' && document.getElementById("resaParkingHauteurVehicule").value != ''){
				if(!checkHauteur()){
					nErreur.push(17);
				}
			}
			calculerTarif();
		}

		erreurs = nErreur.length;
		if(erreurs>0)
		{
			$("#errorFormGeneral").empty();
			$("#errorFormGeneral").append(message);
			document.getElementById("errorFormGeneral").style.color = "#ff0000";
			alert(message);
			return false;
		}else{
			monform.submit();
		}
	}
// ======================================= VALIDATION RESA PARKING


// ======================================= CALCUL DU TARIF PARKING A CHAQUE CHANGEMENT DE VALEUR
	function calculerTarif(){
		var tarif = '0 &euro;';
	  	$("#resaParkingMontant>span").empty();
	  	$("#resaParkingMontant>span").append(tarif);

		$("#errorPeriode").empty();
		$("#errorPeriode").append('');

		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel10").style.color = '#'+site_color;
		document.getElementById("resaParkingDateDepart").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel11").style.color = '#'+site_color;

		var arrivee = document.getElementById('resaParkingDateArrivee').value;
		var depart = document.getElementById('resaParkingDateDepart').value;
		var parking = document.getElementById('resaParkingParking').value;
		var type = document.getElementById('type').value;

		var nErreur = new Array();

		var validDate = false;
		if(arrivee != '' && depart != ''){
			dateArrivee = new Date(arrivee.substring(0,4),arrivee.substring(5,7)-1,arrivee.substring(8,10));
			dateDepart = new Date(depart.substring(0,4),depart.substring(5,7)-1,depart.substring(8,10));
			today = new Date();
			today.setDate(today.getDate()+2);
			today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
			if(dateArrivee && dateDepart){
				if(dateDepart > dateArrivee && dateDepart >= today && dateArrivee >= today){
					validDate = true;
				}else if(dateDepart <= dateArrivee){
					// affichage de l'erreur
			    	$("#errorPeriode").empty();
		    		$("#errorPeriode").append(translations.depart_superieure_arrivee);
		    		document.getElementById("errorPeriode").style.color = "#ff0000";
		    		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
		    		document.getElementById("resaParkingLabel10").style.color = "#ff0000";
		    		document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
		    		document.getElementById("resaParkingLabel11").style.color = "#ff0000";
				}else if(dateDepart < today){
					// affichage de l'erreur
			    	$("#errorPeriode").empty();
		    		$("#errorPeriode").append(translations.depart_superieure_aujourdhui);
		    		document.getElementById("errorPeriode").style.color = "#ff0000";
		    		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
		    		document.getElementById("resaParkingLabel10").style.color = "#ff0000";
		    		document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
		    		document.getElementById("resaParkingLabel11").style.color = "#ff0000";
				}else if(dateArrivee < today){
					// affichage de l'erreur
			    	$("#errorPeriode").empty();
		    		$("#errorPeriode").append(translations.arrivee_superieure_aujourdhui);
		    		document.getElementById("errorPeriode").style.color = "#ff0000";
		    		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
		    		document.getElementById("resaParkingLabel10").style.color = "#ff0000";
		    		document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
		    		document.getElementById("resaParkingLabel11").style.color = "#ff0000";
				}
			}
		}else{
			if (arrivee == '')
			{
				nErreur.push(11);
				document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
				document.getElementById("resaParkingLabel10").style.color = "#ff0000";
			}

			if (depart == '')
			{
				nErreur.push(12);
				document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
				document.getElementById("resaParkingLabel11").style.color = "#ff0000";
			}
		}

		if(validDate && parking != ''){
			$.ajax({
				dataType: 'xml',
				type: 'POST',
				data: 'arrivee='+arrivee+'&depart='+depart+'&parking='+parking+'&type='+type,
				url: '/ajax/calculertarif/',
				success: function(reponse){
					var type = 0;
	                var errortxt = '';
				    $(reponse).find('error').each(
				    	function(){
							type = $(this).attr('type');
							errortxt = $(this).text();
						}
					);
				    appendHtml = "";
	                if(type == 0 && errortxt == ''){
	                	var tarif = $(reponse).find('tarif').text() + ' &euro;';

			    		$("#resaParkingMontant>span").empty();
			    		$("#resaParkingMontant>span").append(tarif);
				    }else{
				    	// affichage de l'erreur
				    	$("#errorPeriode").empty();
			    		$("#errorPeriode").append(errortxt);
			    		document.getElementById("errorPeriode").style.color = "#ff0000";

			    		var tarif = '0 &euro;';
					  	$("#resaParkingMontant>span").empty();
					  	$("#resaParkingMontant>span").append(tarif);
				    }
				}
			});
		}
	}
// ======================================= CALCUL DU TARIF PARKING A CHAQUE CHANGEMENT DE VALEUR


// ======================================= VERIFIE lA HAUTEUR PARKING/VEHICULE
	function isFlottant(value){
		var tmpValue = value;
		if ( ( tmpValue != "" )  && ( tmpValue != null ) ){
			tmpValue = parseFloat(tmpValue);
			tmpValue = tmpValue + "";
			if (tmpValue == value){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}

	function checkHauteur(){
		var retour = false;
		if(document.getElementById("resaParkingLabel14") && document.getElementById("resaParkingHauteurVehicule")){
			document.getElementById("resaParkingLabel14").style.color = '#'+site_color;
			document.getElementById("resaParkingHauteurVehicule").style.border = "2px solid #3e3e3e";

			var hauteurParking = document.getElementById("hauteurParking").value;
			hauteurParking = hauteurParking.replace(/,/g, '.');
			hauteurParking = hauteurParking.replace(/m/g, '.');
			if(hauteurParking.indexOf('.') == hauteurParking.length-1){
				hauteurParking = hauteurParking.substr(0, hauteurParking.indexOf('.'));
			}
			var hauteurVehicule = document.getElementById("resaParkingHauteurVehicule").value;
			hauteurVehicule = hauteurVehicule.replace(/,/g, '.');
			hauteurVehicule = hauteurVehicule.replace(/m/g, '.');
			if(hauteurVehicule.indexOf('.') == hauteurVehicule.length-1){
				hauteurVehicule = hauteurVehicule.substr(0, hauteurVehicule.indexOf('.'));
			}

			if(hauteurParking != '' && hauteurVehicule != ''){
				if((!isNaN(hauteurParking) || !isNaN(hauteurParking)) && (!isNaN(hauteurVehicule) || !isNaN(hauteurVehicule))){
					if(isFlottant(hauteurParking)){
						hauteurParking = parseFloat(hauteurParking);
					}
					if(isFlottant(hauteurVehicule)){
						hauteurVehicule = parseFloat(hauteurVehicule);
					}

					if(hauteurVehicule >= hauteurParking){
						document.getElementById("resaParkingHauteurVehicule").style.border = "2px solid #ff0000";
						document.getElementById("resaParkingLabel14").style.color = "#ff0000";
					}else{
						retour = true;
					}
				}else{
					document.getElementById("resaParkingHauteurVehicule").style.border = "2px solid #ff0000";
					document.getElementById("resaParkingLabel14").style.color = "#ff0000";
				}
			}
		}
		return retour;
	}
// ======================================= VERIFIE lA HAUTEUR PARKING/VEHICULE


// ======================================= AFFICHE / CACHE L'IMAGE SKIPASS SUR PARKING
	function showImgSkiPass(){
		$('#resaParkingNforfaitPlusInfo').show();
	}

	function hideImgSkiPass(){
		$('#resaParkingNforfaitPlusInfo').hide();
	}
// ======================================= AFFICHE / CACHE L'IMAGE SKIPASS SUR PARKING


// ======================================= VALIDATION FORM X GAMES
	function validationFormXGames(message)
	{
		monform = document.getElementById("FormMediaWinterXGames");

		document.getElementById("title").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel1").style.color = '#'+site_color;
		document.getElementById("resaParkingAdresse").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel2").style.color = '#'+site_color;
		document.getElementById("resaParkingCP").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel3").style.color = '#'+site_color;
		document.getElementById("resaParkingVille").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel4").style.color = '#'+site_color;
		document.getElementById("resaParkingLabel5").style.color = '#'+site_color;
		document.getElementById("resaParkingLabel6").style.color = '#'+site_color;
		document.getElementById("resaParkingLabel7").style.color = '#'+site_color;
		document.getElementById("resaParkingLabel8").style.color = '#'+site_color;
		document.getElementById("budget").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel9").style.color = '#'+site_color;
		document.getElementById("resaParkingLabel10").style.color = '#'+site_color;

		$("#errorFormGeneral").empty();
	  	$("#errorFormGeneral").append('');

		var erreurs;
		var nErreur = new Array();

		if (monform.title.value=='')
		{
			nErreur.push(1);
			document.getElementById("title").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel1").style.color = "#ff0000";
		}

		if (monform.hiddentypemedia.value=='')
		{
			nErreur.push(6);
			document.getElementById("resaParkingLabel10").style.color = "#ff0000";
		}

		if (monform.resaParkingAdresse.value=='')
		{
			nErreur.push(2);
			document.getElementById("resaParkingAdresse").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel2").style.color = "#ff0000";
		}

		if (monform.resaParkingCP.value=='')
		{
			nErreur.push(3);
			document.getElementById("resaParkingCP").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel3").style.color = "#ff0000";
		}

		if (monform.resaParkingVille.value=='')
		{
			nErreur.push(4);
			document.getElementById("resaParkingVille").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel4").style.color = "#ff0000";
		}

		if (monform.resaParkingPays.value=='')
		{
			nErreur.push(5);
			document.getElementById("resaParkingLabel5").style.color = "#ff0000";
		}

		if (monform.hiddennbpersonne.value=='')
		{
			nErreur.push(6);
			document.getElementById("resaParkingLabel6").style.color = "#ff0000";
		}

		if (monform.hiddenvehicule.value=='')
		{
			nErreur.push(7);
			document.getElementById("resaParkingLabel7").style.color = "#ff0000";
		}

		if (monform.hiddenhebergement.value=='')
		{
			nErreur.push(8);
			document.getElementById("resaParkingLabel8").style.color = "#ff0000";
		}

		if (monform.budget.value=='')
		{
			nErreur.push(9);
			document.getElementById("budget").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel9").style.color = "#ff0000";
		}

		erreurs = nErreur.length;
		if(erreurs>0)
		{
			$("#errorFormGeneral").empty();
			$("#errorFormGeneral").append(message);
			document.getElementById("errorFormGeneral").style.color = "#ff0000";
			alert(message);
			return false;
		}else{
			monform.submit();
		}
	}
// ======================================= VALIDATION FORM X GAMES


// ======================================= VALIDATION FORM GROUP
	function validationFormGroup(message)
	{
		monform = document.getElementById("FormGroup");

		document.getElementById("arrivee").style.border = "2px solid #3e3e3e";
		document.getElementById("label-arrivee").style.color = '#'+site_color;
		document.getElementById("depart").style.border = "2px solid #3e3e3e";
		document.getElementById("label-depart").style.color = '#'+site_color;

		document.getElementById("raisonsociale").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel1").style.color = '#'+site_color;
		document.getElementById("champtypeSociete").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel10").style.color = '#'+site_color;
		document.getElementById("resaParkingNom").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel2").style.color = '#'+site_color;
		document.getElementById("resaParkingPrenom").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel3").style.color = '#'+site_color;
		document.getElementById("resaParkingEmail").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel4").style.color = '#'+site_color;
		document.getElementById("resaParkingTel").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel5").style.color = '#'+site_color;
		/*
		document.getElementById("resaParkingAdresse").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel6").style.color = '#'+site_color;
		document.getElementById("resaParkingCP").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel7").style.color = '#'+site_color;
		document.getElementById("resaParkingVille").style.border = "2px solid #3e3e3e";
		document.getElementById("resaParkingLabel8").style.color = '#'+site_color;
		*/
		document.getElementById("resaParkingLabel9").style.color = '#'+site_color;

		$("#errorFormGeneral").empty();
	  $("#errorFormGeneral").append('');

		$("#errorPeriode").empty();
	  $("#errorPeriode").append('');

		var erreurs;
		var nErreur = new Array();

		if (monform.raisonsociale.value=='')
		{
			nErreur.push(1);
			document.getElementById("raisonsociale").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel1").style.color = "#ff0000";
		}
		if (monform.hiddentypeSociete.value=='')
		{
			nErreur.push(10);
			document.getElementById("champtypeSociete").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel10").style.color = "#ff0000";
		}
		if (monform.resaParkingNom.value=='')
		{
			nErreur.push(2);
			document.getElementById("resaParkingNom").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel2").style.color = "#ff0000";
		}
		if (monform.resaParkingPrenom.value=='')
		{
			nErreur.push(3);
			document.getElementById("resaParkingPrenom").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel3").style.color = "#ff0000";
		}
		if (monform.resaParkingEmail.value=='')
		{
			nErreur.push(4);
			document.getElementById("resaParkingEmail").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel4").style.color = "#ff0000";
		}
		if (monform.resaParkingTel.value=='')
		{
			nErreur.push(5);
			document.getElementById("resaParkingTel").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel5").style.color = "#ff0000";
		}
		/*
		if (monform.resaParkingAdresse.value=='')
		{
			nErreur.push(6);
			document.getElementById("resaParkingAdresse").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel6").style.color = "#ff0000";
		}
		if (monform.resaParkingCP.value=='')
		{
			nErreur.push(7);
			document.getElementById("resaParkingCP").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel7").style.color = "#ff0000";
		}
		if (monform.resaParkingVille.value=='')
		{
			nErreur.push(8);
			document.getElementById("resaParkingVille").style.border = "2px solid #ff0000";
			document.getElementById("resaParkingLabel8").style.color = "#ff0000";
		}
		*/
		if (monform.resaParkingPays.value=='')
		{
			nErreur.push(9);
			document.getElementById("resaParkingLabel9").style.color = "#ff0000";
		}

		var arrivee = document.getElementById('arrivee').value;
		var depart = document.getElementById('depart').value;
    var dateValid = true;

		if (('' != arrivee) || ('' != depart))
    {
			today = new Date();
			today.setDate(today.getDate()+2);
			today = new Date(today.getFullYear(), today.getMonth(), today.getDate());

      dateArrivee = null;
			if ('' != arrivee)
      {
        dateArrivee = new Date(arrivee.substring(0,4),arrivee.substring(5,7)-1,arrivee.substring(8,10));
      }

      dateDepart = null;
      if ('' != depart)
      {
        dateDepart = new Date(depart.substring(0,4),depart.substring(5,7)-1,depart.substring(8,10));
      }

      if ((null != dateArrivee) && (dateArrivee < today))
      {
        nErreur.push(10);

        dateValid = false;

        $("#errorPeriode").append(translations.arrivee_superieure_aujourdhui);
        document.getElementById("errorPeriode").style.color = "#ff0000";

        document.getElementById("arrivee").style.border = "2px solid #ff0000";
        document.getElementById("label-arrivee").style.color = "#ff0000";
      }

      if ((null != dateDepart) && (dateDepart < today))
      {
        nErreur.push(11);

        dateValid = false;

        if ('' != $("#errorPeriode").text()) $("#errorPeriode").append('<br />');
        $("#errorPeriode").append(translations.depart_superieure_aujourdhui);
        document.getElementById("errorPeriode").style.color = "#ff0000";

        document.getElementById("depart").style.border = "2px solid #ff0000";
        document.getElementById("label-depart").style.color = "#ff0000";
      }

      if (dateValid && (null != dateDepart) && (null != dateArrivee) && (dateDepart <= dateArrivee))
      {
        nErreur.push(12);

        dateValid = false;

        if ('' != $("#errorPeriode").text()) $("#errorPeriode").append('<br />');
        $("#errorPeriode").append(translations.depart_superieure_arrivee);
        document.getElementById("errorPeriode").style.color = "#ff0000";

        document.getElementById("arrivee").style.border = "2px solid #ff0000";
        document.getElementById("label-arrivee").style.color = "#ff0000";
        document.getElementById("depart").style.border = "2px solid #ff0000";
        document.getElementById("label-depart").style.color = "#ff0000";
      }

//			if(dateArrivee && dateDepart){
//				if(dateDepart > dateArrivee && dateDepart >= today && dateArrivee >= today){
//					validDate = true;
//				}else if(dateDepart <= dateArrivee){
//					// affichage de l'erreur
//			    	$("#errorPeriode").empty();
//		    		$("#errorPeriode").append(translations.depart_superieure_arrivee);
//		    		document.getElementById("errorPeriode").style.color = "#ff0000";
//		    		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
//		    		document.getElementById("resaParkingLabel10").style.color = "#ff0000";
//		    		document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
//		    		document.getElementById("resaParkingLabel11").style.color = "#ff0000";
//				}else if(dateDepart < today){
//					// affichage de l'erreur
//			    	$("#errorPeriode").empty();
//		    		$("#errorPeriode").append(translations.depart_superieure_aujourdhui);
//		    		document.getElementById("errorPeriode").style.color = "#ff0000";
//		    		document.getElementById("resaParkingDateArrivee").style.border = "2px solid #ff0000";
//		    		document.getElementById("resaParkingLabel10").style.color = "#ff0000";
//		    		document.getElementById("resaParkingDateDepart").style.border = "2px solid #ff0000";
//		    		document.getElementById("resaParkingLabel11").style.color = "#ff0000";
//				}else if(dateArrivee < today){
//					// affichage de l'erreur
//				}
//			}
		}

		erreurs = nErreur.length;
		if(erreurs>0)
		{
			$("#errorFormGeneral").empty();
			$("#errorFormGeneral").append(message);
			document.getElementById("errorFormGeneral").style.color = "#ff0000";
			alert(message);
			return false;
		}else{
			monform.submit();
		}
	}
// ======================================= VALIDATION FORM GROUP

