tPrix = new Object();
tQuotite = new Object();
tMultiple = new Object();
tNoport = new Object();
tPrixrevente = new Object();
prixErreur = false;
var grilleRollOverLast;

fraisport = 13;
maxupload = 13000;

// Check Flash
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}


function init () {
	//var detail = document.getElementsByName('detail');
	//for (var i=0; i<detail.length; i++) {
		var detail = document.getElementById('detail')
		if (detail) {
			var largeur=0;
			var hauteur=0;
			var div = detail.childNodes;
			for(var j=0;j<div.length;j++) {
				if ((div.item(j).offsetTop+div.item(j).offsetHeight) > hauteur) hauteur = div.item(j).offsetTop+div.item(j).offsetHeight;
				if ((div.item(j).offsetLeft+div.item(j).offsetWidth) > largeur) largeur = div.item(j).offsetLeft+div.item(j).offsetWidth;
			}
			detail.style.width = largeur;
			detail.style.height = hauteur;
		}
		//alert(largeur + "-" + hauteur);
	//}
	// appel prix update ui init table de prix
	prixSwitch();
	try {
		restoreForm();
	} catch(e) {}
	try {
		initPage();
	} catch(e) {}
}



function prixVerif (id) {
		var qtstr = document.getElementById('qt_'+id).value.toString();
		if (qtstr.match(/\D/)) document.getElementById('qt_'+id).value = qtstr.replace(/\D/g,'');
		var qt = parseInt(document.getElementById('qt_'+id).value,10);
		if (isNaN(qt) || qt < tPrix[id][0]['qty'] || qt%tMultiple[id] || (id=='04070027' && qt>1)) {
			document.getElementById('qt_'+id).style.backgroundColor = 'red';
			if (document.getElementById('pu_'+id)) document.getElementById('pu_'+id).innerHTML = '';
			if (document.getElementById('prix_'+id)) document.getElementById('prix_'+id).innerHTML = '';
			if (document.getElementById('benef_'+id)) document.getElementById('benef_'+id).innerHTML = '';
			if (document.getElementById('total')) document.getElementById('total').innerHTML = '';
			if (document.getElementById('tva')) document.getElementById('tva').innerHTML = '';
			if (!document.getElementById('infobulle')) {
				var div = document.createElement('SPAN');
				div.id = 'infobulle';
				div.className = 'surbrillance';
				div.style.position = 'absolute';
				div.style.zIndex = '300000';
				div.style.backgroundColor = 'yellow';
				div.style.color = 'red';
				document.body.appendChild(div);
			} 
			p = document.getElementById('qt_'+id);
			x=0;
			y=0;
			do {
				x+=p.offsetLeft
				y+=p.offsetTop
				p=p.offsetParent
			} while(p); 

			document.getElementById('infobulle').style.left = x ;
			document.getElementById('infobulle').style.top = y + 25;
			if (isNaN(qt) || qt < tPrix[id][0]['qty']) {
				document.getElementById('infobulle').innerHTML = "Quantité minimum : "+tPrix[id][0]['qty'];
			}
			else if (id=='04070027' && qt>1) {
				document.getElementById('infobulle').innerHTML = "Vous ne pouvez pas commander plus d'un kit, vous pourrez préciser le nombre d'enfants à l'étape de la personnalisation";
			}
			else if (qt%tMultiple[id]) {
				document.getElementById('infobulle').innerHTML = "Ce produit se vend par multiple de "+tMultiple[id]+" (ex: "+200+","+(tMultiple[id]+200)+","+(tMultiple[id]*2+200)+"...)";
			}
			document.getElementById('infobulle').style.visibility = "visible";
			
			prixErreur = true;
		}
		else {
			document.getElementById('qt_'+id).style.backgroundColor = 'white';
			if (document.getElementById('infobulle')) {
				document.getElementById('infobulle').style.visibility = "hidden";
			}
			prixErreur = false;
			prixUpdate();
		}
}
// appelé par prixSwitch() et prixVerif()
function prixUpdate() {
	var inputs = document.getElementsByTagName('INPUT');
	var total = 0;
	var port = 0;
	for (var i=0; i<inputs.length; i++) {
		if (inputs[i].id.indexOf("qt_")!=0) continue;
		//var id = inputs[i].id.replace(/\D/g,'');
		var id = inputs[i].id.replace(/^qt_/,'');
		var qt = parseInt(document.getElementById('qt_'+id).value,10);
		// au chargement de la page
		if (!qt) {
			qt = (tPrix[id].length>1) ? tPrix[id][1]['qty'] : tPrix[id][0]['qty'];
			document.getElementById('qt_'+id).value = qt;
			if (document.getElementById('pu_'+id+'_'+qt)) roll(document.getElementById('pu_'+id+'_'+qt).parentNode.parentNode,'click');
		}
		var prixrevente = tPrixrevente[id]; 
		var quotite = (tQuotite[id]) ? tQuotite[id] : 1; 
		// au cas pb prix on met +elevé
		var pu = tPrix[id][0]['prix'];
		for (var j=tPrix[id].length-1;j>=0;j--) {
			if (qt>=tPrix[id][j]['qty']) {
				pu = tPrix[id][j]['prix'];
				break;
			}
		}
		prixFormat('pr_'+id,prixrevente);
		prixFormat('pu_'+id,pu);
		var prix = pu * qt;
		prixFormat('prix_'+id,prix);
		var benef = qt*prixrevente*quotite - prix ;
		if (!prixrevente || !prix) benef='';
		prixFormat('benef_'+id,benef);
		total += Math.round(prix*100)/100;
		if (tNoport[id]==0) port=fraisport;
		if (document.getElementById('qttotal_'+id)) {
			document.getElementById('qttotal_'+id).innerHTML = '<br><center><span style="color:yellow;font-weight:bold;font-size:14px">soit un total de '+quotite*qt+' peluches</span></center>';
			if (!qt) document.getElementById('qttotal_'+id).innerHTML = '';
		}
		prixGrille (id);
	}	
	if (!total)  port=0;
	total += port;
	prixFormat('total',total);
	prixFormat('tva',total - total/1.196);
	prixFormat('port',port);
}
function prixGrille (id) {
	var col,pu,qt,prix,benef;
	var prixrevente = tPrixrevente[id];
	var quotite = (tQuotite[id]) ? tQuotite[id] : 1; 
	for (var j=0;j<tPrix[id].length;j++) {
		qt = tPrix[id][j]['qty'];
		pu = tPrix[id][j]['prix'];
		prixFormat('pu_'+id+'_'+qt,pu);
		prix = pu * qt;
		prixFormat('prix_'+id+'_'+qt,prix);
		benef = qt*prixrevente*quotite - prix ;
		prixFormat('benef_'+id+'_'+qt,benef);
	}
}

function prixFormat(elem,nb) {
	if (!document.getElementById(elem)) return;
	var symb = '&nbsp;€';
	if (document.cookie.indexOf("devise=f")!=-1) {
		nb*=6.55957;
		symb ='&nbsp;F';
		document.getElementById(elem).className='devise2';
	}
	else document.getElementById(elem).className='devise1';
	var ret = (Math.round(nb*100)/100).toString();
	ret = ret.replace('.',',');
	ret = ret.replace(/(\,\d)$/,"$1"+"0");
	ret += symb
	if (elem=='total') document.getElementById(elem).innerHTML = "<span style='font-weight:bold;font-size:15px;'>"+ret+"</span>";
	else if (elem.indexOf('benef')!=-1) document.getElementById(elem).innerHTML = "<span style='font-weight:bold;color:#FF5F00;'>"+ret+"</span>";
	else if (elem.indexOf('pr_')!=-1) document.getElementById(elem).innerHTML = "<span class=devise3>"+ret+"</span>";
	else document.getElementById(elem).innerHTML = ret;
}

function prixSwitch(devise) {
	if (devise == 'e') {
		var img = document.getElementsByName('euro');
		for (var i=0; i<img.length; i++) img[i].src = "initiatives/images/deviseeuroon.gif";
		var img = document.getElementsByName('francs');
		for (var i=0; i<img.length; i++) img[i].src = "initiatives/images/devisefrancsoff.gif";
		document.cookie="devise=e;path=/";
	} 
	else if (devise == 'f' || document.cookie.indexOf("devise=f")!=-1) {
		var img = document.getElementsByName('euro');
		for (var i=0; i<img.length; i++) img[i].src = "initiatives/images/deviseeurooff.gif";
		var img = document.getElementsByName('francs');
		for (var i=0; i<img.length; i++) img[i].src = "initiatives/images/devisefrancson.gif";
		document.cookie="devise=f;path=/";
	}
	//prixFormat('port',fraisport);
	prixUpdate();
}

function getRadio(nom) {
	var radios = document.getElementsByName(nom);
	var value=null;
	for (var i=0; i<radios.length; i++) {
		if (radios[i].checked) {
			value=radios[i].value;
			break;
		}
	}
	return value;
}
function resetRadio(nom) {
	var radios = document.getElementsByName(nom);
	for (var i=0; i<radios.length; i++) {
		radios[i].checked=false;
	}
}

function setValue(nom,enc) {
	valeur = unescape(enc);
	var objs = document.getElementsByName(nom);
	if (!objs.length) return;
	switch (objs[0].tagName) {
		case 'A':
			objs[0].href=valeur;
			objs[0].innerHTML="<span style='color:red'>Cliquez ici pour vérifier le fichier que vous avez téléchargé<br></span>";
		break;
		case 'TEXTAREA':
			objs[0].value=valeur;
		break;
		case 'SELECT':
			for (var i=0; i<objs[0].length; i++) {
				if (objs[0][i].value==valeur) {
					objs[0].selectedIndex=i;
					break;
				}
			}
		break;
		case 'INPUT':
			switch (objs[0].type) {
				case 'text':
					objs[0].value=valeur;
				break;
				case 'hidden':
					objs[0].value=valeur;
				break;
				case 'radio':
					for (var i=0; i<objs.length; i++) {
						if (objs[i].value==valeur) {
							objs[i].checked=true;
							break;
						}
					}
				break;
				case 'checkbox':
					objs[0].checked=true;
				break;
			}
		break;
	}
}

function err (str) {
	alert(str);
	return false;
}

function roll (obj,action) {
	if (action=='over') {
		if (obj.getAttribute('sel')!=1) obj.style.backgroundImage = 'url(/initiatives/images/grille_survol.gif)';
	}
	else if (action=='out') {
		if (obj.getAttribute('sel')!=1) obj.style.backgroundImage = 'none';
	}
	else if (action=='click') {
		var cn = obj.parentNode.childNodes;
		for (i=0;i<cn.length;i++) {
			if (cn[i].tagName=='TR') {
				cn[i].style.backgroundImage = 'none';
				cn[i].setAttribute('sel',0);
			}
		}
		obj.style.backgroundImage = 'url(/initiatives/images/grille_selection.gif)';
		obj.setAttribute('sel',1);
	}
}

function qtChange (id,nb) {
	document.getElementById('qt_'+id).value = nb;
	prixUpdate();
}
// pr bug safari
function unescape(enc) {
	var t=enc.split('%');
	var dec=t[0];
	for (var i=1;i<t.length;i++) {
		dec+=String.fromCharCode(parseInt(t[i].substr(0,2),16));
		dec+=t[i].substr(2,t[i].length-2);
	}
	return dec;
}

function dateCheck(j,m,a) {
	var s=new String();
	s=j.toString()+m.toString()+a.toString();
	if (s.length==0) return true;
	var nd=31;
	if ( (m<7 && m%2==0) || (m>8 && m%2) ) nd=30;
	if (m==2) {
		nd = (a%4) ? 28 : 29;
	}
	if (j>0 && j<=nd && m>0 && m<13 && a>2002 && s.match(/^\d+$/)) return true;
	return false;
}

function popupNomenclature(ref) {
	try {w.focus()} catch(e) {}
	w = window.open('','img','width=780,height=500,scrollbars,resizable,');
	w.document.write("\
		<html><head><title>Lot tombola</title>\
		</head>\
		<body onLoad='focus();'>\
		<table height=100% width=100%><tr><td align=center valign=middle>\
		<img src='/initiatives/images/composants/"+ref+".jpg' border=0>\
		</table>\
		</body></html>\
	");
	w.document.close();
}

function trimFields(form) {
	var l = form.getElementsByTagName('INPUT');
	for (var i=0;i<l.length;i++) {
		if (l[i].type!="text" && l[i].type!="password") continue;
		l[i].value = l[i].value.replace(/[\r\n\t]/g,'');
		l[i].value = l[i].value.replace(/(^ +)|( +$)/g,'');
	}
}

function persoOpen(id,frombdc) {
	frombdc = (frombdc)?1:0;
	if ( !MM_FlashCanPlay ) {
		if (confirm("Pour utiliser l'interface de personnalisation, vous devez disposer de flash player version 6 ou supérieur\nSouhaitez-vous être redirigé maintenant sur la page de téléchargement ?\n\nRemarque: l'installation est très rapide même avec une connexion bas débit\n(Nous vous conseillons de décocher l'installation de yahoo toolbar, si elle vous est proposée)")) document.location="http://www.macromedia.com/go/getflashplayer";
		return;
	}

	if (prixErreur) {
		alert('La quantité commandée est invalide');
		return;
	}
	
	top.window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth) {
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
	document.body.scrollTop = 0 ;
	var w = document.body.clientWidth-20;
	var h = document.body.clientHeight-20;

	if (!document.getElementById('persoMasque')) {
		var persoMasque = document.createElement('DIV');
		persoMasque.id = "persoMasque";
		persoMasque.style.position = "absolute";
		persoMasque.style.top = 0;
		persoMasque.style.left = 0;
		persoMasque.style.zIndex = 200000;
		persoMasque.style.width = (document.body.offsetWidth>document.body.scrollWidth) ? document.body.offsetWidth : document.body.scrollWidth;
		persoMasque.style.height = (document.body.offsetHeight>document.body.scrollHeight) ? document.body.offsetHeight : document.body.scrollHeight;
		persoMasque.style.backgroundColor = "black";
		if (!(navigator.userAgent.indexOf('Macintosh')!=-1 && navigator.userAgent.indexOf('Gecko')!=-1 && navigator.userAgent.indexOf('Safari')==-1)) persoMasque.style.opacity = 0.6;
		persoMasque.style.filter = "alpha(opacity=60)";
		document.body.appendChild(persoMasque);
	}
	document.getElementById('persoMasque').style.visibility = "visible";

	if (!document.getElementById('persoPreloder')) {
		var persoPreloder = document.createElement('DIV');
		persoPreloder.innerHTML = "Chargement de l'interface en cours...";
		persoPreloder.id = "persoPreloder";
		persoPreloder.style.padding = 15;
		persoPreloder.style.background = 'white';
		persoPreloder.style.color = 'orange';
		persoPreloder.style.fontSize = 15;
		persoPreloder.style.position = "absolute";
		persoPreloder.style.visibility = "visible";
		persoPreloder.style.zIndex = 200001;
		document.body.appendChild(persoPreloder);
	}
 	document.getElementById('persoPreloder').style.top = document.body.clientHeight/2 - document.getElementById('persoPreloder').offsetHeight/2;
 	document.getElementById('persoPreloder').style.left = document.body.clientWidth/2 - document.getElementById('persoPreloder').offsetWidth/2;

	if (!document.getElementById('persoLayer')) {
		var persoLayer = document.createElement('DIV');
		persoLayer.id = "persoLayer";
		persoLayer.style.position = "absolute";
		persoLayer.style.visibility = "visible";
		persoLayer.style.top = -4000;
		persoLayer.style.left = 20;
		persoLayer.style.zIndex = 200010;
		persoLayer.style.width = "100%";
		persoLayer.style.height = "100%";
		document.body.appendChild(persoLayer);
	}
	var flash_ratio = 800/500;
	
	var w = document.body.clientWidth-30;
	var h = document.body.clientHeight-30;

	if (flash_ratio > (w/h) ) {
		h = Math.round(w/flash_ratio);
	}
	else {
		w = Math.round(h*flash_ratio);
	}
	
	document.getElementById('persoLayer').innerHTML = '\
	<OBJECT WIDTH='+w+' HEIGHT='+h+' ALIGN="top" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ID="test_layer">\
	 <PARAM NAME=movie VALUE="/initiatives/perso/perso.swf?id='+id+'&frombdc='+frombdc+'">\
	 <PARAM NAME=quality VALUE=high>\
	 <PARAM NAME=salign VALUE=LT>\
	 <PARAM NAME=bgcolor VALUE=#FFFFFF>\
	 <PARAM NAME=align VALUE=top>\
	 <EMBED src="/initiatives/perso/perso.swf?id='+id+'&frombdc='+frombdc+'" quality=high salign=LT bgcolor=#FFFFFF WIDTH='+w+' HEIGHT='+h+' swLiveConnect=true ID="test_layer" NAME="test_layer" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>\
	</OBJECT>\
	';
	
	if (!document.getElementById('persoUpload')) {
		var persoUpload = document.createElement('DIV');
		persoUpload.id = "persoUpload";
		persoUpload.style.position = "absolute";
		persoUpload.style.top = -500;
		persoUpload.style.left = -500;
		persoUpload.style.zIndex = 200002;
		persoUpload.style.backgroundColor = "#e8e4d5";
		persoUpload.style.color = "black";
		persoUpload.style.border = "1px solid #a5a398";
		persoUpload.style.fontSize = "13px";
		persoUpload.style.fontFamily = "arial";
		persoUpload.style.width = "550";
		persoUpload.style.padding = "10px";
		document.body.appendChild(persoUpload);
	}
	document.getElementById('persoUpload').innerHTML = "\
		<p style='font-weight:bold;color:black;font-size:18'>Choix d'une image sur votre ordinateur</p>\
		<form method=post enctype='multipart/form-data' name=formupload target=bg onsubmit=\"document.formupload.telecharger.disabled = true;startUploadMonitor()\">\
		<input type=hidden name=id>\
		<input type=hidden name=width>\
		<input type=hidden name=height>\
		<input type=hidden name=minres>\
		<input type=hidden name=bordure>\
		<input type=hidden name=zoom>\
		<table>\
		<tr valign=top>\
		<td>\
		<div style='width:30;height:30;font-family:arial;color:white;text-align:center;font-size:20;font-weight:bold;line-height:30px;background-image:url(/initiatives/images/fond_etage.gif)'>1</div>\
		</td>\
		<td style='color:black;font-size:12px'>\
		Cliquez sur le bouton ci-dessous pour sélectionner l'image sur votre ordinateur<br><br>\
		<center><input type=file name=image style='margin-bottom:10px;'></center>\
		</td>\
		</tr>\
		<tr valign=top>\
		<td>\
		<div style='width:30;height:30;font-family:arial;color:white;text-align:center;font-size:20;font-weight:bold;line-height:30px;background-image:url(/initiatives/images/fond_etage.gif)'>2</div>\
		</td>\
		<td style='color:black;font-size:12px'>\
		Cliquez ensuite sur le bouton \"Télécharcher\" et attendre jusqu'à la fin de téléchargement<br>\
		<small>(A titre indicatif pour une image de 1000 Ko (=1Mo), le temps de téléchargement est de cinq minutes avec un modem et une minute en ADSL)</small><br><br>\
		<center>\
		<input type=submit name=telecharger value=Télécharger onclick=\"if (!document.formupload.image.value) {alert('Vous devez d\\'abord sélectionner votre image');return false}\">&nbsp;<input type=button name=annuler value=Annuler onclick=\"frames['bg'].location.href='/initiatives/perso/upload.php?annuler=1&id='+document.formupload.id.value\">\
		<div style='background:#eeeeee;width:200;height:10;text-align:left;margin-top:15'><div id=progressbar style='background:green;width:0;height:100%'></div></div>\
		<div id=progressbarinfo></div>\
		</center>\
		</td>\
		</tr>\
		</table>\
	";
}


function persoLoaded() {
	document.getElementById('persoLayer').style.top = 20;
	document.getElementById('persoPreloder').style.visibility = "hidden";
	moveY('persoLayer',-(document.body.clientWidth/(800/500))-20,20,50,50);
}

function moveY (id,start,end,step,interval) {
	if (start%step) start = Math.round(start/step)*step;
	start += step;
	document.getElementById(id).style.top = start;
	if ( step>0 && (start+step) >= end ) document.getElementById(id).style.top = end;
	else if ( step<0 && (start+step) <= end ) document.getElementById(id).style.top = end;
	else setTimeout("moveY('"+id+"',"+start+","+end+","+step+","+interval+")",interval);
}

function persoClose (produit,commander) {
	document.getElementById('persoMasque').style.visibility = "hidden";
	document.getElementById('persoPreloder').style.visibility = "hidden";
	document.getElementById('persoLayer').style.top = -4000;
	if (document.location.toString().indexOf('id=58')!=-1) document.bdc.submit();
	else if (commander) document.location = '/page.php?id=58&quantite=&produit='+produit;
	else document.location.reload(true);
}

uploadok=false;
function persoUploadStart(id,width,height,minres,bordure,zoom) {
	uploadok=false;

	//document.getElementById('persoLayer').style.top = -4000;
	moveY('persoLayer',document.getElementById('persoLayer').offsetTop,-(document.body.clientWidth/(800/500))-20,-50,50);
	
	document.getElementById('progressbar').style.width=0;
	document.getElementById('progressbarinfo').innerHTML='';
	document.formupload.telecharger.disabled=false;
	//document.formupload.telecharger.style.display = 'inline';
	document.formupload.action='/cgi-bin/upload.cgi?uploadid='+id+"&scripturl="+escape("/initiatives/perso/upload.php");
	document.formupload.id.value = id;
	document.formupload.width.value = width;
	document.formupload.height.value = height;
	document.formupload.minres.value = minres;
	document.formupload.bordure.value = bordure;
	document.formupload.zoom.value = zoom;
	//document.getElementById('upload').style.visibility='visible';
	var obj = document.getElementById('persoUpload');
	obj.style.left = document.body.clientWidth/2 - obj.offsetWidth/2;
	obj.style.top = document.body.clientHeight/2 - obj.offsetHeight/2;
}
function persoUploadEnd() {
	uploadok=true;
	document.getElementById('persoUpload').style.top=-500;
	document.getElementById('persoUpload').style.left=-500;
	//document.getElementById('persoLayer').style.top=20;
	moveY('persoLayer',-(document.body.clientWidth/(800/500))-20,20,50,50);
}

function startUploadMonitor() {
	if (navigator.userAgent.indexOf('MSIE')!=-1 && navigator.userAgent.indexOf('PowerPC')!=-1) {
		document.getElementById('persoUpload').style.top=-500;
		document.getElementById('persoUpload').style.left=-500;
		return;
	}
	if (uploadok) return;
	if (document.getElementById('progressbarjs')) document.body.removeChild(document.getElementById('progressbarjs'));
	var s = document.createElement('SCRIPT');
	s.setAttribute('id','progressbarjs');
	s.setAttribute('src','/uploadmonitor.php?uploadid='+document.formupload.id.value+'&rand='+Math.random());
	document.body.appendChild(s);
	window.setTimeout("startUploadMonitor()",4000);
}
function setProgressbarValues (done,total,starttime,time) {
	var pc = Math.round(100*done/total);
	document.getElementById('progressbar').style.width=pc+'%';
	document.getElementById('progressbarinfo').innerHTML=pc+'% transféré (vitesse '+Math.round(done/(time-starttime)/100)/10+' ko/s)';
	
}
function checkEmail(email) {
	return email.toString().match(/^(\w+\-?\.?_?)*\w+@([\w\-]+\.)+\w+$/);
}

function uniqid () {
	var d = new Date();
	var ts = Date.UTC(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds());
	var r = Math.floor(Math.random()*1000000);
	return (ts.toString()+r.toString())
}

function deleteAccents (chaine) {
  chaine = chaine.replace(/[àâäåãáæ]/gi,"a");
  chaine = chaine.replace(/[éèêë]/gi,"e");
  chaine = chaine.replace(/[ïîìí]/gi,"i");
  chaine = chaine.replace(/[öôóòõø]/gi,"o");
  chaine = chaine.replace(/[ùûüú]/gi,"u");
  chaine = chaine.replace(/[ç]/gi,"c");
  chaine = chaine.replace(/[ÿ]/gi,"y");
  chaine = chaine.replace(/[ñ]/gi,"n");
  return chaine;
}

function JSdecrypt(c) {
	var r = new String;
	for (var i=0;i<c.length;i+=2) {
		r += String.fromCharCode(((isNaN(c.charAt(i))?c.charCodeAt(i)-87:parseInt(c.charAt(i),10))*16+(isNaN(c.charAt(i+1))?c.charCodeAt(i+1)-87:parseInt(c.charAt(i+1),10)))-2-(i/2)%3);
	}
	return r;
}

