var adults=new Array();
var adults_index = 0;

var allreadyAdults;
var allreadyChildren;

function Children(num) {
	this.index=num;
}

function addChildren(num) {
	//alert("children added" + this.index);
	this.children[this.index] = new Children(num);
	this.index++;
	
}

function showChildrens(obj) {
	//alert("mpike");
	for(var y=obj.options.length-1; y>=0; y--) {
		obj.options[y] = null;
	}
	
	obj.disabled = false;

	for(var i=0; i<this.index; i++) {
		//alert(i);
		obj.options[i] = new Option(i);
		obj.options[i].value = i;
		
		if(allreadyChildren!=null) {
			if(allreadyChildren == this.children[i].index) { // if allready exist coutry definition in session...
				obj.options[i].selected = true;
			}
		}
	}
		if(allreadyChildren==null) {
			//if(allreadyChildren == this.children[i-1].index) { // if allready exist coutry definition in session...
				obj.options[0].selected = true;
			//}
		}
}

function Adults(num) {
	this.index = 0;
	this.children = new Array();

	this.addChildren = addChildren;
	this.showChildrens = showChildrens;
}

function changeData2(obj1,obj2) {
	//if(obj1.selectedIndex == 0) {
		//obj2.options[0].selected == true;
		//obj2.disabled = true;
		//return;
	//}
	adults[obj1.selectedIndex].showChildrens(obj2);
}

function showAdults(obj) {
	//alert(adults_index);
	for(var y=1; y<=obj.options.length; y++) {
		obj.options[y] = null;
	}

	for(var i=0; i<adults_index; i++) {
		//alert(i);
		obj.options[i] = new Option(i+1);
		obj.options[i].value = i+1;
		
		if(allreadyAdults == i) { // if allready exist coutry definition in session...
			//alert(countries[i-1].code);
			obj.options[i-1].selected = true;
			changeData2(obj,window.document.forma1.children);
		}
		
	}
	
		if(allreadyAdults == null) { // if allready exist coutry definition in session...
			//alert(countries[i-1].code);
			obj.options[0].selected = true;
			changeData2(obj,window.document.forma1.children);
		}
}

function addAdult(c) {
	adults[adults_index] = c;
	adults_index++;
	//alert("adult added" + adults_index);
}