// Developed by Ermisoft LLC.

function SearchHB(sSt) {
	bValid = Search.SearchValidate();
	
	if (bValid) {
	        f.Show('lblInfo');
        	f.Hide('lblWarning');
	        f.Hide('btnClose');

		SearchHBGo(sSt);
	}
}

function SearchHBGo(sSt) {
	var sReturn='';
	var sURL='';
	
	for (i=1;i<=dd.GetText('ddlRooms'); i++) {
		sReturn+='room'+i+'='+dd.GetText('ddl_'+i+'_Adults')+','+
			dd.GetText('ddl_'+i+'_Children')+','+
			dd.GetText('ddl_'+i+'_Infants');
		if(dd.GetText('ddl_'+i+'_Children')>0) {
			sReturn+='_';
			for (j=1;j<=dd.GetText('ddl_'+i+'_Children'); j++) {
				sReturn+=f.GetValue('txtC_'+i+'_'+j);
				if(j<dd.GetText('ddl_'+i+'_Children')) 
					sReturn+=',';
			}
		}
		sReturn+='&';
	};
	
	aArr=dd.GetValue('calDepartureDate_Day')+'_'+dd.GetValue('calDepartureDate_MonthYear');
	aArr=s.Replace(aArr,'_','/');

	sReturn+='date='+aArr+'&';
	sReturn+='duration='+dd.GetText('ddlDuration')+'&';
	
	nBoard=parseInt(dd.GetValue('sddMealBasisID'));
	if (nBoard>0) sReturn+='mealbasisid='+nBoard+'&';
	
	nRating=parseInt(dd.GetValue('ddlRating'));
	if (nRating>0) sReturn+='minstarrating='+nRating+'&';


	sRes=parseInt(dd.GetValue('sddGeographyLevel3ID'));
	sReg=parseInt(dd.GetValue('sddGeographyLevel2ID'));

	if (sReg == -231) {
		sRes = 231;
		sReg = 53;
	} else if (sReg == -41) {
		sRes = 41;
		sReg = 9;
	}

	
	sReturn+='resortid='+Math.abs(sRes);
	sReturn+='&regionid='+Math.abs(sReg);

	sPrID=f.GetValue('hidPropertyID');
	if (sPrID!='') sReturn+='&propertyid='+sPrID;
	if (sSt!=undefined) 
		sReturn+='&track='+sSt;
	sURL='http://www.holidayroomsdirect.com/property_results.asp?cref=0&'+sReturn;
	//alert(sURL)
	window.location=sURL;
}

function SearchHotels() {
	var frm = document.frmSearch;
	
	var dtNow = new Date();
	var iDay = parseInt(frm.ArrD.options[frm.ArrD.selectedIndex].value);
	var iMonth = parseInt(frm.ArrM.options[frm.ArrM.selectedIndex].value);
	var iYear = parseInt(frm.ArrY.options[frm.ArrY.selectedIndex].value);
	var dtArr = new Date();
	dtArr.setFullYear(iYear, iMonth - 1, iDay);
	
	var sHL;
	
	if (dtArr < dtNow) {
		alert('Please select correct Arr. Date');
		frm.ArrD.focus();
    		return;
	}

	for (var i = 1; i <= frm.Rooms.selectedIndex + 1; i++) {
		var el = eval("frm.AdultsChildren" + i);
		if (el.selectedIndex < 1) {
			alert('Please select a Room Type');
			el.focus();
	    		return;
	    	}
	};
	

	if (frm.Country.selectedIndex <= 0) {
                CheckHiddenSearchForm();

		alert('Please select a Country');
		frm.Country.focus();
		return;
    	};

	if (frm.Dest.selectedIndex <= 0) {
                CheckHiddenSearchForm();

		alert('Please select an Area');
		frm.Dest.focus();
		return;
    	};
	
	//if (frm.Rooms.selectedIndex > 0 && frm.Board.selectedIndex <= 0) {
	//	alert('Please select a Board');
	//	frm.Board.focus();
	//	return;
    	//};

	if (checkSelection(frm.HLType))  {
		for (i = 0; i <= frm.HLType.length - 1; i++) // 2
			if (frm.HLType[i].checked)
				sHL = frm.HLType[i].value;
	}
	if (sHL == "FO" || sHL == "FH") {
		if (frm.DepAirport.selectedIndex <= 0) {
			alert('Please select an Airport');
			frm.DepAirport.focus();
			return;
    		};

	}

	for (var i = 1; i <= frm.Rooms.selectedIndex + 1; i++)  {
		var el1 = eval("frm.AdultsChildren" + i);
		var val1 = el1.options[el1.selectedIndex].value;
		var child1 = parseInt(val1.substring(2,3));
		
		for(var j = 1; j <= child1; j++) {
			var elChildAge = eval("frm.ChildAge" + i + "_" + j);
			if(elChildAge.selectedIndex < 1) {
		    		alert('Please select a child age');
		    		elChildAge.focus();
	    			return;
			}
		}
	};
	
	frm.CountryDesc.value = frm.Country.options[frm.Country.selectedIndex].text;
	frm.DestDesc.value = '';
	frm.ZoneDesc.value = '';
	frm.DepAirportDesc.value = '';
	//frm.BoardDesc.value = '';
	if (frm.Dest.selectedIndex > 0) 
		frm.DestDesc.value = frm.Dest.options[frm.Dest.selectedIndex].text;
	if (frm.Zone.selectedIndex > 0) 
		frm.ZoneDesc.value = frm.Zone.options[frm.Zone.selectedIndex].text;
	if (frm.DepAirport.selectedIndex > 0 && (sHL == "FO" || sHL == "FH")) 
		frm.DepAirportDesc.value = frm.DepAirport.options[frm.DepAirport.selectedIndex].text;

	//if (frm.Board.selectedIndex > 0) 
	//	frm.BoardDesc.value = frm.Board.options[frm.Board.selectedIndex].text;
	
	var frm1 = document.frmCheckAvail;
	if (typeof(frm1) != "undefined")
		frm1.DoCheck.value = "";
	
	if (sHL == 'FL' || sHL == 'FH')
		OpenAni('2')
	else
		OpenAni('1');
	frm.submit();
}

function CheckHiddenSearchForm() {
	elItem = document.all("trSFCountry1");
	if (elItem) {
		if (elItem.style.display == 'none')
		elItem.style.display = 'block';
	}
	elItem = document.all("trSFCountry2");
	if (elItem) {
		if (elItem.style.display == 'none')
		elItem.style.display = 'block';
	}
	elItem = document.all("trSFDest1");
	if (elItem) {
		if (elItem.style.display == 'none')
		elItem.style.display = 'block';
	}
	elItem = document.all("trSFDest2");
	if (elItem) {
		if (elItem.style.display == 'none')
		elItem.style.display = 'block';
	}

}

function SearchHotelsSmall() {
	var frm = document.frmSearch;
	
	var el = frm.AdultsChildren1;
	if (el.selectedIndex < 1) {
		alert('Please select a Room Type');
		el.focus();
    		return;
    	};
	
	frm.submit();
}

function BuyRoom(sCode) {
	SearchHotelsSmall();
}

function BuyHotelRoom() {
	alert("Please complete search form for 'live' availability");
	document.frmSearch.ArrD.focus();
}


function FormatN(iNum, iPos) {
	var iNewNum = iNum;
	for (var i=iNewNum.toString().length; i<iPos; i++)
		iNewNum = '0' + iNewNum;
	return iNewNum;
}

function DateAdd(iDays, dtDate) {
	nFullDay = 1000*60*60*24;
	return new Date(dtDate.getTime() + (iDays * nFullDay));
}

function GetDays(dtDate) {
	nFullDay = 1000*60*60*24;
	return dtDate / nFullDay;
}

function setHLType() {
	var frm = document.frmSearch;
	var st, sHL;
	
	if (!checkSelection(frm.HLType))  {
		for (i = 0; i <= frm.HLType.length - 1; i++)  // 2
			if (frm.HLType[i].value == sHLType)
				frm.HLType[i].checked = true;
	}
	
	if (checkSelection(frm.HLType))  {
		for (i = 0; i <= frm.HLType.length - 1; i++)  // 2
			if (frm.HLType[i].checked)
				sHL = frm.HLType[i].value;
	}
	
	if (sHL == 'HO') {
		st = "none";
		aDs = getAreas();
	}
	else 
	{
		st = "block";
		aDs = getAreasIATA();
	}

	buildCountries();
	
	elItem = document.all("trDepAirport1");
	if (elItem) elItem.style.display = st;
	elItem = document.all("trDepAirport2");
	if (elItem) elItem.style.display = st;
}

function setDeparture() {
	var dtNow = new Date();
	var frm = document.frmSearch;
	var nDur = frm.Duration.value;
	
	var iDay = parseInt(frm.ArrD.options[frm.ArrD.selectedIndex].value);
	var iMonth = parseInt(frm.ArrM.options[frm.ArrM.selectedIndex].value);
	var iYear = parseInt(frm.ArrY.options[frm.ArrY.selectedIndex].value);
	var dtArr = new Date();
	dtArr.setFullYear(iYear, iMonth - 1, iDay);
	
	if (dtArr < dtNow) {
		//dtArr.setFullYear(iYear, iMonth, iDay);
		//setArrivalNextMonth();
		//dtArr.setFullYear(iYear + 1, iMonth - 1, iDay);
		//setArrivalNextYear();
	}
	
	dtDep = DateAdd(nDur, dtArr)
	
	frm.DepD.selectedIndex = dtDep.getDate() - 1;
	frm.DepM.selectedIndex = dtDep.getMonth();
	frm.DepY.selectedIndex = dtDep.getFullYear() - nCurrentYear;
}

function setDuration() {
	var nMaxDur = 30;
	var dtNow = new Date();
	var frm = document.frmSearch;
	
	var iDay = parseInt(frm.DepD.options[frm.DepD.selectedIndex].value);
	var iMonth = parseInt(frm.DepM.options[frm.DepM.selectedIndex].value);
	var iYear = parseInt(frm.DepY.options[frm.DepY.selectedIndex].value);
	var dtDep = new Date(iYear,iMonth - 1,iDay);
	
	var iDay = parseInt(frm.ArrD.options[frm.ArrD.selectedIndex].value);
	var iMonth = parseInt(frm.ArrM.options[frm.ArrM.selectedIndex].value);
	var iYear = parseInt(frm.ArrY.options[frm.ArrY.selectedIndex].value);
	var dtArr = new Date(iYear,iMonth - 1,iDay);
	
	var nDur = GetDays(dtDep - dtArr);
	
	if (nDur < 1) {
		nDur = 1;
		frm.Duration.selectedIndex = nDur - 1;
		setDepartureCorrect();
	} else if (nDur > nMaxDur) {
		nDur = nMaxDur;
		frm.Duration.selectedIndex = nDur - 1;
		setDepartureCorrect();
	} else {
		frm.Duration.selectedIndex = nDur - 1;
	}
}

function setArrivalNextYear() {
	var frm = document.frmSearch;
	
	frm.ArrY.selectedIndex = 1;
	frm.DepY.selectedIndex = 1;
}

function setArrivalNextMonth() {
	var frm = document.frmSearch;
	
	if (frm.ArrM.selectedIndex + 1 < frm.ArrM.length) 
		frm.ArrM.selectedIndex = frm.ArrM.selectedIndex + 1
	else {
		frm.ArrM.selectedIndex = 0;
		frm.ArrY.selectedIndex = frm.ArrY.selectedIndex + 1;
	}
	
	if (frm.DepM.selectedIndex + 1 < frm.DepM.length) 
		frm.DepM.selectedIndex = frm.DepM.selectedIndex + 1
	else {
		frm.DepM.selectedIndex = 0;
		frm.DepY.selectedIndex = frm.DepY.selectedIndex + 1;
	}

}

function setDepartureCorrect() {
	var dtNow = new Date();
	var frm = document.frmSearch;
	var nDur = frm.Duration.value;
	
	var iDay = parseInt(frm.ArrD.options[frm.ArrD.selectedIndex].value);
	var iMonth = parseInt(frm.ArrM.options[frm.ArrM.selectedIndex].value);
	var iYear = parseInt(frm.ArrY.options[frm.ArrY.selectedIndex].value);
	var dtArr = new Date(iYear,iMonth - 1,iDay);
	
	var dtDep = DateAdd(nDur, dtArr)
	
	frm.DepD.selectedIndex = dtDep.getDate() - 1;
	frm.DepM.selectedIndex = dtDep.getMonth();
	frm.DepY.selectedIndex = dtDep.getFullYear() - nCurrentYear;
}

function buildDestinations() {
	var frm = document.frmSearch;
	var iFound = -1;
	
	if (frm.Country.selectedIndex > 0) {
		var iCountry = -1;
		for (i=1; i<aDs.length; i++) {
			if (aDs[i][0] == frm.Country[frm.Country.selectedIndex].value) {
				iCountry = i;
				break;
			}
		}
		if (iCountry >= 0) {
			frm.Dest.options.length = 0;
			frm.Dest.options[0] = new Option('Select an Area', '')
			for (i=1; i<aDs[iCountry][1].length; i++) {
				frm.Dest.options[i] = new Option(aDs[iCountry][1][i][1], aDs[iCountry][1][i][0]);
				if (aDs[iCountry][1][i][0] == sDest || foundCode(aDs[iCountry][1][i][0], sDest)) {
					iFound = i;
				} 
			}
			if (iFound > 0) {
				frm.Dest.selectedIndex = iFound;
			}
			else
				frm.Zone.options.length = 0;
		}
		else
		{
			frm.Dest.options.length = 0;
			frm.Zone.options.length = 0;
		}
	}
	else
	{
		frm.Dest.options.length = 0;
		frm.Zone.options.length = 0;
	}
}

function buildZones() {
	var frm = document.frmSearch;
	var iFound = -1;
	
	if (frm.Country.selectedIndex > 0) {
		var iCountry = -1;
		for (i=1; i<aDs.length; i++) {
			if (aDs[i][0] == frm.Country[frm.Country.selectedIndex].value) {
				iCountry = i;
				break;
			}
		}
		var iDest = -1;
		for (i=1; i<aDs[iCountry][1].length; i++) {
			if (aDs[iCountry][1][i][0] == frm.Dest[frm.Dest.selectedIndex].value) {
				iDest = i;
				break;
			}
		}
		if (iCountry >= 0 && iDest >= 0) {
			frm.Zone.options.length = 0;
			frm.Zone.options[0] = new Option('Select a Resort (Optional)', '')
			for (i=0; i<aDs[iCountry][1][iDest][2].length; i++) {
				frm.Zone.options[i+1] = new Option(aDs[iCountry][1][iDest][2][i][1], aDs[iCountry][1][iDest][2][i][0]);
				if (aDs[iCountry][1][iDest][2][i][0] == sZone || foundCode(aDs[iCountry][1][iDest][2][i][0], sZone)) {
					iFound = i+1;
				}
				//if (sZone == '' && aDs[iCountry][1][iDest][2][i][1] == frm.Dest[frm.Dest.selectedIndex].text) {
				//	iFound = i+1;
				//}

			}
			if (iFound > 0) {
				frm.Zone.selectedIndex = iFound;
			}
		}
		else
		frm.Zone.options.length = 0;
	}
	else
	frm.Zone.options.length = 0;
}

function buildElements() {
	//dates, duration, rooms
	buildCommon();
	//board
	//buildBoard();
	//adults and children
	buildAdultsChildren();
	//airports
	buildDepAirports();
}

function initElements() {
	setDeparture();
	setRooms();
}

function buildDepAirports() {
	var frm = document.frmSearch;
	var arrDepAirports = getDepAirports();
	var arrDepMap = getDepAirportsMap();
	var iFound = -1;
	var sDestCode = '';
	var sHL = '', sCodes = '', sCode = '', j = 0;
	
	frm.DepAirport.options.length = 0;
	frm.DepAirport.options[0] = new Option('Select an Airport', '');

	if (checkSelection(frm.HLType))  {
		for (i = 0; i <= frm.HLType.length - 1; i++)  // 2
			if (frm.HLType[i].checked)
				sHL = frm.HLType[i].value;
	}
	
	if (frm.Dest.selectedIndex > 0 && sHL != 'HO') {
		sDestCode = frm.Dest.options[frm.Dest.selectedIndex].value;
		for (k=0; k<arrDepMap.length; k++) {
			if (arrDepMap[k][0] == sDestCode) {
				sCodes = arrDepMap[k][1];
				for (i=0; i<arrDepAirports.length; i++) {
					sCode = arrDepAirports[i][0];
					if (sCodes.indexOf(sCode) >= 0) {
						j++;
						frm.DepAirport.options[j] = new Option(arrDepAirports[i][1], arrDepAirports[i][0]);
						if (arrDepAirports[i][0] == sDepAirport) {
							iFound = j;
						}
					}
				}
			}
		}

	}
	if (iFound > 0) {
		frm.DepAirport.selectedIndex = iFound;
	}
        sDepAirport = '';
}

function buildCountries() {
	var frm = document.frmSearch;
	var sHL, st;
	var arrCountries;
	
	if (checkSelection(frm.HLType))  {
		for (i = 0; i <= frm.HLType.length - 1; i++)  // 2
			if (frm.HLType[i].checked)
				sHL = frm.HLType[i].value;
	}


	if (sHL == 'HO') {
		arrCountries = getCountries();
		st = "block";
	}
	else 
	{
		arrCountries = getCountriesIATA();
		st = "none"
	}
	

	var iFound = -1;

	frm.Country.options.length = 0;

	frm.Country.options[0] = new Option('Select a Country', '');
	for (i=0; i<arrCountries.length; i++) {
		frm.Country.options[i+1] = new Option(arrCountries[i][1], arrCountries[i][0]);
		if (arrCountries[i][0] == sCountry) {
			iFound = i+1;
		}
	}
	
	if (iFound > 0) {
		frm.Country.selectedIndex = iFound;
		buildDestinations();
		buildZones();
	}
	else
	{
		frm.Dest.options.length = 0;
		frm.Zone.options.length = 0;
	}
	
        sCountry = '';
	sDest = '';
	sZone = '';
	
	elItem = document.all("trSFRes1");
	if (elItem) elItem.style.display = st;

	elItem = document.all("trSFRes2");
	if (elItem) elItem.style.display = st;
}

function buildCommon() {
	var frm = document.frmSearch;
	var arrDt = Array('Arr', 'Dep')
	var dtNow = new Date();
	var nStartYear = nCurrentYear;
	var nEndYear = nStartYear + 2;
	var arrMonthes = getMonthes();
	
	//dates
	for (j=0; j<arrDt.length; j++) {	
		for (i=1; i<=31; i++) {
			eval('frm.' + arrDt[j] + 'D.options[i-1] = new Option(i, i)');
			if (eval('s' + arrDt[j] + 'D == i'))
				eval('frm.' + arrDt[j] + 'D.selectedIndex = i-1');
		}
		eval('s' + arrDt[j] + 'D = 0');
		for (i=1; i<=12; i++) {
			eval('frm.' + arrDt[j] + 'M.options[i-1] = new Option(arrMonthes[i-1], i)');
			if (eval('s' + arrDt[j] + 'M == i'))
				eval('frm.' + arrDt[j] + 'M.selectedIndex = i-1');
		}
		eval('s' + arrDt[j] + 'M = 0');
		for (i=nStartYear; i<=nEndYear; i++) {
			eval('frm.' + arrDt[j] + 'Y.options[i-nStartYear] = new Option(i, i)');
			if (eval('s' + arrDt[j] + 'Y == i'))
				eval('frm.' + arrDt[j] + 'Y.selectedIndex = i-nStartYear');
		}
		eval('s' + arrDt[j] + 'Y = 0');
	}
	//duration
	for (i=1; i<=30; i++) {
		frm.Duration.options[i-1] = new Option(i, i);
		if (sDuration == i)
			frm.Duration.selectedIndex = i-1;
	}
	sDuration = 0;
	//rooms
	if (frm.Rooms.type == 'select-one') {
		for (i=1; i<=nMaxRooms; i++) {
			frm.Rooms.options[i-1] = new Option(i, i);
			if (sRooms == i)
				frm.Rooms.selectedIndex = i-1;
		}
	}
	sRooms = 0;
}

function rebuildBoard() {
	var frm = document.frmSearch;
	sBoard = frm.Board.options[frm.Board.selectedIndex].value;
	buildBoard();
}

function buildBoard() {
	var frm = document.frmSearch;
	var nRooms;
	var arrB;
	
	frm.Board.options.length = 0;
	if (frm.Rooms.type == 'select-one') 
		nRooms = frm.Rooms.options[frm.Rooms.selectedIndex].value
	else
		nRooms = frm.Rooms.value;

	if (nRooms == 1) {
		arrB = getBoard();
		frm.Board.options[0] = new Option('Check All', '')
	} 
	else
	{
		arrB = getBoardY();
		frm.Board.options[0] = new Option('Select a Board', '')
	};
	for (i=0; i<arrB.length; i++) {
		frm.Board.options[i+1] = new Option(arrB[i][1], arrB[i][0]);
		if (arrB[i][0] == sBoard) {
			frm.Board.selectedIndex = i+1;
		}
	}
	sBoard = '';
}

function buildAdultsChildren() {
	var elItem;
	var frm = document.frmSearch;
	var arrAC = getAdultsChildren();
	var rm;	

	if (frm.Rooms.type == 'select-one') 
		rm = frm.Rooms.options[frm.Rooms.selectedIndex].value
	else
		rm = frm.Rooms.value;
	
	for (j=1; j<=nMaxRooms; j++) {
		drawRooms(j);
		elItem = document.all("spRoom" + j);
		if (elItem) elItem.innerText = 'Room ' + j + ':';
		elItem = document.all("spChildAge" + j);
		if (elItem) elItem.innerText = 'Child age:';
		elItem = document.all("spChildInfo" + j);
		if (elItem) elItem.innerText = 'Child ages 2 - 11. If you are travelling with an infant, you must request a cot on the booking form for the infant to be added to the booking free of charge.';
		
		var el = eval('frm.AdultsChildren' + j);
		el.options.length = 0;
		el.options[0] = new Option('Select Room Type', '')
		for (i=0; i<arrAC.length; i++) {
			el.options[i+1] = new Option(arrAC[i][1], arrAC[i][0]);
			if (j <= rm && arrRooms.length >= j-1 && arrRooms.length > 0) 
				if (arrRooms[j-1][0] == arrAC[i][0])
					el.selectedIndex = i+1;
		}
		for (i=1; i<=4; i++) {
			var el1 = eval('frm.ChildAge' + j + '_' + i);
			el1.options.length = 0;
			el1.options[0] = new Option('', '')
			var val = el.options[el.selectedIndex].value;
			var child = parseInt(val.substring(2,3));
			for (k=2; k<=11; k++) {
				el1.options[k-1] = new Option(k, k);
				if (j <= rm && arrRooms.length >= j-1 && child>=i) 
					if (arrRooms[j-1][1][i-1] == k)
						el1.selectedIndex = k-1;
			}
		}
	}
}

function setRooms() {
	for (var i = 1; i <= nMaxRooms; i++)  {
		//rooms
		drawRooms(i)
		//infants
		setAges(i);
	};
}

function drawRooms(i) {
	var elItem, st;
	var frm = document.frmSearch;
	var rm;
	
	if (frm.Rooms.type == 'select-one') 
		rm = frm.Rooms.options[frm.Rooms.selectedIndex].value
	else
		rm = frm.Rooms.value;
	
	if (i <= rm) st = "block"
	else st = "none";
	
	//tr
	elItem = document.all("trRoomA1" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("trRoomB1" + i);
	if (elItem) elItem.style.display = st;

	elItem = document.all("trRoomCA" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("trRoomCB" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("trRoomC1" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("trRoomV" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("trRoomV1" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("trRoomI" + i);
	if (elItem) elItem.style.display = st;
	//td
	elItem = document.all("tdRoomA" + i);
	if (elItem) elItem.style.display = st;
	elItem = document.all("tdRoomB" + i);
	if (elItem) elItem.style.display = st;
}

function setAges(num) {
	var elItem;
	var frm = document.frmSearch;
	var rm;
	
	if (frm.Rooms.type == 'select-one') 
		rm = frm.Rooms.options[frm.Rooms.selectedIndex].value
	else
		rm = frm.Rooms.value;
	
	var elItem = eval("frm.AdultsChildren" + num);
	var val = elItem.options[elItem.selectedIndex].value;
	var child = parseInt(val.substring(2,3));
	
	if (child > 0 && num <= rm)
	{
		elItem = document.all("trRoomI" + num);
		if (elItem) elItem.style.display = "block";
		elItem = document.all("spChildAge" + num);
		if (elItem) elItem.style.display = "block";
		for (var i = 1; i <= 4; i++)  {
			var elItem1 = elTD = eval("frm.ChildAge" + num + '_' + i);
			if (i <= child)
				elItem1.style.display = "block"
			else
				elItem1.style.display = "none";
		}
	}
	else
	{
		elItem = document.all("trRoomI" + num);
		if (elItem) elItem.style.display = "none";
		elItem = document.all("spChildAge" + num);
		if (elItem) elItem.style.display = "none";
		for (var i = 1; i <= 4; i++)  {
			var elItem1 = elTD = eval("frm.ChildAge" + num + '_' + i);
			elItem1.style.display = "none";
		}
	};
}

function foundCode(sCode1, sCode2) {
	var i, arrCd1, arrCd2;
	var res = false;
	var j=0;

	arrCd2 = sCode2.split("|");	
	for (i=0; i<arrCd2.length; i++) 
		if (arrCd2[i].length == 0) j++;
	
	if (j+1 == arrCd2.length) {
		arrCd1 = sCode1.split("|");
		for (i=0; i<arrCd1.length; i++) 
			if (arrCd1[i] == arrCd2[i] && arrCd2[i].length > 0)
			res = true;
	}
	return res;
}

function setTRClass(idTR) {
	var elItem = document.all(idTR);
	if (elItem) elItem.className = "border07";
	if (idTR != 'trFL') resetTRClass('trFL');
	if (idTR != 'trHO') resetTRClass('trHO');
	if (idTR != 'trFH') resetTRClass('trFH');
}

function resetTRClass(idTR) {
	var elItem = document.all(idTR);
	if (elItem) elItem.className = "border08";
}

function AlphaSetSelectedDate() {
	var TodayDate = new Date();
	var Day = TodayDate.getDate()-1;
	var Month = TodayDate.getMonth();

	document.AlphaRoomsSearch.FromDateDay.selectedIndex = Day;
	document.AlphaRoomsSearch.FromDateMonth.selectedIndex = Month;
}
