	var monthName=new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

	// initially sets days, monoths and year dropdown
	function initializeDaysMonthsYearSeparate (theform, dayselement, monthselement, yearselement) {

		var objDaysSelect, objMonthsSelect, objYearsSelect
		
		if (dayselement!="")   {
			eval("objDaysSelect = document."+theform+"."+dayselement);
			// days
			objDaysSelect.length = 0;
			for (i = 1; i <= 31; i++) {
				objDaysSelect.options[i-1] = new Option(i, i);
				}
			}

		if (monthselement!="")   {
			eval("objMonthsSelect = document."+theform+"."+monthselement);
			// months
			objMonthsSelect.length = 0;
			for (i = 1; i <= 12; i++) {
				themonthname=monthName[i - 1];
				objMonthsSelect.options[i-1] = new Option(themonthname, i);
				}
			}

		if (yearselement!="")   {
			eval("objYearsSelect = document."+theform+"."+yearselement);

			// years
			// need current year minus 18 as end year!
			var dtToday = new Date();
			startyear=1900;
			endyear=Number(dtToday.getFullYear())-18;
			objYearsSelect.length = 0;
			for (i = startyear; i <= endyear; i++) {
				objYearsSelect.options[i-startyear] = new Option(i, i);
				}
			objYearsSelect.selectedIndex=60;

			}

		}

	// initially sets days, monoths and year dropdown
	function initializeDaysMonthsYear (theform, dayselement, monthsyearelement, selectedDate) {

		var objMonthsYearSelect, i, startmonth, theyear, fstartmonth, selMonth, selYear, selIndex;
		var dtToday = new Date();

		// set variables to current month and year
		theday=Number(dtToday.getDate());
		startmonth=dtToday.getMonth() + 1;
		theyear=dtToday.getFullYear();

		if (selectedDate!="")  {
			selMonth = selectedDate.substring(5,7);
			selYear = selectedDate.substring(0,4);
			theday = selectedDate.substring(8,10);
			}

		// populate days dropdown, dependent on current month and possibility of leap year (current year)
		if (dayselement!="") populateDays (theform, dayselement, theday, startmonth, theyear);

		eval("objMonthsYearSelect = document."+theform+"."+monthsyearelement);

		// clear any current option entries
		objMonthsYearSelect.length = 0;
		for (i = 1; i <= 12; i++) {
			if (startmonth==13)  {
				fstartmonth="01";
				startmonth=1;
				theyear++;
				}
			else  {
				if (startmonth<10) fstartmonth="0"+startmonth;
				else fstartmonth=startmonth;
				}
			theval=theyear + "-" + fstartmonth;
			startmonthname=monthName[startmonth - 1];
			thetext=startmonthname + " " + theyear;
			objMonthsYearSelect.options[i-1] = new Option(thetext, theval);
			if (selectedDate!="")  {
				if (fstartmonth==selMonth && theyear==selYear) selIndex=i-1;
				}
			startmonth++;
			}
		if (selectedDate!="") objMonthsYearSelect.selectedIndex=selIndex;
		}

	// changes days dropdown when monthyear select box is changed
	function updateDaysList(theform, dayselement, monthyear)   {

		var monthyeararray, arrivalday;
		monthyeararray=monthyear.split("-");	

		eval("arrivalday = document." + theform + ".arrivalday.options[document." + theform + ".arrivalday.selectedIndex].value;");

		// populate days dropdown, dependent on current month and possibility of leap year (current year)
		populateDays (theform, dayselement, arrivalday, Number(monthyeararray[1]), Number(monthyeararray[0]));
		}

	// updates days dropdown
	function populateDays (theform, dayselement, theday, themonth, theyear)  {

		var objDaysSelect, i, maxdays;

		// need correct max days in month 
		switch(themonth)   {
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12: maxdays=31;
					break;
			case 2: if (theyear % 4 == 0) maxdays=29;
					else maxdays=28;
					break;
			case 4:
			case 6:
			case 9:
			case 11: maxdays=30;
					break;
			}

		eval("objDaysSelect = document."+theform+"."+dayselement+";");

//		alert("objDaysSelect = document."+theform+"."+dayselement+";");

		// clear any current option entries
		objDaysSelect.length = 0;
		for (i = 1; i <= maxdays; i++) {
			if (i < 10) fi="0" + i;
			else fi=i;
			if (i==theday) objDaysSelect.options[i-1] = new Option(i, fi, true, true);
			else objDaysSelect.options[i-1] = new Option(i, fi);
			}
		}

	function initializeDuration (theform, durationelement, selvalue, minimumdaysallowed)  {
		var strdata="3,4,5,6,7,8,9,10,11,12,13,14,21";		
		var selindex, ndurationelement, c;
		if (minimumdaysallowed==null) minimumdaysallowed = 0;
		arraydata=strdata.split(",");
		eval("ndurationelement = document."+theform+"."+durationelement+";");
		ndurationelement.length=0;
		c=0;
		for (x=0; x<arraydata.length; x++)  {
			if (arraydata[x] >= Number(minimumdaysallowed))   {
				ndurationelement.options[c] = new Option(arraydata[x] + " nights", arraydata[x], false, false);
				if (selvalue!="")  {
					if (selvalue==arraydata[x]) selindex=c;
					}
				c++;
				}
			}
		if (selvalue!="") ndurationelement.selectedIndex=selindex;
		}

	function initializeMaxPrice (theform, maxpriceelement)  {
		eval("maxpriceelement = document."+theform+"."+maxpriceelement);
		maxpriceelement.length=0;
		maxpriceelement.options[0] = new Option("up to \u00A3299", "0-299", false, false);
		maxpriceelement.options[1] = new Option("\u00A3300 to \u00A3499", "300-499", false, false);
		maxpriceelement.options[2] = new Option("\u00A3500 to \u00A3749", "500-749", false, false);
		maxpriceelement.options[3] = new Option("\u00A3750 to \u00A3899", "750-899", false, false);
		maxpriceelement.options[4] = new Option("\u00A3900 to \u00A31199", "900-1199", false, false);
		maxpriceelement.options[5] = new Option("\u00A31200 to \u00A31499", "1200-1499", false, false);
		maxpriceelement.options[6] = new Option("\u00A31500+", "1500+", false, false);
		}

	function toggleAvailabilitySearchElements(thecheckbox)  {
		doc=document.holidaySearch;
		if (thecheckbox.checked==true)  {
//			initializeDaysMonthsYear ("holidaySearch", "theday", "themonthyear", "");
//			initializeDuration ("holidaySearch", "lengthstay");
//			initializeMaxPrice ("holidaySearch", "maxweeklyprice");
			doc.theday.disabled = false;
			doc.themonthyear.disabled = false;
			doc.lengthstay.disabled = false;
			document.getElementById("trigger").style.display = "block";
			}
		else  {
//			doc.theday.length=0;
//			doc.theday.options[0] = new Option(" - ", "",true,true);
//			doc.themonthyear.length=0;
//			doc.themonthyear.options[0] = new Option(" - - ", "",true,true);
//			doc.lengthstay.length=0;
//			doc.lengthstay.options[0] = new Option(" - ", "",true,true);
//			doc.maxweeklyprice.length=0;
//			doc.maxweeklyprice.options[0] = new Option(" - ", "",true,true);
			doc.theday.disabled = true;
			doc.themonthyear.disabled = true;
			doc.lengthstay.disabled = true;
			document.getElementById("trigger").style.display = "none";
			}
		}

	function initParentChildMapObject() 	{
		
		var szInfo, arryInfo, maxElements, i, y, doc, obj;

		doc = document.forms.holidaySearch;
		szInfo = doc.locationmappings.value;
		// get rid of final ||
		szInfo=szInfo.substring(0,szInfo.length-2);
		obj = objChildrenList;
	
		if (objChildrenList == null) {
			obj = new Object();
			arryInfo = szInfo.split("||");
			maxElements = arryInfo.length;
			i = 0;
			y = 0;
			obj.parentID = new Array();
			obj.childID= new Array();
			obj.childname= new Array();
			while ( i < maxElements ) {
				obj.parentID[y] = arryInfo[i];
				obj.childID[y] = arryInfo[i+1];
				obj.childname[y] = arryInfo[i+2];
				i += 3;
				y++;
				}
			objChildrenList = obj ;
			}
//		doc.locationmappings.value = "";
		return;
		}

	function filterChildren(parentSelect, parentname, childname)  {
		var childSelect, maxChildren, actualChildren;
		actualChildren=0;
		eval("childSelect=document.forms.holidaySearch."+childname);
		parentID=Number(parentSelect.options[parentSelect.selectedIndex].value);
		childSelect.length = 0;
		if (parentID==1) childSelect.options[0] = new Option("< Select " + parentname + " first", "",true,true);
		else   {
			maxChildren = objChildrenList.parentID.length;
			childSelect.options[0] = new Option("All " + childname + "s..", "",true,true);
			for (i = 0; i < maxChildren; i++) {
				if (Number(objChildrenList.parentID[i]) == parentID) {
					childSelect.options[childSelect.options.length] = new Option(objChildrenList.childname[i], objChildrenList.childID[i]);
					actualChildren++;
					}
				}
			if (actualChildren==0)   {
				childSelect.options[0].value="";
				childSelect.options[0].text="No " + childname + "s to select";
				}
			}
		return;
		}


