﻿
var directionFrom;
var directionTo;
var mapMarkers = [];
var gmap;
var lastSelected;
var listAsset;
var listAttribute;
var listName;
var iconColour = "";
var assetIcon = "";
var assetTypeId = "";
var assetResult = "RESULT";
var attResult = "";

//On ready, perform various actions, based on selection option from Asset type drop down box
$(document).ready(function() {

    $("#selAsset").change(function() {

        clearMap();
        clearList();
        iconColour = "";


        if ($('#selAsset').val() == "" || $('#selAsset').val() == "-Select Facility Type-") {
            //Clears listbox, main title and result list title
            $('#frmAttribute').html('');
            $("#searchasset").html('');
            $('#ByName').html('');
            assetResult = "RESULT";
            assetIcon = "";

            //Reset the SearchResult title
            $("#searchresult").html("");

            //Reset map extent
            gmap.setCenter(new GLatLng(43.905000, -79.430000), 11); 
        }
        else {
            iconColour = $('#selAsset option:selected').attr('name');
            //alert(iconColour);
            
            //Pass value of selected item in listbox
            popAttributes($('#selAsset').val());
            assetIcon = $('#selAsset').val();
            assetResult = assetIcon.toUpperCase();
            changeTitle();

            //Display all data on the map
            allByType($('#selAsset').val(), 'All');
        }

    });    
});

//Performs additional events
$(function() {
    
    //Rounds header, footer and panel corners
    //$('#townsitebottom1').corner("bottom 15px");

    //Hides set of showattributes titles, corresponsing to Description on the panel
    $('#showattributes_icon').hide();
    $('#showdescription_title').hide();
    
    //Toggles condition on elements, e.g 'slide up if down' or 'display, if hidden'
    $('#showattributes, a#showattributes_icon, a#showdescription_icon, #showattributes_title, #showdescription_title').click(function() {
        $(".assetdescription,#attributeslist,#showattributes_icon,#showdescription_icon, #showattributes_title, #showdescription_title").slideToggle("normal");
    });
    
});


