﻿$(document).ready(function() {
    $("#header ul li a,#hpOurWork a").hover(function() {
        $(this).find('.to').fadeIn();
    }, function() {
        $(this).find('.to').fadeOut();
    });


    if ($("#hprhs .col").length > 0) {
        $("#hprhs .col").eq(1).css("padding-top", "100px");
        $("#hprhs .col").eq(2).css("padding-top", "59px");
    }
});


var map = null;
var geocoder = null;

function initialize() {
    if (GBrowserIsCompatible()) {

        map = new GMap2(document.getElementById("map_canvas"));
        //map.setCenter(new GLatLng(52.061000, 0.191500), 10); // long lat zoom
        geocoder = new GClientGeocoder();

        //map.openInfoWindowHtml(map.getCenter(), "<p>Hiya</p><p><a href=\"http://localhost:2065/GoogleMaps/Default.aspx\">link</a></p>");
        map.setUIToDefault();

        showAddress("The Sidings, Station Rd, Shepreth, Royston, Hertfordshire SG8 6PZ")

    }
}

function showAddress(address) {
    if (geocoder) {
        geocoder.getLatLng(
                    address,
                    function(point) {
                        if (!point) {
                            alert(address + " not found");
                        } else {
                            map.setCenter(point, 13);
                            var marker = new GMarker(point);
                            map.addOverlay(marker);
                            //marker.openInfoWindowHtml(address.capitalize().replace(/,/g, "<br/>"));
                            marker.openInfoWindowHtml("<p style=\"padding:5px\"><img src=\"img/ContactLogo.jpg\"/></p>");

                        }
                    }
                );
    }
}

String.prototype.capitalize = function() {
    return this.replace(/(^|\s)([a-z])/g,
    function(m, p1, p2) {
        return p1 + p2.toUpperCase();
    });
}; 

