var stateProvinceAutoSet = true;
var countryAutoSet = true;
var searchForm = new WebForm();


function advancedSearchForm_onSubmit() {

   if(document.getElementById("city").value=='(Enter city)') {
       document.getElementById("city").value="";
   }
   if(document.getElementById("address")){
       if (document.getElementById("address").value=='(Enter address)') {
           document.getElementById("address").value="";
       }
   }
   if (document.getElementById("hotelName").value=='(Hotel name)') {
       document.getElementById("hotelName").value="";
   }
   if(document.getElementById("zipCode")){
        if(document.getElementById("zipCode").value=='(Enter ZipCode)') {
            document.getElementById("zipCode").value="";
        }
   }
   if(document.getElementById("airportCode").value=='(Enter city)') {
       document.getElementById("airportCode").value="";
   }
    searchForm.resetErrors();
	if (searchType=="city") {
        f.action = "/pro/search/results/city_advanced.html";
		checkDates();
		locationStatus = getLocationSearchStatus();
		if ((locationStatus =="BLANK")) {
			searchForm.addError("searchCriteriaRequiredError" );
		}
		if ((locationStatus =="INVALID_US_SEARCH") ) {
			searchForm.addError("toGeneralUSSearchError" );
		}
		if ((locationStatus =="MISSING_STATE_US_SEARCH") ) {
			searchForm.addError("stateProvinceRequiredError" );
		}
		if ((locationStatus =="CITY_ONLY") ) {
			searchForm.addError("countryRequiredForCitySearchError" );
		}
	}
	if (searchType=="address") {
		f.action = "/pro/search/results/address_advanced.html";
		//city_onBlur();
		checkDates();
		zipCodeStatus = getZipCodeStatus();
		locationStatus = getLocationSearchStatus();
		if (zipCodeStatus == "INVALID") {
			searchForm.addError("invalidZipCodeError", "zipCodeLabel");
		} else if (zipCodeStatus == "BLANK") {
			if ((locationStatus =="BLANK")) {
				searchForm.addError("searchCriteriaRequiredError" );
			}
			if ((locationStatus =="INVALID_US_SEARCH") ) {
				searchForm.addError("toGeneralUSSearchError" );
			}
			if ((locationStatus =="MISSING_STATE_US_SEARCH") ) {
				searchForm.addError("stateProvinceRequiredError" );
			}
			if ((locationStatus =="CITY_ONLY") ) {
				searchForm.addError("countryRequiredForCitySearchError" );
			}
		}
	}
	if (searchType=="hotelName") {
		f.action = "/pro/search/results/hotel_name.html";
		document.searchForm.departureDate.value = dateFormatString;
		document.searchForm.arrivalDate.value = dateFormatString;
		if ((f.hotelName.value == "") || (f.hotelName.value=="(Hotel Name)"))  {
			searchForm.addError("hotelNameRequiredError");
		}
	}
	if (searchType=="airportCode") {
		f.action = "/pro/search/results/airport_advanced.html";
		checkDates();
		if (f.airportCode.value == "") {
			searchForm.addError("airportCodeRequiredError");
		}
	}

    if (searchType=="conventionName") {

        f.action = "/pro/search/results/convention_center.html";
		checkDates();

	}

    if (searchForm.hasErrors()) {

        searchForm.showErrors();
		return false;
	} else {
        return true;
	}
}
function checkDates() {
    if ((document.searchForm.arrivalDate.value == dateFormatString) && (document.searchForm.departureDate.value == dateFormatString)) {
		return "DATES_NOT_SET";
	}

	var checkIn = new validDate(document.searchForm.arrivalDate);
	var checkOut = new validDate(document.searchForm.departureDate);

	if (!(checkIn.valid) && (!checkOut.valid) ) {
		searchForm.addError("~ciAnddepartureDatesInvalidError", "arrivalDateLabel","departureDateLabel")
	} else if (!checkIn.valid ) {
		searchForm.addError("~arrivalDateInvalidError","arrivalDateLabel")
	} else if (!checkOut.valid ) {
		searchForm.addError("~departureDateInvalidError","departureDateLabel")
	} else 	if ( (checkIn.valid) & (checkOut.valid)  ) {
		var datesDelta = checkIn.diffDate( checkOut.d);
		var nowDelta = checkIn.diffDate(new Date());
		if (nowDelta > 0 ) {
			searchForm.addError("~checkInEarlierThanTodayError","arrivalDateLabel");
		} else if (nowDelta < -561) {
			searchForm.addError("~bookToFarInFutureError","arrivalDateLabel");
			searchForm.addError()
		} else if (datesDelta < 0) {
			searchForm.addError("~departureBeforeArrivalError","departureDateLabel");
		} else if (datesDelta > 31) {
			searchForm.addError("~maximumLengthStayExceededError", "arrivalDateLabel","departureDateLabel");
		} else if (datesDelta < 1) {
			searchForm.addError("~arrivalEqualsDepartureError", "arrivalDateLabel","departureDateLabel");
		}
	}
	return "";
}
function getLocationSearchStatus() {
	cityEmpty = (f.city.value =="");
	stateProvinceEmpty = (f.conventionCenterState.value == "");
	countryEmpty = (f.country.value=="");
	countryUS = (f.country.value=="US");

	if ((!cityEmpty) && (!stateProvinceEmpty) && (!countryEmpty)) { return "COMPLETE_SEARCH"; }
	if ((!stateProvinceEmpty) && (!countryEmpty)) { return "STATE_SEARCH"; }
	if ((!cityEmpty) && (!countryUS) && (!countryEmpty)) { return "NON_US_CITY_SEARCH"; }
	if ((!countryEmpty) && (!countryUS) ) { return "NON_US_COUNTRY_SEARCH"; }
	if ((stateProvinceEmpty) && (countryUS) && (!cityEmpty) ){ return "MISSING_STATE_US_SEARCH"; }
	if ((stateProvinceEmpty) && (countryUS) ){ return "INVALID_US_SEARCH"; }
	if ((!cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "CITY_ONLY"; }
	if ((cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "BLANK"; }
	return "INCOMPLETE";
}

function getAirportCode_onClick() {
	window.open('/dp/en_US/common/search/airportLookUp.jsp?element=searchForm.airportCode&brand=westin','mywindow','width=390,height=490')
	return false;
}

var allBlocksArray = ["city", "country", "optionsContainer", "address", "zipCode", "airportBlock", "message", "hotelName", "conventionName", "datesContainer", "searchWithin", "conventionCenterState"];

function tab_onClick(tabName) {
    
    allBlocksArray.forEach(displayProNone);
    allBlocksArray.forEach(function(block){
        setClass(block, "");
    });

    displayBlock("container3");
    displayBlock("iATAContainer");
    searchForm.resetErrors();

    document.getElementById("Radius").name="airportRadius";
    document.getElementById("conventionCenterState").setAttribute('onchange','stateProvince_onChange()');

    var tempArray;
    switch(tabName){
        case "city":
            searchType="city";
            tempArray = ["city", "country", "optionsContainer","datesContainer","conventionCenterState"];
            setClass("cityTab", "selected");
            break;
        case "address":
            searchType="address";
            tempArray = ["city", "country", "optionsContainer","address","zipCode","datesContainer", "searchWithin", "conventionCenterState"];
            setClass("addressTab", "selected");
            break;
        case "airport":
            searchType="airportCode";
            tempArray = ["airportBlock","datesContainer"];
            setClass("airportTab", "selected");
            break;
        case "hotelName":
            searchType="hotelName";
            tempArray = ["message","hotelName"];
            setClass("hotelNameTab", "selected");
            break;
        case "conventionName":
            searchType="conventionName";
            tempArray = ["conventionName", "datesContainer", "searchWithin", "conventionCenterState"];
            setClass("conventionNameTab", "selected");
            //document.getElementById("conventionCenterState").setAttribute('onchange','conventionCenterState_onChange()');
            document.getElementById("conventionCenterState").onchange = conventionCenterState_onChange;
            document.getElementById("Radius").name="conventionRadius";
            //document.getElementById("conventionCenterState").selectedIndex=0;
            initConventionCenter();
            break;
    }
    tempArray.forEach(displayProBlock);
    return false;
}

function clear_onClick() {
	f.city.value="";
	f.streetAddress.value="";
	f.zipCode.value="";
	f.conventionCenterState.selectedIndex = 0;
	f.country.selectedIndex = 0;
	f.airportCode.value="";
	f.airportRadius.selectedIndex = 2;
	f.hotelName.value="";

	f.airportRadiusUnit[0].checked = true;

	for (var i=0;i<f.elements.length;i++) {
		var e=f.elements[i];
		if (e.name=='hotelType') {
			e.checked=false;
		}
		if (e.name=='amenityType') {
			e.checked=false;
		}
	}
}

function setClass(id, _class) {
	document.getElementById(id).className = _class
}
function displayProBlock(id){
    if(document.getElementById(id)) {
        document.getElementById(id).style.display="block";
    }
}
function displayProNone(id){
     if(document.getElementById(id)) {
        document.getElementById(id).style.display="none";
     }
}

function checkLocationFields() {
	locationStatus = getLocationStatus();
	addressEntered = (f.address.value != "")
	isAddressSearch = (f.searchType.value == "address")
	if (!isAddressSearch) {
		if (locationStatus =="BLANK") {
			searchForm.addError("~searchCriteriaRequiredError","cityLabel", "stateProvinceError", "countryError" );
			return;
		}
		if (locationStatus == "CITY_ONLY") {
			searchForm.addError("~countryNeededForCitySearchError", "countryError" );
			return;
		}
		if (locationStatus == "INVALID_US_SEARCH") {
			searchForm.addError("~toGeneralUSSearchError","stateProvinceError" );
			return;
		}
	} else {
		if (zipCodeStatus == "INVALID") {
			searchForm.addError("~invalidZipCodeError","zipLabel");
			return;
		}
		if (zipCodeStatus == "VALID") {
			return;
		}
		if ((locationStatus =="INVALID_US_SEARCH") && (!addressEntered)) {
			searchForm.addError("~searchCriteriaRequiredError","cityLabel", "stateProvinceError", "zipLabel", "addressLabel" );
			return;
		}
		if (addressEntered) {
			if ((f.city.value =="") && (f.state.value == "")) {
				searchForm.addError("~cityAndStateRequiredError","cityLabel", "stateProvinceError");
				return;
			} else if(locationStatus=="STATE_SEARCH") {
				searchForm.addError("~cityRequiredError","cityLabel");
				return;
			} else if(locationStatus=="INVALID_US_SEARCH") {
				searchForm.addError("~stateRequiredError","stateProvinceError");
				return;
			}
		}

	}
}
function getLocationStatus() {
	cityEmpty = (f.city.value =="");
	stateProvinceEmpty = (f.state.value == "");
	countryEmpty = (f.country.value=="");
	countryUS = (f.country.value=="US");

	if ((!cityEmpty) && (!stateProvinceEmpty) && (!countryEmpty)) { return "COMPLETE_SEARCH"; }
	if ((!stateProvinceEmpty) && (!countryEmpty)) { return "STATE_SEARCH"; }
	if ((!cityEmpty) && (!countryUS) && (!countryEmpty)) { return "NON_US_CITY_SEARCH"; }
	if ((!countryEmpty) && (!countryUS) ) { return "NON_US_COUNTRY_SEARCH"; }
	if ((stateProvinceEmpty) && (countryUS) ){ return "INVALID_US_SEARCH"; }
	if ((!cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "CITY_ONLY"; }
	if ((cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "BLANK"; }
	return "INCOMPLETE";
} 
  
function city_onFocus(fieldValue) {
    field_onFocus('city',fieldValue);
    f.city.value = "";
	if (stateProvinceAutoSet) { f.conventionCenterState.selectedIndex = 0; }
	if (countryAutoSet) { f.country.selectedIndex = 0; }
}

function city_onBlur( fieldValue) {

    field_onBlur('city',fieldValue);
    a = isIn(f.city.value.toLowerCase(),topCities)
	if (a != false) {
		setDropDown(a[1],f.conventionCenterState);
		setDropDown(a[2],f.country);
		country_onChange();
		stateProvinceAutoSet = true;
		countryAutoSet = true;
	}
}

function field_onBlur(fieldName,fieldValue) {
    
    if(document.getElementById(fieldName).value=="") {
        document.getElementById(fieldName).value=fieldValue;
    }
}

function field_onFocus(fieldName,fieldValue) {
    if(document.getElementById(fieldName).value==fieldValue) {
        document.getElementById(fieldName).value="";
    }
}

function stateProvince_onChange() {
	c = false;
	if(isIn(f.conventionCenterState.value,us_states)) {
		c = "US";
	} else if(isIn(f.state.value,ca_prov)) {
		c = "CA";
	} else if(isIn(f.state.value,misc)) {
		c = "US";
	}
	if (c != false) {
		setDropDown(c,f.country);
	}
	country_onChange();
	stateProvinceAutoSet = false;
}
function country_onChange() {
	if ((f.country[f.country.selectedIndex].value != "US") && (f.country[f.country.selectedIndex].value != "CA")) {
		setDropDown("",f.state);
	}
	stateProvinceAutoSet = false;
	countryAutoSet = false;
}

function setDropDown(v,dd) {
	for (i = 0; i < dd.options.length ; i++ ) {
		if ( dd.options[i].value == v ) {
			dd.selectedIndex = i;
			return true
		}
	}
	return false;
}


function isIn(elt, list){
	for(var i=0; i < list.length; i++){
		var tempArray = list[i].split(":")
		if( tempArray[0] == elt ){
			return tempArray;
		}
	}
	return false;
}

function advancedSearch_onClick() {
	f.action='/meetings/search/index.html'
	f.submit();
	return false;
}

addLoadEvent(function () {
});

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function init() {
	setDateToToday(false,dateFormatString); // (default dates boolean, default value)
}
/* ********************************************************************** */
/* ***************        BEGIN CALENDAR CODE       ********************* */
var myFloater = -1;
var thisDate;

var dMax = 550;
var dMin = 0;
var sameDate = false;
var aod = "";

var changedDate;
var fType = typeof f;

//-----------------------------------------------------------------
// this function is called from the calendar popup window
function setDate(mn,dy,yr) {
	var dateField;
	if (aod == "arr") {
		 dateField = new validDate(document.searchForm.arrivalDate);
	} else if (aod == "dep") {
		dateField = new validDate(document.searchForm.departureDate);
	}
    _d = new Date(yr,mn,dy);
    // _d.setTime( Date.parse( mn.toString() + "/" + dy.toString() + "/" + yr) );
	dateField.setD(_d);
	dateField.setField();
	arrivalDate_onBlur();
}

//-----------------------------------------------------------------
// this function is called from the calendar icon
function openCal(calType,ciDate,coDate) {
	oInput = ciDate;
	oInput2 = coDate;
	var dt1 = null;
	var dt2 = null;

	if (calType == "arrival") {
		aod = "arr";
		thisDate = oInput;
		var thisDate2 = oInput2;
		ciDate.value = thisDate.value;
		document.SearchForm.inputDate.value = thisDate.value;
		sameDate = true;
		changedDate = "dtArr";
	} else {
		aod = "dep";
		dt1 = new Date(oInput.value);
		dt2 = new Date(oInput2.value);
		thisDate = oInput;
		var thisDate2 = oInput2;

		if (dt1 < dt2) {
			coDate.value = thisDate2.value;
			sameDate = true;
		} else {
			ciDate.value = thisDate.value;
			sameDate = true;
		}

		document.SearchForm.inputDate.value = thisDate2.value;
		changedDate = "dtDep";
	}

	var mybrand = (fType != "undefined") ? ((f.theBrand) ? f.theBrand.value : "") : "";
	myFloater = window.open('','myWindow','scrollbars=no,status=no,width=220,height=200,top=450,left=250,resizable=no');

	if (myFloater.opener == null) myFloater.opener = self;

	myFloater.location.href = "/dp/en_US/common/search/calendar.jsp?brand=" + mybrand;
}
/* ***************         END CALENDAR CODE         ********************** */
/* *********************************************************************** */

function arrivalDate_onFocus() {
	var checkIn = new validDate(document.searchForm.arrivalDate);
	if (  !checkIn.valid ) { document.searchForm.arrivalDate.value="";}
}

function arrivalDate_onBlur() {
	var checkIn = new validDate(document.searchForm.arrivalDate);
	if ( checkIn.valid ) {
		checkIn.setField();
		var checkOut = validDate(document.searchForm.departureDate);
		if (checkOut.valid ) { before = (checkIn.diffDate(checkOut.d) <= 0);}
		if ( (! (checkOut.valid)) || before) {
			checkOut.setD(checkIn.d);
			checkOut.nextDay();
			checkOut.setField();
		}
	} else {document.searchForm.arrivalDate.value=dateFormatString;}
}
function departureDate_onFocus() {
	var checkOut = new validDate(document.searchForm.departureDate);
	if (  !checkOut.valid ) { document.searchForm.departureDate.value="";}
}
function departureDate_onBlur() {
	var checkOut = new validDate(document.searchForm.departureDate);
	if ( checkOut.valid ) { checkOut.setField(); } else {document.searchForm.departureDate.value=dateFormatString;}
}
function getZipCodeStatus() {
	if (document.searchForm.postalCode) {
		var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
		if(document.searchForm.postalCode.value == ''){
			return "BLANK";
		} else if(!objRegExp.test(document.searchForm.postalCode.value)){
			return "INVALID";
		} else {
			return "VALID"
		}
	} else {
		return "BLANK";
	}
}

function MasterPanel(_arr,parent) {
	this.childPanel = _arr;
	this.defaultChild = parent || "city";
	this.activeChild = this.defaultChild;
	this.storedChild = null;
	this.childPanel[this.activeChild].show();
}

MasterPanel.prototype.track = function(f,state) {
	var selectedChild = f;
	if(f=="advanced") this.storedChild = this.activeChild;
	this.childPanel[this.activeChild].reindex();
	this.activeChild = (selectedChild=="advanced") ? this.storedChild : selectedChild;
	this.childPanel[selectedChild].show();
}

function Panel(obj) {
	this.panelName = obj;
	this.panel = document.getElementById(this.panelName);
	this.defaultDisplay = "none";
	//this.panel.style.display = "none";
}

Panel.prototype.show = function() {
	this.panel.style.display = "block";
}

Panel.prototype.reindex = function(sObj) {
	this.panel.style.display = this.defaultDisplay;
	if(sObj!=undefined) {
		panels[sObj].show();
	}
}

function chooseOptions() {
	var _options = [];
	var _forms = []
	var idx = 0;
	var parent = document.getElementById("advanced_panel");
	var label = parent.getElementsByTagName("input");
	for(i=0;i<label.length;i++) {
		if(label[i].id.indexOf("|") != -1) {
			inputField = label[i]
			if(inputField.checked) {
				_options[idx] = []
				_options[idx]["value"] = inputField.getAttribute("value");
				_options[idx]["name"] = inputField.getAttribute("name");
				_options[idx]["id"] = inputField.getAttribute("name") + "|" + inputField.getAttribute("value");
				idx++
			}
		}
	}
	var stringBuilder = decodeOptions(idx);
	var formBuilder = "";
	if (_options.length!=0) {
		for(i=0;i<_options.length;i++) {
			formBuilder += "<input type=\"hidden\" name=\"" + _options[i].name + "\" id=\"i_" + _options[i].id + "\" value=\"" + _options[i].value + "\" />";
		}
        document.getElementById(gForm + "_more_options").innerHTML = stringBuilder;
		document.getElementById(gForm + "_advanced_options").innerHTML = formBuilder;
	} else {
        document.getElementById(gForm + "_more_options").innerHTML = moreOptions + " &gt;";
        document.getElementById(gForm + "_advanced_options").innerHTML = formBuilder;
	}
}

function decodeOptions(idx) {
	return editOptions.replace(/COUNT/, idx);
}

function markEdit() {
	hasChanged = 1;
}

var gForm;
function setAdvancedButtonAction(f) {
    gForm = f;
	populateCheckbox(f);
}

function submitActiveForm() {
    master.childPanel['advanced'].reindex(master.storedChild);
    chooseOptions();
    if (eval(gForm + "_onSubmit()") ) {
        eval("document." + gForm).submit();
    }
}

function resetOption(t, option) {
	t.selectedIndex = option;
}

function populateCheckbox(parent) {
    var advancedPanel = document.getElementById("advanced_panel");
	var labels = advancedPanel.getElementsByTagName("input");
	for(i=0;i<labels.length;i++) {
		if(labels[i].id.indexOf("|") != -1) {
			labels[i].checked = false;
		}
	}
    var inpts = document.getElementById(parent + "_advanced_options").getElementsByTagName("input");
	var form_arr = [];
	for(i=0;i<inpts.length;i++) {
        form_arr[form_arr.length] = inpts[i].id.replace(/i\_/,"");
	}
	for(x=0;x<form_arr.length;x++) {
		document.getElementById(form_arr[x]).checked = true;
	}
}

function changeSibling(sibling,option) {
	eval("document." + sibling)[option].checked = true;
}


var conventionCenterValue;
var req;
var conventionCenterState_onChange = function() {
    var conCenterState = document.getElementById("conventionCenterState");
	//var conCenterCountry = document.getElementById("conventionCenterCountry");
    var conCenterCountry = document.getElementById("country");

    //conCenterState.value = ""

	if (conCenterState.value != "") {
		if(isIn(conCenterState.value,us_states)) {
			conCenterCountry.value = "US";
		} else if(isIn(conCenterState.value,ca_prov)) {
			conCenterCountry.value = "CA";
		} else if(isIn(conCenterState.value,misc)) {
			conCenterCountry.value = "US";
		}
		constructXMLQuery();
	}
}

function conventionCenter_onChange(elem) {
	conventionCenterValue = elem.value;
}
function constructXMLQuery() {
	var conCenterStateValue = document.getElementById("conventionCenterState").value;
    // For the convention center to work on change
    //var conCenterCountryValue = document.getElementById("conventionCenterCountry").value;
    var conCenterCountryValue = document.getElementById("country").value;

    var url = "/service/search/lookupservlet?" + "country=" + conCenterCountryValue + "&state=" + conCenterStateValue + "&lookupType=conCenter";
	loadXMLDoc(url);
}

function loadXMLDoc(url) {
	elem = document.getElementById("conventionCenter");
	clearElemChildren(elem);
	appendToSelect(elem,'', 'Loading...');
	elem.disabled=true;

	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
	// The browser cannot support dynamic City loading - say so
	} else {
		clearElemChildren(elem);
		appendToSelect(elem,'', 'Feature Not Supported By Your Browser');
	}
}
function clearElemChildren(elem) {
	while (elem.childNodes.length > 0) {
		 elem.removeChild(elem.firstChild);
	}
}
function processReqChange() {
	// only if req shows "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			// ...processing statements go here...
			var elem = document.getElementById('conventionCenter');
			while (elem.childNodes.length > 0) {
				elem.removeChild(elem.firstChild);
			}
			elem.disabled = false;
			buildConventionCenterList();
		// We had an error - keep the element disabled and write an error
		} else {
			elem = document.getElementById('conventionCenter');
			clearElemChildren(elem);
			appendToSelect(elem,'', 'An Error Occured');
		}
	}
}

function buildConventionCenterList() {
	var select = document.getElementById("conventionCenter");
	var items = req.responseXML.getElementsByTagName("ConventionCenter");
	appendToSelect(select,'', pleaseSelect);
	for (var i=0; i<items.length; i++) {
		appendToSelect(select,items[i].childNodes[0].nodeValue, items[i].childNodes[0].nodeValue);
	}
	if (items.length == 0) {
		clearElemChildren(elem);
		appendToSelect(select,"","noneFound");
    }

    if (conventionCenterValue != "") {
        n=0;
        while(  n < select.options.length) {
            if( select.options[n].value == conventionCenterValue ){
                select.selectedIndex = n;
				break;
			}
            n++;
        }
	}
    conventionCenterValue="";
}

function appendToSelect(select, value, content) {
    var opt;
    opt = document.createElement("option");
    opt.value = value;
    opt.appendChild(document.createTextNode(content));
    select.appendChild(opt);
}

// Initialize form correctly
function initConventionCenter() {
    var conCenterState = document.getElementById("conventionCenterState");
	var conventionCenter = document.getElementById("conventionCenter");

	if (conCenterState.value != "") {
		constructXMLQuery();
	}
}

addLoadEvent(function () {
   // initConventionCenter();
});

function resetfindby() {
    var selectElement = document.getElementById("findByDropDown");
    var index = selectElement.selectedIndex;
    document.getElementById("searchForm").reset();
    selectElement.options[index].selected =true;
}