/* used by calendar */
function onSelect(calendar, date) {
	if (calendar.dateClicked) {
		calendar.callCloseHandler(); // this calls "onClose" (see above)
		var day = date.substring(0,2);
		var month = date.substring(3,5);
		var year = date.substring(6,10);
		var monthyear;
							
		monthyear = year + "-" + month;

		SetSelectedValue(document.form_tour_enquiry.when_visit_day, day);
		SetSelectedValue(document.form_tour_enquiry.when_visit_monthyear, monthyear);
	}
}

	
	// fills out the "where did you hear about us" <select> box options from MOSAIC 
	function InitializeWhereHearOptions()   {
		var rawData, strA, strB, strC, WHelement;
		
		rawData = document.getElementById("wherehearoptions").innerHTML;
		
		// get rid of line breaks
		strA = rawData.replace(/\r\n/g, "");
		// make <P> tags lowercase to avoid browser differences (IE renders <P>, Firefox renders <p>)
		strA = strA.replace(/<\/P><P>/g, "</p><p>");
		// string to begin after "START" text
		pospos  = strA.indexOf("LISTSTART");
		strB = strA.substring(pospos + 9);
		// string to exclude finishing "END" text
		lenstrB = strB.length;
		strC = strB.substring(0, lenstrB - 11);

		// now create array and populate the <select> box		
		itemsarray = strC.split("</p><p>");
		WHelement = document.form_tour_enquiry.hear_about;
		for (i=1; i<itemsarray.length-1; i++)   {
			WHelement.options[i] = new Option(itemsarray[i], itemsarray[i]);
			}

		}

	// turns date fields on and off depending on whether client wishes to choose dates	
	function toggle_date_fields(thecheckbox)   {
		doc = document.form_tour_enquiry;
		if (thecheckbox.checked==true)   {
			doc.when_visit_day.disabled = false;
			doc.when_visit_monthyear.disabled = false;
			document.getElementById("trigger").style.display = "block";
			}
		else   {
			doc.when_visit_day.disabled = true;
			doc.when_visit_monthyear.disabled = true;
			document.getElementById("trigger").style.display = "none";
			}
		}

