var largeur = 0;

var test = 'oui';

function progress(){
	if (document.avatar.IdAEMembre.value == "" || document.avatar.IdAEIdeal.value == "") {
		document.getElementById('erreur').style.display = 'block';
	}
	else {
		document.getElementById('erreur').style.display = 'none';
		if (test=='oui') {
			document.getElementById('analyse').style.display = 'none';
			document.getElementById('analyse2').style.display = 'none';
			document.getElementById('result').style.display = 'block';
			document.getElementById('patientez').style.display = 'block';
				
			var monDiv = document.getElementById('loader');
			
			var interval = Math.round(Math.random(0)*1000)+1;
			
			if (largeur<640) {
				largeur+=128;
				monDiv.style.width = largeur+'px';
				//alert(largeur);
				
				setTimeout("progress()",interval);
			} else {
				test = 'non';
				largeur = 640;
				monDiv.style.width = largeur+'px';
				
				
				var nb1 = Math.round(Math.random(0)*11)+12;
				
				var nb2 = Math.round(Math.random(0)*2)+3;
				
				document.getElementById('nb_membres').innerHTML = nb1;
				document.getElementById('nb_membres_recherche').innerHTML = nb2;
				
				document.getElementById('patientez').style.display = 'none';
				document.getElementById('prog_bar').style.display = 'none';
				document.getElementById('chiffres').style.display = 'block';
				document.getElementById('chiffres').style.display = 'block';
			}
		}
	}
}

function chargemodule(IdModel) {
  if (IdModel > 0) {
  	document.getElementById('cochez1').style.display = 'none';
		document.avatar.TypePortrait.value = 'moi';		
		document.getElementById('flashcontent').innerHTML = "Si vous ne voyez pas l'animation, merci de <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;promoid=BIOW\" target=\"_blank\">t&eacute;l&eacute;charger Flash Player</a>";
		if (IdModel == 1) {
			var so = new SWFObject("portrait_new.swf?TypePortrait=moi", "portrait", "680", "530", "8", "#faf8e3");
			document.getElementById('rbf').src = 'img/radio_btn_on.gif';		
			document.getElementById('rbh').src = 'img/radio_btn_off.gif';		
			document.avatar.Sexe.value = 'f';
		}
		if (IdModel == 2) {
			var so = new SWFObject("portrait_new2.swf?TypePortrait=moi", "portrait", "680", "530", "8", "#faf8e3");
			document.getElementById('rbf').src = 'img/radio_btn_off.gif';		
			document.getElementById('rbh').src = 'img/radio_btn_on.gif';		
			document.avatar.Sexe.value = 'h';
		}
		so.write('flashcontent');
	}
}

function chargemoduleideal(IdModel) {
  if (IdModel > 0) {
  	document.getElementById('cochez2').style.display = 'none';
		document.avatar.TypePortrait.value = 'ideal';	
  	document.getElementById('flashcontent2').innerHTML = "Si vous ne voyez pas l'animation, merci de <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;promoid=BIOW\" target=\"_blank\">t&eacute;l&eacute;charger Flash Player</a>";
		if (IdModel == 1) {
			var so2 = new SWFObject("portrait_new.swf?TypePortrait=ideal", "portrait2", "680", "530", "8", "#faf8e3");
			document.getElementById('rbidealf').src = 'img/radio_btn_on.gif';		
			document.getElementById('rbidealh').src = 'img/radio_btn_off.gif';
			document.avatar.RechercheSexe.value = 'f';
		}
		if (IdModel == 2) {
			var so2 = new SWFObject("portrait_new2.swf?TypePortrait=ideal", "portrait2", "680", "530", "8", "#faf8e3");
			document.getElementById('rbidealf').src = 'img/radio_btn_off.gif';		
			document.getElementById('rbidealh').src = 'img/radio_btn_on.gif';		
			document.avatar.RechercheSexe.value = 'h';
		}
	  so2.write('flashcontent2');
	}
}

function popupcentree(page,largeur,hauteur) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	var options="toolbar=0,location=0,directories=0,status=1,scrollbars=0,resizable=1,copyhistory=0,menuBar=0";
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
	window.location.href='#amusez';
}

function pop_it(the_action) {
   my_form = document.avatar;
   my_form.action = the_action;
   window.open("popattente.html", "popup", "height=600,width=650,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'");
   my_form.target = "popup";
   my_form.submit();
   window.location.href='#amusez';
}
