// Declare map!
//try {
	ETMap = new mapAttributeSet();
	ETMap.mapDiv = "map1";
	ETMap.mapPointsLat = "mapPointsLat";
	ETMap.mapPointsLon = "mapPointsLon";
	ETMap.mapLabelTitle = "mapTitles";
	ETMap.mapLabelText = "mapLabels";
	ETMap.mapLegend = "mapMarkers";
//} catch(e) {
	// No maps on this page.  Do nothing.
//}

function ToggleVisibility(WhichForm) {
	// Declare for use later
        var TheFormDiv;
	// e.g. "events box", "music box"
        var DynamicClass = WhichForm.toLowerCase() + " box";
	// Each tab in the search box thing
        var AllTheForms = new Array("Food","Music","Events","Movies","Free");
	// Loop through all of them until we find a match
        for(var i = 0; i < AllTheForms.length; i++) {
		// This is the div we want to make visible
                 TheFormDiv = "SearchFormContent" + AllTheForms[i];
		// Match; show div, assign css class
                if(AllTheForms[i].toLowerCase() == WhichForm.toLowerCase()) {
                        document.getElementById('DynamicDiv').className = DynamicClass;
                        document.getElementById(TheFormDiv).style.visibility = 'visible';
                        document.getElementById(TheFormDiv).style.display = 'block';
		// No match; hide div
                } else {
                        document.getElementById(TheFormDiv).style.visibility = 'hidden';
                        document.getElementById(TheFormDiv).style.display = 'none';
                }
        }
}

function TransformForm(WhichForm) {
        if(!WhichForm) { WhichForm = "Free"; }
	// Change image mapped img src.  Take out "temp_" when adding Nightlife search back.
        TheImg = "/images/etweb/events_tabs_" + WhichForm.toLowerCase() + ".gif";
        document.images['SearchFormTabs'].src = TheImg;
	// Show appropriate div, hide all others, assign css class
        ToggleVisibility(WhichForm);
}

function ETClearValue(x) {
	if(x.value == "Name" || x.value == "Nightlife (bars/nightclubs)" || x.value == "Title") {
		x.value='';
	}
}

function in_array(needle,haystack) {
	function equals(a,b) {
		return (a == b);
	}
	for (var i = 0; i < haystack.length; i++) {
		if (equals(haystack[i],needle)) {
			return true;
		}
	}
	return false;
}

function SetFormAction(WhichForm) {
	var arts = new Array(85,96,97,75,107,108,109,122,123,124,129,69,168,152,153);
	var movies = new Array(121,158,159);
	var music = new Array(56,131,126,127,169,130,132,133,134,135,136,137,170,143,139,144,222,240);
	var entertainment = new Array(76,98,99,100,111,102,110,112,161,166,162,163,164,165,74,147,148,149,150,160);

	var TheCategory = WhichForm.SearchCategory.value;

        if(in_array(TheCategory,arts)) {
                WhichForm.action = "/events/index.ssf";
        } else if(in_array(TheCategory,movies)) {
                WhichForm.action = "/movies/index.ssf";
	} else if(in_array(TheCategory,music)) {
		WhichForm.action = "/music/index.ssf";
        } else {
                WhichForm.action = "/entertainment/index.ssf";
        }
}

function MatchDates(TheForm,ThisIndex) {
	if(ThisIndex == 0) { ThisIndex = 1; }
	TheForm.SearchDateEnd.options[ThisIndex-1].selected = true;
}
