
/**
 * Layer recherche
 */
(function($j){
	$j.fn.formChoixDestinataire = function (options) {
		
		this.options = {};
		this.state = 'user'; // user|email
		
		this.init = function(options) {
			var self = this; // To set as a context on sub
			
			// On initialise le formulaire
			if ($j('#destinataire_carte_email_error_message').length>0 || $j('#isEmailSelected').is(':checked')){
				this.change_to_state_email();
			} else {
				this.change_to_state_user();
			}
			
			// Gestion du clic de radio
			if ($j('#popup_ajout_carteclub_destinataire').length>0){
				$j('.radioChoixDest').live('click', function(){
					if ($j('#isUserSelected').is(':checked') && self.state == 'email') {
						self.change_to_state_user();
					} else if ($j('#isEmailSelected').is(':checked') && self.state == 'user'){
						self.change_to_state_email();
					}
				});
			}
		}
		
		this.show_date_validity_user = function(){
			$j('#validity_destinataire_user').css('display', 'block');
		}
		this.hide_date_validity_user = function(){
			$j('#validity_destinataire_user').css('display', 'none');
		}		
		this.show_date_validity_email = function(){
			$j('#validity_destinataire_email').css('display', 'block');
		}
		this.hide_date_validity_email = function(){
			$j('#validity_destinataire_email').css('display', 'none');
		}		
		this.display_email = function(){
			$j('#box_destinataire').css('display', 'block');
		}		
		this.hide_email = function(){
			$j('#box_destinataire').css('display', 'none');
		}
		
		this.change_to_state_user = function(){
			this.hide_email();
			this.hide_date_validity_email();
			this.show_date_validity_user();
			this.state = 'user';
		}		
		this.change_to_state_email = function(){
			this.display_email();
			this.hide_date_validity_user();
			this.show_date_validity_email();
			this.state = 'email';
		}
		
		/**
		 * Launch init
		 */
		this.init(options);
		/**/
	};
	
	$j.fn.googleMapBonnesAdresses = function (options){
		
		this.options = { mapOption : {}, mode : 'full' };
		this.listeTypesToShow = new Array();
		this.listeTypesToShowString = '';
				
		this.init = function(options) {
			var self = this; // To set as a context on sub
			
			this.options = $j.extend({}, this.options, options);
			
			var googlemapBonnesAdressesOptions = {
				zoom: 5,
				center: new google.maps.LatLng('46.7', '2.7'),
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				scrollwheel: false
			};
			
			googlemapBonnesAdressesOptions = $j.extend({}, googlemapBonnesAdressesOptions, this.options.mapOption);
			
			this.map = new GooglemapCreator('googleMapBonnesAdresses');
			this.map.setOptions(googlemapBonnesAdressesOptions);
			this.map.setBoundFitZoomMaxi(8);
			this.map.init();			
			
			$j(this).find('.typeMarker').live('click', function(){
				self.updateMarkers();
			});
			
			if (this.options.mode == 'mini'){
				$j('#googleMapBonnesAdresses').css('cursor', 'pointer');
				$j('#googleMapBonnesAdresses').live('click', function(){
					Shadowbox.options.modal = false;		
					Shadowbox.options.displayNav = false;
					
					var opts = {modal:false,displayNav:false,handleOversize:'none'}; 
					var init = {
						player:     'iframe',
						content:    '/pl/pmd_club.pl?ac=bonnes_adresses_map',
						width:      922,
						height:     602
					};
					Shadowbox.open(init,opts);
				});
			}
			
			this.updateMarkers();
		}
		
		this.updateMarkers = function(){
			this.updateListeTypesToShow();
			
			updateGooglemapMarkersBonnesAdresses(this.map, this.listeTypesToShowString, this.options.mode);
		}
		
		this.updateListeTypesToShow = function (){
			var self = this; // To set as a context on sub
			
			this.listeTypesToShow = new Array();
			
			$j(this).find('.typeMarker').each(function(index){
				var checkBox = $j(this);
				
				if (checkBox.is(':checked')){
					self.listeTypesToShow.push(checkBox.val());
				}				
			});			
			this.listeTypesToShowString = this.listeTypesToShow.join('-');			
		}
		
		/**
		 * Launch init
		 */
		this.init(options);
		/**/
	}
	
	
	$j.fn.formFullSearch = function (options) {
		
		this.listCombosUpdateForm = new Array('#search_pays', '#search_appellation', '#search_couleur', '#search_millesime', '#search_format', '#search_budget');
		this.state = 'opened'; // opened|closed
		
		this.options = {};
		
		this.init = function(options) {
			var self = this; // To set as a context on sub
			this.options = $j.extend({}, this.options, options);
				
			for (i=0; i<this.listCombosUpdateForm.length; i++){
				$j(this.listCombosUpdateForm[i]).live('change', function(){
					self.update_full_search_combo();
				}); 
			}
			
			if ($j('#show_form_search').length>0){
				this.display_form();
			} else {
				this.hide_form();
			}
			
			if ($j('#btn_display_form').length>0){
				$j('#btn_display_form').live('click', function(){
					if (self.state == 'opened'){
						self.hide_form();
					} else if (self.state == 'closed'){
						self.display_form();
					}
				});
			}
			
			if ($j('#btn_reinit').length>0){
				$j('#btn_reinit').live('click', function(){
					self.update_full_search_combo('reset');
				});
			}
		}
		
		this.display_form = function(){
			$j('#form_recherche_criteres').css('display', 'block');
			$j('#btn_display_form').attr('src','/images/interface/fr/btn_moins_de_criteres.gif');
			this.update_full_search_combo('init');
			this.state = 'opened';
		}
		
		this.hide_form = function(){
			$j('#form_recherche_criteres').css('display', 'none');
			$j('#btn_display_form').attr('src','/images/interface/fr/btn_plus_de_criteres.gif');
			this.update_full_search_combo('reset');
			this.state = 'closed';
		}
		
		this.clean_full_search_combo = function(){
			document.getElementById('search_pays').options.length = 0;
			document.getElementById('search_appellation').options.length = 0;
			document.getElementById('search_couleur').options.length = 0;
			document.getElementById('search_millesime').options.length = 0;
			document.getElementById('search_format').options.length = 0;
			document.getElementById('search_budget').options.length = 0;
		}
		
		this.update_full_search_combo = function(action){
			if (typeof action != 'string') {
				action = '';
			}
		
			search_pays 		= $j('#search_pays').val();
			search_appellation	= $j('#search_appellation').val();
			search_couleur		= $j('#search_couleur').val();
			search_millesime	= $j('#search_millesime').val();
			search_format		= $j('#search_format').val();
			search_budget		= $j('#search_budget').val();
			search_txt			= $j('#search_txt').val();
			
			if (action == 'init'){
				search_pays 		= $j('#search_pays_init').val();
				search_appellation	= $j('#search_appellation_init').val();
				search_couleur		= $j('#search_couleur_init').val();
				search_millesime	= $j('#search_millesime_init').val();
				search_format		= $j('#search_format_init').val();
				search_budget		= $j('#search_budget_init').val();
			}
			
			if (action == 'reset'){
				search_pays 		= '';
				search_appellation	= '';
				search_couleur		= '';
				search_millesime	= '';
				search_format		= '';
				search_budget		= '';
			}
			
			$j.ajax({
				url: '/pl/update_search_combo.pl',
				dataType: 'json',
				data: { p		: search_pays,
						a		: search_appellation,
						co		: search_couleur,
						m		: search_millesime,
						fo		: search_format,
						b		: search_budget,
						q		: search_txt,
						action  : action
					  },
				contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
				success: function (data, textStatus, XMLHttpRequest){
					// Pays
					if (data.action == 'init' || data.action == 'reset'){
						document.getElementById('search_pays').options.length = 0;
						document.getElementById('search_pays').options[0] = new Option('Choisir...', '');
						for(i=0;i<data.list_pays.length;i++){
							defaultSelected = false;
							Selected = false;
							if (data.list_pays[i]['selected']){
								defaultSelected = true;
								Selected = true;
							}
							document.getElementById('search_pays').options[i+1] = new Option(data.list_pays[i]['wfec_region_zone_name'], data.list_pays[i]['wfec_region_zone_wfcode'], defaultSelected, Selected);
						}
					}
					
								
					// Appellations
					document.getElementById('search_appellation').options.length = 0;
					document.getElementById('search_appellation').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_appellation.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_appellation[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_appellation').options[i+1] = new Option(data.list_appellation[i]['wfec_product_appellation_nom'], data.list_appellation[i]['wfec_product_appellation_wfcode'], defaultSelected, Selected);
					}
					
					// Couleurs
					document.getElementById('search_couleur').options.length = 0;
					document.getElementById('search_couleur').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_couleur.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_couleur[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_couleur').options[i+1] = new Option(data.list_couleur[i]['wfec_product_couleur_name'], data.list_couleur[i]['wfec_product_couleur_wfcode'], defaultSelected, Selected);
					}
									
					// Millesimes
					document.getElementById('search_millesime').options.length = 0;
					document.getElementById('search_millesime').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_millesime.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_millesime[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_millesime').options[i+1] = new Option(data.list_millesime[i]['wfec_product_infos_millesime'], data.list_millesime[i]['wfec_product_infos_millesime'], defaultSelected, Selected);
					}
									
					// Formats
					document.getElementById('search_format').options.length = 0;
					document.getElementById('search_format').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_format.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_format[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_format').options[i+1] = new Option(data.list_format[i]['wfec_product_format_nom'], data.list_format[i]['wfec_product_format_wfcode'], defaultSelected, Selected);
					}
					
					// Budgets
					document.getElementById('search_budget').options.length = 0;
					document.getElementById('search_budget').options[0] = new Option('Choisir...', '');
					var cnt = 0;
					for(i=0;i<data.list_budget.length;i++){
						if (data.list_budget[i]['display'] == 1){
							cnt++;
							defaultSelected = false;
							Selected = false;
							if (data.list_budget[i]['selected']){
								defaultSelected = true;
								Selected = true;
							}
							document.getElementById('search_budget').options[cnt] = new Option(data.list_budget[i]['wfec_product_budget_label'], data.list_budget[i]['wfec_product_budget_id'], defaultSelected, Selected);
						}
					}
				}
			});
		};
		
		/**
		 * Launch init
		 */
		this.init(options);
		/**/
	};
	
	
	
	$j.fn.formNegoceSearch = function (options) {
		
		this.listCombosUpdateForm = new Array('#search_type', '#search_millesime', '#search_appellation', '#search_classement', '#search_format', '#search_budget');
		this.state = 'opened'; // opened|closed
		
		this.options = {};
		
		this.init = function(options) {
			var self = this; // To set as a context on sub
			this.options = $j.extend({}, this.options, options);
			
			for (i=0; i<this.listCombosUpdateForm.length; i++){
				$j(this.listCombosUpdateForm[i]).live('change', function(){
					self.update_full_search_combo();
				}); 
			}
			
			if ($j('#show_form_search').length>0){
				this.display_form();
			} else {
				this.hide_form();
			}
			
			if ($j('#btn_display_form').length>0){
				$j('#btn_display_form').live('click', function(){
					if (self.state == 'opened'){
						self.hide_form();
					} else if (self.state == 'closed'){
						self.display_form();
					}
				});
			}
			
			if ($j('#btn_reinit').length>0){
				$j('#btn_reinit').live('click', function(){
					self.update_full_search_combo('reset');
				});
			}
		}
		
		this.display_form = function(){
			$j('#form_recherche_criteres').css('display', 'block');
			$j('#btn_display_form').attr('src','/images/interface/fr/btn_moins_de_criteres.gif');
			this.update_full_search_combo('init');
			this.state = 'opened';
		}
		
		this.hide_form = function(){
			$j('#form_recherche_criteres').css('display', 'none');
			$j('#btn_display_form').attr('src','/images/interface/fr/btn_plus_de_criteres.gif');
			this.update_full_search_combo('reset');
			this.state = 'closed';
		}
		
		this.clean_full_search_combo = function(){
			document.getElementById('search_type').options.length = 0;
			document.getElementById('search_millesime').options.length = 0;
			document.getElementById('search_appellation').options.length = 0;
			document.getElementById('search_classement').options.length = 0;
			document.getElementById('search_format').options.length = 0;
			document.getElementById('search_budget').options.length = 0;
		}
		
		this.update_full_search_combo = function(action){
			if (typeof action != 'string') {
				action = '';
			}
		
			search_type 		= $j('#search_type').val();
			search_millesime	= $j('#search_millesime').val();
			search_appellation	= $j('#search_appellation').val();
			search_classement	= $j('#search_classement').val();
			search_format		= $j('#search_format').val();
			search_budget		= $j('#search_budget').val();
			search_txt			= $j('#search_txt').val();
			
			if (action == 'init'){
				search_type 		= $j('#search_type_init').val();
				search_millesime	= $j('#search_millesime_init').val();
				search_appellation	= $j('#search_appellation_init').val();
				search_classement	= $j('#search_classement_init').val();
				search_format		= $j('#search_format_init').val();
				search_budget		= $j('#search_budget_init').val();
			}
			
			if (action == 'reset'){
				search_type 		= '';
				search_millesime	= '';
				search_appellation	= '';
				search_classement	= '';
				search_format		= '';
				search_budget		= '';
			}
			
			$j.ajax({
				url: '/pl/update_search_combo_negoce.pl',
				dataType: 'json',
				data: { nt		: search_type,
						nm		: search_millesime,
						na		: search_appellation,
						nc		: search_classement,
						nfo		: search_format,
						b		: search_budget,
						q		: search_txt,
						action  : action
					  },
				contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
				success: function (data, textStatus, XMLHttpRequest){
					// Types
					document.getElementById('search_type').options.length = 0;
					document.getElementById('search_type').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_type.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_type[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_type').options[i+1] = new Option(data.list_type[i]['wfec_product_sobovi_type_name'], data.list_type[i]['wfec_product_sobovi_type_wfcode'], defaultSelected, Selected);
					}
									
					// Millesimes
					document.getElementById('search_millesime').options.length = 0;
					document.getElementById('search_millesime').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_millesime.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_millesime[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_millesime').options[i+1] = new Option(data.list_millesime[i]['wfec_product_info_sobovi_millesime'], data.list_millesime[i]['wfec_product_info_sobovi_millesime'], defaultSelected, Selected);
					}
					
								
					// Appellations
					document.getElementById('search_appellation').options.length = 0;
					document.getElementById('search_appellation').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_appellation.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_appellation[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_appellation').options[i+1] = new Option(data.list_appellation[i]['wfec_product_sobovi_appellation_name'], data.list_appellation[i]['wfec_product_sobovi_appellation_wfcode'], defaultSelected, Selected);
					}
					
					// Classements
					document.getElementById('search_classement').options.length = 0;
					document.getElementById('search_classement').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_classement.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_classement[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_classement').options[i+1] = new Option(data.list_classement[i]['wfec_product_sobovi_classement_name'], data.list_classement[i]['wfec_product_sobovi_classement_wfcode'], defaultSelected, Selected);
					}
									
					// Formats
					document.getElementById('search_format').options.length = 0;
					document.getElementById('search_format').options[0] = new Option('Choisir...', '');
					for(i=0;i<data.list_format.length;i++){
						defaultSelected = false;
						Selected = false;
						if (data.list_format[i]['selected']){
							defaultSelected = true;
							Selected = true;
						}
						document.getElementById('search_format').options[i+1] = new Option(data.list_format[i]['wfec_product_sobovi_format_name'], data.list_format[i]['wfec_product_sobovi_format_wfcode'], defaultSelected, Selected);
					}
					
					// Budgets
					document.getElementById('search_budget').options.length = 0;
					document.getElementById('search_budget').options[0] = new Option('Choisir...', '');
					var cnt = 0;
					for(i=0;i<data.list_budget.length;i++){
						if (data.list_budget[i]['display'] == 1){
							cnt++;
							defaultSelected = false;
							Selected = false;
							if (data.list_budget[i]['selected']){
								defaultSelected = true;
								Selected = true;
							}
							document.getElementById('search_budget').options[cnt] = new Option(data.list_budget[i]['wfec_product_budget_label'], data.list_budget[i]['wfec_product_budget_id'], defaultSelected, Selected);
						}
					}
				}
			});
		};
		
		/**
		 * Launch init
		 */
		this.init(options);
		/**/
	};

	$j.fn.moduleTriCatalogue = function (options) {
		
		this.listBtnsTris = ['#btn_tri_prix', '#btn_tri_millesime', '#btn_tri_couleur', '#btn_view_all'];
		this.listBtnsTrisParams = ['obp', 'obm', 'obc', 'view_all'];
		this.listBtnsTrisAlwaysActivated = [0, 0, 0, 0];
		
		this.options = {
			searchParams			: '',
			trisParams				: {},
			urlScriptCatalogue		: '/pl/shopping/catalogue.pl',
			imgDownSrc				: '/images/interface/tip_down.png',
			imgUpSrc				: '/images/interface/tip_up.png',
			imgNoTriSrc				: '/images/interface/tip_hide.png'
		};
		
		this.init = function(options) {
			var self = this; // To set as a context on sub
			
			this.options = $j.extend({}, this.options, options);
			
			// Gestion des puces de tri	
			for (i=0; i<this.listBtnsTris.length; i++){
				if ($j(this.listBtnsTris[i]).length>0){
					if ($j(this.listBtnsTris[i]).attr('id') == 'btn_view_all'){
						this.options.trisParams[this.listBtnsTris[i]] = $j(this.listBtnsTris[i]).attr('rel');
					} else {
						if ($j(this.listBtnsTris[i]).attr('rel') == 'asc'){
							this.options.trisParams[this.listBtnsTris[i]] = $j(this.listBtnsTris[i]).attr('rel');
							$j(this.listBtnsTris[i]).find('img').attr('src', this.options.imgUpSrc);
						} else if ($j(this.listBtnsTris[i]).attr('rel') == 'desc'){
							this.options.trisParams[this.listBtnsTris[i]] = $j(this.listBtnsTris[i]).attr('rel');
							$j(this.listBtnsTris[i]).find('img').attr('src', this.options.imgDownSrc);
						} else {
							this.options.trisParams[this.listBtnsTris[i]] = '';
							$j(this.listBtnsTris[i]).find('img').attr('src', this.options.imgNoTriSrc);
						}
					}
				}
			}
			
			// Gestion du clic sur les tris
			for (i=0; i<this.listBtnsTris.length; i++){
				if ($j(this.listBtnsTris[i]).length>0){
					$j(this.listBtnsTris[i]).live('click', {self : self}, function(event){
						event.data.self.triResults($j(this));
					});
				}
			}
		}
		this.triResults = function(currentButton) {
			
			var triParams = '';
			
									
			for (i=0; i<this.listBtnsTris.length; i++){
				if ($j(currentButton).attr('id') == 'btn_view_all'){ // tri avec 'tout afficher' / 'paginer'
					if ($j(currentButton).attr('id') == this.listBtnsTris[i].substr(1)){
						if (this.options.trisParams[this.listBtnsTris[i]] == '1'){
							triParams += '&' + this.listBtnsTrisParams[i] + '=1';
						}
						for (i=0; i<this.listBtnsTris.length; i++){
							if ($j(currentButton).attr('id') != this.listBtnsTris[i].substr(1)){
								if ($j(this.listBtnsTris[i]).length>0){
									if (this.listBtnsTrisAlwaysActivated[i] == 1){
										if (this.options.trisParams[this.listBtnsTris[i]] != ''){
											triParams += '&' + this.listBtnsTrisParams[i] + '=' + this.options.trisParams[this.listBtnsTris[i]];
										} else {
											triParams += '&' + this.listBtnsTrisParams[i] + '=asc';
										}
									} else {
										if (this.options.trisParams[this.listBtnsTris[i]] == 'asc'){
											triParams += '&' + this.listBtnsTrisParams[i] + '=asc';
										} else if (this.options.trisParams[this.listBtnsTris[i]] == 'desc'){
											triParams += '&' + this.listBtnsTrisParams[i] + '=desc';
										}
									}
								}
							}
						}
					}
				} else {	// autres tris
					for (i=0; i<this.listBtnsTris.length; i++){
						if (this.listBtnsTris[i].substr(1) == 'btn_view_all'){
							if ($j(this.listBtnsTris[i]).length>0){
								if (this.options.trisParams[this.listBtnsTris[i]] != '1'){
									console.log (this.options.trisParams[this.listBtnsTris[i]]);
									triParams += '&' + this.listBtnsTrisParams[i] + '=1';
								}
							}
						} else {
							if ($j(currentButton).attr('id') == this.listBtnsTris[i].substr(1)){
								if (this.options.trisParams[this.listBtnsTris[i]] == 'asc'){
									triParams += '&' + this.listBtnsTrisParams[i] + '=desc';
								} else if (this.options.trisParams[this.listBtnsTris[i]] == 'desc'){
									triParams += '&' + this.listBtnsTrisParams[i] + '=asc';
								} else {
									triParams += '&' + this.listBtnsTrisParams[i] + '=asc';
								}
							} else if (this.listBtnsTrisAlwaysActivated[i] == 1){
								if (this.options.trisParams[this.listBtnsTris[i]] != ''){
									triParams += '&' + this.listBtnsTrisParams[i] + '=' + this.options.trisParams[this.listBtnsTris[i]];
								} else {
									triParams += '&' + this.listBtnsTrisParams[i] + '=asc';
								}
							}
						}
					}
				}
			}
			
			var url = this.options.urlScriptCatalogue + '?' + this.options.searchParams + triParams;
			document.location.href = url;
		}
		
		/**
		 * Launch init
		 */
		this.init(options);
		/**/
	};
	
	

	$j.fn.formDepotAnnonce = function (options) {
		this.valueAutre = 6;
		this.valueListe = 7;
		this.options = {};
		
		this.init = function(options) {
			var self = this; // To set as a context on sub
			this.options = $j.extend({}, this.options, options);
		
			if ($j('#pmd_annonce_annonce_nature_wfcode').length > 0){
				$j('#pmd_annonce_annonce_nature_wfcode').live('change', function(){
					self.updateForm();
				}); 
				
				this.updateForm();
			}
		}
		
		this.updateForm = function(){
			var natureValue = $j('#pmd_annonce_annonce_nature_wfcode').val();
			
			$j('#nature_produit_autre').css('display', 'none');
			$j('#nature_produit_liste').css('display', 'none');
			
			if (natureValue == this.valueAutre){
				$j('#nature_produit_autre').css('display', 'block');
			} else if (natureValue == this.valueListe){
				$j('#nature_produit_liste').css('display', 'block');
			}
		}
		
		/**
		 * Launch init
		 */
		this.init(options);
		/**/
	};
	
	
	
})(jQuery);

/**
 * Gestion de l'affichage d'erreurs des champs de formulaire
 */
function initFormError(){
	
	$jq('.boutique_compte_box_form_erreur').live('keyup', function(){
		$jq(this).removeClass('boutique_compte_box_form_erreur');
		if ($jq(this).parents('td.containerFieldForm:first').length > 0){
			$jq(this).parents('td.containerFieldForm:first').find('.boutique_compte_legende_erreur').parents('div:first').css('display', 'none');
			$jq(this).parents('td.containerFieldForm:first').find('.boutique_compte_legende_erreur').css('display', 'none');
		} else if ($jq(this).parents('div.containerFieldForm:first').length > 0){
			$jq(this).parents('div.containerFieldForm:first').find('.boutique_compte_legende_erreur').parents('div:first').css('display', 'none');
			$jq(this).parents('div.containerFieldForm:first').find('.boutique_compte_legende_erreur').css('display', 'none');
		}
	});
	
	$jq('select.boutique_compte_box_form_erreur').live('change', function(){
		$jq(this).removeClass('boutique_compte_box_form_erreur');
		if ($jq(this).parents('td.containerFieldForm:first').length > 0){
			$jq(this).parents('td.containerFieldForm:first').find('.boutique_compte_legende_erreur').parents('div:first').css('display', 'none');
			$jq(this).parents('td.containerFieldForm:first').find('.boutique_compte_legende_erreur').css('display', 'none');
		} else if ($jq(this).parents('div.containerFieldForm:first').length > 0){
			$jq(this).parents('div.containerFieldForm:first').find('.boutique_compte_legende_erreur').parents('div:first').css('display', 'none');
			$jq(this).parents('div.containerFieldForm:first').find('.boutique_compte_legende_erreur').css('display', 'none');
		}
	});
	
	$jq('.fieldCheckBoxError').live('click', function(){
		$jq(this).removeClass('fieldCheckBoxError');
		if ($jq(this).parents('td.containerFieldForm:first').length > 0){
			$jq(this).parents('td.containerFieldForm:first').find('.boutique_compte_legende_erreur').parents('div:first').css('display', 'none');
			$jq(this).parents('td.containerFieldForm:first').find('.boutique_compte_legende_erreur').css('display', 'none');
		} else if ($jq(this).parents('div.containerFieldForm:first').length > 0){
			$jq(this).parents('div.containerFieldForm:first').find('.boutique_compte_legende_erreur').parents('div:first').css('display', 'none');
			$jq(this).parents('div.containerFieldForm:first').find('.boutique_compte_legende_erreur').css('display', 'none');
		}
	});
}




/**
 * DW
 */
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];}
}
