function js_showChildrenAge(num_Children) {
	num_ChildrenSelected = num_Children;
	if (str_childages) {
		var aCA = str_childages.split(",");
	}
	document.getElementById('scadd').innerHTML='';
	if (num_Children > 0) {
		var divTag = document.createElement('div');
		var od='<div>';
		for (i=1; i<=num_Children; i++) {
			k=i-1;
			od+='<div class="flightSearchChild">Child '+i+'<br><select id="num_Children'+i+'" name="num_Children'+i+'" onChange="js_updateChildAges()">';
			for (j=2; j<=17; j++) {
				if (j==0) {
					if ((aCA) && (parseInt(aCA[k]) == 0))
						od+='<option value="0" selected>&lt;1</option>';
					else
						od+='<option value="0">&lt;1</option>';
				} else {
					if ((aCA) && (parseInt(aCA[k]) == j)) 
						od+='<option value="'+j+'" selected>'+j+'</option>';
					else
						od+='<option value="'+j+'">'+j+'</option>';
				}
			}
			od+='</select></div>';
		}
		od+='</div><div style="clear:both;padding-top:5px;"></div>';
		divTag.innerHTML = od;
		$('scadd').appendChild(divTag);
		$('SB_ChildrenAges').style.display = '';
	} else {
		document.getElementById('SB_ChildrenAges').style.display = 'none';
	}
	js_updateChildAges();
}

function js_updateChildAges() {
	var ff=document.getElementById('frm_CA');
	var al='';
	if (num_ChildrenSelected > 0) {
		for (i=1; i<=num_ChildrenSelected; i++) {
			if ($('num_Children'+i)) {
				var ca=$('num_Children'+i).value;
				al+=ca+',';
			}
		}
		al=al.substring(0,al.length-1);
		ff.value=al;
	} else {
		if (str_childages) str_childages = '';
		ff.value = '';
	}
}

function js_showCalendar(obj_SDD, calHolder, restrictRange, dat_deptDate) {
	// Create Calendar objects
	var obj_Cal = document.getElementById(calHolder);
	// Hide select list in IE
	if (document.all) {
		$('sNoA').style.visibility = 'hidden';
		$('sNoC').style.visibility = 'hidden';
		$('sBs').style.visibility = 'hidden';
		$('sSs').style.visibility = 'hidden';
	}
	// Make the calendar
	var str_InputCurrentValue = obj_SDD.value;
	if (str_InputCurrentValue != 'dd/mm/yyyy') {
		var firstSlash = str_InputCurrentValue.indexOf('/');
		var secondSlash = str_InputCurrentValue.indexOf('/',firstSlash+1);
		var thisDay = str_InputCurrentValue.substr(0,firstSlash);
		var thisMonth = parseInt(str_InputCurrentValue.substr(firstSlash+1, secondSlash-firstSlash-1)) - 1;
		var thisYear = str_InputCurrentValue.substr(secondSlash+1,4);
		js_MakeCalendar(obj_SDD.id, restrictRange, thisYear, thisMonth, thisDay);

	} else if (dat_deptDate && dat_deptDate != 'dd/mm/yyyy') {
	
		var firstSlash = dat_deptDate.indexOf('/');
		var secondSlash = dat_deptDate.indexOf('/',firstSlash+1);
		var thisDay = dat_deptDate.substr(0,firstSlash);
		var thisMonth = parseInt(dat_deptDate.substr(firstSlash+1, secondSlash-firstSlash-1)) - 1;
		var thisYear = dat_deptDate.substr(secondSlash+1,4);
		
		js_MakeCalendar(obj_SDD.id, restrictRange, thisYear, thisMonth, thisDay);

	} else {
		js_MakeCalendar(obj_SDD.id, restrictRange, CurrentYear, CurrentMonth);
	}
	// Find the position
	var num_SDDPosX = js_findPosX(obj_SDD);
	var num_SDDPosY = js_findPosY(obj_SDD);
	var num_NewTopPos = num_SDDPosY + 21;
	var num_NewLeftPos = num_SDDPosX + 1;
	// Position the calendar
	obj_Cal.style.top = num_NewTopPos + 'px';
	obj_Cal.style.left = num_NewLeftPos + 'px';
	// Display the calendar
	obj_Cal.style.visibility = 'visible';
}

function js_hideCalendar(calHolder) {
	document.getElementById(calHolder).style.visibility = 'hidden';
	// Show select list in IE
	if (document.all) {
		$('sNoA').style.visibility = 'visible';
		$('sNoC').style.visibility = 'visible';
		$('sBs').style.visibility = 'visible';
		$('sSs').style.visibility = 'visible';
	}
}

function js_findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function js_findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function js_SwitchForm(str_FormType) {
	switch (str_FormType){
		case 'IT':
			$('sDAL').style.display = 'inline';
			$('sDL').style.display = 'none';
			$('sDA').style.display = 'none';
			$('SB_DestResortSearch').style.display = 'block';
			$('SB_FlightType').style.display = 'none';
			$('SB_SearchFrom').style.display = 'inline';
			$('SB_DestFieldName').innerHTML = 'Island holiday to';
			$('SB_DateFieldName1').innerHTML = 'Departing';
			$('SB_DateFieldName2').innerHTML = 'Returning';
			$('SB_BoardSearchDivider').style.display = 'block';
			$('SB_BoardSearch').style.display = 'block';
			$('SB_StarSearch').style.display = 'block';
			break;
		case 'AO':
			$('sDAL').style.display = 'none';
			$('sDL').style.display = 'inline';
			$('sDA').style.display = 'none';
			$('SB_DestResortSearch').style.display = 'block';
			$('SB_FlightType').style.display = 'none';
			$('SB_SearchFrom').style.display = 'none';
			$('SB_DestFieldName').innerHTML = 'Staying at';
			$('SB_DateFieldName1').innerHTML = 'Arriving';
			$('SB_DateFieldName2').innerHTML = 'Leaving';
			$('SB_BoardSearchDivider').style.display = 'block';
			$('SB_BoardSearch').style.display = 'block';
			$('SB_StarSearch').style.display = 'block';
			break;
		case 'FO':
			$('sDAL').style.display = 'none';
			$('sDL').style.display = 'none';
			$('sDA').style.display = 'inline';
			$('SB_DestResortSearch').style.display = 'none';
			$('SB_DestHotelSearch').style.display = 'none';
			$('SB_FlightType').style.display = 'inline';
			$('SB_SearchFrom').style.display = 'inline';
			$('SB_DestFieldName').innerHTML = 'Flying to';
			$('SB_DateFieldName1').innerHTML = 'Departing';
			$('SB_DateFieldName2').innerHTML = 'Returning';
			$('SB_BoardSearchDivider').style.display = 'none';
			$('SB_BoardSearch').style.display = 'none';
			$('SB_StarSearch').style.display = 'none';
			break;
	}
}

function js_getFormType(thisForm) {
	for (i=0; i<3; i++) {
		if (thisForm.frm_searchType[i].checked) {
			var formType = thisForm.frm_searchType[i].value;
			break;
		}
	}
	switch (formType) {
		case 'AO':
			bol_restrictRange = 0;
			break;
		default:
			bol_restrictRange = 1;
	}
}
