function RefreshTotal()
{
	var totalRow = 0;
	var total = 0;
	
	for (var i = 0; i < NbCatAvailable; i++)
	{
		var idcat;
		switch (i) {
			case 0 :	
				var select = document.getElementById('BookMain_BookRoom_DLTc1');
				idcat = select.options[select.selectedIndex].value;			
				break;
			case 1 :
				var select = document.getElementById('BookMain_BookRoom_DLTc2');
				idcat = select.options[select.selectedIndex].value;			
				break;
			case 2 :
				var select = document.getElementById('BookMain_BookRoom_DLTc3');
				idcat = select.options[select.selectedIndex].value;			
				break;
			case 3 :
				var select = document.getElementById('BookMain_BookRoom_DLTc4');
				idcat = select.options[select.selectedIndex].value;			
				break;
			case 4 :
				var select = document.getElementById('BookMain_BookRoom_DLTc5');
				idcat = select.options[select.selectedIndex].value;			
				break;
			case 5 :
				var select = document.getElementById('BookMain_BookRoom_DLTc6');
				idcat = select.options[select.selectedIndex].value;			
				break;				
			case 6 :
				var select = document.getElementById('BookMain_BookRoom_DLTc7');
				idcat = select.options[select.selectedIndex].value;			
				break;
			case 7 :
				var select = document.getElementById('BookMain_BookRoom_DLTc8');
				idcat = select.options[select.selectedIndex].value;			
				break;				
			case 8 :
				var select = document.getElementById('BookMain_BookRoom_DLTc9');
				idcat = select.options[select.selectedIndex].value;			
				break;				
			case 9 :
				var select = document.getElementById('BookMain_BookRoom_DLTc10');
				idcat = select.options[select.selectedIndex].value;			
				break;				
			case 10 :
				var select = document.getElementById('BookMain_BookRoom_DLTc11');
				idcat = select.options[select.selectedIndex].value;			
				break;				
			case 11 :
				var select = document.getElementById('BookMain_BookRoom_DLTc12');
				idcat = select.options[select.selectedIndex].value;			
				break;	
			case 12 :
				var select = document.getElementById('BookMain_BookRoom_DLTc13');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 13 :
				var select = document.getElementById('BookMain_BookRoom_DLTc14');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 14 :
				var select = document.getElementById('BookMain_BookRoom_DLTc15');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 15 :
				var select = document.getElementById('BookMain_BookRoom_DLTc16');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 16 :
				var select = document.getElementById('BookMain_BookRoom_DLTc17');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 17 :
				var select = document.getElementById('BookMain_BookRoom_DLTc18');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 18 :
				var select = document.getElementById('BookMain_BookRoom_DLTc19');
				idcat = select.options[select.selectedIndex].value;			
				break;								
			case 19 :
				var select = document.getElementById('BookMain_BookRoom_DLTc20');
				idcat = select.options[select.selectedIndex].value;			
				break;								
											
			default :			
		} 		
		
		var ii = getIdTabFromIdCat(idcat);
		totalRow = 0;
		for (var j = 0; j < NbNight; j++)
		{
			totalRow += Number(Price[ii][j]);
		}
		
		switch (i) {
			case 0 :	
				totalRow = totalRow * Number(document.getElementById('NbRoom1').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal1'), str.replace(".", ","));
				break;
			case 1 :
				totalRow = totalRow * Number(document.getElementById('NbRoom2').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal2'), str.replace(".", ","));
				break;
			case 2 :
				totalRow = totalRow * Number(document.getElementById('NbRoom3').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal3'), str.replace(".", ","));
				break;
			case 3 :
				totalRow = totalRow * Number(document.getElementById('NbRoom4').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal4'), str.replace(".", ","));
				break;
			case 4 :
				totalRow = totalRow * Number(document.getElementById('NbRoom5').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal5'), str.replace(".", ","));
				break;
			case 5 :
				totalRow = totalRow * Number(document.getElementById('NbRoom6').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal6'), str.replace(".", ","));
				break;
			case 6 :
				totalRow = totalRow * Number(document.getElementById('NbRoom7').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal7'), str.replace(".", ","));
				break;
			case 7 :
				totalRow = totalRow * Number(document.getElementById('NbRoom8').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal8'), str.replace(".", ","));
				break;
			case 8 :
				totalRow = totalRow * Number(document.getElementById('NbRoom9').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal9'), str.replace(".", ","));
				break;
			case 9 :
				totalRow = totalRow * Number(document.getElementById('NbRoom10').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal10'), str.replace(".", ","));
				break;
			case 10 :
				totalRow = totalRow * Number(document.getElementById('NbRoom11').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal11'), str.replace(".", ","));
				break;
			case 11 :
				totalRow = totalRow * Number(document.getElementById('NbRoom12').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal12'), str.replace(".", ","));
				break;	
			case 12 :
				totalRow = totalRow * Number(document.getElementById('NbRoom13').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal13'), str.replace(".", ","));
				break;				
			case 13 :
				totalRow = totalRow * Number(document.getElementById('NbRoom14').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal14'), str.replace(".", ","));
				break;				
			case 14 :
				totalRow = totalRow * Number(document.getElementById('NbRoom15').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal15'), str.replace(".", ","));
				break;				
			case 15 :
				totalRow = totalRow * Number(document.getElementById('NbRoom16').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal16'), str.replace(".", ","));
				break;				
			case 16 :
				totalRow = totalRow * Number(document.getElementById('NbRoom17').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal17'), str.replace(".", ","));
				break;				
			case 17 :
				totalRow = totalRow * Number(document.getElementById('NbRoom18').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal18'), str.replace(".", ","));
				break;				
			case 18 :
				totalRow = totalRow * Number(document.getElementById('NbRoom19').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal19'), str.replace(".", ","));
				break;				
			case 19 :
				totalRow = totalRow * Number(document.getElementById('NbRoom20').selectedIndex);
				str = totalRow.toFixed(2) + " &euro;";
				changeText(document.getElementById('PriceTotal20'), str.replace(".", ","));
				break;				
											
			default :			
		} 		
		total += totalRow;
	}
	str = total.toFixed(2) + " &euro;";
	changeText(document.getElementById('GrandTotal'), str.replace(".", ","));
	
	if (PaiementArrhesMode == 1) 
	{	// fixe
		str = PaiementArrhesValue.toFixed(2) + " &euro;";	
		changeText(document.getElementById('TotalArrhes'), str.replace(".", ","));	
	}
	else
	{
		str = (total.toFixed(2) / 100 * PaiementArrhesValue).toFixed(2) + " &euro;";		
		changeText(document.getElementById('TotalArrhes'), str.replace(".", ","));	
	}
}
				
function getIdTabFromIdCat(idcat)
{
	for (var j = 0; j < nbCat; j++)
	{
		if (tabCat[j] == idcat)
			return(j);
	}
	alert('Erreur : catégorie non trouvée');
	return (0);
}

function RefreshRow(DPLID, txtRoomAvailable, Description, txtPrice, NbRoom, NbAdult, NbChildren)
{
		var select = document.getElementById(DPLID);
		var idcat = select.options[select.selectedIndex].value;
		var i = getIdTabFromIdCat(idcat);
		changeText(document.getElementById(txtRoomAvailable), NbRoomAvailable[i]);	

		var desc;	
		desc = "";					
		if (NbLargeBed[i] > 1)
			desc = NbLargeBed[i] + " camas 2 pers.";				
		if (NbLargeBed[i] == 1)
			desc = NbLargeBed[i] + " cama 2 pers.";
		if (NbLargeBed[i] >= 1 && NbSmallBed[i] >= 1)
			desc += "<br>";
		if (NbSmallBed[i] > 1)
			desc += NbSmallBed[i] + " camas 1 pers.";				
		if (NbSmallBed[i] == 1)
			desc += NbSmallBed[i] + " cama 1 pers.";
		changeText(document.getElementById(Description), desc);	
/*
		if (NbMaxAdult[i] > 1)
			NbMaxPerson.innerHTML = NbMaxAdult[i] + " adultes";
		else
			NbMaxPerson.innerHTML = NbMaxAdult[i] + " adulte";
			
		if (NbMaxChildren[i] > 1)
			NbMaxPerson.innerHTML += "<br>" + NbMaxChildren[i] + " enfants";
		if (NbMaxChildren[i] == 1)
			NbMaxPerson.innerHTML += "<br>" + NbMaxChildren[i] + " enfant";
*/						
		str = Number(Price[i][0]).toFixed(2) + " &euro;";
		var sprice;
		sprice = str.replace(".", ",");
		
		for (var j = 1; j < NbNight; j++)
		{
			if (Price[i][j] != Price[i][j-1])
			{
				// Prix différent - est-il déjà affiché (cas de 20 € - 30 € - 20 €)
				var bFound = 0;
				for (var jj = 0; jj < j; jj++)
				{
					if (Price[i][j] == Price[i][jj])
						bFound = 1;
				}
				if (bFound == 0)
				{
					str = "<br>/" + Number(Price[i][j]).toFixed(2) + " &euro;*";
					sprice += str.replace(".", ",");
					document.getElementById("Remark").style.display = "block";
				}
			}
		}
		
		changeText(document.getElementById(txtPrice), sprice);	

		document.getElementById(NbRoom).options.length = 0;
		for (var j = 0; j <= NbRoomAvailable[i]; j++)
			document.getElementById(NbRoom).options[j] = new Option(j);

		document.getElementById(NbAdult).options.length = 0;
		for (var j = 0; j <= NbMaxAdult[i]; j++)
			document.getElementById(NbAdult).options[j] = new Option(j);

		document.getElementById(NbChildren).options.length = 0;
		for (var j = 0; j <= NbMaxChildren[i]; j++)
			document.getElementById(NbChildren).options[j] = new Option(j);
}

function RoomRefresh(row)
{
	switch (row) {
		case 0 :			
			RefreshRow('BookMain_BookRoom_DLTc1', 'NbRoomAvailable1', 'Description1', 'txtPrice1', 'NbRoom1', 'NbAdult1', 'NbChildren1');											
			break;
		case 1 :
			RefreshRow('BookMain_BookRoom_DLTc2', 'NbRoomAvailable2', 'Description2', 'txtPrice2', 'NbRoom2', 'NbAdult2', 'NbChildren2');
			break;
		case 2 :
			RefreshRow('BookMain_BookRoom_DLTc3', 'NbRoomAvailable3', 'Description3', 'txtPrice3', 'NbRoom3', 'NbAdult3', 'NbChildren3');
			break;
		case 3 :
			RefreshRow('BookMain_BookRoom_DLTc4', 'NbRoomAvailable4', 'Description4', 'txtPrice4', 'NbRoom4', 'NbAdult4', 'NbChildren4');
			break;
		case 4 :
			RefreshRow('BookMain_BookRoom_DLTc5', 'NbRoomAvailable5', 'Description5', 'txtPrice5', 'NbRoom5', 'NbAdult5', 'NbChildren5');
			break;
		case 5 :
			RefreshRow('BookMain_BookRoom_DLTc6', 'NbRoomAvailable6', 'Description6', 'txtPrice6', 'NbRoom6', 'NbAdult6', 'NbChildren6');
			break;
		case 6 :
			RefreshRow('BookMain_BookRoom_DLTc7', 'NbRoomAvailable7', 'Description7', 'txtPrice7', 'NbRoom7', 'NbAdult7', 'NbChildren7');
			break;
		case 7 :
			RefreshRow('BookMain_BookRoom_DLTc8', 'NbRoomAvailable8', 'Description8', 'txtPrice8', 'NbRoom8', 'NbAdult8', 'NbChildren8');
			break;
		case 8 :
			RefreshRow('BookMain_BookRoom_DLTc9', 'NbRoomAvailable9', 'Description9', 'txtPrice9', 'NbRoom9', 'NbAdult9', 'NbChildren9');
			break;
		case 9 :
			RefreshRow('BookMain_BookRoom_DLTc10', 'NbRoomAvailable10', 'Description10', 'txtPrice10', 'NbRoom10', 'NbAdult10', 'NbChildren10');
			break;
		case 10 :
			RefreshRow('BookMain_BookRoom_DLTc11', 'NbRoomAvailable11', 'Description11', 'txtPrice11', 'NbRoom11', 'NbAdult11', 'NbChildren11');
			break;
		case 11 :
			RefreshRow('BookMain_BookRoom_DLTc12', 'NbRoomAvailable12', 'Description12', 'txtPrice12', 'NbRoom12', 'NbAdult12', 'NbChildren12');
			break;	
		case 12 :
			RefreshRow('BookMain_BookRoom_DLTc13', 'NbRoomAvailable13', 'Description13', 'txtPrice13', 'NbRoom13', 'NbAdult13', 'NbChildren13');
			break;
		case 13 :
			RefreshRow('BookMain_BookRoom_DLTc14', 'NbRoomAvailable14', 'Description14', 'txtPrice14', 'NbRoom14', 'NbAdult14', 'NbChildren14');
			break;
		case 14 :
			RefreshRow('BookMain_BookRoom_DLTc15', 'NbRoomAvailable15', 'Description15', 'txtPrice15', 'NbRoom15', 'NbAdult15', 'NbChildren15');
			break;
		case 15 :
			RefreshRow('BookMain_BookRoom_DLTc16', 'NbRoomAvailable16', 'Description16', 'txtPrice16', 'NbRoom16', 'NbAdult16', 'NbChildren16');
			break;
		case 16 :
			RefreshRow('BookMain_BookRoom_DLTc17', 'NbRoomAvailable17', 'Description17', 'txtPrice17', 'NbRoom17', 'NbAdult17', 'NbChildren17');
			break;
		case 17 :
			RefreshRow('BookMain_BookRoom_DLTc18', 'NbRoomAvailable18', 'Description18', 'txtPrice18', 'NbRoom18', 'NbAdult18', 'NbChildren18');
			break;
		case 18 :
			RefreshRow('BookMain_BookRoom_DLTc19', 'NbRoomAvailable19', 'Description19', 'txtPrice19', 'NbRoom19', 'NbAdult19', 'NbChildren19');
			break;
		case 19 :
			RefreshRow('BookMain_BookRoom_DLTc20', 'NbRoomAvailable20', 'Description20', 'txtPrice20', 'NbRoom20', 'NbAdult20', 'NbChildren20');
			break;
					
		default :			
	} 
	RefreshTotal();
}

function changeText(element, text)
{
	//if (element.hasChildNodes()) element.removeChild(element.firstChild);
	//var x = document.createTextNode(text);
	//element.appendChild(x);	
	// OU
	//element.firstChild.nodeValue = text;
	// FINALLY CAUSE <br> in text
	if (isNS4)
	{
		var l = document.layers[element].document;
		l.open();
		l.write(text);
		l.close();	
	}
	else
		if (isIE4)
		{
			eval(element).innerHTML = text;
			eval(element).valeur = text;		
		}
		else
			element.innerHTML = text;
}

function ShowRoom(row)
{
	var DPLID;
	switch (row) {
		case 0 :			
			DPLID = 'BookMain_BookRoom_DLTc1';
			break;
		case 1 :
			DPLID = 'BookMain_BookRoom_DLTc2';
			break;
		case 2 :
			DPLID = 'BookMain_BookRoom_DLTc3';
			break;
		case 3 :
			DPLID = 'BookMain_BookRoom_DLTc4';
			break;
		case 4 :
			DPLID = 'BookMain_BookRoom_DLTc5';
			break;
		case 5 :
			DPLID = 'BookMain_BookRoom_DLTc6';
			break;
		case 6 :
			DPLID = 'BookMain_BookRoom_DLTc7';
			break;
		case 7 :
			DPLID = 'BookMain_BookRoom_DLTc8';
			break;
		case 8 :
			DPLID = 'BookMain_BookRoom_DLTc9';
			break;
		case 9 :
			DPLID = 'BookMain_BookRoom_DLTc10';
			break;
		case 10 :
			DPLID = 'BookMain_BookRoom_DLTc11';
			break;
		case 11 :
			DPLID = 'BookMain_BookRoom_DLTc12';
			break;	
		case 12 :
			DPLID = 'BookMain_BookRoom_DLTc13';
			break;
		case 13 :
			DPLID = 'BookMain_BookRoom_DLTc14';
			break;
		case 14 :
			DPLID = 'BookMain_BookRoom_DLTc15';
			break;
		case 15 :
			DPLID = 'BookMain_BookRoom_DLTc16';
			break;
		case 16 :
			DPLID = 'BookMain_BookRoom_DLTc17';
			break;
		case 17 :
			DPLID = 'BookMain_BookRoom_DLTc18';
			break;
		case 18 :
			DPLID = 'BookMain_BookRoom_DLTc19';
			break;
		case 19 :
			DPLID = 'BookMain_BookRoom_DLTc20';
			break;
					
		default :			
	} 

	var select = document.getElementById(DPLID);
	var i = select.options[select.selectedIndex].value;			
	
	//var i = document.getElementById(DPLID)(document.getElementById(DPLID).selectedIndex).value;	
	window.open('../client/RoomFeatures.aspx?id=' + i, 'Room', "top=20,left=20,width=350,height=285,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
	
}
