function ajax(fichier)
{
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else

return(false);
xhr_object.open("GET", fichier, false);
xhr_object.send(null);

if(xhr_object.readyState == 4) return(xhr_object.responseText);
else return(false);
}

function vlbox(fichier, page_courante, paramplus, titre){
	//alert(titre);
	var les_images=new Array
	les_images[1] = "t_a-propos-de-tigex.gif";
	les_images[2] = "avis-parents.gif";
	les_images[3] = "service-consommateur-nuk.gif";
	les_images[4] = "newsletter.gif";
	les_images[5] = "t_avis.gif";
	les_images[6] = "t_service-conso.gif";
	les_images[7] = "t_forum-mamans.gif";
	les_images[8] = "vie-club-mamans-testeuses.gif";
	les_images[9] = "vacances-arrivent.gif";
	les_images[10] = "t_desincr-newsletter.gif";
	les_images[11] = "t_faire-connaitre.gif";
	les_images[12] = "t_tire-lait.gif";
	les_images[13] = "t_matinees-tigex.gif";
	les_images[14] = "club-mamans-testeuses-1.gif";
	les_images[15] = "t_printemps-approche.gif";
	les_images[16] = "t_baby-alarme.gif";
	les_images[17] = "t_vacances.gif";
	les_images[18] = "t_5-resultions.gif";
	les_images[19] = "creativite-petits.gif";
	les_images[20] = "fabrication-moulin-vent.gif";
	les_images[21] = "fabrication-cerf-volant.gif";
	largeur = 0;
	lalpha = 0;
	ouverture = window.setInterval("plus(3)", 10);
	document.getElementById("transp").style.display = "block";
	document.getElementById("img_vlbox").src ="medias/img/"+les_images[titre];
	if (paramplus == 2) {
	document.getElementById("vlbox_content").innerHTML = ajax(fichier);
	} else if (paramplus != 1){
	document.getElementById("vlbox_content").innerHTML = ajax(fichier + "?url=" + page_courante);
	} else {
	document.getElementById("vlbox_content").innerHTML = ajax(fichier + "&url=" + page_courante);
	}
	/*document.getElementById("vlbox_content").innerHTML = httpRequest(file+"?page="+page_courante);*/
}


function vlbox_ouverte(fichier, titre){
	//alert(titre);
	var les_images=new Array
	les_images[1] = "t_a-propos-de-tigex.gif";
	les_images[2] = "avis-parents.gif";
	les_images[3] = "service-consommateur-nuk.gif";
	les_images[4] = "newsletter.gif";
	les_images[5] = "t_avis.gif";
	les_images[6] = "t_service-conso.gif";
	les_images[7] = "t_forum-mamans.gif";
	les_images[8] = "vie-club-mamans-testeuses.gif";
	les_images[9] = "vacances-arrivent.gif";
	les_images[10] = "t_desincr-newsletter.gif";
	les_images[11] = "t_faire-connaitre.gif";
	les_images[12] = "t_tire-lait.gif";
	les_images[13] = "t_matinees-tigex.gif";
	les_images[14] = "club-mamans-testeuses-1.gif";
	les_images[15] = "t_printemps-approche.gif";
	les_images[16] = "t_baby-alarme.gif";
	les_images[17] = "t_vacances.gif";
	les_images[18] = "t_5-resultions.gif";
	les_images[19] = "creativite-petits.gif";
	les_images[20] = "fabrication-moulin-vent.gif";
	les_images[21] = "fabrication-cerf-volant.gif";
	document.getElementById("transp").style.display = "block";
	document.getElementById("vlbox_content").innerHTML = ajax(fichier);
	document.getElementById("transp").style.width = "99.9%";
	document.getElementById("transp").style.height = "99.9%";
	document.getElementById("transp").style.opacity = 0.4;
	document.getElementById("transp").style.filter = "alpha(opacity=40)";
	document.getElementById("vlbox").style.display = "block";
	document.getElementById("img_vlbox").src ="medias/img/"+les_images[titre];
}

function vlbox_fermer(){
	largeur = 0;
	lalpha = 0;
	document.getElementById("vlbox").style.display = "none";
	fermeture = window.setInterval("moins()", 10);
}

function plus(lavitesse){
	largeur = largeur + (100 - largeur)/lavitesse;
	lalpha = lalpha + ((40 - (lalpha*100))/3)/100;
	// positionnement
	document.getElementById("transp").style.marginLeft = (100 - largeur)/2 + "%";
	document.getElementById("transp").style.marginTop = (100 - largeur)/2 + "%";
	// mise a l'echelle
	document.getElementById("transp").style.width = largeur + "%";
	document.getElementById("transp").style.height = largeur + "%";
	// ajustement de l'alpha
	document.getElementById("transp").style.opacity = lalpha;
	document.getElementById("transp").style.filter = "alpha(opacity=" + (lalpha*100) + ")";
	// augmentation de la vitesse sur la fin pour eviter la nuisance du ralentissement de fin sur les vitesses trop faible
	if (largeur > 94) {
	lavitesse = 2;
	}
	// test de la fin
	if (largeur > 98.9) {
	document.getElementById("transp").style.width = "99.9%";
	document.getElementById("transp").style.height = "99.9%";
	document.getElementById("transp").style.opacity = 0.4;
	document.getElementById("transp").style.filter = "alpha(opacity=40)";
	document.getElementById("vlbox").style.display = "block";
    clearInterval(ouverture);
	}
}

function moins(){
	largeur = largeur + (100 - largeur)/3;
	lalpha = lalpha + ((40 - (lalpha*100))/3)/100;
	// positionnement
	//document.getElementById("transp").style.marginLeft = (100 - largeur)/2 + "%";
	//document.getElementById("transp").style.marginTop = (100 - largeur)/2 + "%";
	// mise a l'echelle
	//document.getElementById("transp").style.width = (100 - largeur) + "%";
	//document.getElementById("transp").style.height = (100 -largeur) + "%";
	// ajustement de l'alpha
	le_alpha = 0.4 - lalpha;
	document.getElementById("transp").style.opacity = le_alpha;
	document.getElementById("transp").style.filter = "alpha(opacity=" + (le_alpha*100) + ")";
	// test de la fin
	if (largeur > 98) {
	//document.getElementById("transp").style.width = "0%";
	//document.getElementById("transp").style.height = "0%";
	document.getElementById("transp").style.opacity = 0;
	document.getElementById("transp").style.filter = "alpha(opacity=0)";
	document.getElementById("transp").style.display = "none";
    clearInterval(fermeture);
	}
}


function valid(nom,prenom,adresse,cp,ville,email,origine){
	var nb=nb_aleatoire(1000000);
	var texte="";
	if(texte = file('compliss/traitement_jeu.php?nom='+nom+'&prenom='+prenom+'&adresse='+adresse+'&cp='+cp+'&ville='+ville+'&email='+email+'&origine='+origine+'&nb='+nb))
	{
		alert(texte);
	}else{
		alert("plantage requête");
	}
}

function cache_block(identifiant){
	document.getElementById(identifiant).style.display = "none";
}

function validAmi(email1,email2,email3,nom_prenom,sender,origine,cle){
	var nb=nb_aleatoire(1000000);
	var texte="";
	if(texte = file('compliss/email_process_ami.php?email1='+email1+'&email2='+email2+'&email3='+email3+'&nom_prenom='+nom_prenom+'&sender='+sender+'&cle='+cle+'&origine='+origine+'&nb='+nb))
	{
		alert(texte);
	}else{
		alert("plantage requête");
	}
}

function trim(str) {
   return str.replace(/(^\s*)|(\s*$)/g,"")
}

function Majuscule(formName,nomchamp){
	chaine=eval('document.'+formName+'.'+nomchamp+'.value');
	for (var i = 0; i < document.forms.length; i++) {
		if(document.forms[i].name==formName){
			for (var j = 0; j < document.forms[i].elements.length; j++) {
				if(document.forms[i].elements[j].name==nomchamp){
					document.forms[i].elements[j].value=chaine.toUpperCase();
				}
			}
		}
	}
}


function block(formName,nomchamp,champstop){

	for (var i = 0; i < document.forms.length; i++) {
		if(document.forms[i].name==formName){
			formnum=i;
			for (var j = 0; j < document.forms[i].elements.length; j++) {
				if(document.forms[i].elements[j].name==nomchamp){
					//alert(nomchamp);
					elementnum=j;
					if(document.forms[i].elements[j].checked != false){
					//if(testerRadio(nomchamp) != 0){
						etat=true;
					}else{
						etat=false;
					}
				}
				if(document.forms[formnum].elements[j].name==champstop){
					fin=j;
				}
			}
		}
	}
	for (var k = elementnum+1; k < document.forms[formnum].elements.length; k++) {
		if(k<=fin){
			document.forms[formnum].elements[k].disabled=etat;
		}
	}
}


function verifFormulaire(num_form,lang,varCheckDate,varFormOblig){
	return (checkDate(num_form,varCheckDate,lang) && checkFields(num_form,varFormOblig,lang));
}


function checkDate(num_form,varOb,lang){
var tabob=varOb.split(',');

missinginfo = "false";
chpmanquant = "";
for (var i = 0; i < document.forms[num_form].elements.length; i++) {
	//alert(i+" "+document.forms[num_form].elements[i].name);
	for(var k=0;k<tabob.length;k++){
		if(tabob[k]==i){
			//alert(i+" "+document.forms[num_form].elements[i].name);
			//alert(tabob[k]+" "+i);
			type = document.forms[num_form].elements[i].type;
			 switch (type)
			 {
				case "text" : 
					if(trim(document.forms[num_form].elements[i].value) != "") {
						chaine=document.forms[num_form].elements[i].name+"";
						if(chaine.indexOf('date')!=-1){//test forme de la date
						//alert(i);
							if ((document.forms[num_form].elements[i].value.indexOf('/') == -1)) {
								missinginfo = "true";
								nom=document.forms[num_form].elements[i].name;
								nom=nom.replace(/_/g,' ');
								nom=nom.replace('[','');
								nom=nom.replace(']','');
								chpmanquant = chpmanquant +  "- " + nom+"\n";
							}else{
								var chaineTabNb="2,2,4";// pour 00/00/0000
								var tabNb=chaineTabNb.split(',');
								var tabdate=document.forms[num_form].elements[i].value.split('/');
								var boolNb="false";
								for(var cpt=0;cpt<tabdate.length;cpt++){
									if(tabdate[cpt].length!=tabNb[cpt]){
										boolNb="true";
									}else{
										if(!is_numeric(tabdate[cpt])){
											boolNb="true";
										}
									}
								}
								if(boolNb=="true"){
									missinginfo = "true";
									nom=document.forms[num_form].elements[i].name;
									nom=nom.replace(/_/g,' ');
									nom=nom.replace('[','');
									nom=nom.replace(']','');
									chpmanquant = chpmanquant +  "- " + nom+"\n";
								}
							}
						}
					}
				break;
			 }
		 }
	 }
}

if (missinginfo != "false") {

	switch(lang){
		case "FR":
			missinginfo ="Certains champs n'ont pas été correctement renseignés :\n\n" +
			chpmanquant +"\n\nCorrigez-les puis soumettez à nouveau le formulaire !";
		break;
		case "fr":
			missinginfo ="Certains champs n'ont pas été correctement renseignés :\n\n" +
			chpmanquant +"\n\nCorrigez-les puis soumettez à nouveau le formulaire !";
		break;
		case "uk","UK":
			missinginfo ="Certain fields were not correctly filled." +
			"\nPlease, submit your form again !";
		break;
		case "es","ES":
			missinginfo ="Seguro campos no se han cumplimentado correctamente." +
			"\nCorríjalos y presente de nuevo el formulario !";
		break;
		case "de","DE":
			missinginfo ="Fehlerhafte Eingabe in Feldern." +
			"\nKorrigieren Sie die Angaben und senden Sie das Formular erneut ab !";
		break;
		case "it","IT":
			missinginfo ="I campi non sono stati informati correttamente." +
			"\nCorreggerli e poi sottoporre di nuovo il formulario !";
		break;
		case "nl","NL":
			missinginfo ="Certain fields were not correctly filled." +
			"\nPlease, submit your form again !";
		break;
		case "pt","PT":
			missinginfo ="Determinados campos não foram enchidos corretamente." +
			"\nPor favor, submeta seu formulário outra vez !";
		break;
	}
	alert(missinginfo);
	return false;
}
else 
	return true;
}

function checkFields(num_form,varOb,lang){
var tabob=varOb.split(',');

missinginfo = "false";
chpmanquant = "";
for (var i = 0; i < document.forms[num_form].elements.length; i++) {
	//alert(i+" "+document.forms[num_form].elements[i].name);
	for(var k=0;k<tabob.length;k++){
		if(tabob[k]==i){
			//alert(i+" "+document.forms[num_form].elements[i].name);
			//alert(tabob[k]+" "+i);
			type = document.forms[num_form].elements[i].type;
			 switch (type)
			 {
				case "text" : 
				case "password" :
				case "file" :
				case "textarea" :
					if(trim(document.forms[num_form].elements[i].value) == "") {
						//alert(i+" "+document.forms[num_form].elements[i].name);
						missinginfo = "true";
						nom=document.forms[num_form].elements[i].name;
						nom=nom.replace(/_/g,' ');
						nom=nom.replace('[','');
						nom=nom.replace(']','');
						chpmanquant = chpmanquant +  "- " + nom+"\n";
					}else{
						chaine=document.forms[num_form].elements[i].name+"";
						if(chaine.indexOf('mail')!=-1){//test forme du mail
						//alert(i);
							if ((document.forms[num_form].elements[i].value.indexOf('@') == -1) || 
								(document.forms[num_form].elements[i].value.indexOf('.') == -1)) {
								missinginfo = "true";
								nom=document.forms[num_form].elements[i].name;
								nom=nom.replace(/_/g,' ');
								nom=nom.replace('[','');
								nom=nom.replace(']','');
								chpmanquant = chpmanquant +  "- " + nom+"\n";
							}
						}
						if(chaine.indexOf('date')!=-1){//test forme de la date
						//alert(i);
							if ((document.forms[num_form].elements[i].value.indexOf('/') == -1)) {
								missinginfo = "true";
								nom=document.forms[num_form].elements[i].name;
								nom=nom.replace(/_/g,' ');
								nom=nom.replace('[','');
								nom=nom.replace(']','');
								chpmanquant = chpmanquant +  "- " + nom+"\n";
							}else{
								var chaineTabNb="2,2,4";// pour 00/00/0000
								var chaineTabValeur="00,00,0000";// pour 00/00/0000
								var tabNb=chaineTabNb.split(',');
								var tabValeur=chaineTabValeur.split(',');
								var tabdate=document.forms[num_form].elements[i].value.split('/');
								var boolNb="false";
								for(var cpt=0;cpt<tabdate.length;cpt++){
									if(tabdate[cpt].length!=tabNb[cpt]){
										boolNb="true";
									}else{
										if(!is_numeric(tabdate[cpt])){
											boolNb="true";
										}else{
											if(tabdate[cpt]==tabValeur[cpt]){
												boolNb="true";
											}
										}
									}
								}
								if(boolNb=="true"){
									missinginfo = "true";
									nom=document.forms[num_form].elements[i].name;
									nom=nom.replace(/_/g,' ');
									nom=nom.replace('[','');
									nom=nom.replace(']','');
									chpmanquant = chpmanquant +  "- " + nom+"\n";
								}
							}
						}
					}
				break;
				case "radio" :
				case "checkbox" :
					NbRadio = document.getElementsByName(document.forms[num_form].elements[i].name).length;
					chec="false";
					for (var j=0; j<NbRadio;j++) {
						if (document.getElementsByName(document.forms[num_form].elements[i].name)[j].checked == true){
						chec="true";
						}
					}
					if(chec=="false"){
						missinginfo = "true";
						nom=document.forms[num_form].elements[i].name;
						nom=nom.replace(/_/g,' ');
						nom=nom.replace('[','');
						nom=nom.replace(']','');
						chpmanquant = chpmanquant +  "- " + nom+"\n";
					}
					i=i+1;
				break;
			 }
		 }
	 }
}

if (missinginfo != "false") {

	switch(lang){
		case "FR":
			missinginfo ="Certains champs obligatoires n'ont pas été correctement renseignés :\n\n" +
			chpmanquant +"\n\nCorrigez-les puis soumettez à nouveau le formulaire !";
		break;
		case "fr":
			missinginfo ="Certains champs obligatoires n'ont pas été correctement renseignés :\n\n" +
			chpmanquant +"\n\nCorrigez-les puis soumettez à nouveau le formulaire !";
		break;
		case "uk","UK":
			missinginfo ="Certain fields were not correctly filled." +
			"\nPlease, submit your form again !";
		break;
		case "es","ES":
			missinginfo ="Seguro campos no se han cumplimentado correctamente." +
			"\nCorríjalos y presente de nuevo el formulario !";
		break;
		case "de","DE":
			missinginfo ="Fehlerhafte Eingabe in Feldern." +
			"\nKorrigieren Sie die Angaben und senden Sie das Formular erneut ab !";
		break;
		case "it","IT":
			missinginfo ="I campi non sono stati informati correttamente." +
			"\nCorreggerli e poi sottoporre di nuovo il formulario !";
		break;
		case "nl","NL":
			missinginfo ="Certain fields were not correctly filled." +
			"\nPlease, submit your form again !";
		break;
		case "pt","PT":
			missinginfo ="Determinados campos não foram enchidos corretamente." +
			"\nPor favor, submeta seu formulário outra vez !";
		break;
	}
	alert(missinginfo);
	return false;
}
else 
	return true;
}



function checkFieldsVersionClic(num_form,varOb,lang){
var tabob=varOb.split(',');

missinginfo = "false";
chpmanquant = "";
for (var i = 0; i < document.forms[num_form].elements.length; i++) {
	for(var k=0;k<tabob.length;k++){
		if(tabob[k]==i){
			//alert(i+" "+document.forms[num_form].elements[i].name);
			//alert(tabob[k]+" "+i);
			type = document.forms[num_form].elements[i].type;
			 switch (type)
			 {
				case "text" : 
				case "password" :
				case "file" :
				case "textarea" :
					if(trim(document.forms[num_form].elements[i].value) == "") {
						//alert(i+" "+document.forms[num_form].elements[i].name);
						missinginfo = "true";
						nom=document.forms[num_form].elements[i].name;
						nom=nom.replace(/_/g,' ');
						nom=nom.replace('[','');
						nom=nom.replace(']','');
						chpmanquant = chpmanquant +  "- " + nom+"\n";
					}else{
						chaine=document.forms[num_form].elements[i].name+"";
						if(chaine.indexOf('mail')!=-1){//test forme du mail
						//alert(i);
							if ((document.forms[num_form].elements[i].value.indexOf('@') == -1) || 
								(document.forms[num_form].elements[i].value.indexOf('.') == -1)) {
								missinginfo = "true";
								nom=document.forms[num_form].elements[i].name;
								nom=nom.replace(/_/g,' ');
								nom=nom.replace('[','');
								nom=nom.replace(']','');
								chpmanquant = chpmanquant +  "- " + nom+"\n";
							}
						}
						if(chaine.indexOf('date')!=-1){//test forme de la date
						//alert(i);
							if ((document.forms[num_form].elements[i].value.indexOf('/') == -1)) {
								missinginfo = "true";
								nom=document.forms[num_form].elements[i].name;
								nom=nom.replace(/_/g,' ');
								nom=nom.replace('[','');
								nom=nom.replace(']','');
								chpmanquant = chpmanquant +  "- " + nom+"\n";
							}else{
								var chaineTabNb="2,2,4";// pour 00/00/0000
								var chaineTabValeur="00,00,0000";// pour 00/00/0000
								var tabNb=chaineTabNb.split(',');
								var tabValeur=chaineTabValeur.split(',');
								var tabdate=document.forms[num_form].elements[i].value.split('/');
								var boolNb="false";
								for(var cpt=0;cpt<tabdate.length;cpt++){
									if(tabdate[cpt].length!=tabNb[cpt]){
										boolNb="true";
									}else{
										if(!is_numeric(tabdate[cpt])){
											boolNb="true";
										}else{
											if(tabdate[cpt]==tabValeur[cpt]){
												boolNb="true";
											}
										}
									}
								}
								if(boolNb=="true"){
									missinginfo = "true";
									nom=document.forms[num_form].elements[i].name;
									nom=nom.replace(/_/g,' ');
									nom=nom.replace('[','');
									nom=nom.replace(']','');
									chpmanquant = chpmanquant +  "- " + nom+"\n";
								}
							}
						}
					}
				break;
				case "radio" :
				case "checkbox" :
					NbRadio = document.getElementsByName(document.forms[num_form].elements[i].name).length;
					chec="false";
					for (var j=0; j<NbRadio;j++) {
						if (document.getElementsByName(document.forms[num_form].elements[i].name)[j].checked == true){
						chec="true";
						}
					}
					if(chec=="false"){
						missinginfo = "true";
						nom=document.forms[num_form].elements[i].name;
						nom=nom.replace(/_/g,' ');
						nom=nom.replace('[','');
						nom=nom.replace(']','');
						chpmanquant = chpmanquant +  "- " + nom+"\n";
					}
					i=i+1;
				break;
			 }
		 }
	 }
}

if (missinginfo != "false") {

	switch(lang){
		case "FR":
			missinginfo ="Certains champs obligatoires n'ont pas été correctement renseignés :\n\n" +
			chpmanquant +"\n\nCorrigez-les puis soumettez à nouveau le formulaire !";
		break;
		case "fr":
			missinginfo ="Certains champs obligatoires n'ont pas été correctement renseignés :\n\n" +
			chpmanquant +"\n\nCorrigez-les puis soumettez à nouveau le formulaire !";
		break;
		case "uk","UK":
			missinginfo ="Certain fields were not correctly filled." +
			"\nPlease, submit your form again !";
		break;
		case "es","ES":
			missinginfo ="Seguro campos no se han cumplimentado correctamente." +
			"\nCorríjalos y presente de nuevo el formulario !";
		break;
		case "de","DE":
			missinginfo ="Fehlerhafte Eingabe in Feldern." +
			"\nKorrigieren Sie die Angaben und senden Sie das Formular erneut ab !";
		break;
		case "it","IT":
			missinginfo ="I campi non sono stati informati correttamente." +
			"\nCorreggerli e poi sottoporre di nuovo il formulario !";
		break;
		case "nl","NL":
			missinginfo ="Certain fields were not correctly filled." +
			"\nPlease, submit your form again !";
		break;
		case "pt","PT":
			missinginfo ="Determinados campos não foram enchidos corretamente." +
			"\nPor favor, submeta seu formulário outra vez !";
		break;
	}
	alert(missinginfo);
	return false;
}
else 
	window.document.forms[num_form].submit();
}

//-----------------------------------------

function cacher_div(chaine){
	tablo=chaine.split(',');
	for(var k=0;k<tablo.length;k++){
		document.getElementById(tablo[k]).style.display='none';
	}
}

function cacher_afficher_div(nom_div){
	if(document.getElementById(nom_div).style.display=='none'){
		document.getElementById(nom_div).style.display='block';
	}else{
		document.getElementById(nom_div).style.display='none';
	}
}

function afficherDiv(nom_div){
	document.getElementById(nom_div).style.display='block';
}

//-----------------------

function is_numeric(num)
	{
		var exp = new RegExp("^[0-9-.]*$","g");
		return exp.test(num);
	}


//-----------------------
//-------
function testerRadio(radio) {
      for (var i=0; i<radio.length;i++) {
         if (radio[i].checked) {
			return radio[i].value;
         }
      }
}

//--------------
function left(str,nbr) {
   return str.substr(0,nbr)
}

function file(fichier)
	{
	if(window.XMLHttpRequest) // FIREFOX
	xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
	return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
}
	
function nb_aleatoire(nb)
{
	return Math.floor(Math.random() * nb)+1;
}
	
function writediv(texte,div)
	{
	document.getElementById(div).innerHTML = texte;
	}
	
function getnumElement(numform,nomelem){
	for (var i = 0; i < document.forms[numform].elements.length; i++) {
		if(document.forms[numform].elements[i].name==nomelem){
			id=i;
		}
	}
	return id;
}

function replaceCommaByPoint(valeur,nbform,champ){
	valeur=valeur.replace(',','.');
	id=getnumElement(nbform,champ);
	document.forms[nbform].elements[id].value=valeur;
}

function goProd(url){
	window.document.location.href=url;
}

function changeProd(id,lang){
	var nb=nb_aleatoire(1000000);
	var texte="";
	if(texte = file('ajax/getListProd.php?id='+id+'&lang='+lang+'&nb='+nb))
	{
		writediv(texte,'recherche');
	}
	else{
		alert("plantage requête");
	}
}

function changeProdMedicpro(id,lang){
	var nb=nb_aleatoire(1000000);
	var texte="";
	if(texte = file('ajax/getListProdMedicpro.php?id='+id+'&lang='+lang+'&nb='+nb))
	{
		writediv(texte,'recherche');
	}
	else{
		alert("plantage requête");
	}
}

function imprimer(){
	window.print();
}

var series = new Array();
var quelleSerie = 0;
var overDown = 0;
var overUp = 0;
var activeDown = 1;
var activeUp = 0;
var precedente = 0;


function overButtonDown(){
	if (activeDown == 1){
		overDown = 1;
		document.getElementById("scrollDown").style.backgroundImage = "url(medias/img/scroll-down_o.jpg)";
		scrollBas();
	}
}

function outButtonDown(){
	overDown = 0;
	clearInterval(pourBas);
	if (activeDown == 1){
		document.getElementById("scrollDown").style.backgroundImage = "url(medias/img/scroll-down.jpg)";
	}
}

function overButtonUp(){
	if (activeUp == 1){
		overUp = 1;
		document.getElementById("scrollUp").style.backgroundImage = "url(medias/img/scroll-up_o.jpg)";
		scrollHaut();
	}
}

function outButtonUp(){
	overUp = 0;
	clearInterval(pourHaut);
	if (activeUp == 1){
		document.getElementById("scrollUp").style.backgroundImage = "url(medias/img/scroll-up.jpg)";
	}
}


function setListe(nbBoite,nbItemSerie){
	totalHauteur = 0;
	totalHauteurSerie = 0;
	for(i=1;i<nbBoite;i++){
		hauteurBoite = document.getElementById("boite"+i).scrollHeight + 25;
		totalHauteur = totalHauteur + hauteurBoite;
		if(i%nbItemSerie == 0){
			series.push(totalHauteur);
			totalHauteur = 0;
		}
	}
	hauteurListe = (series[0] - 74) + "px";
	document.getElementById("liste").style.height = hauteurListe;
	document.getElementById("scrollDown").style.display="block";
	document.getElementById("scrollUp").style.display="block";
}

function scrollBas(){
	pourBas = window.setInterval("listeDescend()",30);
}

function scrollHaut(){
	pourHaut = window.setInterval("listeMonte()",30);
}

function listeDescend(){
		
		activeUp = 1;
		document.getElementById("scrollUp").style.backgroundImage = "url(medias/img/scroll-up.jpg)";
		
		precedente = document.getElementById('liste').scrollTop;
		document.getElementById('liste').scrollTop = document.getElementById('liste').scrollTop + 7;
		
		if (document.getElementById('liste').scrollTop == precedente){
		
			document.getElementById('liste').scrollTop = document.getElementById('liste').scrollHeight;
			activeDown = 0;
			document.getElementById("scrollDown").style.backgroundImage = "url(medias/img/scroll-down_n.jpg)";
			clearInterval(pourBas);
	
		}

}

function listeMonte(){		
		
		activeDown = 1;
		document.getElementById("scrollDown").style.backgroundImage = "url(medias/img/scroll-down.jpg)";
		
		precedente = document.getElementById('liste').scrollTop;
		document.getElementById('liste').scrollTop = document.getElementById('liste').scrollTop - 7;
		
		if (document.getElementById('liste').scrollTop == precedente){
		
			document.getElementById('liste').scrollTop = 0;
			activeUp = 0;
			document.getElementById("scrollUp").style.backgroundImage = "url(medias/img/scroll-up_n.jpg)";
			clearInterval(pourHaut);
	
		}

}
