function removeAllRows(parent){
	if ( parent.hasChildNodes() ){
		while ( parent.childNodes.length >= 1 ){
			parent.removeChild( parent.firstChild );       
		} 
	}
}

function createNightRow(Parent){
	var RowDIV = document.createElement('DIV');
	RowDIV.style.width = "100%";
	RowDIV.style.clear = "both";
	RowDIV.style.height = "20px";
	
	/*============ Create Rom Caption ===============*/
	var CaptionDIV = document.createElement('DIV');
	CaptionDIV.style.width = "124px";
	CaptionDIV.className = "RowNightDIV";
	CaptionDIV.style.padding = "3px 0px 0px 0px";
	CaptionDIV.innerHTML = "Room "+(TotalRooms+1);
	/*===============================================*/
	
	
	/*============ Create Adult Combo ===============*/	
	var AdultComboDIV = document.createElement('DIV');
	AdultComboDIV.style.width = "40px";
	AdultComboDIV.className = "RowNightDIV";
	AdultComboDIV.id = "DIVcmbAdults"+TotalRooms;
	cmbAdults[TotalRooms] = new ComboBox("cmbAdults["+TotalRooms+"]",30,AdultComboDIV);
	cmbAdults[TotalRooms].add(new ComboBoxItem('1',1), new ComboBoxItem('2',2));
	cmbAdults[TotalRooms].choose(1,'1');
	/*===============================================*/
	

	/*============ Create Child Combo ===============*/
		var ChildComboDIV = document.createElement('DIV');
		ChildComboDIV.style.width = "40px";
		ChildComboDIV.className = "RowNightDIV";
		ChildComboDIV.id = "DIVcmbChilds"+TotalRooms;
		cmbChilds[TotalRooms] = new ComboBox("cmbChilds["+TotalRooms+"]",30,ChildComboDIV,TotalRooms);
		cmbChilds[TotalRooms].add(new ComboBoxItem('0',0), new ComboBoxItem('1',1), new ComboBoxItem('2',2));
		cmbChilds[TotalRooms].choose(0,'0');
		
		/*============ Create Ages Combo ===============*/
			cmbChilds[TotalRooms].onChange = function(){
				var index = arguments[0];
				removeAllRows(document.getElementById("DIVChildAges"+index));
				if(cmbChilds[index].value!=0){	
					if(!cmbChilds[index].ages){cmbChilds[index].ages = new Array()}
					
					var CaptionDIV = document.createElement('DIV');
					CaptionDIV.style.width = "84px";
					CaptionDIV.className = "RowNightDIV";
					CaptionDIV.style.padding = "3px 0px 0px 0px";
					CaptionDIV.innerHTML = "Child age *";
					document.getElementById("DIVChildAges"+index).appendChild(CaptionDIV);
					
					for(count=0; count<cmbChilds[index].value; count++){
						var DivAge = document.createElement('DIV');
						DivAge.className = "RowNightDIV";
						DivAge.style.width = "40px";
						cmbChilds[index].ages[count] = new ComboBox("cmbChilds["+index+"].ages["+count+"]",30,DivAge);
						for(i=0;i<=17;i++){
							cmbChilds[index].ages[count].add(new ComboBoxItem(i.toString(),i));
						}
						cmbChilds[index].ages[count].choose(1,'1');
						document.getElementById("DIVChildAges"+index).appendChild(DivAge);
					}	
					document.getElementById("DIVChildAges"+index).style.display = "";
				}else{
					document.getElementById("DIVChildAges"+index).style.display = "none";
					if(cmbChilds[index].ages){
						cmbChilds[index].ages.length = 0;
					}
				}
			}
		/*===============================================*/
	/*===============================================*/
	
	RowDIV.appendChild(CaptionDIV);
	RowDIV.appendChild(AdultComboDIV);
	RowDIV.appendChild(ChildComboDIV);	
	Parent.appendChild(RowDIV);
	
	/*============ Space for AGES DIV ===============*/
	var ChildAgesDIV = document.createElement('DIV');
	ChildAgesDIV.id = "DIVChildAges"+TotalRooms;
	ChildAgesDIV.style.width = "100%";
	ChildAgesDIV.style.clear = "both";
	ChildAgesDIV.style.height = "20px";
	ChildAgesDIV.style.display = "none";
	
	Parent.appendChild(ChildAgesDIV);
	/*===============================================*/
	
	
	TotalRooms += 1;
}
