/**
 * This method is used to display room blocks and hide age children blocks as per selection.
 */

    function showDefaultAdults()
	{

		
	}

	function addRoom(){
		var roomDropdown = document.getElementById('inputrooms');
		if(roomDropdown){
			var value = roomDropdown.selectedIndex;
			if(value != 2){
				++value;
				roomDropdown.selectedIndex = value;
				showInfo(); 
			}
		}
	
	}
	
	function removeRoom(){
		var roomDropdown = document.getElementById('inputrooms');
		if(roomDropdown){
			var value = roomDropdown.selectedIndex;
			if(value != 0){
				--value;
				roomDropdown.selectedIndex = value;
				showInfo(); 
			}
		}
		
	}
	
	
	function showInfo()
	{
		var roomDropdown = document.getElementById('inputrooms');
		if(roomDropdown){
			var value = roomDropdown.selectedIndex;
			var removeLink = document.getElementById('removeRoom');
			var addLink = document.getElementById('addRoom');
			
			if(value == 0){
				if(removeLink != null)
				removeLink.style.display = 'none';
			} else {
				if(removeLink != null)
				removeLink.style.display = 'block';
			}
			
			if(value == 2){
				if(addLink != null)
				addLink.style.display = 'none';
			} else {
				if(addLink != null)
				addLink.style.display = 'block';
			}
		}
	
		var elemBlockRoom2 = document.getElementById('room2block');
		var elemLabelRoom2 = document.getElementById('room2label');
		var elemBlockRoom3 = document.getElementById('room3block');
		var elemLabelRoom3 = document.getElementById('room3label');
		
		if(document.forms["search"].noOfRooms.value == "2")	{
				jQuery(elemBlockRoom2).show();
				jQuery(elemLabelRoom2).show();	
				elemBlockRoom3.style.display="none";
				elemLabelRoom3.style.display="none";
				showChildAge(document.getElementById('inputchildren'));
				showChildAge2(document.getElementById('inputchildren2'));
				showChildAge3(document.getElementById('inputchildren3'));
		}
		else if(document.forms["search"].noOfRooms.value == "3") {
				jQuery(elemBlockRoom3).show();
				jQuery(elemLabelRoom3).show();	
				jQuery(elemBlockRoom2).show();
				jQuery(elemLabelRoom2).show();	
				showChildAge2(document.getElementById('inputchildren2'));
				showChildAge3(document.getElementById('inputchildren3'));
		} else if(document.forms["search"].noOfRooms.value == "1") {
			elemBlockRoom2.style.display="none";
			elemLabelRoom2.style.display="none";
			elemBlockRoom3.style.display="none";
			elemLabelRoom3.style.display="none";
			showChildAge(document.getElementById('inputchildren'));
			showChildAge2(document.getElementById('inputchildren2'));
			showChildAge3(document.getElementById('inputchildren3'));
		}
}
	  
/*
 * This method is used to display and hide children age blocks corresponding to room1 as per selection.
 */
function showChildAge(obj,pageOnload) {
	var maxChildOnForm = 6;
	var elemChild1Label = document.getElementById('child1label');
	var elemChild1 = document.getElementById('child1');
	var elemChild2 = document.getElementById('child2');
	var elemChild3 = document.getElementById('child3');
	var elemChild4 = document.getElementById('child4');
	var elemChild5 = document.getElementById('child5');
	var elemChild6 = document.getElementById('child6');
	var childPerRoom;
		
	if(pageOnload){
		childPerRoom = childrenPerRoomArray[0];	
		
		for(var c=0; c< parseInt(childPerRoom); c++){
			var childAgeDropDown =	document.getElementById('child'+parseInt(c + 1)+'Combo');
			for(var x = 0; x < childAgeDropDown.length; x++){
				if(childAgesPerRoomArray[c] == childAgeDropDown[x].value){
					childAgeDropDown.selectedIndex = x;
					break;
				}	
			}
		}
		
	}else{
		childPerRoom = obj.value;
	}
	
	if(childPerRoom == "0") {
		elemChild1Label.style.display="none";
		elemChild1.style.display="none";
		elemChild2.style.display="none";
		elemChild3.style.display="none";
		elemChild4.style.display="none";
		elemChild5.style.display="none";
		elemChild6.style.display="none";
		for (var i = 1; i <= maxChildOnForm; i++) {
			jQuery('#child' + i + 'Error').hide();
		}
	}

	for(i=1; i<=childPerRoom; i++) {
		jQuery('#child' + i).show();
	}
	
	for(i=parseInt(childPerRoom)+1; i<=6; i++) {
		jQuery('#child' + i).hide();
	}
		

}



/*
 * This method is used to display and hide children age blocks corresponding to room2 as per selection.
 */   

function showChildAge2(obj,pageOnload) {
	if(document.forms["search"].noOfRooms.value == "2" || document.forms["search"].noOfRooms.value == "3") {
		var elemChild2Label = document.getElementById('child2label');
		var elemChild7 = document.getElementById('child7');
		var elemChild8 = document.getElementById('child8');
		var elemChild9 = document.getElementById('child9');
		var elemChild10 = document.getElementById('child10');
		var elemChild11 = document.getElementById('child11');
		var elemChild12 = document.getElementById('child12');

		if(pageOnload){
			childPerRoom = childrenPerRoomArray[1];
			
			for(var c=0; c< parseInt(childPerRoom); c++){
				var childAgeDropDown =	document.getElementById('child'+parseInt(c + 7)+'Combo');
				for(var x = 0; x < childAgeDropDown.length; x++){
					if(childAgesPerRoomArray[(c+6)] == childAgeDropDown[x].value){
						childAgeDropDown.selectedIndex = x;
						break;
					}	
				}
			}
		}else{
			childPerRoom = obj.value;
		}

		if(childPerRoom == "0"){
			elemChild2Label.style.display="none";
			elemChild7.style.display="none";
			elemChild8.style.display="none";
			elemChild9.style.display="none";
			elemChild10.style.display="none";
			elemChild11.style.display="none";
			elemChild12.style.display="none";
			for (var i = 7; i <= 12; i++) {
				jQuery('#child' + i + 'Error').hide();
			}
		}
		
		for(i=7; i<= (parseInt(childPerRoom) + 6); i++) {
			jQuery('#child' + i).show();
		}
		
		for(i=parseInt(childPerRoom)+7; i<=12; i++) {
			jQuery('#child' + i).hide();
		}	

	} else {
		for(i=7; i<=12; i++) {
			jQuery('#child' + i).hide();
		}
	}
}		

/*
 * This method is used to display and hide children age blocks corresponding to room3 as per selection.
 */
 function showChildAge3(obj,pageOnload) {
 	if(document.forms["search"].noOfRooms.value == "3") {
		var elemChild3Label = document.getElementById('child3label');
		var elemChild13 = document.getElementById('child13');
		var elemChild14 = document.getElementById('child14');
		var elemChild15 = document.getElementById('child15');
		var elemChild16 = document.getElementById('child16');
		var elemChild17 = document.getElementById('child17');
		var elemChild18 = document.getElementById('child18');

		if(pageOnload){
			childPerRoom = childrenPerRoomArray[2];
			
			for(var c=0; c < parseInt(childPerRoom); c++){
				var childAgeDropDown =	document.getElementById('child'+parseInt(c + 13)+'Combo');
				for(var x = 0; x < childAgeDropDown.length; x++){
					if(childAgesPerRoomArray[(c + 12)] == childAgeDropDown[x].value){
						childAgeDropDown.selectedIndex = x;
						break;
					}	
				}
			}
		}else{
			childPerRoom = obj.value;
		}
		
		if(childPerRoom == "0"){
			elemChild3Label.style.display="none";
			elemChild13.style.display="none";
			elemChild14.style.display="none";
			elemChild15.style.display="none";
			elemChild16.style.display="none";
			elemChild17.style.display="none";
			elemChild18.style.display="none";
			for (var i = 13; i <= 18; i++) {
				jQuery('#child' + i + 'Error').hide();
			}
		}
		
		for(i=13; i<= (parseInt(childPerRoom) + 12); i++) {
			jQuery('#child' + i).show();
		}
		
		for(i=parseInt(childPerRoom)+13; i<=18; i++) {
			jQuery('#child' + i).hide();
		}	
	} else {
		for(i=13; i<=18; i++) {
			jQuery('#child' + i).hide();
		}		
	}
}
   /*
 * This method is used to set the paxmix option to default
 * for destination landing page for ECIS-1
 */
function resetPaxMix() {
	document.getElementById("inputrooms").selectedIndex = 0;
	document.getElementById("inputadults").selectedIndex = 1;
	/* following line is commented to implement FF8600*/
/*	document.getElementById("inputseniors").selectedIndex = 0; */
	document.getElementById("inputchildren").selectedIndex = 0;
	document.getElementById("inputadults2").selectedIndex = 0;
	document.getElementById("inputchildren2").selectedIndex = 0;
	document.getElementById("inputadults3").selectedIndex = 0;
	document.getElementById("inputchildren3").selectedIndex = 0;
	document.getElementById("child1Combo").selectedIndex = 0;
	document.getElementById("child2Combo").selectedIndex = 0;
	document.getElementById("child3Combo").selectedIndex = 0;
	document.getElementById("child4Combo").selectedIndex = 0;
	document.getElementById("child5Combo").selectedIndex = 0;
	document.getElementById("child6Combo").selectedIndex = 0;
	document.getElementById("child7Combo").selectedIndex = 0;
	document.getElementById("child8Combo").selectedIndex = 0;
	document.getElementById("child9Combo").selectedIndex = 0;
	document.getElementById("child10Combo").selectedIndex = 0;
	document.getElementById("child11Combo").selectedIndex = 0;
	document.getElementById("child12Combo").selectedIndex = 0;
	document.getElementById("child13Combo").selectedIndex = 0;
	document.getElementById("child14Combo").selectedIndex = 0;
	document.getElementById("child15Combo").selectedIndex = 0;
	document.getElementById("child16Combo").selectedIndex = 0;
	document.getElementById("child17Combo").selectedIndex = 0;
	document.getElementById("child18Combo").selectedIndex = 0;
}
