/* 
 This file was generated by Dashcode.  
 You may edit this file to customize your widget or web page 
 according to the license.txt file included in the project.
 */

var matches = new Array();
var currentBranchAddress;
//
// Function: distance()
// Called by navigator object to obtain latitude and longitude
//
function distance(lat1, lon1, lat2, lon2) {
    var radlat1 = Math.PI * lat1/180
    var radlat2 = Math.PI * lat2/180
    var radlon1 = Math.PI * lon1/180
    var radlon2 = Math.PI * lon2/180
    var theta = lon1-lon2
    var radtheta = Math.PI * theta/180
    var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
    dist = Math.acos(dist)
    dist = dist * 180/Math.PI
    dist = dist * 60 * 1.1515
    dist = dist*100;
    dist = Math.round(dist)/100;
    return dist;
}   

var listController = {
    // This object acts as a controller for the list UI.
    // It implements the dataSource methods for the list.
    
    numberOfRows: function() {

        // The List calls this dataSource method to find out how many rows should be in the list.
        this.count = this.count + 1;
        for(var i = 0; i < libraries.data.length; i++){
            var branch_lat = libraries.data[i].latitude;
            var branch_lng = libraries.data[i].longitude;
            var miledistance = distance(branch_lat,branch_lng,client_lat,client_lng);
            if(miledistance < 3){
                libraries.data[i].current_distance = miledistance; 
                matches.push(libraries.data[i]);
            }
        }        
        return matches.length;
    },
    
    prepareRow: function(rowElement, rowIndex, templateElements) {
        // The List calls this dataSource method for every row.  templateElements contains references to all elements inside the template that have an id. We use it to fill in the text of the rowTitle element.
        if (templateElements.rowTitle) {
            templateElements.rowTitle.innerText = matches[rowIndex].branch_name;            
            templateElements.rowDistance.innerText = matches[rowIndex].current_distance + " mi";
        }

        // We also assign an onclick handler that will cause the browser to go to the detail page.
        var self = this;
        var handler = function() {

            var library = matches[rowIndex];
            detailController.setLibrary(library);
            var browser = document.getElementById('browser').object;
            // The Browser's goForward method is used to make the browser push down to a new level.  Going back to previous levels is handled automatically.
            trackLibrary(library.branch_name);
            browser.goForward(document.getElementById('detailLevel'), library.branch_name);
        };
        rowElement.onclick = handler;
    }
};

var detailController = {
    // This object acts as a controller for the detail UI.
    
    setLibrary: function(library) {
        
        this._library = library;
        this._representedObject = library.branch_name;
        
        // When the park is set, this controller also updates the DOM for the detail page appropriately.  As you customize the design for the detail page, you will want to extend this code to make sure that the correct information is populated into the detail UI.
        var detailTitle = document.getElementById('detailTitle');
        detailTitle.innerHTML = this._library.branch_name;
        var detailLocation = document.getElementById('detailLocation');
        detailLocation.innerHTML = this._library.branch_address;
        var detailDescription = document.getElementById('detailDescription');
        detailDescription.innerHTML = this._library.current_distance+" miles from Current Location";
        
        var detailTimeForMonday = document.getElementById('detailTimeMon');
        detailTimeForMonday.innerHTML = this._library.monday;
        var detailTimeForTuesday = document.getElementById('detailTimeTue');
        detailTimeForTuesday.innerHTML = this._library.tuesday;
        var detailTimeForWednesday = document.getElementById('detailTimeWed');
        detailTimeForWednesday.innerHTML = this._library.wednesday;
        var detailTimeForThursday = document.getElementById('detailTimeThu');
        detailTimeForThursday.innerHTML = this._library.thursday;
        var detailTimeForFriday = document.getElementById('detailTimeFri');
        detailTimeForFriday.innerHTML = this._library.friday;
        var detailTimeForSaturday = document.getElementById('detailTimeSat');
        detailTimeForSaturday.innerHTML = this._library.saturday;
        var detailTimeForSunday = document.getElementById('detailTimeSun');
        detailTimeForSunday.innerHTML = this._library.sunday;
        
        currentBranchAddress = this._library.branch_address+"("+this._library.branch_name+")";

    }
    
};


//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{
    dashcode.setupParts();

}


var libraries = { "data":  [{	"latitude" :  40.8659836,	"longitude" :  -73.8634903,	"branch_name" :  "Allerton Branch",	"branch_address" :  "2740 Barnes Avenue, 10467",	"telephone" :  "(718) 881-4240",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8710400,	"longitude" :  -73.8283210,	"branch_name" :  "Baychester Branch",	"branch_address" :  "2049 Asch Loop North, 10475",	"telephone" :  "(718) 379-6700",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8545234,	"longitude" :  -73.8877758,	"branch_name" :  "Belmont Branch",	"branch_address" :  "610 E. 186th Street, 10458",	"telephone" :  "(718) 933-6410",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8268830,	"longitude" :  -73.9227510,	"branch_name" :  "Borough Center",	"branch_address" :  "Bronx Library Center",	"telephone" :  "310 East Kingsbridge Road, 10458.",	"monday": "(718) 579-4244",	"tuesday": "9-9",	"wednesday": "9-9",	"thursday": "9-9",	"friday": "9-9",	"saturday": "9-9",	"sunday": "9-9",	"current_distance" :  0},
{	"latitude" :  40.8265394,	"longitude" :  -73.8498071,	"branch_name" :  "Castle Hill Branch",	"branch_address" :  "947 Castle Hill Avenue, 10473",	"telephone" :  "(718) 824-3838",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8475961,	"longitude" :  -73.7866012,	"branch_name" :  "City Island Branch",	"branch_address" :  "320 City Island Avenue, 10464",	"telephone" :  "(718) 885-1703",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8300087,	"longitude" :  -73.8747487,	"branch_name" :  "Clason's Point Branch",	"branch_address" :  "1215 Morrison Avenue, 10472",	"telephone" :  "(718) 842-1235",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8701554,	"longitude" :  -73.8455824,	"branch_name" :  "Eastchester Branch",	"branch_address" :  "1385 East Gun Hill Road, 10469",	"telephone" :  "(718) 653-3292",	"monday": "10-6",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8885867,	"longitude" :  -73.8409359,	"branch_name" :  "Edenwald Branch",	"branch_address" :  "1255 East 233rd Street, 10466",	"telephone" :  "(718) 798-3355",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8557872,	"longitude" :  -73.9103600,	"branch_name" :  "Francis Martin Branch",	"branch_address" :  "2150 University Avenue, 10453",	"telephone" :  "(718) 295-5287",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8438310,	"longitude" :  -73.9102854,	"branch_name" :  "Grand Concourse Branch",	"branch_address" :  "155 East 173rd Street, 10457",	"telephone" :  "(718) 583-6611",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "12-5",	"current_distance" :  0},
{	"latitude" :  40.8186038,	"longitude" :  -73.8938941,	"branch_name" :  "Hunt's Point Branch",	"branch_address" :  "877 Southern Boulevard, 10459",	"telephone" :  "(718) 617-0338",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8692378,	"longitude" :  -73.9011977,	"branch_name" :  "Jerome Park Branch",	"branch_address" :  "118 Eames Place, 10468",	"telephone" :  "(718) 549-5200",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8804126,	"longitude" :  -73.9077041,	"branch_name" :  "Kingsbridge Branch",	"branch_address" :  "280 West 231st Street, 10463",	"telephone" :  "(718) 548-5656",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8265484,	"longitude" :  -73.9178963,	"branch_name" :  "Melrose Branch",	"branch_address" :  "910 Morris Avenue, 10451",	"telephone" :  "(718) 588-0110",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8479081,	"longitude" :  -73.8567333,	"branch_name" :  "Morris Park Branch",	"branch_address" :  "985 Morris Park Avenue, 10462",	"telephone" :  "(718) 931-0636",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8313300,	"longitude" :  -73.9017650,	"branch_name" :  "Morrisania Branch",	"branch_address" :  "610 East 169th Street, 10456",	"telephone" :  "(718) 589-9268",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8742138,	"longitude" :  -73.8782554,	"branch_name" :  "Mosholu Branch",	"branch_address" :  "285 East 205th Street, 10467",	"telephone" :  "(718) 882-8239",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8114977,	"longitude" :  -73.9244728,	"branch_name" :  "Mott Haven Branch",	"branch_address" :  "321 East 140th Street, 10454",	"telephone" :  "(718) 665-4878",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8335273,	"longitude" :  -73.8581911,	"branch_name" :  "Parkchester Branch",	"branch_address" :  "1985 Westchester Avenue, 10462",	"telephone" :  "(718) 829-7830",	"monday": "8-8",	"tuesday": "8-8",	"wednesday": "8-8",	"thursday": "8-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "12-5",	"current_distance" :  0},
{	"latitude" :  40.8444647,	"longitude" :  -73.8283561,	"branch_name" :  "Pelham Bay Branch",	"branch_address" :  "3060 Middletown Road, 10461",	"telephone" :  "(718) 792-6744",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.9031672,	"longitude" :  -73.9036201,	"branch_name" :  "Riverdale Branch",	"branch_address" :  "5540 Mosholu Avenue, 10471",	"telephone" :  "(718) 549-1212",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8467560,	"longitude" :  -73.9203170,	"branch_name" :  "Sedgwick Branch",	"branch_address" :  "1701 Martin Luther King, Jr. Blvd., 10453",	"telephone" :  "(718) 731-2074",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8181284,	"longitude" :  -73.8626876,	"branch_name" :  "Soundview Branch",	"branch_address" :  "660 Soundview Avenue, 10473",	"telephone" :  "(718) 589-0880",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8864411,	"longitude" :  -73.9143101,	"branch_name" :  "Spuyten Duyvil Branch",	"branch_address" :  "650 W. 235th St., 10463",	"telephone" :  "(718) 796-1202",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8262186,	"longitude" :  -73.8242621,	"branch_name" :  "Throg's Neck Branch",	"branch_address" :  "3025 Cross Bronx Expressway Extension, 10465",	"telephone" :  "(718) 792-2612",	"monday": "10-6",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8461374,	"longitude" :  -73.8985481,	"branch_name" :  "Tremont Branch",	"branch_address" :  "1866 Washington Avenue, 10457",	"telephone" :  "(718) 299-5177",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8829870,	"longitude" :  -73.8942303,	"branch_name" :  "Van Cortlandt Branch",	"branch_address" :  "3874 Sedgwick Avenue, 10463",	"telephone" :  "(718) 543-5150",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8546133,	"longitude" :  -73.8639009,	"branch_name" :  "Van Nest Branch",	"branch_address" :  "2147 Barnes Avenue, 10462",	"telephone" :  "(718) 829-5864",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8909469,	"longitude" :  -73.8598669,	"branch_name" :  "Wakefield Branch",	"branch_address" :  "4100 Lowerre Place, 10466",	"telephone" :  "(718) 652-4663",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8446648,	"longitude" :  -73.8827295,	"branch_name" :  "West Farms Branch",	"branch_address" :  "2085 Honeywell Avenue, 10460",	"telephone" :  "(718) 367-5376",	"monday": "10-6",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8404608,	"longitude" :  -73.8469467,	"branch_name" :  "Westchester Square Branch",	"branch_address" :  "2521 Glebe Avenue, 10461",	"telephone" :  "(718) 863-0436",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.9004989,	"longitude" :  -73.8677562,	"branch_name" :  "Woodlawn Heights Branch",	"branch_address" :  "4355 Katonah Avenue, 10470",	"telephone" :  "(718) 519-9627",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8204523,	"longitude" :  -73.9046987,	"branch_name" :  "Woodstock Branch",	"branch_address" :  "761 East 160th Street, 10456",	"telephone" :  "(718) 665-6255",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7617348,	"longitude" :  -73.9689084,	"branch_name" :  "58th Street Branch",	"branch_address" :  "127 East 58th Street, 10022-1211",	"telephone" :  "(212) 759-7358",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7648430,	"longitude" :  -73.9595640,	"branch_name" :  "67th Street Branch",	"branch_address" :  "328 East 67th Street, 10065-6204",	"telephone" :  "(212) 734-1717",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7859130,	"longitude" :  -73.9518460,	"branch_name" :  "96th Street Branch",	"branch_address" :  "112 East 96th Street, 10128-2597",	"telephone" :  "(212) 289-0908",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8030120,	"longitude" :  -73.9535250,	"branch_name" :  "115th Street Branch",	"branch_address" :  "203 West 115th Street, 10026-2403",	"telephone" :  "(212) 666-9393",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8032153,	"longitude" :  -73.9347226,	"branch_name" :  "125th Street Branch",	"branch_address" :  "224 East 125th Street, 10035-1786",	"telephone" :  "(212) 534-5050",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7943412,	"longitude" :  -73.9433583,	"branch_name" :  "Aguilar Branch",	"branch_address" :  "174 East 110th Street, 10029-3212",	"telephone" :  "(212) 534-2930",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7404410,	"longitude" :  -73.9933760,	"branch_name" :  "Andrew Heiskell Braille & Talking Book Library",	"branch_address" :  "40 West 20th Street, 10011-4211",	"telephone" :  "(212) 206-5400",	"monday": "10-5",	"tuesday": "12-7",	"wednesday": "10-5",	"thursday": "12-7",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7959160,	"longitude" :  -73.9678430,	"branch_name" :  "Bloomingdale Branch",	"branch_address" :  "150 West 100th Street, 10025-5196",	"telephone" :  "(212) 222-8030",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7133130,	"longitude" :  -73.9964900,	"branch_name" :  "Chatham Square Branch",	"branch_address" :  "33 East Broadway, 10002-6804",	"telephone" :  "(212) 964-6598",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7649390,	"longitude" :  -73.9911930,	"branch_name" :  "Columbus Branch",	"branch_address" :  "742 10th Avenue, 10019-7019",	"telephone" :  "(212) 586-5098",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8149032,	"longitude" :  -73.9406969,	"branch_name" :  "Countee Cullen Branch",	"branch_address" :  "104 West 136th Street, 10030-2695",	"telephone" :  "(212) 491-2070",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "12-5",	"current_distance" :  0},
{	"latitude" :  40.7382628,	"longitude" :  -73.9818317,	"branch_name" :  "Epiphany Branch",	"branch_address" :  "228 East 23rd Street, 10010-4672",	"telephone" :  "(212) 679-2645",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8479050,	"longitude" :  -73.9338400,	"branch_name" :  "Fort Washington Branch",	"branch_address" :  "535 West 179th Street, 10033-5799",	"telephone" :  "(212) 927-3533",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8138366,	"longitude" :  -73.9567711,	"branch_name" :  "George Bruce Branch",	"branch_address" :  "518 West 125th Street, 10027-3407",	"telephone" :  "(212) 662-9727",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7539181,	"longitude" :  -73.9739863,	"branch_name" :  "Grand Central Branch",	"branch_address" :  "135 East 46th Street, 10017",	"telephone" :  "(212) 621-0670",	"monday": "8-7",	"tuesday": "8-7",	"wednesday": "8-7",	"thursday": "8-7",	"friday": "8-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7198562,	"longitude" :  -73.9788383,	"branch_name" :  "Hamilton Fish Park Branch",	"branch_address" :  "415 East Houston Street, 10002-1197",	"telephone" :  "(212) 673-2290",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8253888,	"longitude" :  -73.9479152,	"branch_name" :  "Hamilton Grange Branch",	"branch_address" :  "503 West 145th Street, 10031-5101",	"telephone" :  "(212) 926-2147",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8061930,	"longitude" :  -73.9432930,	"branch_name" :  "Harlem Branch",	"branch_address" :  "9 West 124th Street, 10027-5699",	"telephone" :  "(212) 348-5620",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7299150,	"longitude" :  -74.0052810,	"branch_name" :  "Hudson Park Branch",	"branch_address" :  "66 Leroy Street, 10014-3929",	"telephone" :  "(212) 243-6876",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8661219,	"longitude" :  -73.9255634,	"branch_name" :  "Inwood Branch",	"branch_address" :  "4790 Broadway, 10034-4916",	"telephone" :  "(212) 942-2445",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7342410,	"longitude" :  -73.9990840,	"branch_name" :  "Jefferson Market Branch",	"branch_address" :  "425 Avenue of the Americas, 10011-8454",	"telephone" :  "(212) 243-4334",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7438130,	"longitude" :  -73.9799470,	"branch_name" :  "Kips Bay Branch",	"branch_address" :  "446 Third Avenue, 10016-6025",	"telephone" :  "(212) 683-2520",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8268787,	"longitude" :  -73.9354560,	"branch_name" :  "Macomb\'s Bridge Branch",	"branch_address" :  "2650 Adam Clayton Powell, Jr. Blvd., 10039-2004",	"telephone" :  "(212) 281-4900",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7527680,	"longitude" :  -73.9814400,	"branch_name" :  "Mid-Manhattan Library",	"branch_address" :  "455 Fifth Avenue, 10016-0122",	"telephone" :  "917-ASK-NYPL (917-275-6975)",	"monday": "9-9",	"tuesday": "9-9",	"wednesday": "9-9",	"thursday": "10-6",	"friday": "10-6",	"saturday": "10-6",	"sunday": "1-5",	"current_distance" :  0},
{	"latitude" :  40.8060660,	"longitude" :  -73.9648060,	"branch_name" :  "Morningside Heights",	"branch_address" :  "2900 Broadway, 10025-7822",	"telephone" :  "(212) 864-2530",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7445330,	"longitude" :  -73.9958870,	"branch_name" :  "Muhlenberg Branch",	"branch_address" :  "209 West 23rd Street, 10011-2379",	"telephone" :  "(212) 924-1585",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7241280,	"longitude" :  -73.9954541,	"branch_name" :  "Mulberry Street Branch",	"branch_address" :  "10 Jersey Street, 10012-3332",	"telephone" :  "212-966-3424",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7132763,	"longitude" :  -74.0076732,	"branch_name" :  "New Amsterdam Branch",	"branch_address" :  "9 Murray Street, 10007-2223",	"telephone" :  "(212) 732-8186",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7680230,	"longitude" :  -73.9759600,	"branch_name" :  "New York Public Library for the Performing Arts",	"branch_address" :  "40 Lincoln Center Plaza, 10023-7498",	"telephone" :  "(212) 870-1630",	"monday": "12-8",	"tuesday": "11-6",	"wednesday": "11-6",	"thursday": "12-8",	"friday": "11-6",	"saturday": "10-6",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7290420,	"longitude" :  -73.9877990,	"branch_name" :  "Ottendorfer Branch",	"branch_address" :  "135 Second Avenue, 10003-8304",	"telephone" :  "(212) 674-0947",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7740504,	"longitude" :  -73.9849341,	"branch_name" :  "Riverside Branch",	"branch_address" :  "127 Amsterdam Avenue, 10023-6447",	"telephone" :  "(212) 870-1810",	"monday": "10-6",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7612693,	"longitude" :  -73.9503344,	"branch_name" :  "Roosevelt Island Branch",	"branch_address" :  "524 Main Street, 10044-0001",	"telephone" :  "(212) 308-6243",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8144590,	"longitude" :  -73.9408210,	"branch_name" :  "Schomburg Center for Research in Black Culture",	"branch_address" :  "515 Malcolm X Boulevard, 10037-1801",	"telephone" :  "(212) 491-2200",	"monday": "12-8",	"tuesday": "12-8",	"wednesday": "12-8",	"thursday": "11-6",	"friday": "11-6",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7480419,	"longitude" :  -73.9827978,	"branch_name" :  "Science, Industry, and Business Library (SIBL)",	"branch_address" :  "188 Madison Avenue, 10016-4314",	"telephone" :  "(212) 592-7000",	"monday": "11-6",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "11-6",	"saturday": "11-6",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7144490,	"longitude" :  -73.9885210,	"branch_name" :  "Seward Park Branch",	"branch_address" :  "192 East Broadway, 10002-5597",	"telephone" :  "(212) 477-6770",	"monday": "10-8",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "12-5",	"current_distance" :  0},
{	"latitude" :  40.7534830,	"longitude" :  -73.9808780,	"branch_name" :  "Stephen A. Schwarzman Building",	"branch_address" :  "Fifth Avenue at 42nd Street, 10018-2788",	"telephone" :  "917-ASK-NYPL (917-275-6975)",	"monday": "11-6",	"tuesday": "11-7:30",	"wednesday": "11-7:30",	"thursday": "11-6",	"friday": "11-6",	"saturday": "11-6",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7568610,	"longitude" :  -73.9726350,	"branch_name" :  "Terence Cardinal Cooke-Cathedral Branch",	"branch_address" :  "560 Lexington Avenue, 10022-6828",	"telephone" :  "(212) 752-3824",	"monday": "8-6:30",	"tuesday": "8-6:30",	"wednesday": "8-6:30",	"thursday": "8-6:30",	"friday": "10-5",	"saturday": "—",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7273290,	"longitude" :  -73.9804170,	"branch_name" :  "Tompkins Square Branch",	"branch_address" :  "331 East 10th Street, 10009-5099",	"telephone" :  "(212) 228-4747",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.8345160,	"longitude" :  -73.9396690,	"branch_name" :  "Washington Heights Branch",	"branch_address" :  "1000 St. Nicholas Avenue, 10032-5202",	"telephone" :  "(212) 923-6054",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7706920,	"longitude" :  -73.9513530,	"branch_name" :  "Webster Branch",	"branch_address" :  "1465 York Avenue, 10021-8895",	"telephone" :  "(212) 288-5049",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.7736200,	"longitude" :  -73.9564080,	"branch_name" :  "Yorkville Branch",	"branch_address" :  "222 East 79th Street, 10021-1295",	"telephone" :  "(212) 744-5824",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.5905096,	"longitude" :  -74.1008695,	"branch_name" :  "Dongan Hills Branch",	"branch_address" :  "1617 Richmond Road, 10304",	"telephone" :  "(718) 351-1444",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.5525149,	"longitude" :  -74.1508892,	"branch_name" :  "Great Kills Branch",	"branch_address" :  "56 Giffords Lane, 10308",	"telephone" :  "(718) 984-6670",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.5344498,	"longitude" :  -74.1931100,	"branch_name" :  "Huguenot Park Branch",	"branch_address" :  "830 Huguenot Avenue, 10312",	"telephone" :  "(718) 984-4636",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.5717778,	"longitude" :  -74.1121705,	"branch_name" :  "New Dorp Branch",	"branch_address" :  "309 New Dorp Lane, 10306",	"telephone" :  "(718) 351-2977",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.6374570,	"longitude" :  -74.1314062,	"branch_name" :  "Port Richmond Branch",	"branch_address" :  "75 Bennett Street, 10302",	"telephone" :  "(718) 442-0158",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.5677101,	"longitude" :  -74.1397951,	"branch_name" :  "Richmondtown Branch",	"branch_address" :  "200 Clarke Avenue, 10306",	"telephone" :  "(718) 668-0413",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.5956162,	"longitude" :  -74.0630974,	"branch_name" :  "South Beach Branch",	"branch_address" :  "21-25 Robin Road, 10305",	"telephone" :  "(718) 816-5834",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.6418107,	"longitude" :  -74.0769873,	"branch_name" :  "St. George Library Center",	"branch_address" :  "5 Central Avenue, 10301.",	"telephone" :  "(718) 442-8560",	"monday": "8-8",	"tuesday": "8-8",	"wednesday": "8-8",	"thursday": "8-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "10-5",	"current_distance" :  0},
{	"latitude" :  40.6264604,	"longitude" :  -74.0779943,	"branch_name" :  "Stapleton Branch",	"branch_address" :  "132 Canal St., 10304",	"telephone" :  "(718) 727-0427",	"monday": "10-6",	"tuesday": "10-8",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.6098820,	"longitude" :  -74.1479848,	"branch_name" :  "Todt Hill-Westerleigh Branch",	"branch_address" :  "2550 Victory Boulevard, 10314",	"telephone" :  "(718) 494-1642",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "12-5",	"current_distance" :  0},
{	"latitude" :  40.5098710,	"longitude" :  -74.2440899,	"branch_name" :  "Tottenville Branch",	"branch_address" :  "7430 Amboy Road, 10307",	"telephone" :  "(718) 984-0945",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-6",	"thursday": "10-8",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0},
{	"latitude" :  40.6347352,	"longitude" :  -74.1145896,	"branch_name" :  "West New Brighton Branch",	"branch_address" :  "976 Castleton Avenue, 10310",	"telephone" :  "(718) 442-1416",	"monday": "10-8",	"tuesday": "10-6",	"wednesday": "10-8",	"thursday": "10-6",	"friday": "10-5",	"saturday": "10-5",	"sunday": "—",	"current_distance" :  0} ] }


function openMap(event)
{
    // Insert Code Here
    //document.getElementById("mapButton").href = "http://www.apple.com";
    location.href = "http://maps.google.com/?q=New%20York+"+currentBranchAddress;
}

function showAbout(event)
{
    var browser = document.getElementById('browser').object;
    // The Browser's goForward method is used to make the browser push down to a new level.  Going back to previous levels is handled automatically.
    
    browser.goForward(document.getElementById('aboutLevel'),"About");
}

function trackLibrary(library){
    pageTracker._trackPageview('/outgoing/library/'+library);
}



function showTwitterPage(event)
{
    // Insert Code Here
    document.location = "http://m.twitter.com/sze";
}
