function smartList(selectName, getColNum,  matchValue, matchColNum) {
	var theSelect=eval("document.finder."+selectName);
	var theSelectSelected = theSelect.options[theSelect.selectedIndex].text;
	theSelect.options.length=1;
	var x = 0;
	var t = new Array(1);
	for (var i=0; i < a.length; i++) {
		var isMatch = true;
		if (matchValue != "") {
			if (a[i][matchColNum] != unescape(matchValue)) {
				isMatch = false;
			}
		}
		if (isMatch == true) {
			var e = false;
			for (var p = 0; p < t.length; p++) {
				if (t[p] == a[i][getColNum]) {
					e = true;
					break;
				}
			}
			if (e == false) {
				t[x]=a[i][getColNum];
				x++;
			}
		}
	}
	t.sort();
	if (t[0] == "") {
		var n = t.shift();
	}
	for(i=0; i<t.length; i++)  {
		theSelect.options[i+1]= new Option(t[i], escape(t[i]));
		if (matchValue == "") {
			theSelect.options[0].selected = true;
		} else {
			if (theSelect.options[i+1].text == theSelectSelected) {
				theSelect.options[i+1].selected = true;
			}
		}
	}
	return true;
}
function smartSelect(selectName, getColNum,  matchValue, matchColNum) {
	var theSelect=eval("document.finder."+selectName);
	if (matchValue == "") {
		theSelect.options[0].selected = true;
	} else {
		for (var i=0; i < a.length; i++) {
			if (a[i][matchColNum] == unescape(matchValue)) {
				for (p = 0; p < theSelect.length; p++) {
					if (theSelect.options[p].text == a[i][getColNum]) {
						theSelect.options[p].selected = true;
						break;
					}
				} 
			break;
			}
		}
	}
}
function smartReselect() {
	var regionVal = unescape(document.finder.region.options[document.finder.region.selectedIndex].value);
	var countryVal = unescape(document.finder.country.options[document.finder.country.selectedIndex].value);
	if (regionVal != "") {
		smartList('country', 1, regionVal, 0);
		smartList('style', 2, regionVal, 0)
	}
	if (countryVal != "" ) {
		smartList('style', 2, countryVal, 1)
	}
}
function tourfinder(site) {
	var region=document.finder.region.options[document.finder.region.selectedIndex].value;
	var country=document.finder.country.options[document.finder.country.selectedIndex].value;
	var style=document.finder.style.options[document.finder.style.selectedIndex].value;
	var duration=document.finder.duration.options[document.finder.duration.selectedIndex].value;
	var theURL="http://tours.trailfinders."+site+"/tailormadetours.nsf/webmenuTour?ReadForm&region="+region+"&country="+country+"&style="+style+"&duration="+duration;
	if (region=="" & country=="" & style=="" & duration=="") {
		alert("Please select from at least one category to search for tours");
	} else {
		window.location=theURL;
	}
}
function tourfinderIntranet(site) {
	var region=document.finder.region.options[document.finder.region.selectedIndex].value;
	var country=document.finder.country.options[document.finder.country.selectedIndex].value;
	var style=document.finder.style.options[document.finder.style.selectedIndex].value;
	var duration=document.finder.duration.options[document.finder.duration.selectedIndex].value;
	var theURL="http://myintranet.trailfinders."+site+"/tailormadetours.nsf/intranetmenuTour?ReadForm&region="+region+"&country="+country+"&style="+style+"&duration="+duration;
	if (region=="" & country=="" & style=="" & duration=="") {
		alert("Please select from at least one category to search for tours");
	} else {
		window.location=theURL;
	}
}
