﻿// for different language path
var lang = 'spanish';
var pathLang = 'eng';
var pathXML = '/' + pathLang + '/xml';
var pathImage = '/' + pathLang + '/images';
var pathJS = '/' + lang  + '/js';
var pathJSP = '/' + lang + '/jsp';

var gmap = null;
var displayShow = true;
var searchNonFinish = -1;
var searchHighlight = new Array();
var indexKey = new Array();
var indexKeyResult = new Array();
var mapXMLData = new MapXMLData();

if (window.addEventListener) { // Firefox, Gecko, Safari, Konqueror
    window.addEventListener('load', onLoadMap, false);
    window.addEventListener('unload', onUnloadMap, true);
} else if (document.addEventListener) { // Opera
    document.addEventListener('load', onLoadMap, false);
    document.addEventListener('unload', onUnloadMap, true);
} else if (window.attachEvent) { // IE6, IE7
    window.attachEvent('onload', onLoadMap);
    window.attachEvent('unload', onUnloadMap);
} else { // Mac, IE5
    if (window.onload) {
        window.XTRonload = window.onload;
    }
    if (window.onunload) {
        window.XTRonunload = window.onunload;
    }
    window.onload = onLoadMap;
    window.onunload = onUnloadMap;
}

function genKey(){
    var foo = location.host, gKey;
    if (foo.indexOf("dclook.com") >= 0) {
        gKey = "ABQIAAAAbhSakKmVgYRFe8nhqFz3hxQxXZDpUXWhukXnZ93F2jdtMm9BDRQSKeWqKq28oRvJvB2NToqEJNUw_g";
    } else if (foo.indexOf("ppo.discoverhongkong.com") >= 0) {
        gKey = "ABQIAAAAE8pLvlAMOyvGYNDLTKR5shTelpimIQ-A1-E_WB4VtkikYLeMpBS-Pzddc_coXxMZXeeVedq7vshCAw";
    } else if (foo.indexOf("dcthink.com") >= 0) {
        gKey = "ABQIAAAAbhSakKmVgYRFe8nhqFz3hxQjQJPuYsF49VKeS-wq9oFiDnKiChTM_xRA9pELgJUQiBXlz-qB0k_wJg";
    } else if (foo.indexOf("www.discoverhongkong.com") >= 0) {
        gKey = "ABQIAAAAGDvirhmJlDenI-96t3tKRhSxX70ilN-NfXGTDclMjcNDiUZeEBRwl84Nf2f1tktSBFR814dfNaE0qw";
    } else if (foo.indexOf("hktant74.hktb.com") >= 0) {
        gKey = "ABQIAAAAbhSakKmVgYRFe8nhqFz3hxSn1VizQd4R4syKcBuoVaYtO81J8RSLrLK21BBvfZQv0XF0Ok9P05xS5w";
    } else if (foo.indexOf("www.beta.discoverhongkong.com") >= 0) {
        gKey = "ABQIAAAAE8pLvlAMOyvGYNDLTKR5shTjw6_JoTcOFL7ZN6C_nPjXOA0XthTfuPtK0Q93-IlCYHPu9t46e1CpKw";
    } else if(foo.indexOf("202.85.167.167")>=0){
		gKey = "ABQIAAAAD1wtieAlkzqr8fg2psKL4xTXXwvXhaEQKtdoFKBOkLLF1nc7AhQSjfc3cHCRM8ARU4IRKHF8fTJ59w";
	} else if(foo.indexOf("www.hktb.com")>=0){
		gKey = "ABQIAAAA0HoUOO5tiBhg6-RyhbAgBhQOwDAj7ysPAt5oMFivZSM0arHtIRTcAhZSsyddnIPfw0hfJmNBVtixig";
	} else if (foo.indexOf("webserv1.discoverhongkong.com") >= 0){
        gKey = "ABQIAAAAD1wtieAlkzqr8fg2psKL4xTmAENUw_BtMvXYZT-81M5tKaBSixRPY11mewBG0X9K28E4ievABccLsw";
	} else if (foo.indexOf("webserv2.discoverhongkong.com") >= 0){
        gKey = "ABQIAAAAD1wtieAlkzqr8fg2psKL4xQEk1ntXvbiGEDFQDq4JdyBCs6MuBTEnRzEDPJyXblKx-Nqri4-Nq7GPA";
	} else if (foo.indexOf("discoverhongkong.com") >= 0){
        gKey = "ABQIAAAAGDvirhmJlDenI-96t3tKRhSxX70ilN-NfXGTDclMjcNDiUZeEBRwl84Nf2f1tktSBFR814dfNaE0qw";
	}
    document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=" + gKey + "' type='text/javascript'></script>");
    //document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAbhSakKmVgYRFe8nhqFz3hxSn1VizQd4R4syKcBuoVaYtO81J8RSLrLK21BBvfZQv0XF0Ok9P05xS5w' type='text/javascript'></script>");
}

// pre-load map data
function onLoadMap(){
    MM_preloadImages(pathImage + '/map/icon_attractions.png', pathImage + '/map/icon_shopping.png', pathImage + '/map/icon_dining.png', pathImage + '/map/icon_hotels.png', pathImage + '/map/icon_events.png');
    mapXMLData.load(pathLang);
}

// clear memory of map data
function onUnloadMap(){
    indexKey = null;
    indexKeyResult = null;
    mapXMLData.clear();
    GUnload();
}

function getHotelDetail(vhid, addrid){
    openMapLocatorPopup(pathJSP + "/hotel/search-details.jsp?vhid=" + vhid + "&addrid=" + addrid);
}

function getEventDetail(eventid){
    document.eventDetailForm.event_id.value = eventid;
    document.eventDetailForm.submit();
}

// assign image to gicon
function setGIcon(gicon, iconImage){
    gicon.image = iconImage;
    gicon.shadow = "";
    gicon.iconSize = new GSize(34, 33);
    gicon.shadowSize = new GSize(0, 0);
    gicon.iconAnchor = new GPoint(1, 31);
    gicon.infoWindowAnchor = new GPoint(14, 1);
    gicon.infoShadowAnchor = new GPoint(0, 0);
}

// A function to create the marker and set up the event window
function createMarker(point, name, html, gicon, category){
    var marker = new GMarker(point, {
        icon: gicon,
        title: name
    });
    // === Store the category and name info as a marker properties ===
    marker.mycategory = category;
    marker.myname = name;
    var opts = {
        maxWidth: 300
    };
    GEvent.addListener(marker, "click", function(){
        marker.openInfoWindowHtml(html, opts);
    });
    return marker;
}

// store map's xml
function MapXMLData(){
    this.xmlAttraction = new Array();
    this.xmlShop = new Array();
    this.xmlDine = new Array();
    this.xmlHotel = new Array();
    this.xmlEvent = new Array();
    
    this.load = function(pathLang, async){
        var path = '/' + pathLang + '/xml/map';

        this.requestXML(pathLang, 'searchDict', path + '/searchDict.xml', async);
        this.requestXML(pathLang, getMapXMLName(path + '/attractions.xml'), path + '/attractions.xml', async);
        this.requestXML(pathLang, getMapXMLName(path + '/shopDistrict.xml'), path + '/shopDistrict.xml', async);
        this.requestXML(pathLang, getMapXMLName(path + '/diningDistrict.xml'), path + '/diningDistrict.xml', async);
        this.requestXML(pathLang, getMapXMLName(path + '/hotels.xml'), path + '/hotels.xml', async);
        this.requestXML(pathLang, getMapXMLName(path + '/events.xml'), path + '/events.xml', async);
    }
    
    this.requestXML = function(pathLang, type, xmlFile, async){
		if (bigGoogleMap == null || getMapSearchType(bigGoogleMap) == 'trip' ||
			getMapSearchType(bigGoogleMap) == type ||
			(type == 'searchDict' && document.getElementById('searchKey') != null)) {
	        var instance = this;
	        var request = GXmlHttp.create();
			
			if (async)
				request.open("GET", xmlFile, false);
			else
				request.open("GET", xmlFile, true);
	        request.onreadystatechange = function(){
	            if (request.readyState == 4) {
	                var xmlDoc = request.responseXML;
					if (type == 'searchDict') {
						var keys = xmlDoc.documentElement.getElementsByTagName("key");
            
						for (var i = 0; i < keys.length; i++) {
							var from = keys[i].getAttribute("from");
							var to = keys[i].getAttribute("to");
 
							indexKey[indexKey.length] = from.toLowerCase();
							indexKeyResult[indexKeyResult.length] = to.toLowerCase();
						}
					} else if (type == 'attraction') 
	                    instance.xmlAttraction[pathLang] = xmlDoc;
	                else 
	                    if (type == 'shop') 
	                        instance.xmlShop[pathLang] = xmlDoc;
	                    else 
	                        if (type == 'dining') 
	                            instance.xmlDine[pathLang] = xmlDoc;
	                        else 
	                            if (type == 'hotel') 
	                                instance.xmlHotel[pathLang] = xmlDoc;
	                            else 
	                                if (type == 'event') 
	                                    instance.xmlEvent[pathLang] = xmlDoc;
	            }
	        }
	        request.send(null);
		}
    }
    
    this.get = function(pathLang, type, noloop){
        var xmlDoc = null;
        if (type == 'attraction') 
            xmlDoc = this.xmlAttraction[pathLang];
        else 
            if (type == 'shop') 
                xmlDoc = this.xmlShop[pathLang];
            else 
                if (type == 'dining') 
                    xmlDoc = this.xmlDine[pathLang];
                else 
                    if (type == 'hotel') 
                        xmlDoc = this.xmlHotel[pathLang];
                    else 
                        if (type == 'event') 
                            xmlDoc = this.xmlEvent[pathLang];
        
        if (xmlDoc == null) {
            this.load(pathLang, true);
			if (noloop == null || !noloop)
				xmlDoc = this.get(pathLang, type, true);
		}
        return xmlDoc;
    }
    
    this.clear = function(){
        this.xmlAttraction = null;
        this.xmlShop = null;
        this.xmlDine = null;
        this.xmlHotel = null;
        this.xmlEvent = null;
    }
}

// active when click the tab
function readMapData(map, xmlFile, gicon){
    eraseSearchBox();
    displayNoResultsMessage(false);
	
    if (xmlFile != null && xmlFile != "") {
		// ensure request xml success in Firefox 3
		if (mapXMLData.get(pathLang, getMapXMLName(xmlFile)) == null) {
			setTimeout("loadMap(xmlPath,imgPath,'map')", 200);
			return;
		}
    
        var xmlDoc = mapXMLData.get(pathLang, getMapXMLName(xmlFile));
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        
        for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat, lng);
            
            var address = markers[i].getAttribute("address");
            var name = markers[i].getAttribute("name");
            var website = markers[i].getAttribute("website");
            var email = markers[i].getAttribute("email");
            var tel = markers[i].getAttribute("tel");
            var fax = markers[i].getAttribute("fax");
            var vhid = markers[i].getAttribute("vhid");
            
            var addrid = markers[i].getAttribute("addrid");
            var eventid = markers[i].getAttribute("eventid");
            var image1 = markers[i].getAttribute("image");
            var desc = markers[i].getAttribute("districtDesc");
            var category = markers[i].getAttribute("category");
            var show = markers[i].getAttribute("show");
            
            var html = getHTMLValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image1, desc, category);
            // create the marker
            if (show == null) {
                var marker = createMarker(point, name, html, gicon, category);
                map.addOverlay(marker);
            }
        }
    }
}

// active when search map
function readMapDataFromSearch(xmlFile, map, gicon){
    try {
        String.prototype.trim = function(){
            return this.replace(/^\s+|\s+$/g, "");
        }
        String.prototype.ltrim = function(){
            return this.replace(/^\s+/, "");
        }
        String.prototype.rtrim = function(){
            return this.replace(/\s+$/, "");
        }
        
        displayNoResultsMessage(false);
        highlightSelectedImage(); // highlight image using drop down list to search
        var markerMap = new Array();
        var searchKeyObj = document.getElementById("searchKey");
        var catObj = document.getElementById("searchCat");
        
        if ((xmlFile != "" || (catObj != null && catObj.selectedIndex == 0)) && searchKeyObj != null) {
			if (catObj != null)
				searchNonFinish = catObj.options.length - 1;
			
            var replaceKey = new Array();
            replaceKey[replaceKey.length] = 'in';
            replaceKey[replaceKey.length] = 'at';
            replaceKey[replaceKey.length] = 'on';
            
            var searchKey = document.getElementById("searchKey").value.trim().toLowerCase();
            searchKey = replaceAll(searchKey, ',', ' ');
            for (var i = 0; i < replaceKey.length; i++) {
                searchKey = replaceAll(searchKey, " " + replaceKey[i] + " ", " ");
            }
            
            for (var i = 0; i < indexKey.length; i++) {
                if (searchKey.indexOf(indexKey[i]) != -1 && searchKey.indexOf(indexKeyResult[i]) == -1) {
                    searchKey = searchKey.replace(indexKey[i], indexKeyResult[i]);
                }
            }
            searchKey = replaceAll(searchKey, '  ', ' ');
            
            // Request Map's XML
            buildMapXML(map, searchKey, markerMap, pathImage + '/map/icon_attractions.png', pathXML + '/map/attractions.xml', "attraction");
            buildMapXML(map, searchKey, markerMap, pathImage + '/map/icon_shopping.png', pathXML + '/map/shopDistrict.xml', "shop");
            buildMapXML(map, searchKey, markerMap, pathImage + '/map/icon_dining.png', pathXML + '/map/diningDistrict.xml', "dining");
            buildMapXML(map, searchKey, markerMap, pathImage + '/map/icon_hotels.png', pathXML + '/map/hotels.xml', "hotel");
            buildMapXML(map, searchKey, markerMap, pathImage + '/map/icon_events.png', pathXML + '/map/events.xml', "event");
        }
    }
    catch (err) {
        alert(err);
    }
}

function buildMapXML(map, searchKey, markerMap, imgURL, xmlFile, searchType){
    var catObj = document.getElementById("searchCat");
    
    if (getMapSearchType(bigGoogleMap) == searchType ||
	    (catObj != null && (catObj.selectedIndex == 0 ||
	    getMapSearchType(catObj.options[catObj.selectedIndex].value) == searchType))) {
        var gicon = new GIcon();
        setGIcon(gicon, imgURL);
        
        var xmlDoc = mapXMLData.get(getMapXMLLang(xmlFile), getMapXMLName(xmlFile));
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        var searchArr = searchKey.split(" ");
        
        for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat, lng);
            
            var address = markers[i].getAttribute("address");
            var name = markers[i].getAttribute("name");
            var website = markers[i].getAttribute("website");
            var email = markers[i].getAttribute("email");
            var tel = markers[i].getAttribute("tel");
            var fax = markers[i].getAttribute("fax");
            var vhid = markers[i].getAttribute("vhid");
            
            var addrid = markers[i].getAttribute("addrid");
            var eventid = markers[i].getAttribute("eventid");
            var image1 = markers[i].getAttribute("image");
            var desc = markers[i].getAttribute("districtDesc");
            var category = markers[i].getAttribute("category");
            var show = markers[i].getAttribute("show");
            
            var html = getHTMLValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image1, desc, category);
            
            if (displayShow || show == null) {
				var notfound = false;
				if (searchArr.length > 1 || (searchArr.length == 1 && searchArr[0] != "")) {
					for (var j = 0; j < searchArr.length; j++) {
						if (!searchKeyResult(name, searchArr[j]) &&
							!searchKeyResult(address, searchArr[j]) &&
							!searchKeyResult(desc, searchArr[j])) {
							notfound = true;
						}
					}
				}
				
				if (notfound == false) {
					var marker = createMarker(point, name, html, gicon, category);
					map.addOverlay(marker);
					markerMap.push(point);
	            }
	        }
        }
        
        searchDone(map, searchKey, markerMap);
    }
    else {
        searchDone(map, searchKey, markerMap);
    }
}

// check search done
function searchDone(map, searchKey, markerMap){
	var catObj = document.getElementById("searchCat");
	if (catObj != null)
		--searchNonFinish;
    if (catObj == null || searchNonFinish == 0) {
        location.href = "#map";
        if (markerMap.length > 0) {
            zoomMap(map, markerMap);
        }
        else {
            displayNoResultsMessage(true);
        }
    }
}

function searchKeyResult(key, searchKey){
    if (key != null && key != "") {
        var key = replaceAll(key.toLowerCase(), ":", " ");
        key = replaceAll(key, ",", " ");
        key = replaceAll(key, "  ", " ");
        var keyArr = key.split(" ");
        for (var count = 0; count < keyArr.length; count++) {
            if (keyArr[count] == searchKey) {
                return true;
            }
        }
    }
    return false;
}

// zoom to searched marker
function zoomMap(map, markerMap){
    if (markerMap.length > 0) {
        var poly = new GPolyline(markerMap);
        var bounds = poly.getBounds();
        
        var zoomin = map.getBoundsZoomLevel(bounds);
        if (zoomin > 16)
            zoomin = 16;
        else 
            if (zoomin > 10 && zoomin <= 16) 
                zoomin--;
        map.setCenter(bounds.getCenter(), zoomin);
    }
}

function getCheckedValue(radioObj){
    if (!radioObj) 
        return "";
    var radioLength = radioObj.length;
    if (radioLength == undefined) 
        if (radioObj.checked) 
            return radioObj.value;
        else 
            return "";
    for (var i = 0; i < radioLength; i++) {
        if (radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}

function loadMap(xmlfile, imagepath, objectname, search){
    if (!GBrowserIsCompatible()) {
        alert("Sorry, the Google Maps API is not compatible with this browser");
        return;
    }
	
    var gicon = new GIcon();
    var catObj = document.getElementById("searchCat");
    //cat = getCheckedValue(document.getElementsByName("searchCat"));
    if (typeof(search) == 'string') {
        try {
			var cat = '';
			try {
				if (catObj != null)
					cat = catObj.value;
				else
					cat = bigGoogleMap;
				cat = getMapSearchType(cat);
			} catch (err) {
				alert(err);
			}
            if (cat != '') {
                if (cat == "attraction") {
                    imagepath = pathImage + '/map/icon_attractions.png';
                    xmlfile = pathXML + '/map/attractions.xml';
                }
                else 
                    if (cat == "event") {
                        imagepath = pathImage + '/map/icon_events.png';
                        xmlfile = pathXML + '/map/events.xml';
                    }
                    else 
                        if (cat == "shop") {
                            imagepath = pathImage + '/map/icon_shopping.png';
                            xmlfile = pathXML + '/map/shopDistrict.xml';
                        }
                        else 
                            if (cat == "dining") {
                                imagepath = pathImage + '/map/icon_dining.png';
                                xmlfile = pathXML + '/map/diningDistrict.xml';
                            }
                            else 
                                if (cat == "hotel") {
                                    imagepath = pathImage + '/map/icon_hotels.png';
                                    xmlfile = pathXML + '/map/hotels.xml';
                                }
            }
        }
        catch (err) {
            alert(err);
        }
    }
    setGIcon(gicon, imagepath);

    // create the map
    try {
		if (gmap == null) {
			var map = new GMap2(document.getElementById(objectname));
	        
	        if (arguments[5] == null) {
	            map.addControl(new GLargeMapControl());
	            map.addControl(new GMapTypeControl());
	        }
	        var overviewMap = new GOverviewMapControl(); // right bottom small map
	        map.addControl(overviewMap);
	        overviewMap.hide();
			gmap = map;
		} else {
			var map = gmap;
			map.clearOverlays();
		}

        var zoomin = (arguments[4] != null) ? arguments[4] : 10;
        try {
            map.setCenter(new GLatLng(22.356740, 114.152862), zoomin); // set to center of hong kong
        }
        catch (err) {
        }
        if (typeof(search) != 'string') {
            highlightSelectedImage(xmlfile);
            readMapData(map, xmlfile, gicon);
        }
        else {
            if (imagepath != '' || (catObj != null && catObj.options[0].selected))
                readMapDataFromSearch(xmlfile, map, gicon);
        }
    }
    catch (err) {
        alert(err);
    }
}

function MakeCopyrightSmaller(){
    for (var i = 0; i < document.getElementById("map").childNodes.length; ++i) {
        if (document.getElementById("map").childNodes[i].innerHTML.indexOf(String.fromCharCode(169)) !== -1) {
            document.getElementById("map").childNodes[i].style.fontSize = '9px';
            document.getElementById("map").childNodes[i].style.letterSpacing = '0px';
            break;
        }
    }
}

function replaceAll(strOrg, strFind, strReplace){
    var index = 0;
    while (strOrg.indexOf(strFind, index) != -1) {
        strOrg = strOrg.replace(strFind, strReplace);
        index = strOrg.indexOf(strFind, index);
    }
    return strOrg;
}

function highlightSelectedImage(xmlFile){
    try {
        searchHighlight = new Array();
        if (xmlFile == pathXML + "/map/attractions.xml") {
            document.getElementById("imgAttractions").src = pathImage + "/btn_attractions_f2.jpg";
            searchHighlight.push('attractions');
        }
        else 
            document.getElementById("imgAttractions").src = pathImage + "/btn_attractions.jpg";
        if (xmlFile == pathXML + "/map/shopDistrict.xml") {
            document.getElementById("imgShopDistricts").src = pathImage + "/btn_shop_districts_f2.jpg";
            searchHighlight.push('shop');
        }
        else 
            document.getElementById("imgShopDistricts").src = pathImage + "/btn_shop_districts.jpg";
        if (xmlFile == pathXML + "/map/diningDistrict.xml") {
            document.getElementById("imgDineDistricts").src = pathImage + "/btn_dine_districts_f2.jpg";
            searchHighlight.push('dining');
        }
        else 
            document.getElementById("imgDineDistricts").src = pathImage + "/btn_dine_districts.jpg";
        if (xmlFile == pathXML + "/map/hotels.xml") {
            document.getElementById("imgHotels").src = pathImage + "/btn_hotels_f2.jpg";
            searchHighlight.push('hotels');
        }
        else 
            document.getElementById("imgHotels").src = pathImage + "/btn_hotels.jpg";
        if (xmlFile == pathXML + "/map/events.xml") {
            document.getElementById("imgEvents").src = pathImage + "/btn_events_venues_f2.jpg";
            searchHighlight.push('events');
        }
        else 
            document.getElementById("imgEvents").src = pathImage + "/btn_events_venues.jpg";
    } 
    catch (err) {
    }
}

function getMapXMLName(xmlFile){
    if (xmlFile.indexOf("/map/attractions.xml") != -1) 
        return 'attraction';
    else 
        if (xmlFile.indexOf("/map/shopDistrict.xml") != -1) 
            return 'shop';
        else 
            if (xmlFile.indexOf("/map/diningDistrict.xml") != -1) 
                return 'dining';
            else 
                if (xmlFile.indexOf("/map/hotels.xml") != -1) 
                    return 'hotel';
                else 
                    if (xmlFile.indexOf("/map/events.xml") != -1) 
                        return 'event';
                    else 
                        return false;
}

function getMapXMLLang(xmlFile){
    var lang = xmlFile.substring(0, xmlFile.indexOf('/xml'));
    if (lang.substring(0, 1) == '/') 
        lang = lang.substring(1);
    return lang;
}

function getMapSearchType(type){
    if (type == 'trip') 
        return 'trip';
    else 
        if (type == 'attraction' || type == 'attractions') 
            return "attraction";
        else 
            if (type == 'shopping' || type == 'shop') 
                return "shop";
            else 
                if (type == 'dining') 
                    return "dining";
                else 
                    if (type == 'hotel' || type == 'hotels') 
                        return "hotel";
                    else 
                        if (type == 'event' || type == 'events') 
                            return "event";    
}

function checkImageSwap(cat){
    for (var i = 0; i < searchHighlight.length; i++) {
        if (searchHighlight[i] == cat) 
            return false;
    }
    return true;
}

function displayMapMessageBox(display){
    var mapMessageBox = document.getElementById('mapMessageBox');
    if (mapMessageBox != null) {
        if (display) 
            mapMessageBox.style.display = 'block';
        else 
            mapMessageBox.style.display = 'none';
    }
}

function displayNoResultsMessage(display){
    var noResultsMessage = document.getElementById('noResultsMessage');
    if (noResultsMessage != null) {
        if (display) {
            noResultsMessage.style.display = 'block';
            displayMapMessageBox(true);
        }
        else {
            noResultsMessage.style.display = 'none';
            displayMapMessageBox(false);
        }
    }
}

function eraseSearchBox(){
    var searchObj = document.getElementById('searchKey');
    if (searchObj != null)
        searchObj.value = '';
}

if (bigGoogleMap != null) {
    genKey();
    setTimeout('MakeCopyrightSmaller();', 2000);
    setTimeout('MakeCopyrightSmaller();', 4000);
    
    if (bigGoogleMap == 'attraction') {
        document.write("<script type='text/javascript' src='" + pathJS + "/gmap_attractions.js'> </script>");
    }
    else 
        if (bigGoogleMap == 'event') {
            document.write("<script type='text/javascript' src='" + pathJS + "/gmap_events.js'> </script>");
        }
        else 
            if (bigGoogleMap == 'hotel') {
                document.write("<script type='text/javascript' src='" + pathJS + "/gmap_hotels.js'> </script>");
            }
            else 
                if (bigGoogleMap == 'dining') {
                    document.write("<script type='text/javascript' src='" + pathJS + "/gmap_dining_district.js'> </script>");
                }
                else 
                    if (bigGoogleMap == 'shopping') {
                        document.write("<script type='text/javascript' src='" + pathJS + "/gmap_shop_district.js'> </script>");
                    }
                    else 
                        if (bigGoogleMap == 'trip') {
                            document.write("<script type='text/javascript' src='" + pathJS + "/gmap_trip.js'> </script>");
                        }
}
