/* /////////////// variables globales /////////////// */
	var carrous_cur=1;
	var FilterAccessory, ListAccessory, ListMachine, ListMachineSelection, ListQOAccessory, ListQOMachines, ListQOCapsules, reGistration;
	var quantityActive = false;
	var wMsg;
	var checkout_cards__listChamps=null;
	var checkout_cards__champsOuvert=false;
	var selectedMachines = [];
/* /////////////// fin variables globales /////////////// */

/* /////////////// gestion des langues/////////////// */
if(typeof(LangJS)=='undefined') 
	LangJS={};
function f_get_txt(code)
{
	if(LangJS[code]!=null)
		return LangJS[code];
	else
		return '#errTxt#';
}
/* /////////////// fin gestion des langues /////////////// */

/* /////////////// fonctions /////////////// */
	function gup( name )
	{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
		return "";
	  else
		return results[1];
	}
	// function loadSelectStors__regMachPos(country)
	// {
		// $.ajax(
		// { 
			// url: queryResellersGroupList+ '/' + country, 
			// type:'GET',
			// contentType:'application/json',
			// dataType:'json',
			// data:'',
			// success: function(data){	
				// var html_c='<select id="Store_name" name="machineRegistration.storeNameFilter" class="skin_select">';
				// for(var i=0; i<data.length;i++)
				// {
					// html_c+='<option value="'+data[i].first+'">'+data[i].second+'</option>';
				// }
				// html_c+='</select>';
				// $("#Store_name_div").html('');
				// $('#Store_name_div').html(html_c);
				// $('#Store_name').addClass("skin_select");
				// $('#Store_name').selectbox();
			// }
		// });
	// }
	
	function parseJSON (str) {
		if (str === "") str = '""';
		if (str.indexOf("<html")!=-1) str = '""';
		eval("var p=" + str + ";");
		return p;
	}
	
	function checkoutPaymentIframeLoaded()
	{
		$('.nes_recapLoading').hide();
		$('.nes_recapContent').show();
	}
	
	function checkoutPaymentIframeSubmited()
	{
		$('.nes_recapContent').hide();
		$('.nes_recapLoading').show();
	}
	/* gestion des cartes de credit sur la page des checkout */
		function checkout_cards__initForms(pere,tag){
			pere.find('.nes_card-champs').hide();
			checkout_cards__getChamps(tag);
			/* $('#card-number').numeric();
			$('#holder-name').alpha({allow:"'- "});
			$('#Cryptogramme').numeric();
			$('#issu_number').numeric(); */
		}
		function checkout_cards__getChamps(tag){
			checkout_cards__listChamps=paymentCardsDefinition.listPaymentCardType;
			if(paymentCardsDefinition.selectedPaymentCardType!=null)
			{	
				if($("input#"+paymentCardsDefinition.selectedPaymentCardType+"_"+tag+"[tagname='card_"+tag+"']").length!=0)
				{	
					checkout_cards__setChampsVisibility(paymentCardsDefinition.selectedPaymentCardType,tag);
					$('#'+paymentCardsDefinition.selectedPaymentCardType+'_'+tag).attr('checked','checked');
				}
				else
				{
					var collElmtsIds = $("input[tagname='card_"+tag+"']");
					/* collElmtsIds.each(function() {
						var idTemp = this.id;
						var $$ = $(this);
						idTemp = idTemp.replace(/ /g, '_').replace(/\//g, '_').replace(/\./g, '_');
						$$.attr('id', idTemp).next('label').attr('for', idTemp);
					}); */
					var elmtIds = collElmtsIds[0];
					var ids = elmtIds.id;
					//var ids=$("input[tagname='card_"+tag+"']")[0].id;
					checkout_cards__setChampsVisibility(ids.substr(0,ids.length-2),tag);
					$('#'+ids).attr('checked','checked');
				}
			}
			else
			{	
				var collElmtsIds = $("input[tagname='card_"+tag+"']");
				/* collElmtsIds.each(function() {
					var idTemp = this.id;
					var $$ = $(this);
					idTemp = idTemp.replace(/ /g, '_').replace(/\//g, '_').replace(/\./g, '_');
					$$.attr('id', idTemp).next('label').attr('for', idTemp);
				}); */
				var elmtIds = collElmtsIds[0];
				var ids = elmtIds.id;
				checkout_cards__setChampsVisibility(ids.substr(0,ids.length-2),tag);
				$('#'+ids).attr('checked','checked');
				//checkout_cards__setChampsVisibility(paymentCardsDefinition.listPaymentCardType[0]['name'],tag);
			}
			$(".nes_radioCreditCard").each(function ()
				{
					var $this=$(this);
					$this.click(function (){
						checkout_cards__setChampsVisibility($(this)[0].id.substr(0,$(this)[0].id.length-2),tag);
					});
					$this.parent().find('label>img').click(function (){
						$this.click();
					});
				}
			);
		}
		function checkout_cards__setChampsVisibility(id_card,tag){	
			for(var i=0;i<checkout_cards__listChamps.length;i++)
			{
				if(id_card==checkout_cards__listChamps[i]['uid'])
				{
					for(var j=0;j<checkout_cards__listChamps[i]['jsonListField'].length;j++)
					{
						if(checkout_cards__listChamps[i]['jsonListField'][j].visible)
						{	
							$('#'+checkout_cards__listChamps[i]['jsonListField'][j].field+'_div').find('label').html('');
							$('#'+checkout_cards__listChamps[i]['jsonListField'][j].field+'_div').find('label').html(checkout_cards__listChamps[i]['jsonListField'][j].label);
							$('#'+checkout_cards__listChamps[i]['jsonListField'][j].field+'_div').show();
						}
						else
							$('#'+checkout_cards__listChamps[i]['jsonListField'][j].field+'_div').hide();
						//$('#'+checkout_cards__listChamps[i]['jsonListField'][j].field+'_div').find('.error_field').hide();
					}
					if(checkout_cards__listChamps[i]['cryptoFAQLink'])
					{	
						$('.nes_readMore_div').show();
						$('.nes_readMore_div > li > a').attr('href','javascript:var retour=window.open("'+checkout_cards__listChamps[i]['cryptoFAQLink']+'");');
					}
					else
					{	
						$('.nes_readMore_div').hide();
						$('.nes_readMore_div > li > a').attr('href','#');
					}
					break;
				}
			}

		}
		/* function f_verif_fields_credCards()
		{
			var correct=true;
			if(checkout_cards__champsOuvert==true)
			{
				//credit card
				if(  $('#card-number').val()=='' && $('#number_div').css('display')=='block' )
				{
					$('#number_div').find(".error_field").show();
					correct=false;
				}else
				{
					$('#number_div').find(".error_field").hide();
				}
				
				if($('#holder-name').val()=='' && $('#holderName_div').css('display')=='block')
				{
					$('#holderName_div').find(".error_field").show();
					correct=false;
				}else
				{
					$('#holderName_div').find(".error_field").hide();
				}
				
				if($('#issu_number').val()=='' && $('#issueNumber_div').css('display')=='block')
				{
					$('#issueNumber_div').find(".error_field").show();
					correct=false;
				}else
				{
					$('#issueNumber_div').find(".error_field").hide();
				}
				
				if(($('#date_input').val()=='' || $('#year_input').val()=='') && $('#expiratyDate_div').css('display')=='block')
				{
					$('#expiratyDate_div').find(".error_field").show();
					correct=false;
				}else
				{
					$('#expiratyDate_div').find(".error_field").hide();
				}
				
				//if(($('#Cryptogramme').val().length!=minLenChamp['Cryptogramme'] || $('#Cryptogramme').val()=='') && $('#cryptogram_div').css('display')=='block')
				if($('#Cryptogramme').val()=='' && $('#cryptogram_div').css('display')=='block')
				{
					$('#cryptogram_div').find(".error_field").show();
					correct=false;
				}else
				{
					$('#cryptogram_div').find(".error_field").hide();
				}
			}
			return correct;
		} */

	/* Fin : gestion des cartes de credit sur la page des checkout*/
	
	/* Cache la Popin */
		function hidePopinLang(){
			$('#cachePopinLanguage').animate(
				{'opacity':'0.0'},
				500,
				'swing',
				function ()
				{
					$(this).css({'display':'none'});
				}
			);
			
			$('div.nes_msgAccueil').hide();
			$.cookie('nes_popin_language', 'ok', { expires: 365, path:'/'+abbrCountry});
		}
	/* */
	
	/* fonctions pour carrousel de la home */
		function carrous_main_do_change(lien,hash,doswitch)
		{
			$('div.nes_bg-home ul.nes_list-switch-product li a').removeClass('nes_num-on');
			lien.addClass('nes_num-on');
			var carr_index=lien.attr("ordre");
			if(!doswitch)
				$("#nes_switch-image-home"+carrous_cur).stop().fadeOut(500);
			else
				$("#nes_switch-image-home"+$("div.nes_bg-home .nes_list-switch-product li a").length).stop().fadeOut(500);
			
			$(hash).stop().animate({'left':'+=0'}, 499).fadeIn(500, function(){
				$(this).css('opacity',1);
			});
			carrous_cur=parseInt(carr_index);
		}
		
		function carrous_main_do_charge()
		{
			$.ajax(
				{ 
					url: "json/HomeImages.json", 
					type:'POST',
					contentType:'application/json',
					dataType:'json',
					success: function(data){
						//var oData=parseJSON(data);
						for(var i=2;i<data.nbImages+1;i++)
						{
							$('#nes_switch-image-home'+i).css('background',"url("+data.Images[i-2].path+") no-repeat 50% 0");
						}
					}
				}
			);
		}
		
		function carrous_main_do_changeTimer()
		{
			var doswitch=false;
			if(carrous_cur==$("div.nes_bg-home .nes_list-switch-product li a").length)
			{	
				carrous_cur=0;
				doswitch=true;
			}
			carrous_main_do_change($("div.nes_bg-home .nes_list-switch-product li a:eq("+(carrous_cur)+")"),$("div.nes_bg-home .nes_list-switch-product li a")[carrous_cur].hash,doswitch);
		}
	/* */
	
	/* Produits liste machine */
		function centerListMachine_icone(hash){
			var size=0;
			$(hash+' > li').each(function() {
				size+= $(this).width()+5;
			});
			if(size<$(hash).width())
				$(hash).width(size+'px');
			else
				$(hash).width($(hash).width()+'px');
		}
		function centerListMachineFilter(hash){
			var size=0;
			$(' > li', hash).each(function() {
				size+= $(this).width()+4;
			});
			hash.width(size+'px');
			//bloc droite quick order
			/*if($('.nes_quick-filter').width() > 414)
			{
				$('.nes_quick-filter').addClass('nes_quick-filter-big');
			}
			if($('.nes_quick-filter').height() > 32)
			{
				$('.nes_white-quick-bloc').addClass('nes_white-quick-bloc-dcl');
			}*/
		}
		function centerListMachine(hash){
			var size=0;
			$(hash+' > .nes_innerSwitchListMachine .nes_innerListMachineContainer .nes_innerListMachine').each(function() {
				size+= $(this).width()+5;
			});
			$(hash+' > .nes_innerSwitchListMachine .nes_innerListMachineContainer').width(size+'px');
		}
		function centerQuickMachine(hash){
			var size=0;
			$(hash+' > .nes_innerSwitch_quick .nes_feature-filter > li').each(function(i) {
				if(!(i >= 12)){
					size+= $(this).width()+2;
				}
			});
			if($(hash+' > .nes_innerSwitch_quick .nes_feature-filter > li').length > 12){
				$(hash+' > .nes_innerSwitch_quick .nes_feature-filter').css({width : size+'px', padding : '25px 0 17px 2px'});
			}else{
				$(hash+' > .nes_innerSwitch_quick .nes_feature-filter').width(size+'px');
			}
		}
		
		function ajustMargeFilter(){
			var contExt = $('#nes_colLeft');
			$('> div.nes_blocListMachines', contExt).css({
				'marginTop' : $('> div.nes_switchListMachine > div.nes_containerSwitchListMachine > ul.nes_switch_tabs_list-machine > li.nes_switch-active > div.nes_innerSwitchListMachineGlobal > div.nes_innerSwitchListMachine', contExt).height() - 4
			});
		}
		
		function toFadeImgFilter() {
			$('.fadeImg').each(function() {
				$(this).css({opacity:0});
			});
		}
		
		function toFadeImgFilterWithContext(context) {
			$('.fadeImg',context).each(function() {
				$(this).css({opacity:0});
			});
		}
		
		function toFade08ImgFilter() {
			$('.fadeImg').each(function() {
				$(this).css({opacity:0.8});
			});
		}
		
		function toSizeImgFilter() {
			$('.fadeImg').each(function() {
				var $img=$(this).prev('img');
				if($img.length==0)	
					$img=$(this).prev().prev('img').prev('span');
				var toH = $img.height()+1;
				var toW = $img.width()+1;
				$(this).css({width:toW,height:toH});
			});
		}
	/* */
	
	/* Gestion de la retro-tabulation */
		var isMaj = false; 
		$(document).keydown(function (e) { 
			if(e.which == 16){
				isMaj=true; 
			}
		});
		$(document).keyup(function (e) { 
			if(e.which == 16) 
				isMaj=false;
		});
	/* */

	/* Quantity selector */
	function affQuantity(el, initNb) {
		var $containerQuantity = $('<div></div>').addClass('containerQuantity');
		var $containerInnerQuantity = $('<div></div>').addClass('containerInnerQuantity');
		var qSOK = f_get_txt('QSOK');
		var qSQuantity = f_get_txt('otherQuantity');
		var qSQuantityAlert = f_get_txt('QSMsg1');
		var qSMaxQuantityReachedAlert = f_get_txt('QSMaxQuantityReachedMsg');
		var initValue = 10;
		
		if(initNb=='var')
		{
			if(el.children('input').attr('sMulti')!=null)
				initValue = parseInt(el.children('input').attr('sMulti'));
		}else
		{
			initValue = parseInt(initNb);
			if(el.children('input').attr('sMulti')!=null)
				initValue = parseInt(el.children('input').attr('sMulti'));
		}
		var origValue = parseInt(el.children('input').val());
		var isEnter = false;
		var finalState= (initValue != 1) ? 15 : 10;
		el.addClass('nes_select-quantity_js');
		//if(contextPage=='quickorder'){
			//el.children('input').val(0);
			// todo if panier aff qty du panier, sinon 0
		//} else {
			el.children('input').val(origValue);
		//}
		
		function errOrNot(inputQuant) {
			var realOldValue= el.children('input').val();
			/*<span class="nes_quantity-alert">
				<strong>The quantity selected has been modified</strong>
			</span>*/
			var MaxLimit=9999;
			var MaxQuantity = inputQuant.parents('span.nes_select-quantity').children('input').attr('max');
			var inputQuantval=(inputQuant.val()=='')?'NaN':inputQuant.val();
			var newValue = parseInt(Math.round(inputQuantval));
			newValue=(newValue<0)?0:newValue;
			
			if(MaxLimit<initValue * Math.round(Math.ceil(newValue / initValue)))
			{
				var diff=(initValue * Math.round(Math.ceil(newValue / initValue)))-MaxLimit;
				
				newValue=(initValue * Math.round(Math.ceil(newValue / initValue))) - Math.ceil(diff/initValue)*initValue -1;//le -1 est pour forcer l'affichage du message d'arrondissement
			}
			var oldVal = newValue;
			if(!isNaN(newValue) ) {
				if(inputQuant.hasClass('otherQuantitySelector')){
					if(newValue != inputQuant.attr('title')) {
						inputQuant = inputQuant.parents('span.nes_select-quantity').children('input');
						newValue = initValue * Math.round(Math.ceil(newValue / initValue));
						/*if(contextPage=='quickorder' || contextPage=='quickorder-2'){*/
							newValue = (newValue < initValue) && (newValue > 0) ?  initValue:newValue;
						/*}else{
							newValue = (newValue < initValue) ?  initValue:newValue;
						}*/
						if(newValue.toString().length >= 5){
							newValue = newValue-initValue;
						}
						inputQuant.val(newValue);
						inputQuant.next('div.containerQuantity').children('div.containerInnerQuantity').remove();
						inputQuant.parent().removeClass('nes_select-quantity_on').addClass('nes_select-quantity_selected');
						if(newValue > 0){
							inputQuant.parents('.nes_list-filter').addClass("nes_list-selected").css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
						}else{
							inputQuant.parent().removeClass('nes_select-quantity_selected').parents('.nes_list-filter').removeClass("nes_list-selected").css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
						}
						closeQuantitySelector();
					}
				}else{
					newValue = initValue * Math.round(Math.ceil(newValue / initValue));
					newValue = (newValue < initValue) ?  initValue:newValue;
					if(newValue.toString().length >= 5){
						newValue = newValue-initValue;
					}
					inputQuant.val(newValue);
					inputQuant.next('div.containerQuantity').children('div.containerInnerQuantity').remove();
					inputQuant.parent().removeClass('nes_select-quantity_on').addClass('nes_select-quantity_selected');
					if(newValue > 0){
						inputQuant.parents('.nes_list-filter').addClass("nes_list-selected").css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
					}else{
						inputQuant.parents('.nes_list-filter').removeClass("nes_list-selected").css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
					}
					closeQuantitySelector();
				}
				
				// Mantis 11093
				if( newValue > MaxQuantity){
					inputQuant.val(MaxQuantity);
					var parQuant = inputQuant.next('div.containerQuantity');
					parQuant.append('<span class="nes_quantity-alert"><strong>'+ qSMaxQuantityReachedAlert.replace("MAXQUANTITY", MaxQuantity) +'</strong></span>');
					$('.nes_quantity-alert').parents('.nes_select-quantity').css('z-index','2');
					setTimeout(function ()
					{
						inputQuant.next('div.containerQuantity').children('span.nes_quantity-alert').fadeOut('fast',function ()
						{
							$('.nes_quantity-alert').parents('.nes_select-quantity').css('z-index','');
							inputQuant.next('div.containerQuantity').children('span.nes_quantity-alert').remove();
						});
					},3000);
				}else if(newValue!=oldVal)
				{
					var parQuant = inputQuant.next('div.containerQuantity');
					parQuant.append('<span class="nes_quantity-alert"><strong>'+qSQuantityAlert+'</strong></span>');
					$('.nes_quantity-alert').parents('.nes_select-quantity').css('z-index','2');
					setTimeout(function ()
					{
						inputQuant.next('div.containerQuantity').children('span.nes_quantity-alert').fadeOut('fast',function ()
						{
							$('.nes_quantity-alert').parents('.nes_select-quantity').css('z-index','');
							inputQuant.next('div.containerQuantity').children('span.nes_quantity-alert').remove();
						});
					},3000);
				}
				if(realOldValue != newValue)
					inputQuant.trigger('change');
			}else{
				var parQuant = inputQuant.parent('div.formQuantitySelector');
				var txtError = f_get_txt('invalideValue');
				if(!parQuant.hasClass('nes_error')){
					parQuant.addClass('nes_error');
					parQuant.append('<span class="txt_error nes_png">'+txtError+'</span>');
				}
				inputQuant.val('');
				return false;
			}
		}
		
		el.children('input').attr("readonly","readonly").click(function(){
			var $$ = $(this);
			if(contextPage=='quickorder' || contextPage=='quickorder-2' && $$.parents('.nes_quick-offer-pos').length > 0){
				var $$pos = $$.parents('span').parents('div').parents('.nes_quick-transp').parents('.nes_quick-offer-pos').parents('.nes_quick-col-left-offer');
				$$pos.parents('li').siblings('li').find('.nes_quick-col-left-offer').removeClass('nes_quick-col-left-offer-select');
				$$pos.addClass('nes_quick-col-left-offer-select');
			}
			if(!$$.parent().hasClass('nes_select-quantity_on')){
				if($$.parents('.scroll-bloc').length>0 && $$.parents('.scroll-bloc').next('.jScrollPaneTrack').length>0)
					$$.parents('.scroll-bloc')[0].centerMe($$);
				$('span.nes_select-quantity_on > input').each(function() {
					$(this).next('div.containerQuantity').children('div.containerInnerQuantity').remove();
					$(this).parent().removeClass('nes_select-quantity_on');
					$(this).parents('.nes_list-filter').css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
					closeQuantitySelector();
				});
				
				quantityActive = true;
				var subContainerQuantity = $('<ul></ul>').addClass('subQuantity');
				var newSubToAppend = "";
				var incValue;
				if(contextPage=='quickorder' || contextPage=='quickorder-2'){
					var incr = 1;
					for(var i=1; i<=finalState; i++) {
						var newSub;
						if(i <= 11){
							if(i==1){
								newSub = 0;
							}else{
								newSub = initValue*incr;
								incr++;
							}
							if(i == 11)
								incValue = newSub;
						}else{
							newSub += incValue;
						}
						newSubToAppend +='<li><a href="#">'+newSub+'</a></li>';
					}
				}else{
					for(var i=1; i<=finalState; i++) {
						var newSub;
						if(i <= 10){
							newSub = initValue*i;
							if(i == 10)
								incValue = newSub;
						}else{
							newSub += incValue;
						}
						newSubToAppend +='<li><a href="#">'+newSub+'</a></li>';
					}
				}
				subContainerQuantity.append(newSubToAppend);
				$containerInnerQuantity.append(subContainerQuantity);
				$containerInnerQuantity.append('<div class="formQuantitySelector"><input type="text" class="otherQuantitySelector" value="'+qSQuantity+'" title="'+qSQuantity+'" /><a title="" href="#" class="validationQuantitySelector"><span>'+qSOK+'</span></a></div>');
				$containerQuantity.append($containerInnerQuantity);
				$$.after($containerQuantity).parent().addClass('nes_select-quantity_on');
				$$.parents('.nes_list-filter').css({position:'relative', 'z-index':2}).siblings().css({position:'relative', 'z-index':1});
				$containerInnerQuantity = $('<div></div>').addClass('containerInnerQuantity');
				var contQuantity = $$.next('div.containerQuantity').children('div.containerInnerQuantity');
  			
				$('ul.subQuantity > li > a', contQuantity).each(function() {
					$(this).click(function() {
												
						var eqVal = false;
						var MaxQuantity = parseInt( $$.attr('max') );
						var newValue = $(this).text();
						if($$.val() == newValue){
							eqVal = true;
						}else if( newValue > MaxQuantity ){
							// Mantis 11093
							$$.val(MaxQuantity);
							var parQuant = $$.next('div.containerQuantity');
							parQuant.append('<span class="nes_quantity-alert"><strong>'+ qSMaxQuantityReachedAlert.replace("MAXQUANTITY", MaxQuantity) +'</strong></span>');
							$('.nes_quantity-alert').parents('.nes_select-quantity').css('z-index','2');
							setTimeout(function ()
							{
								$$.next('div.containerQuantity').children('span.nes_quantity-alert').fadeOut('fast',function ()
								{
									$('.nes_quantity-alert').parents('.nes_select-quantity').css('z-index','');
									$$.next('div.containerQuantity').children('span.nes_quantity-alert').remove();
								});
							},3000);
						}else{	
							$$.val(newValue);
							
							//Mantis 8866
							if (contextPage == "pdp"){
								$(".nes_select-quantity input").val(newValue);
							}
						}

						$$.next('div.containerQuantity').children('div.containerInnerQuantity').remove();
						$$.parent().removeClass('nes_select-quantity_on').addClass('nes_select-quantity_selected');
						if(newValue > 0){
							$$.parents('.nes_list-filter').addClass("nes_list-selected").css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
						}else{
							$$.parent().removeClass('nes_select-quantity_selected').parents('.nes_list-filter').removeClass("nes_list-selected").css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
						}
						if(eqVal == false)
							$$.trigger('change');
						closeQuantitySelector();
						return false;
					});
					// $(this).hover(function() {
						// $(this).stop().focus();
					// }, function() {
						// $(this).stop().blur();
					// });
				});
				$('input.otherQuantitySelector', contQuantity).each(function() {
					$(this).focus(function() {
						if($(this).val() == $(this).attr('title')) {
							$(this).val("");
						}
					});
					$(this).blur(function() {
						if($(this).val() == ""){
							$(this).val($(this).attr('title'));
						}
					});
				});
				var inputQuan = $('input.otherQuantitySelector', contQuantity);
				var intLimit = 9999;
				intLimit = intLimit.toString();
				$('a.validationQuantitySelector', contQuantity).click(function() {
					errOrNot(inputQuan);
					return false;
				});
				inputQuan.keydown(function (e) { 
					if(e.which == 13){
						errOrNot(inputQuan);
						return false;
					}
					if(e.which == 8){
						
						return true;
					}
				});
				inputQuan.keyup(function (e) { 
					if(($(this).val().length) >= 4)
					{
						$(this).val($(this).val().substr(0,4));
					}
				});
				//$$.trigger('focus');
				openQuantitySelector();
			} else {
				quantityActive = false;
				$$.next('div.containerQuantity').children('div.containerInnerQuantity').remove();
				$$.parent().removeClass('nes_select-quantity_on');
				$$.parents('.nes_list-filter').css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
				closeQuantitySelector();
			}
			return false;
		}).keydown(function(e) {
			if(e.which == 13){
				errOrNot($(this));
				isEnter = true;
				return false;
			}
		}).blur(function() {
			if(contextPage=='quickorder' || contextPage=='quickorder-2'){
				if($(this).val() == ''){
					$(this).val(0);
					// todo if panier aff qty du panier, sinon 0
				}
			} else {
				if($(this).val() == ''){
					$(this).val(initValue);
				}
			}
			closeQuantitySelector();
		});
	}
	function openQuantitySelector()
	{
		
		$('.nes_innerColRight').css('z-index','7');
		$('.nes_blocHeader').css('z-index','7');
	}
	function closeQuantitySelector()
	{

	$('.nes_blocHeader').css('z-index','4');
	$('.nes_innerColRight').css('z-index','5');
	
		
	}
	/* */

	// function "postToURL": fait un submit avec la id et action
	// Author : anas
	// Date : 08/04/2010
	// Param : filterParam (Object JSON)
	// Param : Pagination (Integer)
	function postAction(url,action,id)
	{
		$('body').append('<form id="dynForm" action="'+url+'" method="post"><input type="hidden" name="action" value="'+action+'"><input type="hidden" name="id" value='+id+' /></form>');
		$('#dynForm').submit().remove();
	}
	
	/* /////////////////////////// TRAITEMENT JSON /////////////////////////// */
		// function "querySetBag": Appel Ajax pour récupérer le nombre d'éléments dans le panier
		// Author : shajji
		// Date : 16/02/2010
		// Param : ProductCode (String) 
		// Param : CatalogVersionId (Integer) 
		// Param : Quantity (String) 
		function querySetBag(ProductCode,CatalogVersionId,Quantity)
		{
			if(ProductCode!="" && CatalogVersionId!="" && Quantity!=0)
			var DTOparametres={"ProductCode":ProductCode,"CatalogVersionId":CatalogVersionId,"Quantity":Quantity};
			else
			var DTOparametres={};
			$.getJSON(
						"json/add_to_bag.json",
						DTOparametres,
						function(DTOsetBag) 
						{
							// Retour JSON attendu 
							// DTOsetBag : {
								// "id":String,
								// "nbr":integer, 
								// "success":flag,
								// "message":String
							// }
							if(DTOsetBag.success=="true")
							{
								if(DTOsetBag.nbr!=0)
								{
									if(!$("#nbr_bag").hasClass("nes_num-bag-fill"))
									{
										$("#nbr_bag").addClass("nes_num-bag-fill");
									}
									$("#nbr_bag").text(DTOsetBag.nbr);
									// TO-DO : Mettre en place un message de confirmation
									showMessageAlerte('add_to_bag',DTOsetBag.message);
									//$(this).simpletip({persistent : true});
									//alert(DTOsetBag.message);
								}
							}
							else
							{
								// TO-DO : Mettre en place un message d'erreur
								//alert(DTOsetBag.message);
							}
						}
					);
			return false;
		}
		
		var showMessageAlerte = function(id,titre) {
			var pos = $("#"+id).offset();  
			var width = $("#"+id).width();
			var id_tt=id+'_tt';	
			if($("#"+id).attr('class')=="")
			{
				$("#"+id).attr('class',"actif");
				if($("#"+id_tt).length==0)
				{
					$('body').append('<div class="showMessageAlerte" id="'+id_tt+'">'+titre+'</div>');
				}else
				{
					$("#"+id_tt).html(titre);
				}
				$("#"+id_tt).css( { "left": (pos.left-10) + "px", "top":(pos.top-30) + "px" } );
				$("#"+id_tt).fadeIn('fast',function (){setTimeout(function(){$("#"+id_tt).fadeOut();$("#"+id).removeClass("actif")},2000)});
			}
		}
		
		function checkNumeric(event)
		{
			// Allow only backspace and delete
			 if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 ) {
				// let it happen, don't do anything
			}
			else {
				// Ensure that it is a number and stop the keypress
				if (event.keyCode < 96 || event.keyCode > 105) {
						event.preventDefault(); 
						return true;
				}       
			}
			return false;
		}
		
		// function "queryFilterAccessory": Appel Ajax pour filtrer les listes de produits
		// Author : kgauriaud
		// Date : 24/03/2010
		function queryFilterAccessory(ajaxSelected,fn,scope)
		{
			var DTOparametres={t:''};
			FilterAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryFilterAccessoryUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterAccessory = $.post(
						queryFilterAccessoryUrl,
						DTOparametres, */
						function(DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var collections, productType, finish; // objets extrait du JSON
								var $divCollection, $divProductType, $divFinish, $divItem; // éléments HTML intermédiaires pour la création
								$('.nes_innerListMachineContainer').html("");
								$divCollection = $('#nes_innerSwitchListMachineGlobal_1 .nes_innerListMachineContainer');
								$divProductType = $('#nes_innerSwitchListMachineGlobal_2 .nes_innerListMachineContainer');
								$divFinish = $('#nes_innerSwitchListMachineGlobal_3 .nes_innerListMachineContainer');
								for(var i = 0; i < DTOFilter.selectedCollections.length; i++) {
									collections = DTOFilter.selectedCollections[i];
									$divItem = $('<div></div>').addClass('nes_innerListMachine');
									$divItem.append('<a title="'+collections.name+'" href="#" rel="'+collections.itemId+'"><span class="nes_innerListMachineHover">&nbsp;</span><img alt="'+collections.name+'" src="'+collections.image.url+'" class="nes_png"/><div class="fadeImg"></div><span><strong>'+collections.name+'</strong></span></a>');
									$divCollection.append($divItem);
									
									if ($.browser.msie && $.browser.version == "6.0")
										DD_belatedPNG.fixPng($divItem.find(".nes_png")[0]);
								}
								//$('.nes_innerListMachine > a[rel='+gup('pdpSelectCollection')+']').trigger('click');
								$divCollection.append('<div class="nes_clear"></div>').prepend('<div class="nes_clear"></div>');
								for(var i = 0; i < DTOFilter.selectedProductTypes.length; i++) {
									productType = DTOFilter.selectedProductTypes[i];
									$divItem = $('<div></div>').addClass('nes_innerListMachine');
									$divItem.append('<a title="'+productType.name+'" href="#" rel="'+productType.itemId+'"><span class="nes_innerListMachineHover">&nbsp;</span><img alt="'+productType.name+'" src="'+productType.image.url+'" class="nes_png"/><div class="fadeImg"></div><span><strong>'+productType.name+'</strong></span></a>');
									$divProductType.append($divItem);
									
									if ($.browser.msie && $.browser.version == "6.0")
										DD_belatedPNG.fixPng($divItem.find(".nes_png")[0]);
								}
								$divProductType.append('<div class="nes_clear"></div>').prepend('<div class="nes_clear"></div>');
								for(var i = 0; i < DTOFilter.selectedFinishs.length; i++) {
									finish = DTOFilter.selectedFinishs[i];
									$divItem = $('<div></div>').addClass('nes_innerListMachine');
									$divItem.append('<a title="'+finish.name+'" href="#" rel="'+finish.itemId+'"><span class="nes_innerListMachineHover">&nbsp;</span><img alt="'+finish.name+'" src="'+finish.image.url+'" class="nes_png"/><div class="fadeImg"></div><span><strong>'+finish.name+'</strong></span></a>');
									$divFinish.append($divItem);
									
									if ($.browser.msie && $.browser.version == "6.0")
										DD_belatedPNG.fixPng($divItem.find(".nes_png")[0]);
								}
								$divFinish.append('<div class="nes_clear"></div>').prepend('<div class="nes_clear"></div>');
								centerListMachine('#nes_innerSwitchListMachineGlobal_1');
								toSizeImgFilter();
								toFadeImgFilter();
								
								if(ajaxSelected)
									queryFilterSelectedAccessory(fn,scope);
							}
						}/* ,
						"json" */
					});
				if(!ajaxSelected)
					fn(scope,1);
			return false;
		}
		
		// function "queryFilterSelectedAccessory": Appel Ajax pour filtrer les listes de produits
		// Author : obasaita
		// Date : 17/06/2010
		function queryFilterSelectedAccessory(fn,scope)
		{
			var DTOparametres={t:''};
			FilterAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:querySelectedFilterAccessoryUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterAccessory = $.post(
						querySelectedFilterAccessoryUrl,
						DTOparametres, */
						function(DTOFilter) 
						{	
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var $divCollection, $divProductType, $divFinish; // éléments HTML intermédiaires pour la création
								$divCollection = $('#nes_innerSwitchListMachineGlobal_1 .nes_innerListMachineContainer');
								$divProductType = $('#nes_innerSwitchListMachineGlobal_2 .nes_innerListMachineContainer');
								$divFinish = $('#nes_innerSwitchListMachineGlobal_3 .nes_innerListMachineContainer');
								
								$('.nes_innerSwitchListMachine > form > p > a').css('visibility','visible');
								//toFade08ImgFilter();
								
								/* if(DTOFilter.selectedCollections.length==0)
									toFadeImgFilterWithContext($divCollection); */
								
								for(var i = 0; i < DTOFilter.selectedCollections.length; i++) {
									var $el=$divCollection.find('div.nes_innerListMachine>a[rel='+DTOFilter.selectedCollections[i].itemId+']');
									//$el.find('.fadeImg').css({opacity:0});
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								/* if(DTOFilter.selectedProductTypes.length==0)
									toFadeImgFilterWithContext($divProductType); */
								
								for(var i = 0; i < DTOFilter.selectedProductTypes.length; i++) {
									var $el=$divProductType.find('div.nes_innerListMachine>a[rel='+DTOFilter.selectedProductTypes[i].itemId+']');
									//$el.find('.fadeImg').css({opacity:0});
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								/* if(DTOFilter.selectedFinishs.length==0)
									toFadeImgFilterWithContext($divFinish); */
								
								for(var i = 0; i < DTOFilter.selectedFinishs.length; i++) {
									var $el=$divFinish.find('div.nes_innerListMachine>a[rel='+DTOFilter.selectedFinishs[i].itemId+']');
									//$el.find('.fadeImg').css({opacity:0});
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								paramToQuery();
							}else
							{
								toFadeImgFilter(); //??
								fn(scope,1);
							}
						}/* ,
						"json" */
					});
			return false;
		}
		
		// function "queryListAccessory": Appel Ajax pour afficher les listes de produits
		// Author : kgauriaud, gm
		// Date : 24/03/2010
		// Param : filterParam (Object JSON) 
		// Param : Pagination (Integer)
    // Todo : Faire une fonction générique pour générer un type de template / json à partir d'une url XHR donnée avec pagination en option
		function queryListAccessory(filterParam,Pagination)
		{
			var $target = $('#nes_colLeft div.nes_blocListMachines');
			var $tplSettings = {
				disallow_functions: false,
				filter_data: false,
				filter_params: false,
				runnable_functions: false,
				clone_data: false,
				clone_params: false
			};
      
			if(filterParam!=null && Pagination!=null) {
				var DTOparametres={"filterParam":filterParam,"pagination":Pagination};
			} else {
				var DTOparametres={"filterParam":null,"pagination":1};
			}
			
			DTOparametres=JSON.stringify(DTOparametres);
			
			ListAccessory = $.ajax({
						beforeSend: function(req) {
							$('#nes_ajax-loader').show();
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryListAccessoryUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :function(DTOListAccessory) 
						{
							var DTOListAccessory = JSON.parse(DTOListAccessory);
							if(DTOListAccessory.success==true)
							{
								var pagination; 
								var nextPage = typeof txtNextPage != 'undefined' ? txtNextPage : f_get_txt('Npage');
								var previousPage = typeof txtPreviousPage != 'undefined' ? txtPreviousPage : f_get_txt('Ppage');
								var currentPage = typeof txtCurrentPage != 'undefined' ? txtCurrentPage : f_get_txt('Cpage');
								pagination = DTOListAccessory.pageCount;
								
								$('.nes_blocListMachines').empty().css('height', '2000px').append('<div class="nes_linksNav nes_linksNavTop"></div>');
								$('#nes_colLeft.nes_listAccessories div.nes_linksNav').show().children('div').remove();
								$('.nes_linkBottomPage').show();
								$('.nes_blocNoresults').hide();
								
								if(pagination > 1) {
									if(Pagination == 0)
										Pagination = 1;
									$('#nes_colLeft.nes_listAccessories div.nes_linksNav, .nes_blocListMachines div.nes_linksNavTop').prepend("<div></div>").children('div').append("<ul></ul>");
									for(var i = 1; i <= pagination; i++) {
										if(Pagination == i){
											$('#nes_colLeft.nes_listAccessories div.nes_linksNav > div > ul, .nes_blocListMachines div.nes_linksNavTop > div > ul').append('<li class="nes_enCours"><a title="'+currentPage+'" href="#">'+i+'</a></li>');
										} else {
											$('#nes_colLeft.nes_listAccessories div.nes_linksNav > div > ul, .nes_blocListMachines div.nes_linksNavTop > div > ul').append('<li><a title="'+i+'" href="#">'+i+'</a></li>');
										}
									}
									if(!$('#nes_colLeft.nes_listAccessories div.nes_linksNav > div > ul > li:eq(0), .nes_blocListMachines div.nes_linksNavTop > div > ul > li:eq(0)').hasClass('nes_enCours')) {
										$('#nes_colLeft.nes_listAccessories div.nes_linksNav > div, .nes_blocListMachines div.nes_linksNavTop > div').prepend('<p class="nes_previous"><a title="'+previousPage+'" href="#"><span>'+f_get_txt('previous')+'</span></a></p>');
									}
									if(!$('#nes_colLeft.nes_listAccessories div.nes_linksNav > div > ul > li:last, .nes_blocListMachines div.nes_linksNavTop > div > ul > li:last').hasClass('nes_enCours')) {
										$('#nes_colLeft.nes_listAccessories div.nes_linksNav > div, .nes_blocListMachines div.nes_linksNavTop > div').append('<p class="nes_next"><a title="'+nextPage+'" href="#"><span>'+f_get_txt('next')+'</span></a></p>');
									}
								}
								
								for(var i = 0; i < DTOListAccessory.collections.length; i++) {
									var oCollection = DTOListAccessory.collections[i],
										accessoriesList = oCollection.accessories,
										_TPL_AccessoryHeader = $.createTemplate($.tpl.accessoryHeader, null, $tplSettings),
										bOutOfStock = false;
										
									/* TODO : prevoir le contextPath pour les URLs */
									_TPL_AccessoryHeader = $.processTemplateToText(_TPL_AccessoryHeader, null, {name:oCollection.collectionName});
									$(_TPL_AccessoryHeader).appendTo($target);
									
									for (var j = 0, k = -1, counter = 0, modulo = 4; j < accessoriesList.length; j++){
										var _TPL_AccessoryList = $.createTemplate($.tpl.accessoryList, null, $tplSettings),
											accessory = accessoriesList[j],
											bIsInStock = (accessory.isInStock?true:false);
										
										if (((bIsInStock && !bOutOfStock) || (bOutOfStock && !bIsInStock)) && j != k){
											if (counter%modulo == 3 && accessory.isHighlight){
												if (k == -1 || k < j) k = j;
												while (accessoriesList[k].isHighlight){
													k++;
												}
												accessory = accessoriesList[k];
												j--;
											} else if(accessory.isHighlight) {
												counter++;
											}
											counter++;
											
											_TPL_AccessoryList = $.processTemplateToText(_TPL_AccessoryList, accessory, {
												addToBag : f_get_txt('addToBag'),
												viewDetails : f_get_txt('viewDetails'),
												isEndOfLine : (counter%modulo==0)
											});
											
											$(_TPL_AccessoryList).find('img.nes_png')
												.css({visibility : 'hidden'})
												.preload(function(){
													$(this).hide().css({visibility : 'visible'}).parent().removeClass('nes_loader');
													if($.browser.msie)
														$(this).show();
													else
														$(this).fadeIn(600);
													})
												.end()
												.appendTo($target);
												
											$target.children(":last").mouseenter(productBlockOver)
																	.mouseleave(productBlockOut);
										}
										if (j + 1 == accessoriesList.length && bOutOfStock == false){
											j = -1;
											k = -1;
											bOutOfStock = true;
										}
									}
									$target.append( $('<div class="nes_clear"></div>') ).css('height', 'auto');
								}
								
								// Mantis 9668 & 10734
								// Transparence IE6
								if ($.browser.msie && $.browser.version == "6.0"){
									$target.find(".nes_png").load(definitelyFixPng);
									$target.find("h2.nes_png").each(definitelyFixPng);
								}
								
								$target.append( $('<div class="nes_clear"></div>') ).css('height', 'auto');
								$('#nes_footer').css('position', 'static');
								BagController.initDiffered();								
							} else {
								$('.nes_blocListMachines').empty();
								$('.nes_blocNoresults').not('#nes_ajax-loader').show();
								$('.nes_linkBottomPage').hide();
								$('div.nes_linksNav').hide();
							}
						}
					}
				);
			return false;
		}
		
		// function "queryFilterMachine": Appel Ajax pour filtrer les listes de produits
		// Author : kgauriaud, gm
		// Date : 30/03/2010
		function queryFilterMachine(ajaxSelected,fn,scope)
		{
			var DTOparametres={t:''};
			FilterAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryFilterMachineUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :
			/* FilterAccessory = $.post(
						queryFilterMachineUrl,
						DTOparametres, */ 
						function(DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var range, feature, color, price; // objets extrait du JSON
								var $range, $feature, $color, $price, $divItem; // éléments HTML intermédiaires pour la création
								var firstEl = 0;
								var lastEl = 3;
								$('.nes_innerListMachineContainer').html("");
								$range = $('#nes_innerSwitchListMachineGlobal_1 .nes_innerListMachineContainer');
								$feature = $('#nes_innerSwitchListMachineGlobal_2 .nes_feature-filter');
								$color = $('#nes_innerSwitchListMachineGlobal_3 .nes_innerListMachineContainer');
								$price = $('#nes_innerSwitchListMachineGlobal_4');
								for(var i = 0; i < DTOFilter.selectedRanges.length; i++) {
									range = DTOFilter.selectedRanges[i];
									$divItem = $('<div></div>').addClass('nes_innerListMachine');
									$divItem.append('<a title="'+range.name+'" href="#" rel="'+range.itemId+'"><span class="nes_innerListMachineHover">&nbsp;</span><img alt="'+range.name+'" src="'+range.image.url+'" class="nes_png" />     <div class="fadeImg"></div>     <span><strong>'+range.name+'</strong></span></a>');
									$range.append($divItem);
									
									if ($.browser.msie && $.browser.version == "6.0")
										DD_belatedPNG.fixPng($divItem.find(".nes_png")[0]);
								}
								$range.append('<div class="nes_clear"></div>').prepend('<div class="nes_clear"></div>');
								$feature.html("");
								for(var i = 0; i < DTOFilter.selectedFeatures.length; i++) {
									feature = DTOFilter.selectedFeatures[i];
									$divItem = $('<li></li>');
									if(i == firstEl) {
										$divItem.addClass('nes_li-img-first');
										firstEl+=4;
									} else if(i == lastEl) {
										$divItem.addClass('nes_li-img-last');
										lastEl+=4;
									}
									$divItem.append('<a href="#" title="'+feature.name+'" rel="'+feature.itemId+'" class="info-bulle-css"><img src="'+feature.image1.url+'" alt="'+feature.name+'" class="nes_img-filter-off" /><img src="'+feature.image2.url+'" alt="'+feature.name+'" class="nes_img-filter-on" /><span>'+feature.name+'</span></a>');
									$feature.append($divItem);
								}
								$feature.parent().append('<div class="nes_clear"></div>').prepend('<div class="nes_clear"></div>');
								for(var i = 0; i < DTOFilter.selectedColors.length; i++) {
									color = DTOFilter.selectedColors[i];
									$divItem = $('<div></div>').addClass('nes_innerListMachine');
									$divItem.append('<a title="'+color.name+'" href="#" rel="'+color.itemId+'"><span class="nes_innerListMachineHover">&nbsp;</span><img alt="'+color.name+'" src="'+color.image.url+'" /><div class="fadeImg"></div><span><strong>'+color.name+'</strong></span></a>');
									$color.append($divItem);
								}
								$color.append('<div class="nes_clear"></div>').prepend('<div class="nes_clear"></div>');
								if(DTOFilter.minPrice != null && DTOFilter.unitPrice != null) {
									var minPriceEl = $('#Minimum_price', $price).parent();
									var maxPriceEl = $('#Maximum_price', $price).parent();
									var idCacheMinPriceEl = minPriceEl.children('select').attr('id');
									var idCacheMaxPriceEl = maxPriceEl.children('select').attr('id');
									minPriceEl.html("");
									maxPriceEl.html("");
									minPriceEl.html('<select id="'+idCacheMinPriceEl+'" name="'+idCacheMinPriceEl+'" class="skin_select"></select>');
									maxPriceEl.html('<select id="'+idCacheMaxPriceEl+'" name="'+idCacheMaxPriceEl+'" class="skin_select"></select>');
									var minPriceElSelect = minPriceEl.children('#'+idCacheMinPriceEl);
									var maxPriceElSelect = maxPriceEl.children('#'+idCacheMaxPriceEl);
									if(DTOFilter.priceList != null) {
										var itemPrice;
										var lps='';
										for(var i = 0; i < DTOFilter.priceList.length; i++) {
											itemPrice = DTOFilter.priceList[i];
											minPriceElSelect.append('<option value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										}
										for(var i = 30; i >= 0; i--) {
											itemPrice = DTOFilter.priceList[i];
											lps=(i==30)?'selected="selected"':''; 
											maxPriceElSelect.append('<option '+lps+' value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										}
									}else{
/* 									if(DTOFilter.priceList != null) {
										var itemPrice;
										var lps='';
										for(var i = 0; i < DTOFilter.priceList.length; i++) {
											itemPrice = DTOFilter.priceList[i];
											lps=(i==30)?'selected="true"':''; 
											minPriceElSelect.append('<option value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
											maxPriceElSelect.prepend('<option '+lps+' value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										}
									}else{
 */										var itemPrice = DTOFilter.minPrice;
										for(var i = 0; i <= 30; i++) {
											minPriceElSelect.append('<option value="'+i+'">'+itemPrice+' '+DTOFilter.currencySymbol+'</option>');
											itemPrice += DTOFilter.unitPrice;
										}
										itemPrice -= DTOFilter.unitPrice;
										var lps='';
										for(var i = 30; i >= 0; i--) {
											lps=(i==30)?'selected="true"':''; 
											maxPriceElSelect.prepend('<option '+lps+' value="'+i+'">'+itemPrice+' '+DTOFilter.currencySymbol+'</option>');
											itemPrice -= DTOFilter.unitPrice;
										}
									}
									$('#'+idCacheMaxPriceEl+'.skin_select, #'+idCacheMinPriceEl+'.skin_select', $price).selectbox();
									$('.nes_errorErea').hide();
								}
								centerListMachine('#nes_innerSwitchListMachineGlobal_1');
								//centerListMachine_icone('.nes_feature-filter');
								InstallationInfoBulle();
								toSizeImgFilter();
								centerSpanV();
								toFade08ImgFilter();
								toFadeImgFilter();
								
								if(ajaxSelected)
									queryFilterMachineSelected(fn,scope);
								else
									toFadeImgFilter();
									
								toSizeImgFilter();
							}
						} /* ,
						"json" */ 
					});
					if(!ajaxSelected)
						fn(scope);
			return false;
		}
		
		// function "queryFilterMachineSelected": Appel Ajax pour filtrer les listes de produits
		// Author : obasaita
		// Date : 16/06/2010
		function queryFilterMachineSelected(fn,scope)
		{
			var DTOparametres={t:''};
			FilterAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:querySelectedFilterMachineUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterAccessory = $.post(
						querySelectedFilterMachineUrl,
						DTOparametres, */
						function(DTOFilter) 
						{
							var $range,$feature,$color,$price;
							$range = $('#nes_innerSwitchListMachineGlobal_1 .nes_innerListMachineContainer');
							$feature = $('#nes_innerSwitchListMachineGlobal_2 .nes_feature-filter');
							$color = $('#nes_innerSwitchListMachineGlobal_3 .nes_innerListMachineContainer');
							$price = $('#nes_innerSwitchListMachineGlobal_4');
							
							var DTOFilter = JSON.parse(DTOFilter);
							
							if(DTOFilter.successComparator==true)
							{
								for(var i = 0; i < DTOFilter.comparatorFilter.length; i++) {
									selectedMachines.push(DTOFilter.comparatorFilter[i].code);
								} 
							}
							
							if(DTOFilter.success==true)
							{
								//toFade08ImgFilter();
								$('.nes_innerSwitchListMachine > form > p > a').css('visibility','visible');
								
								/* if(DTOFilter.selectedRanges.length==0)
									toFadeImgFilterWithContext($range); */
								for(var i = 0; i < DTOFilter.selectedRanges.length; i++) {
									var $el=$range.find('div.nes_innerListMachine>a[rel='+DTOFilter.selectedRanges[i].itemId+']');
									//$el.find('.fadeImg').css({opacity:0});
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								/* if(DTOFilter.selectedFeatures.length>0)
									$feature.find('li>a>img.nes_img-filter-off').css({opacity:0.3}); */
								for(var i = 0; i < DTOFilter.selectedFeatures.length; i++) {
									var $el=$feature.find('li>a[rel='+DTOFilter.selectedFeatures[i].itemId+']');
									$el.find('img.nes_img-filter-off').css('display','none');
									$el.find('img.nes_img-filter-on').css('display','block');
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								/* if(DTOFilter.selectedColors.length==0)
									toFadeImgFilterWithContext($color); */
								for(var i = 0; i < DTOFilter.selectedColors.length; i++) {
									var $el=$color.find('div.nes_innerListMachine>a[rel='+DTOFilter.selectedColors[i].itemId+']');
									//$el.find('.fadeImg').css({opacity:0});
									$el.addClass('nes_innerListMachine_lien_selected');
								} 
								
								var $min=$price.find('div.nes_innerSwitchListMachine>form').find('input#Minimum_price_input.selectbox');
								var $max=$price.find('div.nes_innerSwitchListMachine>form').find('input#Maximum_price_input.selectbox');
									
								var $minS=$price.find('div.nes_innerSwitchListMachine>form').find('#Minimum_price');
								var $maxS=$price.find('div.nes_innerSwitchListMachine>form').find('#Maximum_price');
								$min.val(DTOFilter.minPriceWithCurrency);
								$minS.val(DTOFilter.minPrice);
								$max.val(DTOFilter.maxPriceWithCurrency);
								$maxS.val(DTOFilter.maxPrice);			

								gestionQOFilters.mac[4].value =DTOFilter.minPrice;
								gestionQOFilters.mac[3].value = DTOFilter.maxPrice;
										
								/* var currency=$min.val().split(' ')[1];
								
								$min.val(DTOFilter.minPrice+' '+currency);
								$max.val(DTOFilter.maxPrice+' '+currency); */
								
								paramToQuery();
							}else
							{
								toFadeImgFilter();
								fn(scope);
							}
						}/* ,
						"json" */
					});
			return false;
		}
		
		// function "queryListMachine": Appel Ajax pour afficher les listes de produits
		// Author : kgauriaud
		// Date : 29/03/2010
		// Param : filterParam (string : Object JSON) 
		function queryListMachine(filterParam)
		{
			var $target = $('#nes_colLeft div.nes_blocListMachines');
			var $tplSettings = {
			disallow_functions: false,
  			filter_data: false,
  			filter_params: false,
  			runnable_functions: false,
  			clone_data: false,
  			clone_params: false
			};
      
			DTOparametres=JSON.stringify(filterParam);
			ListMachine = $.ajax({
						beforeSend: function(req) {
							$('#nes_ajax-loader').show();
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryListMachineUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :function(DTOListMachine) 
						{
            
						var DTOListMachine = JSON.parse(DTOListMachine)
							bOutOfStock = false;

						if(DTOListMachine.success===true){
							$('.nes_blocListMachines').empty().css('height','2000px');
							$('.nes_linkBottomPage').show();
							$('.nes_blocNoresults').hide();

							for(var i = 0, j = -1, counter = 0, modulo = 4; i < DTOListMachine.machineList.length; i++) {
								var oMachine = DTOListMachine.machineList[i],
									channElt = false,
									bIsInStock = (oMachine.isInStock?true:false);

								//var _TPL_ = $.createTemplate($.tpl.machine, null, $tplSettings);
								if (((bIsInStock && !bOutOfStock) || (bOutOfStock && !bIsInStock)) && i != j){
									for(var u=0; u<oMachine.channels.length; u++){
										if(oMachine.channels[u] == 'B2B'){
											channElt = true;
										}
									}
										
									var _TPL_ = $.createTemplate($.tpl.machine, null, $tplSettings);
				
									if (counter%modulo == 3 && oMachine.isHighlight){
										if (j == -1 || j < i) j = i;
										while (DTOListMachine.machineList[j].isHighlight){
											j++;
										}
										oMachine = DTOListMachine.machineList[j];
										i--;
									} else if(oMachine.isHighlight) {
										counter++;
									}
									counter++;
									
									_TPL_ = $.processTemplateToText(_TPL_, oMachine, {
									  addToBag : f_get_txt('addToBag'),
									  viewDetails : f_get_txt('viewDetails'),
									  isRoadRunner : (channElt == true && oMachine.b2BSimplifiedRegistration == true && oMachine.isOrderableB2B == true),
									  isEndOfLine : (counter%modulo == 0)
									});
									
									$(_TPL_).find('a.nes_machineAddDetails').data('properties', {
										id:oMachine.code,
										name:oMachine.name,  
										thumbnail:($.browser.msie && $.browser.version == "6.0"?oMachine.mediaQuickOrder.url:oMachine.mediaListPage.url)
									})
									.end()
									.find('img.nes_png').css({
										visibility : 'hidden'
									}).preload(function(){
										$(this).hide().css({visibility : 'visible'}).parent().removeClass('nes_loader');
										if($.browser.msie)
										  $(this).show();
										else
										  $(this).fadeIn(600);
									})
									.end()
									.appendTo($target);	
									
									$target.children(":last").mouseenter(productBlockOver)
															.mouseleave(productBlockOut);
															
									if ($.browser.msie && $.browser.version == "6.0"){
										$target.children(":last").find("img.nes_png").load(function(){
											var img = this;
											
											$(img).siblings().remove();
											DD_belatedPNG.fixPng(img);
										});
									}
								}
								if (i + 1 == DTOListMachine.machineList.length && bOutOfStock == false){
									i = -1;
									j = -1;
									bOutOfStock = true;
								}
							}
						
						
						$target.append( $('<div class="nes_clear"></div>') ).css('height', 'auto');
						$('#nes_footer').css('position','static');
						BagController.initDiffered();
						
						if($.isFunction($.fn.comparator))
								$('#nes_innerListMachineCompareWrapper').comparator({preSelect:selectedMachines});
						}
						else
						{
							$('.nes_blocListMachines').empty().height(0);
							$('.nes_blocNoresults').not('#nes_ajax-loader').show();
							$('.nes_linkBottomPage').hide();
						}
					}
				}
			);
			return false;
		}
		
		// function "queryRegistration": Appel Ajax pour afficher les champs de formulaire
		// Author : kgauriaud
		// Date : 30/03/2010
		// Param : typeParam (string) 
		// Param : countryParam (string)
		// Param : contextParam (objet jquery) juste pour le dev js, a ne pas envoyer au serveur
		function queryRegistration(typeParam, countryParam, contextParam)
		{
			if(typeParam!=null && typeParam!="" && countryParam!=null && countryParam!="") {
				var typeParam = typeParam, 
				countryParam = countryParam;
			} else {
				var typeParam = "", countryParam = "";
			}
			reGistration = $.ajax({
									beforeSend: function(req) { req.setRequestHeader("Accept", "application/json"); },
									url: queryRegistrationUrl+countryParam+"/"+typeParam,
									type:"POST",
									contentType:"application/json",
									dataType:"json",
									//processData :false,
									data: {t: ''},
									success : function(DTORegistration){
												var contextEl = contextParam.length > 0?contextParam:"";
												if(DTORegistration.success==true)
												{
													var formElements, itemEl, labelEl;
													var currEl = $('> ul:not(.nes_bill-add-form) > li:first', contextEl); 
													// var gender = $('.customerForm_title select', contextEl).parent();
													// var idCache = gender.children('select').attr('id');
													// gender.html('');
													// gender.html('<select id="'+idCache+'" name="'+idCache+'" class="skin_select"></select>');
													// var genderSelect = gender.children('#'+idCache);
													// $.each(DTORegistration.titleValues, function(k, v) {
															// genderSelect.append('<option value="'+k+'">'+v+'</option>');
													// });
													// $('#'+idCache+'.skin_select', contextEl).selectbox();
													for(var i = 0; i < DTORegistration.jsonListField.length; i++) {
														formElements = DTORegistration.jsonListField[i];
														itemEl = $('.customerForm_'+formElements.field, contextEl);
														currEl.eq(0).after(itemEl.eq(0));
														currEl.eq(1).after(itemEl.eq(1));
														var mandat = itemEl.eq(0).find('label:first').text();
														var isMandatory = mandat.indexOf('*');
														if(formElements.mandatory != true){
															if(isMandatory != -1) {
																mandat = mandat.split(' *');
																itemEl.find('label:first').text(mandat[0]);
															}
														} else {
															if(isMandatory == -1) {
																mandat += ' *';
																itemEl.find('label:first').text(mandat);
															}
														}
														if(formElements.width > 0){
															itemEl.find('input:first').attr('maxlength', formElements.width);
														}else{
															itemEl.find('input:first').removeAttr('maxlength');
														}
														if(formElements.visible != true){
															itemEl.addClass("nes_none");
														} else {
															itemEl.removeClass("nes_none");
														}
														currEl = itemEl;
														
														//Mantis 5099
														//Char limit on textarea adress
														if (DTORegistration.jsonListField[i].field == "remark"){
															var	limitNum = DTORegistration.jsonListField[i].width;

															$("#delivery-man")
																.attr("maxlength", limitNum)
																.bind("keydown", function(){
																	if (this.value.length > limitNum){
																		this.value = this.value.slice(0, limitNum)
																	}
																})
																.bind("keyup", function(){
																	if (this.value.length > limitNum){
																		this.value = this.value.slice(0, limitNum)
																	}
																});
														}
													}
													//shippingAddress.countryCode_input
													if (contextEl != ""){
														if($(contextEl).siblings().find('ul.nes_bill-add-form').length > 0)
														{	
															if(DTORegistration.availableForBilling)
															{
																$('div.nes_inlineRadio > input[name=billingSameShipping]').attr('disabled',false);
															}else
															{
																var rad=$('div.nes_inlineRadio > input[name=billingSameShipping]')[1];
																if(rad != null)
																{
																	rad.click();
																	$('div.nes_inlineRadio > input[name=billingSameShipping]').attr('disabled',true);
																}
															}
														}
													}
												}
							}
				});
				return false;
		}				
		// function "queryListMachineSelection": Appel Ajax pour afficher les listes de produits
		// Author : kgauriaud
		// Date : 08/04/2010
		// Param : filterParam (Object JSON) 
		// Param : Pagination (Integer) 
		function queryListMachineSelection(filterParam)
		{
			DTOparametres=JSON.stringify(filterParam);
			ListMachineSelection = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryListMachineSelectionUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :function(DTOListMachineSelection) 
						{
							var DTOListMachineSelection = JSON.parse(DTOListMachineSelection);
							var lastEl = 3;
							if(DTOListMachineSelection.success==true)
							{
								var machineList; // objets extrait du JSON
								var $divItem, $linkImg, $divInfos; // éléments HTML intermédiaires pour la création
								$('.nes_mac-selection').html("");
								$(".nes_blocNoresults").hide();
								for(var i = 0; i < DTOListMachineSelection.machineList.length; i++) {
									machineList = DTOListMachineSelection.machineList[i];
									$divItem = $('<div></div>');
									if(i == lastEl){
										$divItem.addClass('nes_innerBlocListMachinesSmall');
										lastEl+=4;
									} 
									else {
										$divItem.addClass('nes_innerBlocListMachines');
									}
									$linkImg = $('<a></a>').attr({title:machineList.name, href:"#", rel : (machineList.code.indexOf('\'') != -1 ) ? machineList.code.substr(1,machineList.code.length-2) : machineList.code}); 
									$linkImg.click(function() {
										$('body').append('<form id="dynForm" action="' + (contextPage == "registration"?"":saveMachineInstance) + '" method="post"><input type="hidden" name="_eventId" value="continue"><input type="hidden" id="JSmachineId" name="' + (contextPage == "registration"?"machineRegistration.machineId":"machineCode") + '" value="" /></form>');
										$('#JSmachineId').val($(this).attr('rel'));
										$('#dynForm').submit();
										$('#dynForm').remove();										
										return false;
									});
									if(machineList.mediaListPage.url!=null)
										$linkImg.append('<span class="nes_link-product-center"><img src="'+machineList.mediaListPage.url+'" class="nes_png" alt="'+machineList.name+'" /></span>');
									else
										$linkImg.append('<span class="nes_link-product-center"><img src="'+defaultImageURL+'" class="nes_png" alt="'+machineList.name+'" /></span>');
										
									$divInfos = $('<span></span>').addClass('nes_listInfosMachine');
									if(machineList.name.length > 29) {
										$divInfos.addClass('nes_listInfosMachine-2Lines');
									}
									if(machineList.name.length > 54) {
										$divInfos.addClass('nes_listInfosMachine-3Lines');
									}
									$divInfos.append('<span class="nes_machineName">'+machineList.name+'</span>');

									$divInfos.append('<span class="nes_selectLink"><span>'+f_get_txt('select')+'</span></span>');
									
									$linkImg.append($divInfos);
									$divItem.append($linkImg);
									$('.nes_mac-selection').append($divItem);
									
									if ($.browser.msie && $.browser.version == "6.0")
										DD_belatedPNG.fixPng($divItem.find(".nes_png")[0]);
								}
								$('.nes_mac-selection').append('<div class="nes_clear"></div>');
							}
							else
							{
								$('.nes_mac-selection').html("");
								$(".nes_blocNoresults").show();
								$('.nes_linkBottomPage').hide();
							}
						}
					}
				);
			return false;
		}

		// function "queryFilterQOAccessory": Appel Ajax pour filtrer les listes de produits Accessoires de QuickOrder
		// Author : kgauriaud
		// Date : 12/04/2010
		function queryFilterQOAccessory(ajaxSelected,fn,scope)
		{
			var DTOparametres={t:''};
			FilterQOAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryFilterQOAccessoryUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterQOAccessory = $.post(
						queryFilterQOAccessoryUrl,
						DTOparametres, */
						function(DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var collections, productType, finish; // objets extrait du JSON
								var $divCollection, $divProductType, $divFinish, $liItem; // éléments HTML intermédiaires pour la création
								var lastEl = 2;
								var classLignes='';
								$divCollection = $('#nes_switch_content_quick_1 .nes_innerSwitch_quick');
								$divProductType = $('#nes_switch_content_quick_2 .nes_innerSwitch_quick');
								$divFinish = $('#nes_switch_content_quick_3 .nes_innerSwitch_quick');
								switch(Math.ceil(DTOFilter.filterParam.selectedCollections.length/3))
								{
									case 1:
										classLignes='nes_filter-3col-1-1igne';
										break;
									case 2:
										classLignes='nes_filter-3col-2-1igne';
										break;
									case 3:
										classLignes='nes_filter-3col-3-1igne';
										break;
									default:
										classLignes='';
										break;
								}
								$divCollection.html("").append('<ol class="nes_filter-3col '+classLignes+'"></ol><div class="nes_clear"></div>');
								$divCollection = $divCollection.children('ol.nes_filter-3col');
								for(var i = 0; i < DTOFilter.filterParam.selectedCollections.length; i++) {
									collections = DTOFilter.filterParam.selectedCollections[i];
									$liItem = $('<li></li>');
									if(lastEl == i){
										$liItem.addClass("nes_lastItem");
										lastEl+=3;
									}
									$liItem.append('<input type="checkbox" name="'+collections.itemId+'" id="'+collections.itemId+'" /><label for="'+collections.itemId+'">'+collections.name+'</label>');
									$divCollection.append($liItem);
								}
								switch(Math.ceil(DTOFilter.filterParam.selectedProductTypes.length/3))
								{
									case 1:
										classLignes='nes_filter-3col-1-1igne';
										break;
									case 2:
										classLignes='nes_filter-3col-2-1igne';
										break;
									case 3:
										classLignes='nes_filter-3col-3-1igne';
										break;
									default:
										classLignes='';
										break;
								}
								$divProductType.html("").append('<ol class="nes_filter-3col '+classLignes+'"></ol><div class="nes_clear"></div>');
								$divProductType = $divProductType.children('ol.nes_filter-3col');
								lastEl = 2;
								for(var i = 0; i < DTOFilter.filterParam.selectedProductTypes.length; i++) {
									productType = DTOFilter.filterParam.selectedProductTypes[i];
									$liItem = $('<li></li>');
									if(lastEl == i){
										$liItem.addClass("nes_lastItem");
										lastEl+=3;
									}
									$liItem.append('<input type="checkbox" name="'+productType.itemId+'" id="'+productType.itemId+'" /><label for="'+productType.itemId+'">'+productType.name+'</label>');
									$divProductType.append($liItem);
								}
								switch(Math.ceil(DTOFilter.filterParam.selectedFinishs.length/3))
								{
									case 1:
										classLignes='nes_filter-3col-1-1igne';
										break;
									case 2:
										classLignes='nes_filter-3col-2-1igne';
										break;
									case 3:
										classLignes='nes_filter-3col-3-1igne';
										break;
									default:
										classLignes='';
										break;
								}
								$divFinish.html("").append('<ol class="nes_filter-3col '+classLignes+'"></ol><div class="nes_clear"></div>');
								$divFinish = $divFinish.children('ol.nes_filter-3col');
								lastEl = 2;
								for(var i = 0; i < DTOFilter.filterParam.selectedFinishs.length; i++) {
									finish = DTOFilter.filterParam.selectedFinishs[i];
									$liItem = $('<li></li>');
									if(lastEl == i){
										$liItem.addClass("nes_lastItem");
										lastEl+=3;
									}
									$liItem.append('<input type="checkbox" name="'+finish.itemId+'" id="'+finish.itemId+'" /><label for="'+finish.itemId+'">'+finish.name+'</label>');
									$divFinish.append($liItem);
								}
								//$('.nes_text-filter > a').css('visibility','hidden');
								if(ajaxSelected)
									queryFilterQOSelectedAccessory(fn,scope);
							}
						}/* ,
						"json" */
					});
				if(!ajaxSelected)
					fn(scope,1);
			return false;
		}
		
		// function "queryFilterQOSelectedAccessory": Appel Ajax pour filtrer les listes de produits Accessoires de QuickOrder
		// Author : obasaita
		// Date : 17/06/2010
		function queryFilterQOSelectedAccessory(fn,scope)
		{
			var DTOparametres={t:''};
			FilterQOAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:querySelectedFilterQOAccessoryUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
						/* FilterQOAccessory = $.post(
						querySelectedFilterQOAccessoryUrl,
						DTOparametres, */
						function(DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var $divCollection, $divProductType, $divFinish; // éléments HTML intermédiaires pour la création
								$divCollection = $('#nes_switch_content_quick_1 .nes_innerSwitch_quick');
								$divProductType = $('#nes_switch_content_quick_2 .nes_innerSwitch_quick');
								$divFinish = $('#nes_switch_content_quick_3 .nes_innerSwitch_quick');
								for(var i = 0; i < DTOFilter.selectedCollections.length; i++) {
									var $el=$divCollection.find('ol>li>input#'+DTOFilter.selectedCollections[i].itemId);
									$el.attr('checked','checked');
								}
								
								for(var i = 0; i < DTOFilter.selectedProductTypes.length; i++) {
									var $el=$divProductType.find('ol>li>input#'+DTOFilter.selectedProductTypes[i].itemId);
									$el.attr('checked','checked');
								}
								
								for(var i = 0; i < DTOFilter.selectedFinishs.length; i++) {
									var $el=$divFinish.find('ol>li>input#'+DTOFilter.selectedFinishs[i].itemId);
									$el.attr('checked','checked');
								}
								//$('.nes_text-filter > a').css('visibility','visible');
								paramToQueryQo();
							}else
							{
								fn(scope,1);
							}
						}/* ,
						"json" */
					});
			return false;
		}
		
		// function "queryListQOAccessory": Appel Ajax pour afficher les listes de produits Accessoires de QuickOrder
		// Author : kgauriaud
		// Date : 12/04/2010
		// Param : filterParam (Object JSON) 
		// Param : Pagination (Integer) 
		function queryListQOAccessory(filterParam,Pagination)
		{
			if(filterParam!=null && Pagination!=null) {
				var DTOparametres={"filterParam":filterParam,"pagination":Pagination};
			} else {
				var DTOparametres={"filterParam":null,"pagination":1};
			}
			DTOparametres=JSON.stringify(DTOparametres);
			ListQOAccessory = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryListQOAccessoryUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :function(DTOListAccessory) 
						{
							var DTOListAccessory = JSON.parse(DTOListAccessory);
							if(DTOListAccessory.success==true)
							{
								var family, collections, pagination, product; // objets extrait du JSON
								var $h2, $h3, $divContainer, $divItem, $quantityContainer, $quantitySelect, $viewDetail, $divInfos; // éléments HTML intermédiaires pour la création
								pagination = DTOListAccessory.pageCount;
								$('.nes_list-form-quick .nes_blocNoresults').hide();
								$('#nes_colMid div.nes_linksNav').show().children('div').remove();
								$('#nes_colMid div.nes_linksNav').prepend("<div ></div>");
								if(pagination > 1) {
									if(Pagination == 0)
										Pagination = 1;
									$('#nes_colMid div.nes_linksNav').children('div').append("<ul></ul>");
									for(var i = 1; i <= pagination; i++) {
										if(Pagination == i){
											$('#nes_colMid div.nes_linksNav > div > ul').append('<li class="nes_enCours"><a title="'+f_get_txt('Cpage')+'" href="#">'+i+'</a></li>');
										} else {
											$('#nes_colMid div.nes_linksNav > div > ul').append('<li><a title="'+i+'" href="#">'+i+'</a></li>');
										}
									}
									if(!$('#nes_colMid div.nes_linksNav > div > ul > li:eq(0)').hasClass('nes_enCours')) {
										$('#nes_colMid div.nes_linksNav > div').prepend('<p class="nes_previous"><a title="'+f_get_txt('Ppage')+'" href="#"><span>'+f_get_txt('previous')+'</span></a></p>');
									}
									if(!$('#nes_colMid div.nes_linksNav > div > ul > li:last').hasClass('nes_enCours')) {
										$('#nes_colMid div.nes_linksNav > div').append('<p class="nes_next"><a title="'+f_get_txt('Npage')+'" href="#"><span>'+f_get_txt('next')+'</span></a></p>');
									}
								}else
								{
									$('#nes_colMid div.nes_linksNav >div ').addClass('nes_linksNavSepNone');
								}
								$('.nes_list-quick').html("");
								for(var h = 0; h < DTOListAccessory.collections.length; h++) {
									family = DTOListAccessory.collections[h];
									$divContainer = $('<div></div>').addClass('nes_globalList');
									$h2 = $('<h2></h2>');
									$h2.text(family.collectionName);
									$divContainer.append($h2);
									for(var i = 0; i < family.accessoryType.length; i++) {
										collections = family.accessoryType[i];
										// boucle sur les collections
										$h3 = $('<h3></h3>');
										$h3.text(collections.accessoryType);
										$divContainer.append($h3);
										for(var j = 0; j < collections.accessories.length; j++) {
											product = collections.accessories[j];
											var phonetic = "";
											var prodInShoppingBag = product.quantityInShoppingBag;
											$divItem = $('<div></div>').addClass('nes_list-filter');
											if(prodInShoppingBag > 0){
												$divItem.addClass('nes_list-selected');
											}
											if(j == collections.accessories.length-1){
												$divItem.addClass('nes_list-filterLast');
											}
											if(product.isHighlight != null && product.isHighlight === true){
												if (product.mediaHighlightQuickOrderBackground.url != null){
													$divItem.addClass('nes_list-special-big').css('background','url('+product.mediaHighlightQuickOrderBackground.url+') no-repeat 0 0');
												}else {
													$divItem.addClass('nes_list-special-big');
												}
											}
											$divItem.append('<span><a href="'+contextPath+product.urlQuickView+'" title="'+product.name+'" class="nes_list-img open"><img src="'+product.mediaQuickOrder.url+'" class="nes_png" alt="'+product.name+'" /></a><a href="'+contextPath+product.urlQuickView+'" title="'+product.name+'" class="nes_list-name open"><span>'+product.name+'</span>'+phonetic+'</a></span><span class="nes_list-price">'+product.formatedPrice+(product.isInStock?"<strong>x</strong>":"<strong style='visibility:hidden'>x</strong>") +'</span>');
											//$divItem.append('<span><a href="'+contextPath+product.urlDetail+'" title="'+product.name+'" class="nes_list-img"><img src="'+product.mediaQuickOrder.url+'" class="nes_png" alt="'+product.name+'" /></a><a href="'+contextPath+product.urlDetail+'" title="'+product.name+'" class="nes_list-name"><span>'+product.name+'</span>'+phonetic+'</a></span><span class="nes_list-price">'+product.formatedPrice+'<strong>x</strong></span>');
											
											if (product.isInStock){
												$quantityContainer = $('<span></span>').addClass('nes_list-qty');
												$quantityContainer.append('<label for="'+product.catalogId+'" class="nes_none">'+f_get_txt('quantity')+'</label>');
												$quantitySelect = $('<span></span>').addClass('nes_select-quantity');
												
												// Mantis 11093 : ajouter attribue max
												if(product.maxQuantity)
													var max = product.maxQuantity
												else
													var max = 9999;
												$quantitySelect.append('<input class="nes_linkAddToBag_qs" prod="'+product.code+'" max="'+ max +'" tag="id:'+product.code+';quantity:{input_q_'+product.uniqueId+'}" id="input_q_'+product.uniqueId+'" type="text" value="'+product.quantityInShoppingBag+'" />');
												if(product.salesMultiple != null){
													affQuantity($quantitySelect, product.salesMultiple);
												}else{
													affQuantity($quantitySelect, '10');
												}
												$quantityContainer.append($quantitySelect);
												$divItem.append($quantityContainer);
											} else {
												$('<span class="nes_out_stock">' + f_get_txt('outOfStock') + '</span>').appendTo($divItem)
											}

											$divItem.append('<div class="nes_clear"></div>');
											$divContainer.append($divItem);
										}
										$('.nes_list-quick').append($divContainer).css('height', 'auto');
									}
									//Mantis 9895
									//Footer position on QuickOrder
									setFooterPosition();
									setQOBlockHeight();
								}
								
								if ($.browser.msie && $.browser.version == "6.0"){
									$(".nes_globalList img.nes_png").load(definitelyFixPng);									
								}
								BagController.initDiffered('qsUpd');
								popin(w.config.popin1);
							}
							else
							{
								$('.nes_list-quick').html("").height(0);
								$('.nes_list-form-quick .nes_blocNoresults').show();
								$('#nes_colMid div.nes_linksNav div').html('');
								$('#nes_colMid div.nes_linksNav >div ').addClass('nes_linksNavSepNone');
							}
							
							if(firstLoadPromotions == true)
							{
								firstLoadPromotions = false;
								promotionLoader.getPromotions();
							}
						}
					}
				);
			return false;
		}
		
		// function "queryFilterQOCapsules": Appel Ajax pour filtrer les listes de produits Capsules de QuickOrder
		// Author : kgauriaud
		// Date : 12/04/2010
		function queryFilterQOCapsules(ajaxSelected,fn,scope)
		{
			var DTOparametres={t:''};
			FilterQOCapsules = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryFilterQOCapsulesUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterQOCapsules = $.post(
						queryFilterQOCapsulesUrl,
						DTOparametres, */
						function (DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var AromaticNotes, Ranges, SizeOfCup; // objets extrait du JSON
								var $divAromaticNotes, $divRanges, $divSizeOfCup, $divItem, $liItem; // éléments HTML intermédiaires pour la création
								var lastEl = 2;
								var classLignes='';
								$divSizeOfCup = $('#nes_switch_content_quick_1 .nes_innerSwitch_quick .nes_block-size');
								$divIntensity = $('#nes_switch_content_quick_2 .nes_innerSwitch_quick');
								$divAromaticNotes = $('#nes_switch_content_quick_3 .nes_innerSwitch_quick');
								$divRanges = $('#nes_switch_content_quick_4 .nes_innerSwitch_quick');
								switch(Math.ceil(DTOFilter.selectedAromaticNotes.length/3))
								{
									case 1:
										classLignes='nes_filter-3col-1-1igne';
										break;
									case 2:
										classLignes='nes_filter-3col-2-1igne';
										break;
									case 3:
										classLignes='nes_filter-3col-3-1igne';
										break;
									default:
										classLignes='';
										break;
								}
								$divAromaticNotes.html("").append('<ol class="nes_filter-3col '+classLignes+'"></ol><div class="nes_clear"></div>');
								$divAromaticNotes = $divAromaticNotes.children('ol.nes_filter-3col');
								for(var i = 0; i < DTOFilter.selectedAromaticNotes.length; i++) {
									AromaticNotes = DTOFilter.selectedAromaticNotes[i];
									$liItem = $('<li></li>');
									if(lastEl == i){
										$liItem.addClass("nes_lastItem");
										lastEl+=3;
									}
									$liItem.append('<input type="checkbox" name="'+AromaticNotes.itemId+'" id="'+AromaticNotes.itemId+'" /><label for="'+AromaticNotes.itemId+'">'+AromaticNotes.itemName+'</label>');
									$divAromaticNotes.append($liItem);
								}
								switch(Math.ceil(DTOFilter.selectedRanges.length/3))
								{
									case 1:
										classLignes='nes_filter-3col-1-1igne';
										break;
									case 2:
										classLignes='nes_filter-3col-2-1igne';
										break;
									case 3:
										classLignes='nes_filter-3col-3-1igne';
										break;
									default:
										classLignes='';
										break;
								}
								$divRanges.html("").append('<ol class="nes_filter-3col '+classLignes+'"></ol><div class="nes_clear"></div>');
								$divRanges = $divRanges.children('ol.nes_filter-3col');
								lastEl = 2;
								for(var i = 0; i < DTOFilter.selectedRanges.length; i++) {
									Ranges = DTOFilter.selectedRanges[i];
									$liItem = $('<li></li>');
									if(lastEl == i){
										$liItem.addClass("nes_lastItem");
										lastEl+=3;
									}
									$liItem.append('<input type="checkbox" name="'+Ranges.itemId+'" id="'+Ranges.itemId+'" /><label for="'+Ranges.itemId+'">'+Ranges.itemName+'</label>');
									$divRanges.append($liItem);
								}
								$divSizeOfCup.html("");
								for(var i = 0; i < DTOFilter.selectedSizeOfCup.length; i++) {
									SizeOfCup = DTOFilter.selectedSizeOfCup[i];
									$divItem = $('<div></div>').addClass('nes_size-filter');
									var urlon=SizeOfCup.image.url;
									urlon=urlon.substr(0,urlon.length-4)+'-on'+urlon.substr(urlon.length-4);
									$divItem.append('<div class="nes_script-show"><label for="'+SizeOfCup.itemId+'">'+SizeOfCup.name+'</label><input type="checkbox" name="'+SizeOfCup.itemId+'" id="'+SizeOfCup.itemId+'" /></div><a class="info-bulle-css" title="'+SizeOfCup.description+' '+SizeOfCup.capacityDescription+'" href="#" rel="'+SizeOfCup.itemId+'"><span class="nes_size-hover">&nbsp;</span><img src="'+SizeOfCup.image.url+'" class="nes_png nes_size-off" alt="'+SizeOfCup.name+'" /><div class="fadeImg"></div><img src="'+urlon+'" class="nes_png nes_size-on" alt="'+SizeOfCup.name+'" /><span>'+SizeOfCup.name+'</span></a>');
									
									$divSizeOfCup.append($divItem);
								}
								$divSizeOfCup.append('<div class="nes_clear"></div>');
								$('#slider_intensity').slider( "destroy" );
								$('#slider_intensity').slider({
									range: true,
									values: [DTOFilter.minIntensity, DTOFilter.maxIntensity],
									min: 1, max: 10, step: 1,
									start: function(event, ui) {
										$(ui.handle).css('top','-1.5em');
									},
									slide: function(event, ui) {
										if($(this).slider("values", 0) >= $(this).slider("values", 1)) { 
											if(ui.handle.nextElementSibling==null)
												$(this).slider( "option", "values", [$(this).slider("values", 0),$(this).slider("values", 0)+1] );
											else
												$(this).slider( "option", "values", [$(this).slider("values", 1)-1,$(this).slider("values", 1)] );
											return false; 
										}
									},
									stop: function(event, ui) {
										$(ui.handle).css('top','-1.6em');
										paramToQueryQo();
										//$('.nes_text-filter > a').css('visibility','visible');
									}
								});
								$('.nes_script-show').css('display','none');
								//$('.nes_text-filter > a').css('visibility','hidden');
								InstallationInfoBulle();
								$('.nes_size-on').hide();
								toSizeImgFilter();
								toFadeImgFilter();
								
								if(ajaxSelected)
									queryFilterQOSelectedCapsules(fn,scope);
								if ($.browser.msie && $.browser.version == "6.0"){
									$(".nes_filter-menu img.nes_png").each(function(){
										var img = this;
									
										setTimeout(function(){DD_belatedPNG.fixPng(img);}, 1);												
									})
								}
							}
						}/* ,
						"json" */
					});
				if(!ajaxSelected)
					fn(scope);
		}
		
		// function "queryFilterQOSelectedCapsules": Appel Ajax pour filtrer les listes de produits Capsules de QuickOrder
		// Author : obasaita
		// Date : 16/06/2010
		function queryFilterQOSelectedCapsules(fn,scope)
		{
			var DTOparametres={t:''};
			FilterQOCapsules = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:querySelectedFilterQOCapsulesUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterQOCapsules = $.post(
						querySelectedFilterQOCapsulesUrl,
						DTOparametres, */
						function (DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								//$('.nes_text-filter > a').css('visibility','visible');
								
								var $divAromaticNotes,$divIntensity, $divRanges, $divSizeOfCup; // éléments HTML intermédiaires pour la création
								$divSizeOfCup = $('#nes_switch_content_quick_1 .nes_innerSwitch_quick .nes_block-size');
								$divIntensity = $('#nes_switch_content_quick_2 .nes_innerSwitch_quick');
								$divAromaticNotes = $('#nes_switch_content_quick_3 .nes_innerSwitch_quick');
								$divRanges = $('#nes_switch_content_quick_4 .nes_innerSwitch_quick');
								
								toFade08ImgFilter();
								
								for(var i = 0; i < DTOFilter.selectedAromaticNotes.length; i++) {
									var $el=$divAromaticNotes.find('ol>li>input#'+DTOFilter.selectedAromaticNotes[i].itemId);
									$el.attr('checked','checked');
								}
								
								for(var i = 0; i < DTOFilter.selectedRanges.length; i++) {
									var $el=$divRanges.find('ol>li>input#'+DTOFilter.selectedRanges[i].itemId);
									$el.attr('checked','checked');
								}
								if(DTOFilter.selectedSizeOfCup.length==0)
									toFadeImgFilterWithContext($divSizeOfCup);
								
								for(var i = 0; i < DTOFilter.selectedSizeOfCup.length; i++) {
									$el=$divSizeOfCup.find('div>a[rel='+DTOFilter.selectedSizeOfCup[i].itemId+']');
									//$el.find('img').css({opacity:1});
									$el.find('.fadeImg').css({opacity:0});
									$el.find('.nes_size-on').show();
									$el.find('.nes_size-off').hide();
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								$('#slider_intensity').slider( "destroy" );
								$('#slider_intensity').slider({
									range: true,
									values: [DTOFilter.minIntensity, DTOFilter.maxIntensity],
									min: 1, max: 10, step: 1,
									start: function(event, ui) {
										$(ui.handle).css('top','-1.5em');
									},
									slide: function(event, ui) {
										if($(this).slider("values", 0) >= $(this).slider("values", 1)) { 
											if(ui.handle.nextElementSibling==null)
												$(this).slider( "option", "values", [$(this).slider("values", 0),$(this).slider("values", 0)+1] );
											else
												$(this).slider( "option", "values", [$(this).slider("values", 1)-1,$(this).slider("values", 1)] );
											return false; 
										}
									},
									stop: function(event, ui) {
										$(ui.handle).css('top','-1.6em');
										paramToQueryQo();
										//$('.nes_text-filter > a').css('visibility','visible');
									}
								});
								paramToQueryQo();
							}else
							{
								fn(scope);
							}
						}/* ,
						"json" */
					});
		}
		
		// function "queryListQOCapsules": Appel Ajax pour afficher les listes de produits Capsules de QuickOrder
		// Author : kgauriaud
		// Date : 13/04/2010
		// Param : filterParam (Object JSON) 
		function queryListQOCapsules(filterParam)
		{
			DTOparametres=JSON.stringify(filterParam);
			ListQOCapsules = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryListQOCapsulesUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :function(DTOListCapsules) 
						{
							var DTOListCapsules = JSON.parse(DTOListCapsules);
							if(DTOListCapsules.success==true)
							{
								var capsuleRange, capsuleList; // objets extrait du JSON
								var $h2, $h3, $divContainer, $divItem, $quantityContainer, $quantitySelect, $viewDetail, $divInfos; // éléments HTML intermédiaires pour la création
								$('.nes_list-form-quick .nes_blocNoresults').hide();
								$('.nes_list-quick').html("");
								for(var i = 0; i < DTOListCapsules.capsuleRange.length; i++) {
									capsuleRange = DTOListCapsules.capsuleRange[i];
									$divContainer = $('<div></div>').addClass('nes_globalList');
									$h2 = $('<h2></h2>');
									$h2.text(capsuleRange.rangeName);
									$divContainer.append($h2);
									for(var j = 0; j < capsuleRange.capsuleList.length; j++) {
										capsuleList = capsuleRange.capsuleList[j];
										var phonetic = "";
										var prodInShoppingBag = capsuleList.quantityInShoppingBag;
										if(capsuleList.phoneticName != null){
											phonetic = '<strong>'+capsuleList.phoneticName+'</strong>';
										}
										$divItem = $('<div></div>').addClass('nes_list-filter');
										if(prodInShoppingBag > 0){
											$divItem.addClass('nes_list-selected');
										}
										if(phonetic != ""){
											$divItem.addClass('nes_list-filter-phonetic');
										}
										if(capsuleList.isHighlight != null && capsuleList.isHighlight === true){
											if (capsuleList.mediaHighlightQuickOrderBackground.url != null){
												$divItem.addClass('nes_list-special-big').css('background','url('+capsuleList.mediaHighlightQuickOrderBackground.url+') no-repeat 0 0');
											}else {
												$divItem.addClass('nes_list-special-big');
											}
										}
										$divItem.append('<span><a href="'+contextPath+capsuleList.urlQuickView+'" title="'+capsuleList.name+'" class="nes_list-img open"><img src="'+capsuleList.mediaQuickOrder.url+'" class="nes_png" alt="'+capsuleList.name+'" /></a><a href="'+contextPath+capsuleList.urlQuickView+'" title="'+capsuleList.name+'" class="nes_list-name open"><span>'+capsuleList.name+'</span>'+phonetic+'</a></span><span class="nes_list-price">'+capsuleList.formatedPrice+ (capsuleList.isInStock?"<strong>x</strong>":"<strong style='visibility:hidden'>x</strong>") +'</span>');
										//$divItem.append('<span><a href="'+contextPath+capsuleList.urlDetail+'" title="'+capsuleList.name+'" class="nes_list-img"><img src="'+capsuleList.mediaQuickOrder.url+'" class="nes_png" alt="'+capsuleList.name+'" /></a><a href="'+contextPath+capsuleList.urlDetail+'" title="'+capsuleList.name+'" class="nes_list-name"><span>'+capsuleList.name+'</span>'+phonetic+'</a></span><span class="nes_list-price">'+capsuleList.formatedPrice+'<strong>x</strong></span>');
										
										if (capsuleList.isInStock){
											$quantityContainer = $('<span></span>').addClass('nes_list-qty');
											$quantityContainer.append('<label for="'+capsuleList.catalogId+'" class="nes_none">'+f_get_txt('quantity')+'</label>');
											$quantitySelect = $('<span></span>').addClass('nes_select-quantity');
											
											// Mantis 11093 : ajouter attribue max
											if(capsuleList.maxQuantity)
												var max = capsuleList.maxQuantity
											else
												var max = 9999;
											$quantitySelect.append('<input class="nes_linkAddToBag_qs" prod="'+capsuleList.code+'" max="'+ max +'" tag="id:'+capsuleList.code+';quantity:{input_q_'+i+'_'+j+'}" id="input_q_'+i+'_'+j+'" type="text" value="'+capsuleList.quantityInShoppingBag+'" />');
											if(capsuleList.salesMultiple != null){
												affQuantity($quantitySelect, capsuleList.salesMultiple);
											}else{
												affQuantity($quantitySelect, '10');
											}
											$quantityContainer.append($quantitySelect);
											$divItem.append($quantityContainer);										
										} else {
											$('<span class="nes_out_stock">' + f_get_txt('outOfStock') + '</span>').appendTo($divItem);
										}

										$divItem.append('<div class="nes_clear"></div>');
										$divContainer.append($divItem);
										
										if ($.browser.msie && $.browser.version == "6.0"){
											$divContainer.find("img.nes_png").each(function(){
												var img = this;
											
												setTimeout(function(){DD_belatedPNG.fixPng(img);}, 1);												
											})
										}

									}
									$('.nes_list-quick').append($divContainer).css('height', 'auto');
									
									//Mantis 9895
									//Footer position on QuickOrder
									setFooterPosition();
									setQOBlockHeight();
								}
								BagController.initDiffered('qsUpd');
								popin(w.config.popin1);
							}
							else
							{
								$('.nes_list-quick').html("").height(0);
								$('#nes_footer').css('position', 'static');
								$('.nes_list-form-quick .nes_blocNoresults').show();
							}
							
							if(firstLoadPromotions == true)
							{
								firstLoadPromotions = false;
								promotionLoader.getPromotions();
							}
						}
					}
				);
			return false;
		}
		
		// function "queryFilterQOMachines": Appel Ajax pour filtrer les listes de produits Machines de QuickOrder
		// Author : kgauriaud
		// Date : 12/04/2010
		function queryFilterQOMachines(ajaxSelected,fn,scope)
		{
			$('.nes_errorErea').hide();
			var DTOparametres={t:''};
			FilterQOMachines = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryFilterQOMachinesUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterQOMachines = $.post(
						queryFilterQOMachinesUrl,
						DTOparametres, */
						function(DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var classLignes='';
								var Ranges, Features, Colors; // objets extrait du JSON
								var $divRanges, $divFeatures, $divColors, $divItem, $liItem; // éléments HTML intermédiaires pour la création
								var lastEl = 2;
								$divRanges = $('#nes_switch_content_quick_1 .nes_innerSwitch_quick');
								$divFeatures = $('#nes_switch_content_quick_2 .nes_innerSwitch_quick');
								$divColors = $('#nes_switch_content_quick_3 .nes_innerSwitch_quick');
								$divPrice = $('#nes_switch_content_quick_4');
								switch(Math.ceil(DTOFilter.selectedRanges.length/3))
								{
									case 1:
										classLignes='nes_filter-3col-1-1igne';
										break;
									case 2:
										classLignes='nes_filter-3col-2-1igne';
										break;
									case 3:
										classLignes='nes_filter-3col-3-1igne';
										break;
									default:
										classLignes='';
										break;
								}
								$divRanges.html("").append('<ol class="nes_filter-3col '+classLignes+'"></ol><div class="nes_clear"></div>');
								$divRanges = $divRanges.children('ol.nes_filter-3col');
								for(var i = 0; i < DTOFilter.selectedRanges.length; i++) {
									Ranges = DTOFilter.selectedRanges[i];
									$liItem = $('<li></li>');
									if(lastEl == i){
										$liItem.addClass("nes_lastItem");
										lastEl+=3;
									}
									$liItem.append('<input type="checkbox" name="'+Ranges.itemId+'" id="'+Ranges.itemId+'" /><label for="'+Ranges.itemId+'">'+Ranges.name+'</label>');
									$divRanges.append($liItem);
								}
								lastEl=2;
								$divFeatures.html("").append('<ul class="nes_feature-filter nes_img-function"></ul><div class="nes_clear"></div>');
								$divFeatures = $divFeatures.children('ul.nes_feature-filter');
								for(var i = 0; i < DTOFilter.selectedFeatures.length; i++) {
									Features = DTOFilter.selectedFeatures[i];
									$liItem = $('<li></li>');
									$liItem.append('<a href="#" rel="'+Features.itemId+'" title="'+Features.name+'" class="info-bulle-css"><img src="'+Features.image1.url+'" alt="'+Features.name+'" class="nes_img-filter-off" /><img src="'+Features.image2.url+'" alt="'+Features.name+'" class="nes_img-filter-on" /></a>');
									$divFeatures.append($liItem);
								}
								InstallationInfoBulle();
								$divColors.html("");
								var $divItemContainer = $('<div></div>').addClass('nes_color-filtre');
								var comptColors = 2;
								for(var i = 0; i < DTOFilter.selectedColors.length; i++) {
									Colors = DTOFilter.selectedColors[i];
									$divItem = $('<div></div>');
									if(comptColors == i) {
										$divItem.addClass('nes_last-color-filter');
										comptColors+=3;
									}
									$divItem.append('<a href="#" rel="'+Colors.itemId+'" title="'+Colors.name+'"><span class="nes_hovered-f-color"><img src="'+Colors.image.url+'" alt="'+Colors.name+'" /><span>'+Colors.name+'</span></span></a>');
									$divItemContainer.append($divItem);
								}
								$divColors.append($divItemContainer);
								if(DTOFilter.minPrice != null && DTOFilter.unitPrice != null) {
									$('.nes_priceForm').css('display','block');
									var minPriceEl = $('#Minimum_price', $divPrice).parent();
									var maxPriceEl = $('#Maximum_price', $divPrice).parent();
									var idCacheMinPriceEl = minPriceEl.children('select').attr('id');
									var idCacheMaxPriceEl = maxPriceEl.children('select').attr('id');
									minPriceEl.html("");
									maxPriceEl.html("");
									minPriceEl.html('<select id="'+idCacheMinPriceEl+'" name="'+idCacheMinPriceEl+'" class="skin_select"></select>');
									maxPriceEl.html('<select id="'+idCacheMaxPriceEl+'" name="'+idCacheMaxPriceEl+'" class="skin_select"></select>');
									var minPriceElSelect = minPriceEl.children('#'+idCacheMinPriceEl);
									var maxPriceElSelect = maxPriceEl.children('#'+idCacheMaxPriceEl);
									if(DTOFilter.priceList != null) {
										var itemPrice;
										var lps='';
										// for(var i = 0; i < DTOFilter.priceList.length; i++) {
											// itemPrice = DTOFilter.priceList[i];
											// lps=(i==30)?'selected="true"':''; 
											// minPriceElSelect.append('<option value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
											// maxPriceElSelect.prepend('<option '+lps+' value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										// }
										
										for(var i = 0; i < DTOFilter.priceList.length; i++) {
											itemPrice = DTOFilter.priceList[i];
											minPriceElSelect.append('<option value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										}
										for(var i = 30; i >= 0; i--) {
											itemPrice = DTOFilter.priceList[i];
											lps=(i==30)?'selected="selected"':''; 
											maxPriceElSelect.append('<option '+lps+' value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										}
										
										gestionQOFilters.mac[4].value = DTOFilter.priceList[0].first;
										gestionQOFilters.mac[3].value = DTOFilter.priceList[30].first;
										
										// for(var i = 0; i < DTOFilter.priceList.length; i++) {
											// itemPrice = DTOFilter.priceList[i];
											// minPriceElSelect.append('<option value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										// }
										// for(var i = DTOFilter.priceList.length-1; i >= 0; i--) {
											// itemPrice = DTOFilter.priceList[i];
											// lps=(i==30)?'selected="true"':''; 
											// maxPriceElSelect.append('<option '+lps+' value="'+itemPrice.first+'">'+itemPrice.second+'</option>');
										// }
									}else{
										var itemPrice = DTOFilter.minPrice;
										for(var i = 0; i <= 30; i++) {
											minPriceElSelect.append('<option value="'+i+'">'+itemPrice+' '+DTOFilter.currencySymbol+'</option>');
											itemPrice += DTOFilter.unitPrice;
										}
										itemPrice -= DTOFilter.unitPrice;
										var lps='';
										for(var i = 30; i >= 0; i--) {
											lps=(i==30)?'selected="true"':''; 
											maxPriceElSelect.append('<option '+lps+' value="'+i+'">'+itemPrice+' '+DTOFilter.currencySymbol+'</option>');
											itemPrice -= DTOFilter.unitPrice;
										}
									}
									$('#'+idCacheMaxPriceEl+'.skin_select, #'+idCacheMinPriceEl+'.skin_select', $divPrice).selectbox();
								}
								centerListMachine_icone('.nes_feature-filter');
								//$('.nes_text-filter > a').css('visibility','hidden');
								
								if(ajaxSelected)
									queryFilterQOSelectedMachines(fn,scope);
							}
						}/* ,
						"json" */
					});
				if(!ajaxSelected)
					fn(scope);
			return false;
		}
		
		// function "queryFilterQOSelectedMachines": Appel Ajax pour filtrer les listes de produits Machines de QuickOrder
		// Author : obasaita
		// Date : 16/06/2010
		function queryFilterQOSelectedMachines(fn,scope)
		{
			var DTOparametres={t:''};
			FilterQOMachines = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:querySelectedFilterQOMachinesUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success : 
			/* FilterQOMachines = $.post(
						querySelectedFilterQOMachinesUrl,
						DTOparametres, */
						function(DTOFilter) 
						{
							var DTOFilter = JSON.parse(DTOFilter);
							if(DTOFilter.success==true)
							{
								var $divRanges, $divFeatures, $divColors,$divPrice; // éléments HTML intermédiaires pour la création
								$divRanges = $('#nes_switch_content_quick_1 .nes_innerSwitch_quick');
								$divFeatures = $('#nes_switch_content_quick_2 .nes_innerSwitch_quick');
								$divColors = $('#nes_switch_content_quick_3 .nes_innerSwitch_quick');
								$divPrice = $('#nes_switch_content_quick_4');
								
								//$('.nes_text-filter > a').css('visibility','visible');
								
								for(var i = 0; i < DTOFilter.selectedRanges.length; i++) {
									var $el=$divRanges.find('ol>li>input#'+DTOFilter.selectedRanges[i].itemId);
									$el.attr('checked','checked');
								}
								
								if(DTOFilter.selectedFeatures.length>0)
									$divFeatures.find('ul>li>a>img.nes_img-filter-off').css({opacity:0.3});
									
								for(var i = 0; i < DTOFilter.selectedFeatures.length; i++) {
									var $el=$divFeatures.find('ul>li>a[rel='+DTOFilter.selectedFeatures[i].itemId+']');
									$el.find('img.nes_img-filter-off').css('display','none');
									$el.find('img.nes_img-filter-on').css('display','block');
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								for(var i = 0; i < DTOFilter.selectedColors.length; i++) {
									var $el=$divColors.find('div.nes_color-filtre>div>a[rel='+DTOFilter.selectedColors[i].itemId+']');
									$el.addClass('nes_innerListMachine_lien_selected');
								}
								
								var $min=$divPrice.find('div.nes_innerSwitch_quick>div').find('input#Minimum_price_input.selectbox');
								var $max=$divPrice.find('div.nes_innerSwitch_quick>div').find('input#Maximum_price_input.selectbox');
								
								var $minS=$divPrice.find('div.nes_innerSwitch_quick>div').find('#Minimum_price');
								var $maxS=$divPrice.find('div.nes_innerSwitch_quick>div').find('#Maximum_price');
								$min.val(DTOFilter.minPriceWithCurrency);
								$minS.val(DTOFilter.minPrice);
								$max.val(DTOFilter.maxPriceWithCurrency);
								$maxS.val(DTOFilter.maxPrice);
								/* var currency=$min.val().split(' ')[1];
								
								$min.val(DTOFilter.minPrice+' '+currency);
								$max.val(DTOFilter.maxPrice+' '+currency); */
								
								paramToQueryQo();
							}else
							{
								fn(scope);
							}
							
						}/* ,
						"json" */
					});
			return false;
		}
		
		// function "queryListQOMachines": Appel Ajax pour afficher les listes de produits Machines de QuickOrder
		// Author : kgauriaud
		// Date : 13/04/2010
		// Param : filterParam (Object JSON) 
		function queryListQOMachines(filterParam)
		{
			DTOparametres=JSON.stringify(filterParam);
			ListQOMachines = $.ajax({
							beforeSend: function(req) {
							req.setRequestHeader("Accept", "application/json");
						},
						url:queryListQOMachinesUrl,
						type:"POST",
						contentType:"application/json",
						dataType:"json",
						//processData :false,
						data:DTOparametres,
						success :function(DTOListMachines) 
						{
							var DTOListMachines = JSON.parse(DTOListMachines);
							if(DTOListMachines.success==true)
							{
								var listMachineRange, machines; // objets extrait du JSON
								var $h2, $h3, $divContainer, $divItem, $quantityContainer, $quantitySelect, $viewDetail, $divInfos; // éléments HTML intermédiaires pour la création
								$('.nes_list-form-quick .nes_blocNoresults').hide();
								$('.nes_list-quick').html("");
								for(var i = 0; i < DTOListMachines.listMachineRange.length; i++) {
									listMachineRange = DTOListMachines.listMachineRange[i];
									$divContainer = $('<div></div>').addClass('nes_globalList');
									$h2 = $('<h2></h2>');
									$h2.text(listMachineRange.rangeName);
									$divContainer.append($h2);
									for(var j = 0; j < listMachineRange.machines.length; j++) {
										machines = listMachineRange.machines[j];
										var phonetic = "";
										$divItem = $('<div></div>').addClass('nes_list-filter');
										if(machines.isHighlight != null && machines.isHighlight === true){
											if (machines.mediaHighlightQuickOrderBackground.url != null){
												$divItem.addClass('nes_list-special-big').css('background','url('+machines.mediaHighlightQuickOrderBackground.url+') no-repeat 0 0');
											}else {
												$divItem.addClass('nes_list-special-big');
											}
										}
										
										if( machines.maxQuantityReached )
											$divItem.append('<span><a href="'+contextPath+machines.urlQuickView+'" title="'+machines.name+'" class="nes_list-img open"><img src="'+machines.mediaQuickOrder.url+'" class="nes_png" alt="'+machines.name+'" /></a><a href="'+contextPath+machines.urlQuickView+'" title="'+machines.name+'" class="nes_list-name open"><span>'+machines.name+'</span>'+phonetic+'</a></span><div class="nes_r-float nes_price-block-bag"><span class="nes_list-price">'+machines.formatedPrice+'</span><span class="nes_out_stock">' + f_get_txt('messageMaxQuantityReached') + '</span></div>' + '<div class="nes_clear"></div>');
										else
											$divItem.append('<span><a href="'+contextPath+machines.urlQuickView+'" title="'+machines.name+'" class="nes_list-img open"><img src="'+machines.mediaQuickOrder.url+'" class="nes_png" alt="'+machines.name+'" /></a><a href="'+contextPath+machines.urlQuickView+'" title="'+machines.name+'" class="nes_list-name open"><span>'+machines.name+'</span>'+phonetic+'</a></span><div class="nes_r-float nes_price-block-bag"><span class="nes_list-price">'+machines.formatedPrice+'</span>' + (machines.isInStock?'<span class="nes_addToBag"><a href="javascript:void(0);" class="nes_linkAddToBag_normal" tag="id:'+machines.code+';quantity:1" prod="'+machines.code+'" rel="'+machines.code+'" title="'+f_get_txt('addToBagThe')+' '+machines.name+'">'+f_get_txt('addToBag')+'</a></span>':'') + '</div>' + (!machines.isInStock?'<span class="nes_out_stock">' + f_get_txt('outOfStock') + '</span>':'') + '<div class="nes_clear"></div>');

										//$divItem.append('<span><a href="'+contextPath+machines.urlDetail+'" title="'+machines.name+'" class="nes_list-img"><img src="'+machines.mediaQuickOrder.url+'" class="nes_png" alt="'+machines.name+'" /></a><a href="'+contextPath+machines.urlDetail+'" title="'+machines.name+'" class="nes_list-name"><span>'+machines.name+'</span>'+phonetic+'</a></span><div class="nes_r-float nes_price-block-bag"><span class="nes_list-price">'+machines.formatedPrice+'</span><span class="nes_addToBag"><a href="javascript:void(0);" class="nes_linkAddToBag_normal" tag="id:'+machines.code+';quantity:1" rel="'+machines.code+'" prod="'+machines.code+'" title="'+f_get_txt('addToBagThe')+' '+machines.name+'">'+f_get_txt('addToBag')+'</a></span></div><div class="nes_clear"></div>');
										$divContainer.append($divItem);
									}
									$('.nes_list-quick').append($divContainer).css('height', 'auto');
									
									//Mantis 9895
									//Footer position on QuickOrder
									setFooterPosition();
									setQOBlockHeight();
								}
								
								if ($.browser.msie && $.browser.version == "6.0"){
									$(".nes_globalList img.nes_png").load(definitelyFixPng);
								}
								BagController.initDiffered('normal');
								popin(w.config.popin1);
							}
							else
							{
								$('.nes_list-quick').html("").height(0);
								$('#nes_footer').css('position', 'static');
								$('.nes_list-form-quick .nes_blocNoresults').show();
							}
							if(firstLoadPromotions == true)
							{
								firstLoadPromotions = false;
								promotionLoader.getPromotions();
							}
						}
					}
				);
			return false;
		}
		
	/* /////////////////////////// FIN TRAITEMENT JSON /////////////////////////// */
	
	/* /////////////////////////// UTILITAIRES JSON /////////////////////////// */
		/* Implements JSON stringify and parse functions v1.0
		 * http://www.sitepoint.com/blogs/2009/08/19/javascript-json-serialization/
		 * By Craig Buckler, Optimalworks.net
		 * As featured on SitePoint.com
		 * Please use as you wish at your own risk. */
			var JSON = {};
		/* JSON serialization to Sring @param obj : the JSON Object to serialize */
			JSON.stringify = JSON.stringify || function (obj) {
				var t = typeof (obj);
				if (t != "object" || obj === null) {
					// simple data type
					if (t == "string") obj = '"'+obj+'"';
					return String(obj);
				}else{
					// recurse array or object
					var n, v, json = [], arr = (obj && obj.constructor == Array);
					for (n in obj) {
						v = obj[n]; t = typeof(v);
						if (t == "string") v = '"'+v+'"';
						else if (t == "object" && v !== null) v = JSON.stringify(v);
						json.push((arr ? "" : '"' + n + '":') + String(v));
					}
					return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
				}
			};
		/* String de-serialization to JSON @param str : the string to deserialize */
			JSON.parse = JSON.parse || function (str) {
				if (typeof(str) != "string") return str;
				if (str === "") str = '""';
				eval("var p=" + str + ";");
				return p;
			};
		
		/* Formatage des filtres au format JSON a envoyer au serveur (listes accessoires et machines) */
			var toQuery = {};
			function paramToQuery() {
				var toQueryTemp = {};
				$('.nes_switch_tabs_list-machine > li').each(function() {
					var $$ = $(this);
					var categoryName = $$.children("a").attr('rel');
					if(categoryName == "selectedPrice") {
						var minPrice = parseInt($$.find("#Minimum_price").val());
						var maxPrice = parseInt($$.find("#Maximum_price").val());
						
						if(maxPrice<minPrice)
							$('div.nes_errorErea').show();
						else
							$('div.nes_errorErea').hide();
						var toPush = {"minPrice": minPrice, "maxPrice": maxPrice};
						jQuery.extend(toQueryTemp, toPush);
					} else if(categoryName != "selectedComparator") {
						var category = [];
						$$.find("a.nes_innerListMachine_lien_selected").each(function() {
							var filtre = {itemId : $(this).attr('rel')};
							category.push(filtre);
						});
						var toPush = eval('('+'{"'+categoryName+'":'+JSON.stringify(category)+'}'+')');
						jQuery.extend(toQueryTemp, toPush);
					}
				});
				toQuery = toQueryTemp;
				
				if(doGestionQOFilters(toQuery))
				{
					if($('.nes_switch_tabs_list-machine').find('a.nes_innerListMachine_lien_selected').length > 0)
						$('.nes_innerSwitchListMachine >form>p>a').css('visibility','visible');
				}else
				{
					$('.nes_innerSwitchListMachine >form>p>a').css('visibility','hidden');
				}
				
				if(contextPage=='list' && $('#nes_colLeft').hasClass('nes_listAccessories')){
					// if(typeof(ListAccessory)!= 'undefined')
						// ListAccessory.abort();
					return queryListAccessory(toQuery,1);
				}
				if(contextPage=='list' && $('#nes_colLeft').hasClass('nes_listMachine')){
					// if(typeof(ListMachine)!= 'undefined')
						// ListMachine.abort();
					return queryListMachine(toQuery);
				}
				if((contextPage=='registration' && $('#nes_colLeft').hasClass('nes_listAccessories')) || (contextPage == 'myAccount' && $('#nes_colLeft').hasClass('nes_listMachine'))){
					// ListMachineSelection.abort();
					return queryListMachineSelection(toQuery);
				}
			}
			
			gestionQOFilters ={
				'acc':[	{name:'selectedCollections',type:'array'},
						{name:'selectedFinishs',type:'array'},
						{name:'selectedProductTypes',type:'array'}],
				'mac':[	{name:'selectedColors',type:'array'},
						{name:'selectedFeatures',type:'array'},
						{name:'selectedRanges',type:'array'},
						{name:'maxPrice',type:'int',value:0},
						{name:'minPrice',type:'int',value:0}],
				'cap':[	{name:'selectedAromaticNotes',type:'array'},
						{name:'selectedRanges',type:'array'},
						{name:'selectedSizeOfCup',type:'array'},
						{name:'maxIntensity',type:'int',value:10},
						{name:'minIntensity',type:'int',value:1}]
			};
			
			function doGestionQOFilters(query)
			{
				if (!isEmpty(query)){
					for(var i=0; i<gestionQOFilters[contextGestionQOFilters].length;i++)
					{
						switch(gestionQOFilters[contextGestionQOFilters][i].type)
						{
							case 'array':
								if(query[gestionQOFilters[contextGestionQOFilters][i].name].length != 0)
								{	
									return true;
								}
								break;
							case 'int':
								if(query[gestionQOFilters[contextGestionQOFilters][i].name] != gestionQOFilters[contextGestionQOFilters][i].value)
								{	
									return true;
								}
								break;
						}
					}
				}
				return false;
			}
			
			function paramToQueryQo() {
				var toQueryTemp = {};
				$('.nes_switch_tabs_quick > li').each(function() {
					var $$ = $(this);
					var categoryName = $$.children("a").attr('rel');
					if(categoryName == "selectedPrice") {
						var minPrice = parseInt($$.find("#Minimum_price").val());
						var maxPrice = parseInt($$.find("#Maximum_price").val());
						if(maxPrice<minPrice){
							$('div.nes_errorErea').show().parents('div.nes_filter-1Line-1clo').addClass('nes_error');
						}else{
							$('div.nes_errorErea').hide().parents('div.nes_filter-1Line-1clo').removeClass('nes_error');
						}
						var toPush = {"minPrice": minPrice, "maxPrice": maxPrice,"minPriceWithCurrency": $$.find("#Minimum_price_input").val(), "maxPriceWithCurrency": $$.find("#Maximum_price_input").val()};
						jQuery.extend(toQueryTemp, toPush);
					} else if(categoryName == "selectedIntensity") {
						var minIntensity = parseInt($("#slider_intensity").slider("values", 0));
						var maxIntensity = parseInt($("#slider_intensity").slider("values", 1));
						var toPush = {"maxIntensity": maxIntensity, "minIntensity": minIntensity};
						jQuery.extend(toQueryTemp, toPush);
					} else if(categoryName == "selectedSizeOfCup" || categoryName == "selectedFeatures" || categoryName == "selectedColors") {
						var category = [];
						$$.find("a.nes_innerListMachine_lien_selected").each(function() {
							var filtre = {itemId : $(this).attr('rel')};
							category.push(filtre);
						});
						var toPush = eval('('+'{"'+categoryName+'":'+JSON.stringify(category)+'}'+')');
						jQuery.extend(toQueryTemp, toPush);
					} else {
						var category = [];
						$$.find("input:checked").each(function() {
							var filtre = {itemId : $(this).attr('id')};
							category.push(filtre);
						});
						var toPush = eval('('+'{"'+categoryName+'":'+JSON.stringify(category)+'}'+')');
						jQuery.extend(toQueryTemp, toPush);
					}
				});
				toQuery = toQueryTemp;
				
				if(doGestionQOFilters(toQuery))
				{
					$('.nes_text-filter > a').css('visibility','visible');
				}else
				{
					$('.nes_text-filter > a').css('visibility','hidden');
				}
				
				if(contextPage=='quickorder' && $('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderAccessories')){
					if(typeof(ListQOAccessory)!= 'undefined')
						ListQOAccessory.abort();
					return queryListQOAccessory(toQuery,1);
				} else if(contextPage=='quickorder' && $('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderMachines')){
					if(typeof(ListQOMachines)!= 'undefined')
						ListQOMachines.abort();
					return queryListQOMachines(toQuery);
				} else {
					if(typeof(ListQOCapsules)!= 'undefined')
						ListQOCapsules.abort();
					return queryListQOCapsules(toQuery);
				}
			}
	/* /////////////////////////// FIN UTILITAIRES JSON /////////////////////////// */
	function centerSpanV()
	{
		$('.nes_switchListMachine .nes_feature-filter li a span').each(function(){
			var comparateur = 16;
			var hauteur_fade = $(this).height();
			if (hauteur_fade > comparateur)
			{
				$(this).addClass('nes_span-vcenter');
			}
		});
	}
	
	function searchArray(arr, obj) {
		for(var i=0; i<arr.length; i++) {
			if (arr[i] == obj) return true;
		}
	}
		
	/////////////////////
	// EVENT UTILITIES //
	/////////////////////
	// START
	
	function productBlockOver(){
		if(!$(this).hasClass('nes_innerBlocListMachinesCompare'))
			$(this).addClass('nes_on');
		if($(this).hasClass('nes_innerBlocListMachines-RR'))
			$(this).addClass('nes_innerBlocListMachines-RR-hover');
	}
	
	function productBlockOut(){
		if(!$(this).hasClass('nes_innerBlocListMachinesCompare'))
			$(this).removeClass('nes_on');	
		if($(this).hasClass('nes_innerBlocListMachines-RR'))
			$(this).removeClass('nes_innerBlocListMachines-RR-hover');
	}
	
	function setFooterPosition(){
		var $footer = $("#nes_footer");

		$footer.show();
		if ($(document).height() <= $(window).height()){
			$footer.css({
				position:"absolute",
				top:$(window).height() - $footer.height()
			});
		} else {
			 $footer.css("position", "static");
		}
		
		if ($footer.css("display") == "none")
			$footer.show();
	}
	
	function setQOBlockHeight(){
		var $QOBlock = $(".nes_bg-quick");
		
		if ($QOBlock.length < 0) return;

		var $footer = $("#nes_footer");

		if ($(document).height() <= $(window).height() + 4){
			$QOBlock.css("height", $(window).height() - $("#nes_footer").height() - $("#nes_header").height() - $("#nes_main-nav").height() - $(".nes_quick-filter-bas").height());
		} else {
			$QOBlock.css("height", "");
		}		
	}
	
	function isEmpty(ob){
		for(var i in ob){ 
			if(ob.hasOwnProperty(i))
				return false;
		}
		return true;
	}	

	function definitelyFixPng(){
		var img = this;
		
		$(img).siblings("shape").remove();
		DD_belatedPNG.fixPng(img);
	}
	
	// END EVENT UTILITIES
	
/* /////////////// fin fonctions /////////////// */
var firstLoadPromotions = true;
var contextGestionQOFilters;
var gestionQOFilters;

$(document).ready(function() {
		/*** INIT ***/
		if(contextPage=='quickorder') {
			if( $('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderAccessories')) {
				contextGestionQOFilters = 'acc';
			} else if(contextPage=='quickorder' && $('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderMachines')){
				contextGestionQOFilters = 'mac';
			} else {
				contextGestionQOFilters = 'cap';
			}
		} else {
			if(contextPage=='registration') {
				contextGestionQOFilters = 'mac';
			} else {
				if( $('.nes_listAccessories').length != 0)
				{
					contextGestionQOFilters = 'acc';
				} else if($('.nes_listMachine').length != 0 || $('.nes_mac-selection').length != 0)
				{
					contextGestionQOFilters = 'mac';
				}
			}
		}
		
		$(".nes_checkOutSubmitWithLoader").click(function (){$(".cacheLoader-check").css('display','block');});
		$('div#nes_header-content').addClass('nes_header-content-script');
		var footerEl = $('#nes_footer');
		
		$('body').addClass('nes_script');
		$('.nes_switchListMachine').addClass('nes_switchListMachine-script');
		$('.nes_switch-interne').addClass('nes_ae_switch_tabs');
		$('.nes_pdp-2 .nes_caroussel').addClass('infiniteCarousel');
		$('#nes_carouselContainer').addClass('nes_carousel-internal');
		$('.nes_script-show, .nes_msg-information').css('display','none');
		
		// centrage elements
		//centerListMachine_icone('.nes_feature-filter');
		$('.nes_quick-filter').each(function() {
			centerListMachineFilter($(this));
		});
		
		// Carrousel
		$('.nes_tab-content .nes_caroussel').each(function(){
			if($(this).find('li').length > 2){
				$(this).addClass('infiniteCarousel');
			}else{
				$(this).addClass('nes-two-elements');
				if($(this).find('li').length==1)
					$(this).addClass('nes_noFadeOnHover');
			}
		});
		$('.nes_accountContent .nes_caroussel').each(function(){
			if($(this).find('li').length <= 1){
				$(this).addClass('nes-two-elements');
				if($(this).find('li').length==1)
					$(this).addClass('nes_noFadeOnHover');
			}
			else{
				$(this).addClass('infiniteCarousel');
			}
		});
		$('.nes_caroussel-home').each(function(){
			if($(this).find('li').length <= 4){
				$(this).addClass('nes-two-elements');
				if($(this).find('li').length==1)
					$(this).addClass('nes_noFadeOnHover');
			}
			else{
				$(this).addClass('infiniteCarousel');
			}
		});
		//$('.infiniteCarousel').infiniteCarousel();//deplacer en bas pour des raison d'ordre d'execution dans les pages pdp
		//8035
		if ($('.infiniteCarousel').length)
		{
			$('.infiniteCarousel').infiniteCarousel();
		}
		/////
		// initialisation pour les listes accessoires, machine, machine selection et les quick order
		if(contextPage=='list' && $('#nes_colLeft').hasClass('nes_listAccessories')){
			var scope=null;
			// if ( typeof( window[ 'pdpSelectCollection' ] ) != "undefined" )
				// scope=pdpSelectCollection;
			queryFilterAccessory(true,queryListAccessory,scope);
		}
		else if(contextPage=='list' && $('#nes_colLeft').hasClass('nes_listMachine')){
			queryFilterMachine(true,queryListMachine,null);
			//queryListMachine(null);
		}
		else if((contextPage=='registration' && $('#nes_colLeft').hasClass('nes_listAccessories')) || (contextPage == 'myAccount' && $('#nes_colLeft').hasClass('nes_listMachine'))){
			queryFilterMachine(false,queryListMachineSelection,null);
			//queryListMachineSelection(null);
		}
		else if(contextPage=='quickorder' && $('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderAccessories')){
			queryFilterQOAccessory(true,queryListQOAccessory,null);
		} 
		else if(contextPage=='quickorder' && $('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderMachines')){
			queryFilterQOMachines(true,queryListQOMachines,null);
			//queryListQOMachines(null);
		} 
		else if(contextPage=='quickorder' && !$('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderMachines') && !$('#nes_colMid .nes_colMid-small').hasClass('nes_quickOrderAccessories')){
			queryFilterQOCapsules(true,queryListQOCapsules,null);
			//queryListQOCapsules(null);
		}else if(contextPage == 'quickorder-2') {
			promotionLoader.getPromotions();
		}
		function clickRadioTypeAddress_checkoutPayment(obj)
		{
			var typeParam = obj.attr('value');
			var contextParam = obj.parents('fieldset');
			if(contextParam.length==0)
				contextParam = obj.parents('ul.nes_address-info.nes_address-info-form');
			var countryParam = $('.customerForm_country select', contextParam).val();
			queryRegistration(typeParam, countryParam, contextParam);
		}
		// registration
		if($("#registration").length && contextPage=='formRegistration'){
			$('#registration > .nes_registrationContent > fieldset').each(function() {
				
				var contextParam = $(this);
				var typeParam = $('ul:not(.nes_bill-add-form) > li:eq(0) input:checked', contextParam).attr('value');
				var countryParam = $('.customerForm_country select', contextParam).val();
				if($('ul:not(.nes_bill-add-form) > li input[name$=addressType]', contextParam).length!=0)
					queryRegistration(typeParam, countryParam, contextParam);
			});
			if($('#registration > .nes_registrationContent > fieldset').length==0)
			{
				$('#registration input[name$=addressType]:checked').each(function() {
					clickRadioTypeAddress_checkoutPayment($(this));
				});
			}	
			$('#registration input[name$=addressType]').live('click',function() {
				clickRadioTypeAddress_checkoutPayment($(this));
			});
			//clickRadioTypeAddress_checkoutPayment($('#registration input[name$=addressType]:eq(0)'));
		}
		
		// if ($("#registration").length && contextPage == ""){
			// $.ajax({
				// beforeSend: function(req) {
					// req.setRequestHeader("Accept", "application/json");
				// },
				// url:queryRegistrationInformationUrl + "jp/private",
				// type:"GET",
				// contentType:"application/json",
				// dataType:"json",
				// success:function(data){
					// var	fieldLi;
				
					// $(data).each(function(){
						// var	labelLi = $("<label>"),
							// inputLi = $("<input>").attr({
										// type:"text",
										// maxLength:20,
										// id:
									// }),
							// divLi = $("<div>").addClass("nes_clear");

						// console.log($(this));
					// });
/* 					{"email":{"field":"","order":2,"label":"","width":40,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},"firstName":{"field":"","order":0,"label":"","width":0,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},"lastName":{"field":"","order":1,"label":"","width":20,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},"companyName":{"field":"","order":100,"label":"","width":0,"mandatory":false,"visible":false,"regexp":null,"regexpErrorLabel":null},"contactName":{"field":"","order":100,"label":"","width":0,"mandatory":false,"visible":false,"regexp":null,"regexpErrorLabel":null},"success":true,"confirmationEmail":{"field":"","order":100,"label":"","width":0,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},"informationJsonListField":[{"field":"","order":0,"label":"","width":0,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},{"field":"","order":1,"label":"","width":20,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},{"field":"","order":2,"label":"","width":40,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null},{"field":"","order":100,"label":"","width":0,"mandatory":false,"visible":false,"regexp":null,"regexpErrorLabel":null},{"field":"","order":100,"label":"","width":0,"mandatory":false,"visible":false,"regexp":null,"regexpErrorLabel":null},{"field":"","order":100,"label":"","width":0,"mandatory":true,"visible":true,"regexp":null,"regexpErrorLabel":null}]}
 */			//	}
			// });
		// }
		
		// liens d'accessibilité 
		if ($('ul.liensAccessibilite').size() > 0) {
			$('ul.liensAccessibilite a').addClass ('accessibleHiddenLink').css('display', 'inline');
			$('ul.liensAccessibilite a').focus(function() {
				if ($(this).hasClass('accessibleHiddenLink')) {
					$(this).removeClass('accessibleHiddenLink');
				}
			});
		}
		// language
		$('div.nes_block_language').css({'position':'absolute', 'left':'-999999px', 'display':'block'});
		/* si il n'y a pas de cookie, affichage de la popin de langue */
		welcomeMsg = typeof welcomeMsg != 'undefined' ? welcomeMsg : false; 
		//if($.cookie('nes_popin_language') != 'ok') {
		if(welcomeMsg) {
			if(wMsg != null){
				if(wMsg == true){
					$('div.nes_msgAccueil').show();
					$('#cachePopinLanguage').css(
						{
							'display':'block',
							'z-index':'8',
							'opacity':'0.0'
						}).animate(
						{
							'opacity':'0.3' 
						}, 
						500);
				}
			} else {
				$('div.nes_msgAccueil').show();
				$('#cachePopinLanguage').css(
					{
						'display':'block',
						'z-index':'8',
						'opacity':'0.0'
					}).animate(
					{
						'opacity':'0.3' 
					}, 
					500);
			}
		}
		
		abbrCountry = typeof abbrCountry != 'undefined' ? abbrCountry : '';
		//if($.cookie('nes_popin_language') != 'ok') {
		if(welcomeMsg) {
			var hidPopinLang = setTimeout("hidePopinLang()", 5000);
		}
		
		/* Quantity selector */
		if(contextPage=='quickorder'){
			$('span.nes_select-quantity').each(function() {
				affQuantity($(this), '10');
			});
		} else if(contextPage=='shopping_bag') {
			$('span.nes_select-quantity').each(function() {
				affQuantity($(this), 'var');
			});
		} else if(contextPage=='pdp') {
			if(multipleSize != null && multipleSize != "" && !isNaN(parseInt(multipleSize))) {
				$('span.nes_select-quantity').each(function(){
					affQuantity($(this), multipleSize);
				});
			} else if(contextPage!='quickorder-2') {
				$('span.nes_select-quantity').each(function(){
					affQuantity($(this), '10');
				});
			}
			//Fond pdp
			if(bgProduct != "") {
				$('div.nes_bg-opacite').css({"background" : "url("+bgProduct+") no-repeat 50% 0"});
			}
		} else if(contextPage=='registrationConf') {
			//Fond promotions
			if(bgPromotion != "") {
				$('body.nes_body-offer').css({"background" : "url("+bgPromotion+") no-repeat 50% 0"});
			}
		}
		/* country dispatch */
		$('div.contentListCountry').each(function(){
			var $$ = $(this);
			var collElmts = $('div.innerListCountry', $$);
			var sizeElmts = Math.floor($$.width() / collElmts.length);
			collElmts.each(function() {
				$(this).css({'float':'left','width':sizeElmts});
			});
			$('div.innerListCountry:last', $$).css({'float':'right'});
		});
		
		/* link back des pages content */
		$('li.nes_back-link > a.nes_contentBack').click(function() {
			window.history.back();
			return false;
		});
	/*** FIN INIT ***/
	
	/*** LISTENERS ***/
		// Print
		$('.nes_print-link').click(function() {
			window.print();
		});
		
		$('input.nes_infomsg').focus(function(){
			$(this).siblings('.nes_msg-information').css({display:'block'});
		});
		$('input.nes_infomsg').blur(function(){
			$(this).siblings('.nes_msg-information').css({display:'none'});
		});
		
		$('body').live('click', function(event) {
			if (!$(event.target).closest('ul.nes_language-selection').length) {
				$('#cachePopinLanguage').animate(
					{'opacity':'0.0'},
					500,
					'swing',
					function ()
					{
						$(this).css({'display':'none'});
					}
				);
				$('div.nes_block_language').css({position:'absolute', left:'-999999px'});
				$('div.nes_msgAccueil').hide();
				$('ul.nes_language-selection > li > a').removeClass('nes_selected-link-on');
				if(welcomeMsg) {
					clearTimeout(hidPopinLang);
					$.cookie('nes_popin_language', 'ok', { expires: 365, path:'/'+abbrCountry});
				}
			};
			
			if (!$(event.target).closest('span.nes_select-quantity').length) {
				if(quantityActive == true){
					$('span.nes_select-quantity_on > input').each(function() {
						$(this).next('div.containerQuantity').children('div.containerInnerQuantity').remove();
						$(this).parent().removeClass('nes_select-quantity_on');
						$(this).parents('.nes_list-filter').css({'position':'', 'z-index':''}).siblings().css({'position':'', 'z-index':''});
					});
					quantityActive=false;
				}
			};
			
			if (!$(event.target).closest('div.nes_link-details').length) {
				$('div.nes_link-details', $('#nes_content')).removeClass('nes_link-details-opened');
			};
		});
	
		// language
		$('ul.nes_language-selection > li > a').each(function(){
			$(this).hover(function() {
				//$('div.nes_msgAccueil').show();
			}, function() {
				//$('div.nes_msgAccueil').hide();
			}).click(function(){
				$('div.nes_msgAccueil').hide();
				if( $(this).hasClass('nes_selected-link-on') ) {
					$(this).removeClass('nes_selected-link-on');
					$(this).siblings('div.nes_block_language').css({position:'absolute', left:'-999999px'});
					$('#cachePopinLanguage').animate(
						{'opacity':'0.0'},
						500,
						'swing',
						function ()
						{
							$(this).css({'display':'none'});
						}
					);
				}else{
					$(this).addClass('nes_selected-link-on');
					$(this).siblings('div.nes_block_language').css({position:'absolute', left:'-121px'});
					$('#cachePopinLanguage').css(
						{
							'display':'block',
							'z-index':'8',
							'opacity':'0.0'
						}).animate(
						{
							'opacity':'0.3' 
						}, 
						500);
				}
			});
		});
	
		// gestion du copy/paste
		$('input.disableCopyPaste').each(function(){
			$(this).next('span.nes_msg-information').hide();
		});
		$('input.disableCopyPaste').bind("contextmenu", function(e) {
			e.preventDefault();
		});
		$('input.disableCopyPaste').bind('copy', function(e) {
			e.preventDefault();
		});
		$('input.disableCopyPaste').bind('paste', function(e) {
			$(this).next('span.nes_msg-information').show();
			e.preventDefault();
		});
		$('input.disableCopyPaste').bind('blur', function(e) {
			$(this).next('span.nes_msg-information').hide();
		});
		
		// Gestion Sign In 
		$('#nes_header-log form.nes_log-form').css({'position':'absolute', 'left':'-999999px', 'display':'block'});
		
		$('.nes_bloc_pass input').each(function() {
			
			$(this).keyup(function(event) {
				if (event.which==9)
				{
					return false;
				}
				if ($(this).attr("value") == "")
					$(this).siblings('div.nes_hidden_pass').show();
				else
					$(this).siblings('div.nes_hidden_pass').hide();

			})
		});
		$('#nes_header-log .nes_log-form .fieldLeft #j_username').each(function() {
			$(this).keyup(function(event) {
				if ($(this).attr("value") == ""){
					$('#nes_header-log .nes_hidden_pass').show();
					$('#nes_header-log .nes_log-form .nes_bloc_pass input').attr('value','');
				}
				else
					$('#nes_header-log .nes_hidden_pass').hide();
			})
		});
		$('.nes_registrationForm .nes_registrationContent #j_username').each(function() {
			
			$(this).keyup(function(event) {
				if ($(this).attr("value") == ""){
					$('.nes_registrationForm .nes_registrationContent .nes_bloc_pass input').attr('value','');
					$('.nes_registrationForm .nes_registrationContent .nes_hidden_pass').show();
				}

				else
					$('.nes_registrationForm .nes_registrationContent .nes_hidden_pass').hide();

			})
		});
		$('.nes_bloc_pass input').focus(function(){
			$(this).siblings('div.nes_hidden_pass').hide();
		});
		$('.nes_bloc_pass input').blur(function(){
			if ($(this).attr("value") == "")
				$(this).siblings('div.nes_hidden_pass').show();
		});
		$('a.signIn').click(function() {
			if($('#nes_header-log form.nes_log-form').css('position')=='absolute'){
				$('#nes_header-log form.nes_log-form').css({position :'relative', left:'0'});
				$('#nes_header-log ul.nes_register-sign').addClass('nes_register-sign-chrome');
			}else {
				$('#nes_header-log form.nes_log-form').css({position:'absolute', left:'-999999px'});
				$('#nes_header-log ul.nes_register-sign').removeClass('nes_register-sign-chrome');
			}
		});
		
		$('a.signIn, ul.nes_register-sign > li:last > a').focus(function() {
			$('#nes_header-log form.nes_log-form').css({position:'absolute', left:'-999999px'});
			$('#nes_header-log ul.nes_register-sign').removeClass('nes_register-sign-chrome');
		});
		$('#nes_header-log form.nes_log-form a, #nes_header-log form.nes_log-form input').focus(function() {
			$('#nes_header-log form.nes_log-form').css({position :'relative', left:'0'});
			$('#nes_header-log ul.nes_register-sign').addClass('nes_register-sign-chrome');
		});
		$('#nes_header-log form.nes_log-form div.nes_log-form-submit input[type=submit], #nes_colLeft form.nes_registrationForm li.nes_signIn input[type=submit]').unbind().bind('click', function(e) {
			e.stopPropagation();
			e.preventDefault();
			var $this = $(this);
			var $loader = $('<img src="'+f_get_txt('imagePath')+'loader.gif" alt="" />');
			if($this.parents('#nes_header-log')){
				$loader.css({'position':'absolute','top':0,'left':'-50px'}).appendTo($this.parent());
			}else if($this.parents('#nes_colLeft')){
				$this.after($loader);
			}
			$this.attr('disabled','disabled').unbind('click').parents('form').submit();
			//return false;
		}).parents('form').unbind('submit');
		// Fin Gestion Sign In 
		
		// Définition de l'évènément "click" sur la pagination des listes accessoires
		$("#nes_colLeft.nes_listAccessories div.nes_linksNav > div > ul > li > a").live('click', function() { 	
			var $$ = $(this);
			if (!$$.parent('li').hasClass('nes_enCours')){
				var newPagi = parseInt($$.text());
				ListAccessory.abort();
				queryListAccessory(toQuery,newPagi);
				return false;
			}
			return false;
		});
		$("#nes_colLeft.nes_listAccessories div.nes_linksNav > div > .nes_previous > a").live('click', function()
		{
			var $this = $(this).parents(".nes_linksNav").find("li.nes_enCours");
			if($this.prev().length != 0){
				var $$ = $this.prev().children("a");
				$this.stop().removeClass("nes_enCours").prev().addClass("nes_enCours");
				var newPagi = parseInt($$.text());
				ListAccessory.abort();
				queryListAccessory(toQuery,newPagi);
			}
			return false;
		});
		$("#nes_colLeft.nes_listAccessories div.nes_linksNav > div > .nes_next > a").live('click', function()
		{
			var $this = $(this).parents('.nes_linksNav').find("li.nes_enCours");
			if($this.next().length != 0){
				var $$ = $this.next().children("a");
				$this.stop().removeClass("nes_enCours").next().addClass("nes_enCours");
				var newPagi = parseInt($$.text());
				ListAccessory.abort();
				queryListAccessory(toQuery,newPagi);
			}
			return false;
		});
		
		// Définition de l'évènément "click" sur la pagination des quickorder accessoires
		$("#nes_colMid div.nes_linksNav > div > ul > li > a").live('click', function()
		{ 	
			var $$ = $(this);
			if (!$$.parent('li').hasClass('nes_enCours')){
				var newPagi = parseInt($$.text());
				ListQOAccessory.abort();
				queryListQOAccessory(toQuery,newPagi);
				return false;
			}
			return false;
		});
		$("#nes_colMid div.nes_linksNav > div > .nes_previous > a").live('click', function()
		{
			var $this = $(this).parents(".nes_linksNav").find("li.nes_enCours");
			if($this.prev().length != 0){
				var $$ = $this.prev().children("a");
				$this.stop().removeClass("nes_enCours").prev().addClass("nes_enCours");
				var newPagi = parseInt($$.text());
				ListQOAccessory.abort();
				queryListQOAccessory(toQuery,newPagi);
			}
			return false;
		});
		$("#nes_colMid div.nes_linksNav > div > .nes_next > a").live('click', function()
		{
			var $this = $(this).parents(".nes_linksNav").find("li.nes_enCours");
			if($this.next().length != 0){
				var $$ = $this.next().children("a");
				$this.stop().removeClass("nes_enCours").next().addClass("nes_enCours");
				var newPagi = parseInt($$.text());
				ListQOAccessory.abort();
				queryListQOAccessory(toQuery,newPagi);
			}
			return false;
		});
		
		// layers details
		$('div.nes_link-details', $('#nes_content')).each(function() {
			var $$ = $(this);
			$$.children('a').click(function() {
				if($$.hasClass('nes_link-details-opened')) {
					
					$(this).parents('li').removeClass('li_zindex');
					$('div.nes_link-details', $('#nes_content')).removeClass('nes_link-details-opened');
				}else{
					
					$(this).parents('li').siblings('li').removeClass('li_zindex');
					$('div.nes_link-details', $('#nes_content')).removeClass('nes_link-details-opened');
					$$.addClass('nes_link-details-opened');
				}
				$('.nes_link-details-opened').parents('li').addClass('li_zindex');
				return false;
			});
		});
		
		// popin Chocolat
		$('a.closePopinChocolat', $('#popinChocolat').get(0)).live('click', function() {
			$('#popinChocolat').hide();
			return false;
		});
		
		// Switch
		/*$(".nes_switch_container .nes_switch_content").css('display','none');
		$(".nes_switch_content:eq(0)").css('display','block');
		$(".nes_switch_container .nes_ae_switch_tabs .nes_switch_content-click").click(function()
		{ 
			$(this).parent().parent().siblings().removeClass('nes_active');
			$(this).parent().parent().addClass('nes_active');
			$(this).parent().parent().siblings().find('> h2 > a').each(function(){$(this).attr("title",$(this).find('span').html())});
			$(this).attr("title",$(this).find('span').html()+": "+f_get_txt('currentView'));
			$('.nes_switch_content').css('display','none');
			$(this.hash).css('display','block');
			this.blur();
			fixBugHideShowWebKit($(this.hash).find('.nes_caroussel'));
			return false;
		});*/

		$(".nes_switch_container .nes_switch_content").css('visibility','hidden');
		$(".nes_switch_content:eq(0)").css('visibility','visible');
		$(".nes_switch_container .nes_ae_switch_tabs .nes_switch_content-click").click(function()
		{ 
			$(this).parent().parent().siblings().removeClass('nes_active');
			$(this).parent().parent().addClass('nes_active');
			$(this).parent().parent().siblings().find('> h2 > a').each(function(){$(this).attr("title",$(this).find('span').html())});
			$(this).attr("title",$(this).find('span').html()+": "+f_get_txt('currentView'));
			$('.nes_switch_content').css('visibility','hidden');
			$(this.hash).css('visibility','visible');
			this.blur();
			fixBugHideShowWebKit($(this.hash).find('.nes_caroussel'));
			return false;
		});
	
		$(".nes_switch-view-content").css('visibility','hidden');
		$(".nes_switch-view-content:eq(0)").css('visibility','visible');
		$(".nes_fonction-user-product .nes_list-switch-product li a").click(function(){ 
				$('.nes_fonction-user-product .nes_list-switch-product li a').each(function(){
					$(this).removeClass('nes_num-on');
					// var tempVerifCurrent = $(this).attr('title');
					// if(tempVerifCurrent.indexOf(" - "+f_get_txt('currentView')) != -1){
						// tempVerifCurrent = tempVerifCurrent.split(" - "+f_get_txt('currentView'));
						// $(this).attr('title', tempVerifCurrent[0]);
					// }
				});
				//$(this).addClass('nes_num-on').attr('title', $(this).attr('title')+" - "+f_get_txt('currentView'));
				$(this).addClass('nes_num-on');
		  $(".nes_switch-view-content").css('visibility','hidden');
		  $(this.hash).css('visibility','visible');
		  this.blur();
		  return false;
		});
		
		// Onglets Quick order capsule
		$(".nes_switch_container_quick .nes_switch_content_quick").hide();
		$(".nes_switch_container_quick").each(function() {
		$(this).find('.nes_switch_content_quick:eq(0)').show();
		$("div.nes_bg-home .nes_switch-product-content:eq(0)").show();
		});
		$(".nes_switch_container_quick .nes_switch_tabs_quick > li > a").click(function(){ 
			$(this).parent().siblings().removeClass('nes_quick-active');
			$(".nes_switch_container_quick .nes_switch_tabs_quick > li > a").addClass('nes_quick-fade-border');
			$(this).parent().addClass('nes_quick-active');
			$(this).parent().siblings().find('> a').each(function(){$(this).attr("title","")});
			$(this).attr("title",f_get_txt('currentView'));
			$(this).parents('.nes_switch_tabs_quick').find('li .nes_switch_content_quick').hide();
			$(this.hash).show();
			centerQuickMachine(this.hash);
			this.blur();
			return false;
		});
		
		// Onglets Liste machines
		$(".nes_switchListMachine-script .nes_containerSwitchListMachine .nes_innerSwitchListMachineGlobal").css('visibility','hidden');
		$(".nes_switchListMachine-script .nes_containerSwitchListMachine").each(function() {
			$(this).find('.nes_innerSwitchListMachineGlobal:eq(0)').css('visibility','visible');
			centerListMachine('.nes_innerSwitchListMachineGlobal:eq(0)')
		});
		$(".nes_switchListMachine-script .nes_containerSwitchListMachine .nes_switch_tabs_list-machine > li > a").live('click', function(){ 
			$(this).parent().siblings().removeClass('nes_switch-active');
			$(".nes_switchListMachine-script .nes_containerSwitchListMachine .nes_switch_tabs_list-machine > li > a").addClass('nes_quick-fade-border');
			$(this).parent().addClass('nes_switch-active');
			$(this).parent().siblings().find(' > a').each(function(){
				var oldTitle = $(this).attr("title").split(" - "+f_get_txt('currentView'));
				$(this).attr("title", oldTitle[0]);
			});
			$(this).attr("title",$(this).attr("title")+" - "+f_get_txt('currentView'));
			$(this).parents('.nes_switchListMachine-script .nes_switch_tabs_list-machine').find('li .nes_innerSwitchListMachineGlobal').css('visibility','hidden');
			$(this.hash).css('visibility','visible');
			centerListMachine(this.hash);
			ajustMargeFilter();
			toSizeImgFilter();
			this.blur();
			return false;
		});
	
		// Panorama home
		$("div.nes_bg-home .nes_switch-product-content").hide();
		$("div.nes_bg-home .nes_switch-product-content:eq(0)").show();
		$("div.nes_bg-home .nes_list-switch-product li a").click(function(){ 
			if(!$(this.hash).is(":visible")) {
				$('div.nes_bg-home .nes_list-switch-product li a').each(function() {
					$(this).removeClass('nes_num-on');
					var oldTitle = $(this).attr("title").split(" - "+f_get_txt('currentView'));
					$(this).attr("title", oldTitle[0]);
				});
				$(this).addClass('nes_num-on').attr("title",$(this).attr("title")+" - "+f_get_txt('currentView'));
				carrous_main_do_change($(this),this.hash,false);
			}
			this.blur();
			return false;
		});
		$("div.nes_bg-home > div.nes_switch-product-content > div.nes_block-news-global > div.nes_news-block-gray > div.nes_news-content-gray").each(function() {
			$(this).hover(function() {
				clearInterval (carrous_main_do_Timer);
			}, function() {
				carrous_main_do_Timer = setInterval("carrous_main_do_changeTimer()",12000);
			});
		});
		
		// Liste machine
		$('.nes_machineName a').focus(function() {
			$(this).parents(".nes_listInfosMachine").parent().addClass("nes_on");
		});
		$('.nes_machineViewDetails a, .nes_linkBackTop a, .nes_innerBlocListMachinesBig > a, .nes_innerBlocListMachines > a, .nes_innerBlocListMachinesSmall > a, .nes_innerBlocListMachinesBig .nes_remise a, .nes_innerBlocListMachines .nes_remise a, .nes_innerBlocListMachinesSmall .nes_remise a').focus(function() {
			$(".nes_blocListMachines > div").removeClass("nes_on");
			$(".nes_bgListAccessories > div").removeClass("nes_on");
		});
		// $('.nes_innerBlocListMachines, .nes_innerBlocListMachinesBig, .nes_innerBlocListMachinesSmall').live('mouseover', function() {
			// if(!$(this).hasClass('nes_innerBlocListMachinesCompare'))
			// $(this).addClass('nes_on');
		// }).live('mouseout', function() {
			// if(!$(this).hasClass('nes_innerBlocListMachinesCompare'))
			// $(this).removeClass('nes_on');
		// });
		
		// gestion du focus dans les plp
		$('.nes_innerBlocListMachinesBig > a, .nes_innerBlocListMachines > a, .nes_innerBlocListMachinesSmall > a').focus(function() {
			$(this).keydown(function (e) { 
				if(e.which == 9 && isMaj == true) { 
					$(this).parent().prev().addClass("nes_on");
					isMaj=false;
				}
			});
		});
		$('.nes_innerBlocListMachinesBig > a, .nes_innerBlocListMachines > a, .nes_innerBlocListMachinesSmall > a, .nes_innerBlocListMachinesBig .nes_remise a, .nes_innerBlocListMachines .nes_remise a, .nes_innerBlocListMachinesSmall .nes_remise a').focus(function() {
			$(this).keydown(function (e) { 
				if(e.which == 9 && isMaj == true) { 
					$('#nes_nav > li.nes_menu_focus').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
					$('#nes_nav > li.nes_menu_focus:last').addClass('nes_nav-on').find('div.nes_menu').css({left: '0'});
					isMaj=false;
				}
			});
		});
		
		// Registration	
		$('.nes_radio-click').each(function() {
			var context = $(this);
			var toHide = $('.nes_radio-hide', context);
			var Hide = $('.nes_click-hide', context);
			var Show = $('.nes_click-show', context);
			toHide.hide();
			toHide.find('input').css('background','#a0a0a0');
			if(Show.is(':checked')) {
				toHide.find('input').attr('disabled','');
				toHide.find('input').css('background','white');
			}
			Hide.click(function(){
				//toHide.find('input').val('');
				toHide.find('input').attr('disabled','disabled');
				toHide.find('input').css('background','#a0a0a0');
				//toHide.hide();
			});
			Show.click(function(){
				//toHide.show();
				toHide.find('input').attr('disabled','');
				toHide.find('input').css('background','white');
			});
		});
		
		// Plier/deplier
		$('.nes_hide-support').hide();
		$('.nes_edito-support li h2 a').click(function(){
			var $this = $(this);
			if($this.parents('h2').siblings('.nes_hide-support').hasClass('nes_opened-support')) {
				$this.removeClass('nes_link-support');
				$('.nes_hide-support').removeClass('nes_opened-support').hide();
			}else{
				$('.nes_edito-support li h2 a').removeClass('nes_link-support');
				$('.nes_hide-support').removeClass('nes_opened-support').hide();
				$this.addClass('nes_link-support').parents('h2').siblings('.nes_hide-support').addClass('nes_opened-support').show();
			}
		});
		$('a[rel="external"]').click(function() {
			window.open($(this).attr('href'));
			return false;
		});
		
		// Suppression du li de callback
		var noCall = typeof noCallback != 'undefined' ? noCallback : false;
		if(noCall == true) {
			var elmtR = $('ul.nes_r-list-contact', $('#nes_colRight').get(0));
			var elmt = $('div.nes_blackBloc-content > ul', $('#nes_content').get(0));
			elmtR.children('li.nes_callback').remove();
			elmt.children('li.nes_callback').remove();
			elmt.parent('div.nes_blackBloc-content').addClass('nes_blackBloc-content-closed');
			elmt.css({
				'float':'left',
				backgroundPosition:'1px 0'
			});
			elmt.parent('div.nes_blackBloc-content').width(elmt.parent('div.nes_blackBloc-content').width() - 143 );
		}
	/*** FIN LISTENERS ***/

/**************************************************************  
		MENU  
**************************************************************/
	// Navigation du haut
	var hoverIn;
	var hoverOut;
	var ie7 = ( $.browser.msie && ($.browser.version == "7.0") ) ? true:false;
	$('#nes_nav > li > div.nes_menu-1').addClass('nes_menu').css({left: '-9999px'}).css('display','block');
	$('#nes_nav > li > a').css({display: 'block'});
	$('#nes_nav > li > a').css({'float': 'left'});
	$('#nes_nav > li').hover(function() {
		var $$ = $(this);
		clearTimeout(hoverOut);
		clearTimeout(hoverIn);
		hoverIn = setTimeout ( function() {
				$('div.nes_bg-opacite').addClass('nes_bg-opacite-hover')
									.css({
										//'position': 'relative',
										 'z-index':'8'
									 });
				var contPa = $('#nes_global');
				if(!$('#voileie').length > 0){
					var voilou = $('<div id="voileie"></div>');
					voilou.css({
						'position'   : 'absolute',
						'background' : '#000000',
						'z-index'    : '8',
						'top'        : 0,
						'opacity'    : 0,
						'height'     : contPa.height(),
						'width'      : contPa.width()
					});
					contPa.append(voilou);
				}
				$('#voileie').css({
						'height' : contPa.height(),
						'width'  : contPa.width()
							}).animate({
						'opacity':'0.7' 
							}, 500);
			footerEl.css({opacity:'0.3'});
			$('#nes_nav > li.nes_menu_focus').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
			$$.addClass('nes_nav-on').children('div.nes_menu').css({left: '0'});
		}, 500 );
	}, function() {
		var $$ = $(this);
		clearTimeout(hoverIn);
		hoverOut = setTimeout ( function() {
				$('div.nes_bg-opacite').css({
										 position: 'static'
									 }).removeClass('nes_bg-opacite-hover');
				$('#voileie').animate({
										 'opacity':'0' 
									 }, 500).animate({
						'height': 0,
						'width' : 0
							}, 100);
			footerEl.css({opacity:'1'});
			$('#nes_nav > li').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
		}, 500 );
	});
	
	$('#nes_nav > li a').focus(function() {
		var $$ = $(this).parents('li.nes_menu_focus');
		$('div.nes_bg-opacite').addClass('nes_bg-opacite-hover')
							.css({
								 /* opacity:'0.3',  */
								 position: 'relative'
							 })
							.css('z-index','8');
		var contPa = $('#nes_global');
		if ($.browser.msie)
			$("body").css("overflow", "hidden");
		if(!$('#voileie').length > 0){
			var voilou = $('<div id="voileie"></div>');
			voilou.css({
				'position'   : 'absolute',
				'background' : '#000000',
				'z-index'    : '8',
				'top'        : contPa.offset().top,
				'opacity'    : 0,
				'height'     : $(document).height() - contPa.offset().top,
				'width'      : $(document).width()
			});
			$("body").append(voilou);
		}
		$('#voileie').css({
				'height' : $(document).height() - contPa.offset().top,
				'width'  : $(document).width()
					}).animate({
				'opacity':'0.7' 
					}, 500);
		//footerEl.css({opacity:'0.3'});
		$('#nes_nav > li.nes_menu_focus').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
		$$.addClass('nes_nav-on').find('div.nes_menu').css({left: '0'});
	}).click(function() {
		clearTimeout(hoverIn);
	});
	
	$(/*'ul.nes_language-selection > li > a.nes_selected-link, ul.nes_language-selection > li > div.nes_block_language > p.nes_chooseCountry > a,*/ '#nes_second-nav > li:eq(0) > a')
	.focus(function() {
		$('div.nes_bg-opacite').css({
								 opacity:'1', 
								 position: 'static'
							 })
							.removeClass('nes_bg-opacite-hover');
		footerEl.css({opacity:'1'});
		$('#nes_nav > li.nes_menu_focus').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
	});	

	// Gestion du focus de la nav pour ie 
	if($.browser.msie){
		$('#nes_second-nav > li:eq(0) > a').focus(function() {
			$(this).keydown(function (e) { 
				if(e.which == 9 && isMaj == true) { 
					$('div.nes_bg-opacite').addClass('nes_bg-opacite-hover')
										.css({
											 opacity:'0.3', 
											 position: 'relative'
										 })
										.css('z-index','8');
					footerEl.css({opacity:'0.3'});
					$('#nes_nav > li.nes_menu_focus').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
					$('#nes_nav > li.nes_menu_focus:last').addClass('nes_nav-on').find('div.nes_menu').css({left: '0'});
				}
			});
		});
		$('#nes_nav > li.nes_menu_focus > a').focus(function() {
			$(this).keydown(function (e) { 
				if(e.which == 9 && isMaj == true) { 
					$('div.nes_bg-opacite').addClass('nes_bg-opacite-hover')
										.css({
											 opacity:'0.3', 
											 position: 'relative'
										 })
										.css('z-index','8');
					footerEl.css({opacity:'0.3'});
					$('#nes_nav > li.nes_menu_focus').removeClass('nes_nav-on').children('div.nes_menu').css({left: '-9999px'});
					$(this).parent().prev().addClass('nes_nav-on').find('div.nes_menu').css({left: '0'});
				}
			});
		});
	}	
	/************************************************/
		// Gestion d'ajout dans le panier : Définition de l'évènément "click" sur le bouton "-" pour diminuer la quantité 
		$("#quantityIncrease").click(function()
		{ 	
			this.blur();
			var Quantity=$("#dec-input").val(); // Récupération de la valeur dans l'input
			if(Quantity=="") Quantity=0;
			Quantity=parseInt(Quantity)+1; // Récupération de la valeur dans l'input
			return $("#dec-input").val(Quantity.toString());
		});
		
		// Gestion d'ajout dans le panier : decrease
		$("#quantityDecrease").click(function()
		{ 	
			this.blur();
			var Quantity=$("#dec-input").val(); // Récupération de la valeur dans l'input
			if(Quantity=="") Quantity=0;
			Quantity=parseInt(Quantity)-1; // Récupération de la valeur dans l'input
			if(Quantity<0) Quantity=0;
			return $("#dec-input").val(Quantity.toString());
		});
		
		 if($("#dec-input")) $("#dec-input").keydown(function(event) {
			checkNumeric(event)
		});
	
		// Définition de l'évènément "click" sur "Add To bag"
		$("#add_to_bag").click(function()
		{ 	
			this.blur();
			// Récupération des valeurs des paramètres d'appel
			var ProductCode="C2010"; // Donnée à définir (hidden? ou variable?)
			var CatalogVersionId="Cap";
			var Quantity=$("#dec-input").val(); // Récupération de la valeur dans l'input
			if(Quantity=="" || Quantity==0)
			{
				showMessageAlerte('add_to_bag',"quantite : 0");
			}
			else
			{
				if($("#add_to_bag").attr('class')=="")
				{
					return querySetBag(ProductCode,CatalogVersionId,Quantity);
				}
				else return false;
			}
		});
	
		// Définition de l'évènément "click" sur "Add To compare"
		$("#add_to_compare").click(function()
		{ 	
			this.blur();
			// Récupération des valeurs des paramètres d'appel
			var ProductCode="M2010"; // Donnée à définir (hidden? ou variable?)
			var CatalogVersionId="Cap";
			
			return querySetCompare(ProductCode,CatalogVersionId);
		});
		
		// Gestion du focus sur le delete dans les shoppings bags
		$('.nes_blocShoppingBag ul > li > a').focus(function() {
			if(!$(this).parent('li').hasClass('nes_noHover-alert') && !$(this).parent('li').hasClass('nes_noHover_2')) {
				$(this).parent('li').addClass('nes_on');
			}
		});
		$('.nes_blocShoppingBag ul > li > a').blur(function() {
			if($(this).parent('li').hasClass('nes_on')) {
				$(this).parent('li').removeClass('nes_on');
			}
		});
		
	//Gestion erreur des formulaires
	$('.nes_error').each(function() {
		var $$ = $(this);
		$("input", $$).each(function(){
			$(this).keydown(function () { 
				if($(this).siblings("span.nes_png").length != 0) {
/* 					$(this).siblings("span.nes_png").animate({opacity:0, marginTop:0, paddingTop:0, height:0}, "fast", function() {
						$(this).remove();
						if($$.find("span.nes_png").length == 0)
							$$.removeClass("nes_error");
					});
 */					$(this).siblings("span.nes_png").remove();
						if($$.find("span.nes_png").length == 0)
							$$.removeClass("nes_error");
				} if($$.parents('ul.loginError').length != 0){
					var dadEl = $$.parents('ul.loginError');
					$$.removeClass("nes_error");
					if(dadEl.find(".nes_error").length == 1)
/* 						dadEl.find("span.nes_png").animate({opacity:0, marginTop:0, paddingTop:0, height:0}, "fast", function() {
							$(this).remove();
							$(this).parents(".nes_error").removeClass("nes_error");
							if($$.find("span.nes_png").length == 0)
								$$.removeClass("nes_error");
						});
 */						dadEl.find("span.nes_png").remove();
							$(this).parents(".nes_error").removeClass("nes_error");
							if($$.find("span.nes_png").length == 0)
								$$.removeClass("nes_error");
				} else {
					$$.removeClass("nes_error");
				}
			});
		});
	});
	//Gestion erreur des formulaires
	$('.nes_error').each(function() {
		var $$ = $(this);
		$("input", $$).each(function(){
			$(this).keydown(function () { 
				if($(this).parents('div').siblings("span.nes_png").length != 0) {
/* 					
 */					$(this).parents('div').siblings("span.nes_png").remove();
						if($$.find("span.nes_png").length == 0)
							$$.removeClass("nes_error");
				} if($$.parents('ul.loginError').length != 0){
					var dadEl = $$.parents('ul.loginError');
					$$.removeClass("nes_error");
					if(dadEl.find(".nes_error").length == 1)
/* 						
 */						dadEl.find("span.nes_png").remove();
							$(this).parents(".nes_error").removeClass("nes_error");
							if($$.find("span.nes_png").length == 0)
								$$.removeClass("nes_error");
				} else {
					$$.removeClass("nes_error");
				}
			});
		});
	});
	$('.nes_card-champs').each(function() {
		var $$ = $(this);
		$("input", $$).each(function(){
			$(this).keydown(function () { 
				$(this).siblings("span.error_field").animate({opacity:0, marginTop:0, paddingTop:0, height:0}, "fast", function() {
					$(this).remove();
				});
			});
		});
	});
	
	/****************************************/
	//si on est sur la home
	if($("div.nes_bg-home .nes_list-switch-product li a").length)
	{
		carrous_main_do_Timer = setInterval("carrous_main_do_changeTimer()",12000);
		//carrous_main_do_charge();
	}
	/***********************************************/
	//si on est sur la page registration_machine_pos
	if(contextPage=="registrationMP")
	{
		var ctxt=$('input[name=machineRegistration.storeType]')
		ctxt.click(function ()
		{
			if($(this)[0].id=='inStore')
			{
				$('#nes_registration_machine_pos_store').show();
				//loadSelectStors__regMachPos($('#Country').val());
			}else
			{
				$('#nes_registration_machine_pos_store').hide();
			}
		});
		ctxt.each(function ()
		{
			if($(this).attr('checked')==true)
			{
				$(this).trigger('click');
				
			}
		});
	}
	if(contextPage=="quickorder" || contextPage=="quickorder-2")
	{
		$('.nes_shop-bulle-top-showed').hide();
		$('.nes_goqo-clicked').click(function(){
			if($('.nes_shop-bulle-top-showed > div > div').html()!='none')
			{
				$(this).parents('.nes_yel-shop-link').siblings('.nes_shop-bulle-top-showed').show();
				$(this).parents('.nes_innerBlocShoppingBag').find('.nes_shop-bulle-top-showed').show();
			}else
			{
				if(QO_btnProceed_url!=null)
					window.location=QO_btnProceed_url;
			}
		});
	}
	
	$('input[type=submit].nes_submitOnceBtn').unbind().bind('click', function(e) {
		e.stopPropagation();
		e.preventDefault();
		var $this = $(this);
		$this.attr('disabled','disabled').unbind('click').parents('form').submit();
	}).parents('form').unbind('submit');
	
	$('input[type=submit].nes_submitOnceBtnChckOt').unbind().bind('click', function(e) {
		e.stopPropagation();
		e.preventDefault();
		var $this = $(this);
		$this.parents('form').find("#_eventId").attr('name', '_eventId');
		
		if ($this.attr("name").search(/_eventId/) > -1){
		   eventId = $this.attr("name").match(/_eventId_(\w*)/)[1];
		} else {
		   eventId = $this.attr("name");
		}
		$("#_eventId").val(eventId);
		
		$this.attr('disabled','disabled').unbind('click').parents('form').submit();
	}).parents('form').unbind('submit');
	
	/* $('.nes_submitOnceBtn').unbind().bind('click', function(e) {
			e.stopPropagation();
			e.preventDefault();
			var $this = $(this);
			$this.unbind();
			$this.bind('click', function(e) {return false;});
			$this.parents('form').submit();
			return false;
	}); */
	
	$('.nes_calque-load').hide();
	
	$('#nes_energy-information').hover(
	function (e)
	{
		$('#nes_energy-information_img').css('display','block');
		$('#nes_energy-information_img').css('position','fixed');
		$('#nes_energy-information_img').css('top',e.originalEvent.clientY+'px');
		$('#nes_energy-information_img').css('left',e.originalEvent.clientX+'px');
		$('#nes_energy-information_img').css('z-index','100');
	},
	function ()
	{
		$('#nes_energy-information_img').css('display','none');
	}
	)
	
	//desactivation du click sur les liens ayants la classe nes_noFollow
	$('a.nes_noFollow').live('click', function(){return false;});
	
	//Hover on "Learn More" button (on delivery pages)	
	var fctCardElt;
	if ($.browser.msie && $.browser.version == "6.0"){
		fctCardElt = $(".nes_method-shipping-bottom .nes_fct-card li a, .nes_method-shipping-bottom li.nes_list-check-method-selected .nes_fct-card li a").not('[class]');
	} else {
		fctCardElt = $(".nes_fct-card li a, .nes_method-shipping-bottom .nes_fct-card li a").not('[class]');
	}
	
	fctCardElt.hover(function(){
		$(this).addClass("nes_fct-card_hover");
	},function(){
		$(this).removeClass("nes_fct-card_hover");	
	});	

	//Mantis 9970
	//2 submits in one form
	if (contextPage == "registrationMP"){
		$("body").keypress(function(e){
			if (e && e.keyCode == 13){
				e.preventDefault();
				var focusElt = document.activeElement.id;
				
				if (!(focusElt == "Store_name_input" || focusElt == "machineRegistration.cityFilter")){
					$("#continue").click();
				} else
					$("#search").click();
			}
		})
		
		//Mantis 9453
		//Sort Button with POST form
		$("#header_name .nes_tri-table img, #header_city .nes_tri-table img, #header_zip .nes_tri-table img").click(function(){
			$input = $(this).parent().parent().siblings("input");
			
			if ($(this).attr("src").search(/top\.gif/) > -1)
				$input.val("aes");
			else
				$input.val("des");

			$("#search").click();
		})
	}
	
	//Mantis 10044
	if (contextPage == "formRegistration"){
		$("body").keypress(function(e){
			if (e && e.keyCode == 13){
				
				// Mantis 10966 
				var focusElt = document.activeElement.id;
				if( focusElt != 'text-gift' && focusElt != 'delivery-man')
					e.preventDefault();
				
				if (focusElt.length > 0){
					$("input[name='_eventId_editAddress']:visible").click();
					$("input[name='_eventId_saveAddress']:visible").click();
				} else
					$("#continue").click();
			}
		})

		//Mantis 10113
		$("input[type='submit']").click(function(e){
			var	$input = $(this),
				eventId;
			
			if ($input.attr("name").search(/_eventId/) > -1){
				eventId = $input.attr("name").match(/_eventId_(\w*)/)[1];
			} else {
				eventId = $input.attr("name");
			}
		
			$("#_eventId").val(eventId);
		})		
	}
	// Mantis 10936 
	// maxlength for textarea gift message
	var stock_maxlength=0;
	var maxlengthMessageGift;
	$("#text-gift")
		.bind("keyup", function(e){
			if(stock_maxlength==0){
				maxlengthMessageGift = $(this).attr('maxlength');
				stock_maxlength++;
			}
			//Les retours à la ligne compte pour 2 caractères ppour IE9 et MOZILLA comme pour les autre IE
			if(navigator.appName == "Netscape" || (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion == "5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")){
				espace_txtgift = this.value.split(new RegExp(/\n/)).length-1;
			} else espace_txtgift=0;
			
			$(this).attr('maxlength', maxlengthMessageGift-espace_txtgift);
			
			if (this.value.length > maxlengthMessageGift-espace_txtgift){
				this.value = this.value.slice(0, maxlengthMessageGift-espace_txtgift)
			}
		})
		
		
	// Mantis 4216 
	$('.nes-verify-gift-card').click(function(){
		verifyGiftCardAction();
		return false;
	});
		

});
window.onload=function(){
	if ($('.nes_home-resolution').length)
	{
		$('body').css('overflow-x','hidden');
	}
	
	setFooterPosition();
	setQOBlockHeight();
	$(window)
		.scroll(setFooterPosition)
		.resize(function(){setFooterPosition();setQOBlockHeight();})
};
