function getDOMBundleCartSoftware( id, name, quantity, currency, price, isAction ) {

	var line = document.createElement( "tr" );
	if( isAction == true ) {
		line.setAttribute( "onclick", "viewSoftwareDetails( "+id+" );");
	}
	var independantCell = document.createElement( "td" );						
	// LOGO
	cell = independantCell.cloneNode( false );
	cell.innerHTML = "<img src=../images/"+id+"/"+id+"_icone.jpg>";
	cell.className = "logo";
	line.appendChild( cell );
	// NAME:
	cell = independantCell.cloneNode( false );
	cell.innerHTML = name;
	cell.className = "name";
	line.appendChild( cell );
	// QUANTITY
	cell = independantCell.cloneNode( false );
//GGF2	cell.innerHTML = quantity;
	cell.id="qty_"+id;
	cell.className = "quantity";
	line.appendChild( cell );
	// LESS:
	if( isAction == true ) {
		cell = independantCell.cloneNode( false );
		cell.innerHTML = "<div class='less' onclick='remove_product("+id+")'></div>";
		line.appendChild( cell );
	}
	// AMOUNT
	cell = independantCell.cloneNode( false );
	cell.className = "price";
	var currency = currency;
	var amount = null;
	if( currency == "USD" ) {
		amount = "$" + price;
	} else {
		amount = price + " &euro;";
	}						
	cell.innerHTML = amount;
	line.appendChild( cell );
	
	return line;
}

var rebateTitle = false;
function checkAndAddRebateTitle( tbodyRebateSofts ) {
	if( rebateTitle == false ) {
		var titleRebateSoft = document.createElement( "th" );
		titleRebateSoft.id = "rebateTitle";
		titleRebateSoft.className = "recipeTitle";
		titleRebateSoft.innerHTML = "Fixed discount apps";
		titleRebateSoft.setAttribute( "colspan",5 );
		tbodyRebateSofts.appendChild( titleRebateSoft );
		rebateTitle =true;
	}
}

var bundleTitle = false;
function checkAndAddBundleTitle( tbodyBundleSofts ) {
	/*if( bundleTitle == false ) {
		var titleBundleSoft = document.createElement( "th" );
		titleBundleSoft.id = "rebateTitle";
		titleBundleSoft.className = "recipeTitle";
		titleBundleSoft.innerHTML = "My recipe";
		titleBundleSoft.setAttribute( "colspan",5 );
		tbodyBundleSofts.appendChild( titleBundleSoft );
		bundleTitle =true;
	}*/
}

function getDOMRebateCartSoftware( id, name, quantity, currency, price, isAction ) {

	var line = document.createElement( "tr" );
	if( isAction == true ) {
		line.setAttribute( "onclick", "viewSoftwareDetails( "+id+" );");
	}
	var independantCell = document.createElement( "td" );						
	// LOGO
	cell = independantCell.cloneNode( false );
	cell.innerHTML = "<img src=../images/"+id+"/"+id+"_icone.jpg>";
	cell.className = "logo";
	line.appendChild( cell );
	// NAME:
	cell = independantCell.cloneNode( false );
	cell.innerHTML = name;
	cell.className = "name";
	line.appendChild( cell );
	// QUANTITY
	cell = independantCell.cloneNode( false );
//GGF2	cell.innerHTML = quantity;
	cell.className = "quantity";
	line.appendChild( cell );
	// LESS:
	if( isAction == true ) {
		cell = independantCell.cloneNode( false );
		cell.innerHTML = "<div class='less' onclick='remove_product("+id+")'></div>";
		line.appendChild( cell );
	}
	// AMOUNT
	cell = independantCell.cloneNode( false );
	cell.className = "price";
	var currency = currency;
	var amount = null;
	if( currency == "USD" ) {
		amount = "$" + price;
	} else {
		amount = price + " &euro;";
	}						
	cell.innerHTML = amount;
	line.appendChild( cell );
	
	return line;
}

function getDOMBundleCartTotals(quantityUp, rebatePercentUp, actualRebate, totalRebate, total, economy , currency ) {
	var table = document.createElement( "table" );
	var tbody = document.createElement( "tbody" );
	//table.className = "totals";
	
	// information
	if( quantityUp > 0 ) { // change this !!! ??
		var information = document.createElement( "tr" );
		information.className = "information";
	
		var app = ( quantityUp > 1 )?"apps":"app";
		var html = "Add <span style='font-size:18px'>"+quantityUp+"</span> "+app+" and get ";
		html += "<span style='font-size:18px'>"+rebatePercentUp + "% </span>rebate on each products !";
	
		var td = document.createElement( "td" );
		td.setAttribute( "colspan", "2" );
		td.innerHTML = html;
		
		information.appendChild( td );
		tbody.appendChild( information );
	}
	// old total
	var oldTotal = document.createElement( "tr" );
	oldTotal.className = "oldTotal";
	appendCell( oldTotal, "Sub total &nbsp;:&nbsp;", null );
	appendCell( oldTotal, "&nbsp;"+formatPrice( total, currency ), "number" );
	tbody.appendChild( oldTotal );
	
	// rebate
	var rebateDetails = document.createElement( "tr" );
	html = "<span class='reductionPercent'><span style='font-size:13px'>- "+actualRebate+"%</span> rebate on each products</span>";
	var td = document.createElement( "td" );
	td.innerHTML = html;
	td.setAttribute( "colspan", 2 );	
	rebateDetails.appendChild( td );	
//	appendCell( rebateDetails, html, null );
	//appendCell( rebateDetails, "-&nbsp;&nbsp;"+formatPrice( economy, currency ) , 'reductionPrice' );
//	appendCell( rebateDetails, "-&nbsp;&nbsp;"+actualRebate+"%" , 'reductionPrice' );
	tbody.appendChild( rebateDetails );	
	
//	GGF2
	// total
	if( _step == "validation" ) {
		var totalEl = document.createElement( "tr" );
		appendCell( totalEl, "Total&nbsp;:&nbsp;", null );
		appendCell( totalEl, "&nbsp;"+formatPrice( totalRebate, currency ), "total" );
		tbody.appendChild( totalEl );
	}
	table.appendChild( tbody );
	
	return table;
}

/* return a tr line */
function getDOMRebateCartTotals( total, currency ) {
	var div = document.createElement( "div" );
	div.className = "rebateTotal";
	div.innerHTML = "Total&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+formatPrice( total, currency );
	return div;
	
	/*
	var line = document.createElement( "tr" );
	line.className = "line";
	
	var td = document.createElement("td");
	td.setAttribute( "colspan", 3 );
	td.innerHTML = formatPrice( total, currency );
	line.appendChild( td );
	
	return line;*/
}

function appendCell( parent, text, className ) {
	var td = document.createElement( "td" );
	td.innerHTML = text;
	if( className ) {
		td.className = className;
	}
	parent.appendChild( td );
}