// JavaScript Document
$(document).ready(function() {

    // Page Date + Time

    var NewDat = new Date();
    var DatStr = '';

    if (NewDat.getMonth() == 0) { DatStr = 'January'; }
    if (NewDat.getMonth() == 1) { DatStr = 'February'; }
    if (NewDat.getMonth() == 2) { DatStr = 'March'; }
    if (NewDat.getMonth() == 3) { DatStr = 'April'; }
    if (NewDat.getMonth() == 4) { DatStr = 'May'; }
    if (NewDat.getMonth() == 5) { DatStr = 'June'; }
    if (NewDat.getMonth() == 6) { DatStr = 'July'; }
    if (NewDat.getMonth() == 7) { DatStr = 'August'; }
    if (NewDat.getMonth() == 8) { DatStr = 'September'; }
    if (NewDat.getMonth() == 9) { DatStr = 'October'; }
    if (NewDat.getMonth() == 10) { DatStr = 'November'; }
    if (NewDat.getMonth() == 11) { DatStr = 'December'; }

    DatStr += ' ' + NewDat.getDate();
    DatStr += '&nbsp;<span class="timeDisplay">';
    if (NewDat.getHours() < 10) { DatStr += '0' + NewDat.getHours(); } else { DatStr += NewDat.getHours(); }
    if (NewDat.getMinutes() < 10) { DatStr += ':0' + NewDat.getMinutes(); } else { DatStr += ':' + NewDat.getMinutes(); }
    DatStr += '</span>';

    $('#dateDisplay').html(DatStr);


    // Image Gallery

    $('.imageLink').click(function() {
        $('#MainImage').html('<img src="' + $(this).attr("rel") + '" alt=" " width="303" height="187" />');

        $('.imageLink').each(function() {
            if ($(this).hasClass("active")) { $(this).removeClass("active"); }
        });

        $(this).toggleClass('active');

        return false;

    });

    if (document.getElementById("map") != null && document.getElementById("map").length > 0) {

        var map = new GMap2(document.getElementById("map"));
        //map.setMapType(G_HYBRID_MAP);

        // Arrows and "+" and "-" buttons in the upper left
        map.addControl(new GSmallMapControl());

        // Buttons "Map", "Satellite", "Hybrid" in the upper right
        map.addControl(new GMapTypeControl());

        // Set center
        var center = new GLatLng(51.548992, -0.120666);
        map.setCenter(center, 15);

        var location1 = new GMarker(new GLatLng(51.548992, -0.120666));
        GEvent.addListener(location1, "click", function() { location1.openInfoWindowHtml('<span style="color: black">AMAZON PR<span>') });
        map.addOverlay(location1);

    }

});
