// JavaScript Document
// -- Post-rendering script	
var f = document.forms['custom'];  

// set user's resort area if returning to page after error
setSelect(document.forms['custom'].resort_cun, "");     
setSelect(document.forms['custom'].resort_mbj, "");     	

// -- Go with function pointers for explicit call on initial load
function num_of_rooms_onChange() {
	showRoomDetail();
	num_of_children_onChange();
}

function num_of_children_onChange() {
	showHideAgeSelects(f.num_of_rooms.value);
}

function prefix_dep_onFocus() {
	active_dep = true;
}

function prefix_dep_onBlur() {
	active_dep = false; 
	update_dep();
}  

function prefix_des_onFocus() {
	active_des = true;
}

function prefix_des_onBlur() {
	active_des = false; 
	update_des();
}  

// page load activities
function do_page_load() {
	updateResortAreas(); 
	f.departure_city_code.onchange = update_dep;
	f.prefix_dep.onfocus = prefix_dep_onFocus;
	f.prefix_dep.onblur = prefix_dep_onBlur;
	
	f.destination_city_code.onchange = update_des;
	f.prefix_des.onfocus = prefix_des_onFocus;	
	f.prefix_des.onblur = prefix_des_onBlur;	  
	
	f.num_of_rooms.onchange = num_of_rooms_onChange;
	f.num_of_children1.onchange = num_of_children_onChange;
	f.num_of_children2.onchange = num_of_children_onChange;
	f.num_of_children3.onchange = num_of_children_onChange;  
	
	if (f.prefix_des.value != '') setSelect(f.destination_city_code, f.prefix_des.value);
	if (f.prefix_dep.value != '') setSelect(f.departure_city_code, f.prefix_dep.value);
	
	setSelect(document.forms['custom'].num_of_rooms, 0);  
	
	// --Establish event capturing to handle type ahead -->
	if (NS4) document.captureEvents(Event.KEYUP);
	document.onkeyup = checkKey;         
	
	// -- Initial call to making sure rooms display correctly
	if (flights_only()) hideRooms(); 
	else showRooms();
	
	if (f.infants_in_seats[0].checked) hideWarnInLaps();
	else showWarnInLaps();
	// -- both hideRooms and showRooms call showRoomDetail that we
	//    would want to call in num_of_rooms_onChange(). So, we
	//    only need to call num_of_children_onChange() to complete
	//    initialization
	num_of_children_onChange();
	
	//set default package
	if (! (flights_only() || hotel_only() || flights_and_hotel() || packages()) ) {
		update_tabs("SP");;
	} else update_tabs(f.vacation_type.value);
}	

