﻿/*
    Local Pages 2008 - Javascript Files
    File:               localpages.js
    
    Change History:
    
        17-Dec-07       Steven Gray     - Initial Draft
 */
 
/// <summary>
///    Generate the search url for a top-categories button.
/// </summary>
function GenerateSearchUrl(strCategoryText)
{
    var strLocation = document.getElementById("lpucSearchForm1_SearchForm_TxtLocation").value    
    var chkShowOnMap = document.getElementById("lpucSearchForm1_SearchForm_ChkMap")
    
    if ((strLocation == null) || (strLocation.length == 0))
    {
        alert('Please specify a location!');
        return false;
    }
    
    strCategoryText = escape(strCategoryText);
    var strNewUrl = '';
    if (chkShowOnMap.checked)
        strNewUrl = '/resultsmap.aspx?map=true&Location=' + strLocation  + '&Category=' + strCategoryText;
    else        
        strNewUrl = '/results.aspx?Location=' + strLocation  + '&Category=' + strCategoryText;
    document.location.href = strNewUrl;
    return false;
}

/// <summary>
///     Add a pushmin to the google maps instance.
/// </summary>
function AddPushPin(lat, lng, label, text)
{    
    var myPoint = new LatLonPoint(lat, lng);     
    var my_marker = new Marker(myPoint);
    
    // add a label to the marker
    my_marker.setLabel(label);

    // add info bubble to the marker
    my_marker.setInfoBubble(text);
    my_marker.setIcon("/Images/Icons/Arrow_Down_Map.gif");

    // display marker 
    mapstraction.addMarker(my_marker);
}


/// <summary>
///     Centre on the specified point at the specified radius.
/// </summary>
function CenterOnLocation(lat, lng, locationText)
{
    var myPoint = new LatLonPoint(lat, lng);
    var my_marker = new Marker(myPoint);
    
    mapstraction.setCenterAndZoom(myPoint, 12);
    mapstraction.addControls({
        pan: true, 
        zoom: "small",
        map_type: true 
    });
    
    // add a label to the marker
    my_marker.setLabel(locationText);
    my_marker.setInfoBubble(locationText);
    my_marker.setIcon("/Images/Icons/Arrow_Down_Home.gif");
    mapstraction.addMarker(my_marker);

}
