var MapHandler = {

    iframeId : "google-maps-iframe",

    hrefId : "google-maps-href",

    map : null,

    update : function() {
        if (GBrowserIsCompatible()) {
            var llArr = $('#shipPosition_shipId').val().split(/,/);
            var point = new GLatLng(llArr[0], llArr[1]);
            MapHandler.map.setCenter(point, 12);
            MapHandler.map.addOverlay(new GMarker(point));
        }
    },

    initialize :function() {
        if (GBrowserIsCompatible()) {
            MapHandler.map = new GMap2(document.getElementById("google-maps-canvas"));
            var point = new GLatLng($('#current-latitude').val(), $('#current-longitude').val());
            MapHandler.map.setCenter(point, 12);
            MapHandler.map.setUIToDefault();
            MapHandler.map.setMapType(G_SATELLITE_MAP);
            MapHandler.map.addOverlay(new GMarker(point));
        }
    }
};

var FlashAnimations = {

    start : function() {
        swfobject.embedSWF("/static/flash/lighthouse.swf", "lighthouse-box",
                           "288", "123", "9.0.0",
                           "expressInstall.swf",
                           {});
        swfobject.embedSWF("/static/flash/buoy.swf", "buoy-box",
                           "69", "37", "9.0.0",
                           "expressInstall.swf",
                           {});
    },

    stop : function() {
        swfobject.removeSWF('lighthouse-box');
        swfobject.removeSWF('buoy-box');
    }
    
};


$(document).ready(function() {

    if ($('#message').size() > 0) {
        FlashAnimations.stop();
        $('#message').dialog({
            dialogClass: 'alert',
            draggable: false,
            modal: true,
            buttons: {
                "Ok": function() {
                    $(this).dialog("close");
                    $('#message').remove();
                    FlashAnimations.start();
                }
            }
        });

    } else {
        FlashAnimations.start();
    }


});


