﻿    function processAddressKeyDown(event,btnId) {
        //alert('premuto INVIO');
        if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
         {
             var btn = document.getElementById(btnId);
             event.returnValue = false;
             event.cancel = true; 
            openPath(btn);
        }
                
    }
    
    
    //Used for open the Google Maps Page
    function openPath(btn)
    {       
        //Get the id of the clicked button and used for get the id of the textbox
        var id=btn.id;        
        var number=id.split("_");        
                
        var txt=document.getElementById("txtPath_"+number[1]);                    
        var from=txt.value.replace(/ /g,"+");                
        
        var hiCoordinates=document.getElementById("hiLocation_"+number[1]);
        var coordinates=hiCoordinates.value;
        
        var hiAddress=document.getElementById("hiAddress_"+number[1]);
        var address=hiAddress.value;

        var to = address + "@" + coordinates;

        //alert('prima apertura Finestra: http://maps.google.it/maps?daddr='+to+'&saddr='+from );
        window.open("http://maps.google.it/maps?daddr=" + to + "&saddr=" + from, "_blank");
    }

    function addLoadEvent(func) {
        //alert('add');
        var oldonload = window.onload;
        if (typeof window.onload != 'function') 
        {
            window.onload = func;
        }
        else {
            window.onload = function() {if (oldonload) {oldonload();} func();}
        }
    }

    function initializeMapPosition(map, coordinateX, coordinateY, zoomLevel)
    {
        if (map) {
            if (window.attachEvent) {
                // Internet Explorer
                window.attachEvent("onunload", function() { GUnload(); });
            }
            else {
                // Firefox and standard browsers
                window.addEventListener("unload", function() { GUnload(); }, false);
            }

            map.setCenter(new GLatLng(coordinateX, coordinateY), parseInt(zoomLevel));
            map.panTo(new GLatLng(coordinateX, coordinateY));




        }
 
    }
    
     //used for show the panel with the road indications from the link
    //and hide the link used for open the panel
    function showPathPanel(id)
    {       
        //visualizza pannello
        var div=document.getElementById("pnlPath_"+id);
        div.style.display = "";

        var txtVai = document.getElementById("txtPath_" + id);
        txtVai.focus();
        
        //rende invisibile il link
        var lnk=document.getElementById("lnkPath_"+id);
        lnk.style.display = "none";
    }
    