﻿function menuItems(item) {
    alert(item);
}
//---------------------------------------
//MENU ITEMS
//home click
$("#homeLink").click(function () {
    $("li").removeClass("jq-current");
    $(".jq-home").addClass("jq-current");
});
//About us click
$("#aboutLink").click(function () {
    $("li").removeClass("jq-current");
    $(".jq-about").addClass("jq-current");
});
//Why Recycle click
$("#whyLink").click(function () {
    $("li").removeClass("jq-current");
    $(".jq-why").addClass("jq-current");
});
//Locations click
$("#locationsLink").click(function () {
    $("li").removeClass("jq-current");
    $(".jq-locations").addClass("jq-current");
});
//Process click
$("#contactLink").click(function () {
    $("li").removeClass("jq-current");
    $(".jq-process").addClass("jq-current");
});
//---------------------------------------
//Used for bing maps
var arrInfo = [];

function getMap() {

    var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
                { credentials: "AsyiBmWiWslo-LsH4xMHeHQSYGWdhszkY9bljpfs9XF6gColvG3cn0HZts-USueN",
                    center: new Microsoft.Maps.Location(39.94, -75.6),
                    mapTypeId: Microsoft.Maps.MapTypeId.road,
                    zoom: 9,
                   // disableMouseInput: true
                });

    //Create a collection to store multiple pins;
    var pins = new Microsoft.Maps.EntityCollection();
    var infoBoxs = new Microsoft.Maps.EntityCollection();

    //create array of pins
    var arrPins = [];

    //Get coords based Location div
    //Get child div's
    $("#Locations > div").each(function (i) {
        
        var innerDiv = $(this).html();

        var coords = jQuery(".coords", this).text();
        var coord = coords.split(",");

        //Define pin location
        arrPins[i] = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(coord[0], coord[1]),
                                { icon: './images/VE_logo.png',
                                    width: 100,
                                    height: 31,
                                    typeName: i.toString()
                                });

        // Create the info box for the pushpin
        arrInfo[i] = new Microsoft.Maps.Infobox(arrPins[i].getLocation(),
                {
                    visible: false,
                    offset: new Microsoft.Maps.Point(0, 15),
                    zIndex: 999,
                    id: i,
                    htmlContent: '<div class="infoBoxText">' + innerDiv + '</div>'
                });

        //Add to infoBox collection
        infoBoxs.push(arrInfo[i]);

        // Add a handler for the pushpin click event.
        Microsoft.Maps.Events.addHandler(arrPins[i], 'mouseover', displayInfobox);

        // Hide the info box when the map is moved.
        Microsoft.Maps.Events.addHandler(arrPins[i], 'mouseout', hideInfobox);
        Microsoft.Maps.Events.addHandler(arrPins[i], 'click', hideInfobox);

        //Add to pin collection
        pins.push(arrPins[i]);
    });
    //removes coords from info box
    $('.infoBoxText.coords').remove();

    map.entities.push(pins);
    map.entities.push(infoBoxs);
}

function displayInfobox(e) {
    var idx = parseInt(e.target.getTypeName());
    arrInfo[idx].setOptions({ visible: true });
    var i = idx + 1;
    $("#Loc" + i).addClass("watermark");
}


function hideInfobox(e) {
    var idx = parseInt(e.target.getTypeName());
    arrInfo[idx].setOptions({ visible: false });
    var i = idx + 1;
    $("#Loc" + i).removeClass("watermark");
}
//---------------------------------------
