/**
 * Function used on all locations/* pages
 *
 * @package    byronfinance.com
 * @author     Rob Edwards
 * @copyright  (c)  bryce:FARRAH
 */




/**
 * Use this function to create the marker. It takes the address HTML and adds the
 * buttons to allow for the user to get directions 'to' or 'from' the point set.
 *
 * @author Rob Edwards
 */
function createMarker(map, point, name, content, address) {
    
    //Create the marker
    var marker = new GMarker(point);
    
    var url = String(window.location.href);
    var search = String(name);
    
    search = search.toLowerCase();

    // The inactive version of the direction info
    var html = content + '<p>Add your postcode below to get<br /> directions to our '+name+' office.</p>'+
        '<p><form class="map-form" id="'+ name +'" target="_blank" action="http://maps.google.co.uk/maps" method="get">'+
            '<input type="hidden" name="daddr" value="'+ address +'" />'+
            '<input type="hidden" name="hl" value="en" />'+
            '<div class="form-row">'+
                '<label for="saddr">Postcode: </label>'+
                '<input type="text" name="saddr" id="saddr" value="" /><br class="clear" />'+
            '</div>'+
            '<div class="form-row">'+
                '<input style="clear: both;" class="submit" value="Get Directions" type="submit" /><br />'+
            '</div>'+
        '</form></p>';
    

    //Add the click functionality to the marker
    GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(html);
    });
    
    map.addOverlay(marker);
    
    if(url.match(search) != null) {
        marker.openInfoWindowHtml(html);
    }
}


