 /*
 *	@titre: inscriptionEtape1
 *	@description: javascript inscription FUAJ
 *	@auteur: neov - http://www.neov.net.
 *	@creation: 20100127.
 *	@modification: 
 *	@required: jQuery
 *
 */
var dc = function(el) { return document.createElement(el); }

var jours = '<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option><option value=""></option>';

var mois = '<option value="1">janvier</option><option value="2">f&eacute;vrier</option><option value="3">mars</option><option value="4">avril</option><option value="5">mai</option><option value="6">juin</option><option value="7">juillet</option><option value="8">ao&ucirc;t</option><option value="9">septembre</option><option value="10">octobre</option><option value="11">novembre</option><option value="12">d&eacute;cembre</option><option value=""></option>';

var annee = (new Date).getFullYear();

//var o = $("#divToPrint");

// QAS
var fadeTime = 300;
var lastOpen = null;
var iType = 0;
var iRang = 0;
//Determination des noms des champs
var id_Div = '';
var txt_adresse = '';
var txt_code =  '';
var txt_ville = '';
var adresse = new Array();
var regExpBeginning = /^\s+/;
var regExpEnd = /\s+$/;

$(
	function()
	{
			
		  $('#formInscriptionStepOne').submit( 
			function () {
					 var total = 0;
					 var nbTypesAdhesions = 0;
					 nbTypesAdhesions = $('ul#listeTypeAdhesionEtape1 li').length;
					 //alert(nbTypesAdhesions);	
					 
					 for(var i=0; i<nbTypesAdhesions; i++)
					 {
					 		var selector =  'ul#listeTypeAdhesionEtape1 li select:eq('+i+')';
					 		total += parseInt($(selector).val());
					 } 
					 //alert($('ul#listeTypeAdhesionEtape1 li select:eq(3)').val());
					 
					 if (total == 0)
					 {
					 		alert ("Veuillez sélectionner au moins une adhésion.");
					 		return false;
					 }
					 
					 if (total > 9)
					 {
					 		alert ("Vous ne pouvez pas commander plus de 9 cartes dans une même commande.");
					 		return false;
					 }
					 
				}
			);
			

		
		//$('#formInscriptionStepTwo .lesEnfants select:not(.jour .mois .annee)').change( 
		$('#formInscriptionStepTwo .lesEnfants select[@id^=select_enfant]').change( 
			function (event){
				var theYear = setYearInterval(0, 16);
				var $this = $(this);
				var a = $(this).val();
				var clss = $(this).attr('class'); 
				var nbDivExistant = $($(this).parent().parent().find('div')).length;
				var bReconstruire = false;
				if (a < nbDivExistant) {
					bReconstruire = true;
					nbDivExistant = 0;
					$(this).parent().parent().find('div').remove();
				}
				
				for(i=nbDivExistant; i<a; i++) {
					var div = $(dc('div')).append(
						$(dc('p'))
							.addClass('clearfix')
							.append(
								$(dc('label'))
									.attr({'for': 'txt_nom3_'+clss+'_'+i})
									.text('*Nom :'),
								$(dc('input'))
									.attr({type: 'text', name:'txt_nom3_'+clss+'_'+i, id:'txt_nom3_'+clss+'_'+i})
									.addClass('fValidate[\'required\',\'alphaCrmfuaj\']')
							),
						$(dc('p'))
							.addClass('clearfix')
							.append(
								$(dc('label'))
									.attr({'for': 'txt_prenom3_'+clss+'_'+ i})
									.text('*Prénom :'),
								$(dc('input'))
									.attr({type: 'text', name:'txt_prenom3_'+clss+'_'+i, id:'txt_prenom3_'+clss+'_'+i})
									.addClass('fValidate[\'required\',\'alphaCrmfuaj\']')
							),
						$(dc('p'))
							.addClass('clearfix date')
							.append(
								$(dc('label'))
									.attr({'for': 'select_jour3_'+clss+'_'+ i})
									.text('*Date de naissance :'),
								$(dc('select'))
									.attr({name:'select_jour3_'+clss+'_'+i, id:'select_jour3_'+clss+'_'+i})
									.css("width", "46px")
									.addClass('fValidate[\'required\']')
									.append(jours),
								$(dc('select'))
									.attr({name:'select_mois3_'+clss+'_'+i, id:'select_mois3_'+clss+'_'+i})
									.css("width", "85px")
									.addClass('fValidate[\'required\']')
									.append(mois),
								$(dc('select'))
									.attr({name:'select_annee3_'+clss+'_'+i, id:'select_annee3_'+clss+'_'+i})
									.addClass('fValidate[\'required\']')
									.css("width", "63px")
									.append(theYear)
							),
						$(dc('br'))	
					);
					
					if (!bReconstruire) {
						$(div).insertAfter($($(this).parent().parent().find('div:last')));
					} else {
						$(this).parent().parent().append(div);
					}

				}
			}
			
		) ;
		
		$('#printConfirmation').click(
			function(){
				//boom();
				window.print();
				return false;
				}	
			);
		
			
		$('.bloc_adresse input').change(function(){
			
			var adresseComplet = false;
			var tData = $(this).attr('id').split("_");
			if(tData.length == 2) {
				//nous sommes dans l'étape 3
				iType = 0;
				iRang = 0;
			}else{
				//Etape 2
				iType = tData[tData.length - 2 ]
				iRang = tData[tData.length - 1 ];
			}	
			
			//Determination des noms des champs
			id_Div = (iType == 0 ) ? '#bloc_adresse': '#bloc_adresse_'+iType+'_'+iRang;
			txt_adresse = (iType == 0) ? '#txt_adresse': '#txt_adresse_'+iType+'_'+iRang ;
			txt_code =  (iType == 0) ? '#txt_code' : '#txt_code_'+iType+'_'+iRang ;
			txt_ville = (iType == 0) ? '#txt_ville' : '#txt_ville_'+iType+'_'+iRang ;
			
			$(id_Div +' input').each(function(i){
				if($(this).val()==""){
					adresseComplet = false;
					return false;
				}else{
					adresseComplet = true;
				}
			});
			
			if(adresseComplet){
				// Affichage Layer		
				/*afficherMasque();
				ajaxStartLayerAttente(iType,iRang);*/
			}
	});
	
	$('.demande_adhesion').find('#lien_mdp').click(
		function()
		{
			$('.demande_mdp').show();
			$('.demande_adhesion').hide();
	});
	
	$('.demande_mdp').find('#lien_adhesion').click(
			function()
			{
				$('.demande_mdp').hide();
				$('.demande_adhesion').show();
			}
	);
	
/*	$('.errorDivClose').click(function(){
		closeLayerAttente(iType,iRang);
	});	
*/

});


	/*
	*   Charge la liste de stypes d'adhésion
	**/	
function loadTypeAdhesion()
{
	var cheminEffacerMail = 'http://www.fuaj.org/crmfuaj/srcs/www/admin.php?module=adhesion&action=adhesionFo:listerTypeAdhesion';
			$.ajax(
				{
					type: 'GET',
					url: cheminEffacerMail,
					//data: { adresseMail : theMail, iAction : modeAjoutFavori},
					dataType: 'json',
					success: function(response)
					{
						//alert (response.tContents);
						responseBuilderStepOne(response.tContents) ;
						//$rep->data = array('iNb'=>$t_allTypeAdhesion['iNbEnreg'], 'tContents'=>$t_allTypeAdhesion['toListeTypeAdhesion']) ;		
					}
				}
		); 
}

	/*
	*   Résultat à  afficher dans la table des liste des adhésions
	**/	
function responseBuilderStepOne (tTypeAdhesion)
	{
			var z_contentListStepOneFirstPart = '<li class="clearfix"><label for="select_quantite"><a href="#" title="';
			var z_contentListStepOneSecondAPart = '">';
			var z_contentListStepOneSecondBPart = '<img src="squelettes/img/inscription/design/picto_info.gif" alt="Info" /></a></label><select name="select_quantite';
			var z_contentListStepOneThirdPart = '" id="select_quantite'; 
			var z_contentListStepOneForthPart =  '" <option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option></select>';
			var z_contentListStepOneFithPart = '<input type="hidden" name="typeAdhesion';
			var z_contentListStepOneSixthPart = '" id="typeAdhesion';
			var z_contentListStepOneSeventhPart = '" value="';
			var z_contentListStepOneEigthPart = '">';
			var z_contentListStepOneNinthPart = '</li>';
			 
			
			//alert (tTypeAdhesion[2].fuaj_typeAdhesion_libelle);
			var z_finalContent = '';
			for (var i = 0; i<tTypeAdhesion.length; i++ )
			{  var z_temp = '';
				 z_temp = 	
				 z_contentListStepOneFirstPart +  
				 tTypeAdhesion[i].fuaj_typeAdhesion_libelle +
				 z_contentListStepOneSecondAPart +
				 tTypeAdhesion[i].fuaj_typeAdhesion_libelle +				 
				 z_contentListStepOneSecondBPart + i +
				 z_contentListStepOneThirdPart +  i +
				 z_contentListStepOneForthPart +
				 z_contentListStepOneFithPart + i +
				 z_contentListStepOneSixthPart + i +
				 z_contentListStepOneSeventhPart +
				 tTypeAdhesion[i].fuaj_typeAdhesion_groupe +
				 z_contentListStepOneEigthPart +
				 z_contentListStepOneNinthPart ;
				 
				 z_finalContent +=  z_temp;
				 
			}
			//alert (z_finalContent);
			$('#listeTypeAdhesionEtape1').html(z_finalContent);  
			
	} 


/*
*     Gestion de la validation du premier étape de l'inscription 
**/
function submitHandlerStepOne()
{
	 alert ("clicked");
	 return false;
}


function setYearInterval(yearBegin, yearEnd)
{  
		var theYear='';
		for(i=(annee-yearBegin);i>=(annee-yearEnd);i--)
		{
			theYear += '<option value="'+i+'">'+i+'</option>';	
		}
		//alert (theYear);
		theYear += '<option value=""></option>';
		return theYear; 
}
		
function printSelection(node){

  var content = node.innerHTML
  var pwin=window.open('','print_content','width=100,height=100');

  pwin.document.open();
  pwin.document.write('<html><head><link href="#CHEMIN{css/inscriptionPrint.css}" rel="stylesheet" type="text/css" media="print"/></head><body onload="window.print()">'+content+'</body></html>');
  pwin.document.close();
 
  setTimeout(function(){pwin.close();},1000);

}

function boom()
{
		//alert (document.css());
		
		//alert ($("#bloc_confirmation").html());
		//$("#bloc_confirmation").print();
		$content = $("#bloc_confirmation").html();
  	var pwin=window.open('','print_content','width=100,height=100');
		pwin.document.open();	
		pwin.document.write('<html><head><style>' +styleSheet+'</style><body onload="window.print()"><div class="bloc_confirmation">'+$content+'</div></div></body></html>');
		pwin.document.close();
		setTimeout(function(){pwin.close();},500);	      
		  
}

var styleSheet = 
' .clearfix{display:block;} h2.numero_commande { margin-bottom:17px; margin-left:8px; margin:0; padding-top:30px; font-family:Verdana,Arial,Helvetica,sans-serif; font-size:1.2em; }  div.bloc_carte{ margin:0; padding:0; padding-top:25px; } h3.clearfix { margin:0; padding:0; padding-bottom:35px; background:transparent url(squelettes/img/pointille-gris.gif) repeat-x scroll left bottom; display:block; } h3.clearfix img.left { border:0 none; float:left; padding-left:3px; height:29px; width:94px; } h3.clearfix img.right { border:0 none; float:right; padding-left:6px; height:29px; width:88px; } div.bloc_carte ul { font-family:Verdana,Arial,Helvetica,sans-serif; font-size:62.5%; } div.bloc_carte ul li { text-align:left; padding:20px 0 20px; margin:0; list-style-type:none; list-style-position:outside; list-style-image:none; background:transparent url(squelettes/img/pointille-gris.gif) repeat-x scroll left bottom; display:block; } ul li label { margin:0; padding:0; float:left; width:265px; } ul li label a { margin:0; padding:0; padding-left:25px; font-weight:normal; display:block; background:transparent url(squelettes/img/puce-plus.gif) no-repeat scroll 8px 5px; color:#CA4800; text-decoration:none; } ul li span { float:right; font-size:1.2em; padding-right:25px; } ul li.sous_total p span.left { padding-right:25px; font-size:1.2em; float:left; padding:0; text-align:right; width:85%; font-weight:bold; } ul li.sous_total p span.right { margin:0; padding-left:6px; padding-right:25px; font-size:1.2em; width:40px; text-align:left; padding:0 0 0 40px; float:left; display:block; font-weight:bold; } div.detail_confirmation { font-family:Verdana,Arial,Helvetica,sans-serif; text-align:left; margin:0; padding:0; padding-bottom:55px; padding-top:28px; } div.detail_confirmation div { float:left; padding-bottom:23px; padding-left:23px; } .detail_confirmation h4 { background:transparent url(squelettes/img/inscription/design/picto_noir.gif) no-repeat scroll 0 2px; font-size:1em; margin:0; padding-left:10px; } .detail_confirmation p { text-align:left; padding:0; margin-bottom:1em; clear:both; font-size:1.1em; margin:0; padding-bottom:18px; } .detail_confirmation p.adresse { margin-bottom:1em; clear:both; padding-left: 9px; padding-bottom: 0; margin: 0; font-size: 1.1em; } p.print { visibility:hidden; display:none; }';

/**
* Teste si le mail dans la zone de 
* confirmation est même(étape 2)
*/
function sameMail(_zValue,_zid){
	var tData = _zid.split("_");
	var iType = tData[tData.length - 2 ]
	var iRang = tData[tData.length - 1 ];
	var zMailOriginal = $("#txt_mail_"+iType+"_"+iRang).val();

	if(zMailOriginal!=_zValue){
		$("#txt_confirm_"+iType+"_"+iRang).removeClass("");
		$("#txt_confirm_"+iType+"_"+iRang).addClass("fValidate[\'required\',\'email\',\'emailCrmfuaj\']");
	}else{
		$("#txt_confirm_"+iType+"_"+iRang).removeClass("");
		$("#txt_confirm_"+iType+"_"+iRang).addClass("fValidate[\'required\',\'email\']");
	}
}

function rechargerAdresse(iType,iRang){
		var moniker= $('#addresse_proposition_'+iType+'_'+iRang+' :selected').val();
		
		ajaxRechargerAdresseStartLayerAttente(iType,iRang);
		
		$.ajax({
					type : "POST",
					url  : j_basepath + "admin.php",
					data : "module=personne&action=verificationAdresse:verifierFormat&moniker="+moniker,
					dataType : "json",
					async : false,
					success : function(data){
						if(data.adresse.length == 6){
							$('#adresse_msg_'+iType+'_'+iRang).remove();
							$('#addresse_proposition_'+iType+'_'+iRang).remove();
							var adresse1 = data.adresse.slice(0,5).join(" ");
							adresse1 = adresse1.replace(regExpBeginning, "").replace(regExpEnd, "");
							$(txt_adresse).val(adresse1);
							var reg = new RegExp("[0-9]{5}","g");
							$(txt_code).val(reg.exec(data.adresse[data.adresse.length - 1]));
							$(txt_ville).val(data.adresse[data.adresse.length - 1].replace(reg,""));
							
						}
						ajaxRechargerAdresseSuccessLayerAttente(iType,iRang);
					}
		});
		
}

function ajaxStartLayerAttente(iType,iRang) {	
	var message = 'Vérification de votre adresse en cours.';	
	$('#loaderImage_'+iType+'_'+iRang).show();
	$('#errorDivClose_'+iType+'_'+iRang).hide();
	$('#errorMessage_'+iType+'_'+iRang).html(message);
	$('#errorProposition_'+iType+'_'+iRang).html('');	
	$('#errorBouton_'+iType+'_'+iRang).html('');
	$('select[@id^=addresse_proposition_]').parent('p').remove();	
	$('#ajaxBusy_'+iType+'_'+iRang).fadeIn(fadeTime,function(){		
	
		//Appel Ajax pour la validation de l'adresse
		var adresse1   = $(txt_adresse).val();
		var adresse2   = "";
		var codePostal = $(txt_code).val();
		var ville      = $(txt_ville).val();
			$.ajax({
				type : "POST",
				url  : j_basepath + "admin.php",
				data : "module=personne&action=verificationAdresse:verifier&adresse1="+adresse1+"&adresse2="+adresse2+"&ville="+ville+"&codePostal="+codePostal,//+"&nom="+nom,
				dataType : "json",
				async : false,
				success : function(data){
					// Affichage Layer
					ajaxSuccessLayerAttente(iType, iRang, data);
				}
			});
	});	
}

function ajaxSuccessLayerAttente(iType,iRang,data) {
	var message = '';
	$('#loaderImage_'+iType+'_'+iRang).hide();	
	$('#errorDivClose_'+iType+'_'+iRang).hide();
	$('#errorProposition_'+iType+'_'+iRang).html('');
	$('#errorBouton_'+iType+'_'+iRang).html('');
	$('#errorMessage_'+iType+'_'+iRang).html(data.message);
	switch(data.sVerifyLevel){
		case "Verified":
			var reg = new RegExp("[0-9]{5}","g"); 
			var zAdresse = data.adresse[0]+" "+data.adresse[1]+" "+data.adresse[2]+ " " +data.adresse[3]+" "+data.adresse[4];
			zAdresse = zAdresse.replace(regExpBeginning, "").replace(regExpEnd, "");
			$(txt_adresse).val(zAdresse);
			$(txt_ville).val(data.adresse[5].replace(reg,""));
			$(txt_code).val(reg.exec(data.adresse[5]));
			$('#errorDivClose_'+iType+'_'+iRang).show();
			$('#masque').css({'cursor': 'default'}).click(function(){
				closeLayerAttente(iType,iRang);
			});
			$('#ajaxBusy_'+iType+'_'+iRang).click(function(){
				closeLayerAttente(iType,iRang);
			});
			return false;			
		case "PremisesPartial":
		case "StreetPartial": 
		case "Multiple": 
			var selection = "<p class='clearfix'><SELECT onChange='rechargerAdresse("+iType+","+iRang+")' style='width: 360px;margin-left:10px;' id='addresse_proposition_"+iType + '_' + iRang + "'></SELECT></p>";
			$(selection).appendTo($('#ajaxBusy_'+iType+'_'+iRang));
			
			var option = "<option value='0' selected >Choisissez...</option>";
			$(option).appendTo($('#addresse_proposition_'+iType+'_'+iRang));
			
			//boucle picklist
			for(ind in data.adresse){
				option = "<option value='" + ind + "'>"+ data.adresse[ind] + "</option>";
				$(option).appendTo($('#addresse_proposition_'+iType+'_'+iRang));
			}
			
			$('#addresse_proposition_'+iType+'_'+iRang+' option').get(0).selected = true;								
			return false;
			
		case "InteractionRequired":
			adresse = data.adresse;
			var msg1 = "Vous avez entré : <strong>" + $(txt_adresse).val()+" "+$(txt_code).val() + " " +$(txt_ville).val() + "</strong><br>";
			msg1 += "Adresse recommandée : <strong>" + adresse.join(" ").replace(regExpBeginning, "").replace(regExpEnd, "")+ "</strong><br><br>";			
			var msg2 = "<a href=\"javascript:closeLayerAttente(" + iType+ "," + iRang +");\">Conserver l'adresse saisie</a>";			
			msg2 += "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:modifierAdresse();'>Modifier cette adresse</a>";
			//$('#errorMessage_'+iType+'_'+iRang).append('');
			$('#errorProposition_'+iType+'_'+iRang).append(msg1);
			$('#errorBouton_'+iType+'_'+iRang).append(msg2);
			$('#errorDivClose_'+iType+'_'+iRang).show();
			return false;			
		default :
			//startTimerForCloseLayerAttente(iType,iRang);
			var msg2 = "<a href=\"javascript:closeLayerAttente(" + iType+ "," + iRang +");\">Quitter et Conserver l'adresse saisie</a>";
			$('#errorBouton_'+iType+'_'+iRang).append(msg2);
			$('#errorDivClose_'+iType+'_'+iRang).show();
			$('#masque').css({'cursor': 'default'}).click(function(){
				closeLayerAttente(iType,iRang);
			});
			return false;
			//break;
	}	
}

function modifierAdresse(){
	var reg = new RegExp("[0-9]{5}","g");  
	var zAdresse = adresse[0]+" "+adresse[1]+" "+adresse[2]+ " " +adresse[3]+ " "+adresse[4];
	zAdresse = zAdresse.replace(regExpBeginning, "").replace(regExpEnd, "");
	$(txt_adresse).val(zAdresse);
	$(txt_code).val(reg.exec(adresse[5]));
	$(txt_ville).val(adresse[5].replace(reg,""));
	closeLayerAttente(iType,iRang);
}

function ajaxRechargerAdresseStartLayerAttente(iType,iRang) {
	//afficherMasque();
	var message = 'Veuillez patienter pendant quelques secondes.';
	$('select[@id^=addresse_proposition_]').parent('p').remove();	
	$('#loaderImage_'+iType+'_'+iRang).show();
	$('#errorDivClose_'+iType+'_'+iRang).hide();
	$('#errorProposition_'+iType+'_'+iRang).html('');
	$('#errorBouton_'+iType+'_'+iRang).html('');	
	$('#errorMessage_'+iType+'_'+iRang).html(message);	
}

function ajaxRechargerAdresseSuccessLayerAttente(iType,iRang) {
	var message = 'Votre adresse a été rectifiée.';	
	$('#loaderImage_'+iType+'_'+iRang).hide();
	$('#errorDivClose_'+iType+'_'+iRang).show();
	$('#errorMessage_'+iType+'_'+iRang).html(message);
	$('#errorProposition_'+iType+'_'+iRang).html('');
	$('#errorBouton_'+iType+'_'+iRang).html('');
	$('select[@id^=addresse_proposition_]').parent('p').remove();	
	$('#masque').css({'cursor': 'default'}).click(function(){
		closeLayerAttente(iType,iRang);
	});
	$('#ajaxBusy_'+iType+'_'+iRang).click(function(){
		closeLayerAttente(iType,iRang);
	});
}

function closeLayerAttente(iType,iRang) {
	$('#ajaxBusy_'+iType+'_'+iRang).fadeOut(fadeTime, cacherMasque);	
}

function startTimerForCloseLayerAttente(iType,iRang) {	
	setTimeout("closeLayerAttente("+iType+","+iRang+")", fadeTime);
}

function afficherMasque()
{
	var tsize = ___getPageSize();
	//$('#masque').css({'width': tsize[0] + 'px', 'height': tsize[1] +'px', 'filter': 'alpha(opacity=50)', '-moz-opacity': '0.5', '-khtml-opacity': '0.5', 'opacity': '0.5'}).show();	
	$('#masque').unbind('click');
	$('div[@id^=ajaxBusy_]').unbind('click');
	$('#masque').css({'width': tsize[0] + 'px', 'height': tsize[1] +'px', 'filter': 'alpha(opacity=50)', 'opacity': '0.5'}).show();	
}

function cacherMasque() {
	$('#masque').fadeOut(fadeTime);
}

function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};


function onChangeTypeAdhesion(key){
	
	var select_id = '#select_quantite' + key;
	
	if($(select_id).val()==1){
		$('form select').each(function(index){
			if($(this).attr('id') != $(select_id).attr('id')){
				$(this).val(0);
			}
		});
	}
}
