function totat_get_ventes(name){
	var key = name.split('_');
	key = key[1];
	price = $("pxp_"+key).innerHTML *1.0 ;
	pv = $("pv_"+key).innerHTML ;
	qty =$("qt_"+key).value ;
	total = price*qty
	total = total.toFixed(2);
	totalpv = pv * qty ;
	totalpv = totalpv.toFixed(2);
	
	
	
	$('total_'+key).innerHTML = total + " &euro;" ;
	$('totalpv_'+key).innerHTML = totalpv + " PV"  ;
	total_gen_vente();
}
function total_gen_vente(){
	var max = __ui ;
	totalGen = 0 ;
	totalGenpv = 0 ;
	
	
	for(i=0;i< max ; i++){
		price = $("pxp_"+i).innerHTML * 1.0;
		pv = $("pv_"+i).innerHTML * 1.0;
		qty =$("qt_"+i).value ;
		total = price*qty
		totalpv = pv * qty ;
		
		totalGenpv = totalGenpv + totalpv ;
		totalGen = totalGen + total ;
	}
	var totalGen = totalGen.toFixed(2);
	var totalGenpv = totalGenpv.toFixed(2);
	
	var pc = document.getElementById("transp").value ;
	pc = pc.replace(',','.') ;
	pc = pc*1.0 ;
	pc = 1+pc ;
	totaltransport = totalGen*pc;
	var totaltransport = totaltransport.toFixed(2);
	$('gen').innerHTML = totalGen +" &euro;" ;
	$('genpv').innerHTML = totalGenpv+" PV"  ;
	$('gentran').innerHTML = totaltransport +" &euro;"  ;
}


function add_row_nc(id){
	//alert(__ui);
__ui =0 ;	
var t = document.getElementById(id) ;
var r  = document.createElement('tr');
var ca = document.createElement('td');
var cb = document.createElement('td');
cb.innerHTML = "<div id='idp_" + __ui+"'></div>";
var cc = document.createElement('td'); 
var cd = document.createElement('td');
cd.innerHTML = "<div id='pxp_" + __ui+"'></div>";
var ce = document.createElement('td');
ce.innerHTML = "<div id='pv_" + __ui+"'></div>";
var cf = document.createElement('td');
cf.innerHTML = "<div id='total_" + __ui+"'></div>";
var cg = document.createElement('td');
cg.innerHTML = "<div id='totalpv_" + __ui+"'></div>";
var ta = document.createElement('input');

ta.name = 'ref_' + __ui ;
ta.id='ref_' + __ui ;
ta.setAttribute("onChange","getproduit('ref_" + __ui+"','px_"+__ui+"');");
ta.setAttribute("onKeyup","load('idp_"+ __ui+"');");
ta.size=6 ;
var tb = document.createElement('input');
tb.name = 'px_' + __ui ;
tb.id='px_' + __ui ;
tb.type = 'hidden';

var tc = document.createElement('input');
tc.name='qt_' + __ui ;
tc.id='qt_' + __ui ;
tc.setAttribute("onChange","totat_get_ventes('qt_"+__ui+"');");
tc.value=0;
tc.size=6;

ca.appendChild(ta);
cc.appendChild(tc);
cd.appendChild(tb);	

r.appendChild(ca);
r.appendChild(cb);
r.appendChild(cc);
r.appendChild(cd);
r.appendChild(ce);
r.appendChild(cf);
r.appendChild(cg);
t.appendChild(r);
__ui++ ;
}
function add_row_nc_10(){
	for(i=0;i<10;i++){
		add_row_nc('tbl');
	}
}