/**
 * @author lorebook.lotro.com
 */
var mapIcons = {};

var GME_DEFAULT_ICON = google.maps.DEFAULT_ICON;
var markers = Array();
var currentRow = null;
//var CONTENT_URL = "http://images.lorebook.lotro.com/";
var CONTENT_URL = "http://loreimages.level3.lotro.com/";
var GOOGLE_MAP_CONTENT_URL = "http://content.level3.turbine.com/sites/google_map/";


function infoWindowClosed(){
    if (currentRow) {
        var row = document.getElementById(currentRow);
        row.className = row.className.replace(" rowOn", "");
        currentRow = null;
    }
	
	
}

function highlightSearchRow(id){
    if (currentRow) {
        var row = document.getElementById(currentRow);
        row.className = row.className.replace(" rowOn", "");
        currentRow = null;
    }
    var row = document.getElementById("row_" + id);
    if (row) {
        row.className += " rowOn";
        currentRow = "row_" + id;
    }
}

function openMarker(id){
    var marker = markers[id];
    if (marker) {
        if (marker.tabs) {
            marker.openInfoWindowTabsHtml(marker.tabs);
        }
        else 
            if (marker.caption) {
                marker.openInfoWindowHtml(marker.caption);
            }
    }
    highlightSearchRow(id);
}

function createMarker(id, point, options){
    var marker = new google.maps.Marker(point, options);
    marker.id = id;
    markers[id] = marker;
    google.maps.Event.addListener(marker, "click", function(){
        marker.openInfoWindowHtml(marker.caption);
        highlightSearchRow(marker.id);
    });
    
    return marker;
}

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

function makeMap1(){
    if (google.maps.BrowserIsCompatible()) {
        map = new google.maps.Map2(document.getElementById("map1"));
        
        GEvent.addListener(map, 'click', function(overlay, point){
           if (overlay) {
             if (overlay.tabs) {
                overlay.openInfoWindowTabsHtml(overlay.tabs);
             }
           else 
             if (overlay.caption) {
               overlay.openInfoWindowHtml(overlay.caption);
             }
           }
        });
        map.enableContinuousZoom();
        map.enableDoubleClickZoom();
		map.disableScrollWheelZoom();
        map.addControl(new google.maps.SmallMapControl());
        
        map.setCenter(areaArray[document.getElementById('housingArea_area_id').value].loc, 6, G_GAME_MAP);
		
		initMyData();
    }
    else {
        document.getElementById("map1").innerHTML = "In order to see the map that would go in this space, you will need to use a <a href=\"http://local.google.com/support/bin/answer.py?answer=16532&amp;topic=1499\">compatible web browser</a>.";
        
    }
}

