﻿function ucMapaInterativo() {
    this.setTimeOpenBoxInfo;
    this.pageMapaInterativo;
    this.DateHourNow = new Number();
    
    //Inicializa o Objeto ucMapaInterativo
    //pTypeInfo[Tipo de informacao selecionada]
    this.Initialize = function(pTypeInfo, pDateHourNow) {
        ucMapaInterativo.pageMapaInterativo = pTypeInfo;
        ucMapaInterativo.DateHourNow = pDateHourNow;
        var sTypeInfo = (pTypeInfo == undefined || pTypeInfo == "") ? "trafego" : pTypeInfo;

        $(document).ready(function() {
            ucMapaInterativo.ChangeNavigation(sTypeInfo);
            $("#ContentPage .box-mapa-interativo ul.navigation li a").click(function() { ucMapaInterativo.ChangeNavigation($(this).parent("li").attr("class")); });
        });
    }

    //Carrega XML e transforma em Objeto
    //pUrl[Url do Xml]
    //pParams[Parametros enviados] 
    //pFunction[Funcao que é chamada após ter realizado a operacao o com sucesso]
    this.Ajax = function(pUrl, pParams, pFunction, pParamsFunc) {
        Main.LoadAjax(".box-mapa-interativo");
        $.ajax({
            url: pUrl,
            data: pParams,
            dataType: "xml",
            error: function(error) {
                //throw (error)
                //alert(error);
                Main.LoadAjaxClear();
            },
            success: function(content) {
                if (pFunction != null && pFunction != undefined)
                    pFunction(content, pParamsFunc);
                Main.LoadAjaxClear();
            }
        });
    }

    //Altera os tipos de informacoes do mapa
    //pType[trafego - cameras - operacao - clima - pedagios - pm-servicos - balancas]
    this.ChangeNavigation = function(pType) {
        try {
            $("#ContentPage .box-mapa-interativo ul.navigation li a").css("background-position", "0 0");
            $("#ContentPage .box-mapa-interativo .content-mapa-interativo  > *").remove();
            switch (pType) {
                case "trafego":
                    $("#ContentPage .box-mapa-interativo ul.navigation li.trafego a").css("background-position", "0 -15px");
                    ucMapaInterativo.Ajax("/Xml/Fluxos.xml", null, ucMapaInterativo.LoadTraffic);
                    break;
                case "cameras":
                    $("#ContentPage .box-mapa-interativo ul.navigation li.cameras a").css("background-position", "0 -15px");
                    ucMapaInterativo.Ajax("/Xml/Cameras.ashx", null, ucMapaInterativo.LoadCamera);
                    break;
                case "clima":
                    $("#ContentPage .box-mapa-interativo ul.navigation li.clima a").css("background-position", "0 -15px");
                    ucMapaInterativo.Ajax("/Xml/Operacao.xml", null, ucMapaInterativo.LoadWeather);
                    break;
                case "pedagios":
                    $("#ContentPage .box-mapa-interativo ul.navigation li.pedagios a").css("background-position", "0 -15px");
                    ucMapaInterativo.Ajax("/Xml/Pedagios.xml", null, ucMapaInterativo.LoadToll);
                    break;
                case "pm-servicos":
                    $("#ContentPage .box-mapa-interativo ul.navigation li.pm-servicos a").css("background-position", "0 -15px");
                    ucMapaInterativo.Ajax("/Xml/PM-Servicos.xml", null, ucMapaInterativo.LoadServices);
                    break;
                case "balancas":
                    $("#ContentPage .box-mapa-interativo ul.navigation li.balancas a").css("background-position", "0 -15px");
                    ucMapaInterativo.Ajax("/Xml/Balancas.xml", null, ucMapaInterativo.LoadScales);
                    break;                     
            }

            //Navegacao Box de Informacoes
            $("#ContentPage .box-info-map .content").hide();
            $("#ContentPage .box-info-map .title").removeClass("title-active");
            $("#ContentPage .info-" + pType + " .content").show();
            $("#ContentPage .info-" + pType + " .title").addClass("title-active");
            $(document).pngFix();
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna Posicao conforme Km
    //pKm[0 a 80]
    this.GetPositionByKm = function(pKm, pWidthImg) {
        try {
            var positionLeft = new Number();
            var divisionKm = new Number(113);
            var imgPosition = parseInt(parseInt(pWidthImg) / 2);
            
            positionLeft = ((pKm * 113) / 10) - imgPosition;
            return positionLeft.toString() + "px";
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna Posicao do topo
    //pTop[0 a 322]
    this.GetPositionByTop = function(pTop, pWidthImg) {
        try {
            var positionTop = new Number();
            var imgPosition = parseInt(parseInt(pWidthImg) / 2);

            positionTop = parseInt(pTop - imgPosition);
            return positionTop.toString() + "px";
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna a posicao por
    //pRoad[Rodovia + Sentido]
    this.GetPositionByRoad = function(pRoad, pHeightImg) {
        try {
            var positionTop = Number();
            var imgPosition = parseInt(parseInt(pHeightImg) / 2);
            switch (pRoad) {
                case "PQ. ECOLÓGICO DO TIETÊ-Oeste":
                    positionTop = 110;
                    break;
                case "PQ. ECOLÓGICO DO TIETÊ-Leste":
                    positionTop = 185;
                    break;
                case "GUARULHOS-Leste":
                    positionTop = 185;
                    break;
                case "GUARULHOS-Leste":
                    positionTop = 185;
                    break;
                case "MOGI DAS CRUZES-Oeste":
                    positionTop = 110;
                    break;
                case "MOGI DAS CRUZES-Leste":
                    positionTop = 185;
                    break;
                case "GUARAREMA-Oeste":
                    positionTop = 110;
                    break;
                case "GUARAREMA-Leste":
                    positionTop = 185;
                    break;
                case "JACAREÍ-Oeste":
                    positionTop = 110;
                    break;
                case "JACAREÍ-Leste":
                    positionTop = 185;
                    break;
                case "CAÇAPAVA-Oeste":
                    positionTop = 110;
                    break;
                case "CAÇAPAVA-Leste":
                    positionTop = 185;
                    break;
                case "AEROPORTO-Oeste":
                    positionTop = 110;
                    break;
                case "AEROPORTO-Leste":
                    positionTop = 185;
                    break;
                default:
                    positionTop = -9000;
                    break;
            }

            positionTop = (positionTop - imgPosition);
            return positionTop.toString() + "px";
        }
        catch (e) {
            //alert(e);
        }
    }    

    //Cria box com informacoes do icone selecionado
    // pType[Trafego - ]
    this.CreateBoxInfo = function(pType) {
        try {

            $(document.createElement("div")).addClass("box-info-item").appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                .hover(function() {
                    clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                },
                function() {
                    ucMapaInterativo.CloseBoxInfo();
                });

            $(document.createElement("div")).addClass("info").appendTo("#ContentPage .box-mapa-interativo .box-info-item");

            if (pType == "Trafego") {
                $(document.createElement("strong")).attr({ id: "MapInfoCarRoadWay" }).addClass("title").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).text("Trecho: ").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("strong")).attr({ id: "MapInfoCarZone" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                //$(document.createElement("span")).text("Veículos / hora: ").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                //$(document.createElement("strong")).attr({ id: "MapInfoCarTime" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                //$(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).text("Condição: ").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("strong")).attr({ id: "MapInfoCarCondition" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "/Mapa-Interativo/Trafego-Tempo-Viagem#idBoxInfo_Trafego", title: "+ detalhes" }).text("+ detalhes").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
            }
            else if (pType == "Cameras") {
                $(document.createElement("strong")).attr({ id: "MapInfoCamRoad" }).addClass("title").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).attr({ id: "MapInfoCamIfo" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "javascript:void(0)", rel: "CameraLiveMap", id: "MapInfoCamLnkImg", alt: "", title: "" }).addClass("lnkFoto").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("img")).attr({ src: "", id: "MapInfoCamImg", width: "130", height: "89", onError: "this.src='/Themes/" + Main.Theme + "/Img/MapaInterativo/nao-disponivel-camera.jpg';  $(this).parents('a').attr('href', '/Themes/" + Main.Theme + "/Img/MapaInterativo/nao-disponivel-camera-gd.gif')" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info .lnkFoto");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "/Mapa-Interativo/Cameras#idBoxInfo_Cameras", title: "+ detalhes" }).text("+ detalhes").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
            }
            else if (pType == "Clima") {
                $(document.createElement("strong")).attr({ id: "MapInfoWeatherTitle" }).addClass("title").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).attr({ id: "MapInfoWeatherIfo" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "Mapa-Interativo/Clima#idBoxInfo_Clima", title: "+ detalhes" }).text("+ detalhes").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
            }
            else if (pType == "Pedagios") {
                $(document.createElement("strong")).attr({ id: "MapInfoTollTitle" }).addClass("title").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).attr({ id: "MapInfoTollInfo" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "/Mapa-Interativo/Pedagios#idBoxInfo_Pedagios", title: "+ detalhes" }).text("+ detalhes").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
            }
            else if (pType == "Servicos") {
                $(document.createElement("span")).attr({ id: "MapInfoServiceInfo" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).attr({ id: "MapInfoServiceKm" }).addClass("featured").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "/Mapa-Interativo/PM-Servicos#idBoxInfo_Servicos", title: "+ detalhes" }).text("+ detalhes").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("div")).attr({ id: "MapInfoServiceIcons" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
            }
            else if (pType == "Balancas") {
                $(document.createElement("span")).attr({ id: "MapInfoScalesInfo" }).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("span")).attr({ id: "MapInfoScalesKm" }).addClass("featured").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("br")).appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
                $(document.createElement("a")).attr({ href: "/Mapa-Interativo/Balancas#idBoxInfo_Balancas", title: "+ detalhes" }).text("+ detalhes").appendTo("#ContentPage .box-mapa-interativo .box-info-item .info");
            }

            $(document.createElement("img")).attr({ src: "/Themes/" + Main.Theme + "/Img/ucMapaInterativo/box-info-tip.png", alt: " " }).addClass("tip").appendTo("#ContentPage .box-mapa-interativo .box-info-item");
        }
        catch (e) {
            //alert(e);
        }
    }

    //Fecha Box de informacoes
    this.CloseBoxInfo = function() {
        try {
            $("#ContentPage .box-mapa-interativo .box-info-item").hide();
            clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
        }
        catch (e) {
            //alert(e);
        }

    }

    /**********************
    TRAFEGO
    **********************/

    //Carrega Informacoes de Trafego
    //pContent[Objeto Xml]
    this.LoadTraffic = function(pContent) {
        try {
            var Type = new String("Trafego");
            var arrRunway = new Array();
            arrRunway = Main.TransformStringArray($(pContent).find("operacao").attr("pistas"), "");

            $(pContent).find("rodovias rodovia").each(function(i, e) {

            var positionTop = ucMapaInterativo.GetTrafficPositionByRoad($(e).attr("regiao") + "-" + $(e).attr("sentido"));
                var positionLeft = ucMapaInterativo.GetTrafficPositionByZone($(e).attr("regiao"), $(e).attr("sentido"), $(e).attr("nome"));

                //Cria instrucoes Css e posicionamento
                var cssObjImg = {
                    'position': "absolute",
                    'top': positionTop,
                    'left': positionLeft,
                    'cursor': "pointer",
                    'zIndex': "10"
                }
                //Cria elemento Img
                $(document.createElement("img"))
                    .attr({ src: ucMapaInterativo.GetTrafficImageName(arrRunway, e), id: Type + "_" + i, alt: " " })
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .addClass("item-mapa")
                    .hover(function() {
                        ucMapaInterativo.OpenTrafficInfo(e, cssObjImg, pContent);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                   });

                //Cria instrucoes Css e posicionamento do numero
                var cssObjNum = {

                    'position': "absolute",
                    'top': (parseInt(positionTop)) + "px",
                    'left': (parseInt(positionLeft)) + "px",
                    'width': "43px",
                    'textAlign': "center",
                    'fontSize': "11px",
                    'fontWeight': "bold",
                    'color': "#fff",
                    'cursor': "pointer",
                    'zIndex': "20"
                }

                if (ucMapaInterativo.pageMapaInterativo != undefined) {
                    //Cria elemento span com o numero
                    $(document.createElement("span"))
                    .css(cssObjNum)
                    .text(i + 1)
                    .addClass("item-mapa")
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenTrafficInfo(e, cssObjImg, pContent);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                   });
                }

            });

            ucMapaInterativo.CreateBoxInfo(Type);

            ucMapaInterativo.SetBoxInfoVehiclesPerHour(pContent);
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna a posicao do carro por:
    //pRoad[ANCHIETA - IMIGRANTES - CÔNEGO DOMÊNICO RANGONI - PADRE MANOEL DA NOBREGA + Sentido]
    this.GetTrafficPositionByRoad = function(pRoad) {
        try {
            var positionTop = Number();
            switch (pRoad.toString().toUpperCase()) {
                case "PQ. ECOLÓGICO DO TIETÊ-OESTE":
                    positionTop = 145;
                    break;
                case "PQ. ECOLÓGICO DO TIETÊ-LESTE":
                    positionTop = 165;
                    break;
                case "GUARULHOS-OESTE":
                    positionTop = 145;
                    break;
                case "GUARULHOS-LESTE":
                    positionTop = 165;
                    break;
                case "MOGI DAS CRUZES-OESTE":
                    positionTop = 145;
                    break;
                case "MOGI DAS CRUZES-LESTE":
                    positionTop = 165;
                    break;
                case "GUARAREMA-OESTE":
                    positionTop = 145;
                    break;
                case "GUARAREMA-LESTE":
                    positionTop = 165;
                    break;
                case "JACAREÍ-OESTE":
                    positionTop = 145;
                    break;
                case "JACAREÍ-LESTE":
                    positionTop = 165;
                    break;
                case "CAÇAPAVA-OESTE":
                    positionTop = 145;
                    break;
                case "CAÇAPAVA-LESTE":
                    positionTop = 165;
                    break;
                case "SÃO JOSÉ DOS CAMPOS-NORTE":
                    positionTop = 235;
                    break;
                case "SÃO JOSÉ DOS CAMPOS-SUL":
                    positionTop = 235;
                    break;
                case "AEROPORTO-NORTE":
                    positionTop = 95;
                    break;
                case "AEROPORTO-SUL":
                    positionTop = 95;
                    break;
                default:
                    positionTop = -9000;
                    break;
            }

            return positionTop.toString() + "px";
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna a posicao do carro por:
    //pZone[PLANALTO - SERRA - BAIXADA]
    //pWay[Sul - Norte - Leste - Oeste]
    //pRoad[ANCHIETA - IMIGRANTES - CÔNEGO DOMÊNICO RANGONI - PADRE MANOEL DA NOBREGA]
    this.GetTrafficPositionByZone = function(pZone, pWay, pRoad) {
        try {
            var positionLeft = Number();
            switch (pZone.toString().toUpperCase()) {
                case "PQ. ECOLÓGICO DO TIETÊ":
                    positionLeft = 35;
                    break;
                case "GUARULHOS":
                    positionLeft = 155;
                    break;
                case "MOGI DAS CRUZES":
                    positionLeft = 360;
                    break;
                case "GUARAREMA":
                    positionLeft = 455;
                    break;
                case "JACAREÍ":
                    positionLeft = 725;
                    break;
                case "CAÇAPAVA":
                    positionLeft = 880;
                    break;
                case "SÃO JOSÉ DOS CAMPOS":
                    positionLeft = 793;
                    break;
                case "AEROPORTO":
                    positionLeft = 86;
                    break;
                default:
                    positionLeft = -9000;
                    break;
            }
            if ((pZone.toString().toUpperCase() == "AEROPORTO") && (pWay.toString().toUpperCase() == "NORTE")) positionLeft = positionLeft + 45;

            if ((pZone.toString().toUpperCase() == "SÃO JOSÉ DOS CAMPOS") && (pWay.toString().toUpperCase() == "NORTE")) positionLeft = positionLeft + 45;
            
            return positionLeft.toString() + "px";
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna o sentido e cor da imagem por
    //pWay[Sul - Norte - Leste - Oeste]
    //pCondition[Bom, Normal, Lento]
    this.GetTrafficImageName = function(pArrRunway, e) {
        try {
            var pathImage = new String("/Themes/" + Main.Theme + "/Img/ucMapaInterativo/");
            var nameImage = new String();
            var conditionType = new String();
            var wayType = (($(e).attr("sentido") == "Leste") || ($(e).attr("sentido") == "Sul")) ? "d" : "u";

            if (($(e).attr("regiao") == "SERRA"))
                wayType = ucMapaInterativo.GetCarWay(pArrRunway, $(e).attr("nome") + "-" + $(e).attr("sentido"));

            switch ($(e).attr("condicao")) {
                case "Bom":
                    conditionType = "good";
                    break;
                case "Normal":
                    conditionType = "good";
                    break;
                case "Baixo":
                    conditionType = "good";
                    break;
                case "Parcial":
                    conditionType = "normal";
                    break;
                case "Lento":
                    conditionType = "slow";
                    break;
                case "Interditado":
                    conditionType = "slow";
                    break;
                case "Congestionado":
                    conditionType = "slow";
                    break;
                case "Intenso":
                    conditionType = "slow";
                    break;
                default:
                    conditionType = "slow";
                    break;
            }
            nameImage = "ico-car-" + conditionType + "-" + wayType + ".png";

            return pathImage + nameImage;
        }
        catch (e) {
            //alert(e);
        }
    }

    //Pega posicao do carro
    this.GetCarWay = function(pArrRunway, pRoadWay) {
        try {
            var wayType = new String();

            switch (pRoadWay) {
                case "IMIGRANTES-Sul":
                    wayType = pArrRunway[0];
                    break;
                case "IMIGRANTES-Norte":
                    wayType = pArrRunway[3];
                    break;
                case "ANCHIETA-Sul":
                    wayType = pArrRunway[6];
                    break;
                case "ANCHIETA-Norte":
                    wayType = pArrRunway[8];
                    break;
            }
            return (wayType == "D") ? "d" : "u";
        }
        catch (e) {
            //alert(e);   
        }
    }

    //Abre modal com informacoes do trafego
    //pObj[objeto Fluxo] 
    //pCssObj[objeto css da img carro]
    this.OpenTrafficInfo = function(pObj, pCssObj, pContent) {
        try {
            $("#MapInfoCarRoadWay").text("SP 70 - Sentido " + $(pObj).attr("sentido"));
            $("#MapInfoCarZone").text($(pObj).attr("regiao"));
            $("#MapInfoCarTime").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, $(pObj).attr("nome"), $(pObj).attr("sentido")));
            $("#MapInfoCarCondition").text($(pObj).attr("condicao"));

            $("#ContentPage .box-mapa-interativo .box-info-item").css({
                'top': parseInt(pCssObj.top) - $("#ContentPage .box-mapa-interativo .box-info-item").height() - 7,
                'left': pCssObj.left
            }).show();
        }
        catch (e) {
            //alert(e);
        }
    }

    //Pega no Xml informacoes de quantidade de veiculos por hora
    this.GetInfoVehiclesPerHour = function(pContent, pRoad, pWay) {
        try {
            return $(pContent).find("rodovias_fluxo rodovia[nome*='" + pRoad.toString() + "'] fluxos fluxo[sentido*='" + pWay.toString() + "']").attr("valor");
        }
        catch (e) {
            //alert(e);
        }
    }

    // Seta informacao no box de quantidade de veiculos por hora
    this.SetBoxInfoVehiclesPerHour = function(pContent) {
        try {
            $(".box-veiculos-hora .road-sp70-itaquaquecetuba .veiculo-leste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "Itaquaquecetuba", "Leste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-itaquaquecetuba .veiculo-oeste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "Itaquaquecetuba", "Oeste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-guararema .veiculo-leste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "Guararema", "Leste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-guararema .veiculo-oeste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "Guararema", "Oeste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-sjcampos .veiculo-leste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "São José dos Campos", "Leste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-sjcampos .veiculo-oeste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "São José dos Campos", "Oeste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-cacapava .veiculo-leste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "Caçapava", "Leste") + " veículos / hora");
            $(".box-veiculos-hora .road-sp70-cacapava .veiculo-oeste").text(ucMapaInterativo.GetInfoVehiclesPerHour(pContent, "Caçapava", "Oeste") + " veículos / hora");
        }
        catch (e) {
            //alert(e);
        }
    }
    
    /**********************
    CAMERAS
    **********************/

    //Carrega Informacoes das Cameras
    //pContent[Objeto Xml]
    this.LoadCamera = function(pContent) {
        try {
            var Type = new String("Cameras");
            $(pContent).find("camera").each(function(i, e) {
                var positionTop = ucMapaInterativo.GetPositionByTop($(e).attr("positionTop"), "25px");
                var positionLeft = ucMapaInterativo.GetPositionByKm($(e).attr("km"), "50px");
            
                //Cria instrucoes Css e posicionamento da imagem
                var cssObjImg = {
                    'position': "absolute",
                    'top': positionTop,
                    'left': positionLeft,
                    'cursor': "pointer",
                    'zIndex': "10"
                }

                //Cria elemento Img
                $(document.createElement("img"))
                    .attr({ src: ucMapaInterativo.GetCameraImageName(), id: Type + "_" + i, alt: " " })
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenCameraInfo(e, cssObjImg);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                   });

                //Cria instrucoes Css e posicionamento do numero
                var cssObjNum = {

                    'position': "absolute",
                    'top': (parseInt(positionTop) + 5) + "px",
                    'left': (parseInt(positionLeft) + 17) + "px",
                    'fontSize': "12px",
                    'fontWeight': "bold",
                    'color': "#fff",
                    'cursor': "pointer",
                    'zIndex': "20"
                }
                //Cria elemento span com o numero
                if (ucMapaInterativo.pageMapaInterativo != undefined) {
                    $(document.createElement("span"))
                    .css(cssObjNum)
                    .text(i + 1)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenCameraInfo(e, cssObjImg);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                    });
                }
            });
            ucMapaInterativo.CreateBoxInfo(Type);
        }
        catch (e) {
            //alert(e);
        }
    }
    
    //Retorna a posicao da camera por:
    //pRoad[ANCHIETA - IMIGRANTES - CÔNEGO DOMÊNICO RANGONI - PADRE MANOEL DA NOBREGA]
    this.GetCameraPositionByRoad = function(pRoad) {
        try {

            var positionTop = Number();

            switch (pRoad.toString().toUpperCase()) {
                case "Rod. Carvalho Pinto":
                    positionTop = 135;
                    break;
                default:
                    positionTop = -9000;
                    break;
            }
           
            return positionTop.toString() + "px";
        }
        catch (e) {
            //alert(e);
        }
    }
    
    //Retorna caminho da image camera:
    this.GetCameraImageName = function() {
        try {
            return new String("/Themes/" + Main.Theme + "/Img/ucMapaInterativo/camera.png");
        }
        catch (e) {
            //alert(e);
        }
    }

    //Abre modal com informacoes do trafego
    //pObj[objeto Fluxo] 
    //pCssObj[objeto css da img carro]
    this.OpenCameraInfo = function(pObj, pCssObj) {
        try {
            $("#MapInfoCamImg").attr("src", "-");

            $("#MapInfoCamRoad").text($(pObj).attr("rodovia"));
            $("#MapInfoCamLnkImg").attr("href", "/Content/Cameras/" + $(pObj).attr("img")).attr("alt", $(pObj).attr("rodovia") + " / Km " + $(pObj).attr("kmExibe")).attr("title", $(pObj).attr("rodovia") + " / Km " + $(pObj).attr("kmExibe") + " - Atualizado: " + $(pObj).attr("data"));
            $("#MapInfoCamImg").attr("src", "/Content/Cameras/" + $(pObj).attr("img"));
            $("#MapInfoCamIfo").text($(pObj).attr("trecho") + " / Km " + $(pObj).attr("kmExibe"));

            $("a[rel='CameraLiveMap']").colorbox();

            $("#ContentPage .box-mapa-interativo .box-info-item").css({
                'top': parseInt(pCssObj.top) - $("#ContentPage .box-mapa-interativo .box-info-item").height() - 7,
                'left': pCssObj.left
            }).show();
        }
        catch (e) {
            //alert(e);
        }
    }


    /**********************
    CLIMA
    **********************/

    //Carrega Informacoes do Clima
    //pContent[Objeto Xml]
    this.LoadWeather = function(pContent) {
        try {
            var Type = new String("Clima");
            $(pContent).find("tempo").each(function(i, e) {
                
                //Cria instrucoes Css e posicionamento da imagem
                var cssObjImg = {
                    'position': "absolute",
                    'top': ucMapaInterativo.GetWeatherPositionByTop($(e).attr("local")),
                    'left': ucMapaInterativo.GetWeatherPositionByZone($(e).attr("local")),
                    'cursor': "pointer",
                    'zIndex': "10"
                }

                var objWeather = ucMapaInterativo.GetWeatherObj($(e).attr("condicao"), $(e).attr("local"));
                
                //Cria elemento Img
                $(document.createElement("img"))
                    .attr({ src: objWeather.ImagePath + objWeather.ImageName, id: Type + "_" + i, alt: " " })
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenWeatherInfo(objWeather, cssObjImg);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                   });
            });
            ucMapaInterativo.CreateBoxInfo(Type);
        }
        catch (e) {
            //alert(e);
        }
    }
    
    //Retorna Objeto de Clima
    //pId[1 a 6]
    //pId[]
    this.GetWeatherObj = function(pId, pZone) {
        try {
            var obj = new Object();
            obj.ImagePath = new String("/Themes/" + Main.Theme + "/Img/WidgetPrevisaoTempo/")
            obj.ImageName = new String();
            obj.Legend = new String();
            obj.Zone = new String();
            
            switch (parseInt(pId)) {
                case 1:
                    obj.Legend = "Bom";
                    obj.Zone = pZone;
                    obj.ImageName = (ucMapaInterativo.DateHourNow <= 5 || ucMapaInterativo.DateHourNow >= 19) ? "ico-weather-2n.png" : "ico-weather-2.png";
                    break;
                case 2:
                    obj.Legend = "Com Chuva";
                    obj.Zone = pZone;
                    obj.ImageName = (ucMapaInterativo.DateHourNow <= 5 || ucMapaInterativo.DateHourNow >= 19) ? "ico-weather-5n.png" : "ico-weather-5.png";
                    break;
                case 3:
                    obj.Legend = "Com Garoa";
                    obj.Zone = pZone;
                    obj.ImageName = (ucMapaInterativo.DateHourNow <= 5 || ucMapaInterativo.DateHourNow >= 19) ? "ico-weather-4rn.png" : "ico-weather-4r.png";
                    break;
                case 4:
                    obj.Legend = "Com Neblina";
                    obj.Zone = pZone;
                    obj.ImageName = (ucMapaInterativo.DateHourNow <= 5 || ucMapaInterativo.DateHourNow >= 19) ? "ico-weather-9.png" : "ico-weather-9.png";
                    break;
                case 5:
                    obj.Legend = "Com Sol";
                    obj.Zone = pZone;
                    obj.ImageName = (ucMapaInterativo.DateHourNow <= 5 || ucMapaInterativo.DateHourNow >= 19) ? "ico-weather-1n.png" : "ico-weather-1.png";
                    break;
                case 6:
                    obj.Legend = "Encoberto";
                    obj.Zone = pZone;
                    obj.ImageName = (ucMapaInterativo.DateHourNow <= 5 || ucMapaInterativo.DateHourNow >= 19) ? "ico-weather-3n.png" : "ico-weather-3.png";
                    break;
            }

            return obj;

        }
        catch (e) {
            //alert(e);
        }
    }
    
    //Retorna Posicao da imagem
    //pId[]
    this.GetWeatherPositionByZone = function(pZone) {
        try {
            var positionLeft = new String();
            switch (pZone.toString()) {

                case "Pq. Ecológico do Tietê":
                    positionLeft = this.GetPositionByKm("1.5", "20");
                    break;
                case "Guarulhos":
                    positionLeft = this.GetPositionByKm("10.5", "20");
                    break;
                case "Itaquaquecetuba":
                    positionLeft = this.GetPositionByKm("28.5", "20");
                    break;
                case "Mogi das Cruzes":
                    positionLeft = this.GetPositionByKm("36.8", "20");
                    break;
                case "Guararema":
                    positionLeft = this.GetPositionByKm("44", "20");
                    break;
                case "Jacareí":
                    positionLeft = this.GetPositionByKm("64.5", "20");
                    break;
                case "São José dos Campos":
                    positionLeft = this.GetPositionByKm("73", "20");
                    break;
                case "Caçapava":
                    positionLeft = this.GetPositionByKm("76", "20");
                    break;
                case "Taubaté":
                    positionLeft = this.GetPositionByKm("80", "20");
                    break;
                case "Aeroporto":
                    positionLeft = this.GetPositionByKm("10.5", "20");
                    break;
                default:
                    positionLeft = -9000;
                    break;
            }
            return positionLeft.toString();

        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna Posicao da imagem
    //pId[]
    this.GetWeatherPositionByTop = function(pZone) {
        try {
            var positionTop = new String();
            switch (pZone.toString()) {

                case "Pq. Ecológico do Tietê":
                    positionTop = 145;
                    break;
                case "Guarulhos":
                    positionTop = 120;
                    break;
                case "Itaquaquecetuba":
                    positionTop = 220;
                    break;
                case "Mogi das Cruzes":
                    positionTop = 240;
                    break;
                case "Guararema":
                    positionTop = 145;
                    break;
                case "Jacareí":
                    positionTop = 145;
                    break;
                case "São José dos Campos":
                    positionTop = 220;
                    break;
                case "Caçapava":
                    positionTop = 145;
                    break;
                case "Taubaté":
                    positionTop = 145;
                    break;
                case "Aeroporto":
                    positionTop = 70;
                    break;
                default:
                    positionTop = -9000;
                    break;
            }
            return positionTop.toString() + "px";

        }
        catch (e) {
            //alert(e);
        }
    }

    //Abre modal com informacoes do Clima
    //pObj[objeto Fluxo] 
    //pCssObj[objeto css da img carro]
    this.OpenWeatherInfo = function(pObj, pCssObj) {
    try {
            $("#MapInfoWeatherTitle").text(pObj.Zone);
            $("#MapInfoWeatherIfo").text(pObj.Legend);

            $("#ContentPage .box-mapa-interativo .box-info-item").css({
                'top': parseInt(pCssObj.top) - $("#ContentPage .box-mapa-interativo .box-info-item").height() - 7,
                'left': pCssObj.left
            }).show();
        }
        catch (e) {
            //alert(e);
        }
    }

    /**********************
    PEDAGIO
    **********************/
    //Carrega Informacoes das Cameras
    //pContent[Objeto Xml]
    this.LoadToll = function(pContent) {
        try {
            var Type = new String("Pedagios");
            $(pContent).find("pedagio").each(function(i, e) {
            var positionTop = ucMapaInterativo.GetPositionByTop($(e).attr("positionTop"), "28px");
                var positionLeft = ucMapaInterativo.GetPositionByKm($(e).attr("km"), "27px");

                //Cria instrucoes Css e posicionamento da imagem
                var cssObjImg = {
                    'position': "absolute",
                    'top': positionTop,
                    'left': positionLeft,
                    'cursor': "pointer",
                    'zIndex': "10"
                }

                //Cria elemento Img
                $(document.createElement("img"))
                    .attr({ src: ucMapaInterativo.GetTollImageName($(e).attr("status")), id: Type + "_" + i, alt: " " })
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenTollInfo(e, cssObjImg);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                   });
            });
            ucMapaInterativo.CreateBoxInfo(Type);

            ucMapaInterativo.CreateTollMaskRoad("146px", "270px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("166px", "270px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("146px", "460px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("166px", "460px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("146px", "743px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("166px", "743px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("146px", "895px", "15px");
            ucMapaInterativo.CreateTollMaskRoad("166px", "895px", "15px");            
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna caminho da image do pedagio
    this.GetTollImageName = function(pStatus) {
        try {
            var ImagePath = new String("/Themes/" + Main.Theme + "/Img/ucMapaInterativo/");
            var ImageName = new String();
            ImageName = (pStatus == "ABERTO") ? "ico-toll-open.png" : "ico-toll-close.png";

            return ImagePath + ImageName;
        }
        catch (e) {
            //alert(e);
        }
    }

    //Abre modal com informacoes
    //pObj[objeto Fluxo] 
    //pCssObj[objeto css da img carro]
    this.OpenTollInfo = function(pObj, pCssObj) {
        try {
            $("#MapInfoTollTitle").text($(pObj).attr("rodovia"));
            $("#MapInfoTollInfo").text($(pObj).attr("trecho"));

            $("#ContentPage .box-mapa-interativo .box-info-item").css({
                'top': parseInt(pCssObj.top) - $("#ContentPage .box-mapa-interativo .box-info-item").height() - 7,
                'left': pCssObj.left
            }).show();
        }
        catch (e) {
            //alert(e);
        }
    }

    //Cria mascara de pedagio
    this.CreateTollMaskRoad = function(pPositionTop, pPositionLeft, pHeight) {
        try {
            var cssObjImg = {
                'display': "block",
                'position': "absolute",
                'top': pPositionTop,
                'left': pPositionLeft,
                'width': "6px",
                'height': pHeight,
                'backgroundColor': "#484a4d",
                'zIndex': "10"
            }

            //Cria elemento Img
            $(document.createElement("span"))
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo");
        }
        catch (e) {
            //alert(e);
        }
    }

    /**********************
    PM / SERVICOS
    **********************/
    //Carrega Informacoes das Servico
    //pContent[Objeto Xml]
    this.LoadServices = function(pContent) {
        try {
            var Type = new String("Servicos");
            $(pContent).find("servico").each(function(i, e) {
            var positionTop = ucMapaInterativo.GetPositionByTop($(e).attr("positionTop"), "22px");
                var positionLeft = ucMapaInterativo.GetPositionByKm($(e).attr("km"), "27px");

                //Cria instrucoes Css e posicionamento da imagem
                var cssObjDiv = {
                    'position': "absolute",
                    'top': positionTop,
                    'left': positionLeft,
                    'cursor': "pointer",
                    'zIndex': "10"
                }

                var arrTipos = new Array();
                arrTipos = Main.TransformStringArray($(e).attr("tipo"), ",");

                //Cria elemento Img
                $(document.createElement("div"))
                    .attr({ id: Type + "_" + i })
                    .css(cssObjDiv)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenServicesInfo(e, cssObjDiv, Main.TransformStringArray($(e).attr("tiposub"), ","));
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    });

                ucMapaInterativo.SetServicesImagens(arrTipos, Type + "_" + i);
            });
            ucMapaInterativo.CreateBoxInfo(Type);
        }
        catch (e) {
            //alert(e);
        }
    }

    //Seta as imagens no box de cadas servico
    this.SetServicesImagens = function(pArrTypeImg, pObjParent) {
        try {
            for (var i = 0; i < pArrTypeImg.length; i++) {

                //Cria instrucoes Css e posicionamento da imagem
                var cssObjImg = {
                    'display': "block",
                    'float': "left"
                }
                
                //Cria elemento Img
                $(document.createElement("img"))
                    .attr({ src: ucMapaInterativo.GetServicesImageName(pArrTypeImg[i]), alt: " " })
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo #" + pObjParent);
            }
        }
        catch (e) {
            //alert(e);
        }
    }

    //Seta as imagens no box info de cadas servico
    this.SetServicesBoxInfoImagens = function(pArrTypeImg) {
        try {
            $("#MapInfoServiceIcons").html("");
            if (pArrTypeImg != "") {
                for (var i = 0; i < pArrTypeImg.length; i++) {

                    //Cria instrucoes Css e posicionamento da imagem
                    var cssObjImg = {
                        'display': "block",
                        'float': "left"
                    }

                    //Cria elemento Img
                    $(document.createElement("img"))
                    .attr({ src: ucMapaInterativo.GetServicesImageName(pArrTypeImg[i]), alt: " " })
                    .css(cssObjImg)
                    .appendTo("#MapInfoServiceIcons");
                }
            }
        }
        catch (e) {
            //alert(e);
        }
    }
    
  
     //Retorna caminho da image servico
    this.GetServicesImageName = function(pType) {
        try {
            var ImagePath = new String("/Themes/" + Main.Theme + "/Img/ucMapaInterativo/");
            var ImageName = new String();

            switch (pType.toString().trim()) {
                case "Restaurante":
                    ImageName = "ico-serv-restaurant.png";
                    break;
                case "Posto":
                    ImageName = "ico-serv-gas.png";
                    break;
                case "GNV":
                    ImageName = "ico-serv-gnv.png";
                    break;
                case "WC":
                    ImageName = "ico-serv-wc.png";
                    break;
                case "PM":
                    ImageName = "ico-pm.png";
                    break;
                case "PF":
                    ImageName = "ico-pf.png";
                    break;
                case "PE":
                    ImageName = "ico-pe.png";
                    break;
                case "SAU":
                    ImageName = "ico-serv-sau.png";
                    break;
                case "Servico":
                    ImageName = "ico-posto_serv.png";
                    break;                    
            }
            
            return ImagePath + ImageName;
        }
        catch (e) {
            //alert(e);
        }
    }
    
     //Abre modal com informacoes do servico
    //pObj[objeto Fluxo]
    //pCssObj[objeto css da img carro]
    //pArrTypeImg[Array com sub tipos dos servicos dentro de um posto de servico]
    this.OpenServicesInfo = function(pObj, pCssObj, pArrTypeImg) {
        try {
            
            $("#MapInfoServiceInfo").text($(pObj).attr("nome") + ": ");
            $("#MapInfoServiceKm").text("Km " + $(pObj).attr("kmExibe"));

            ucMapaInterativo.SetServicesBoxInfoImagens(pArrTypeImg);

            $("#ContentPage .box-mapa-interativo .box-info-item").css({
                'top': parseInt(pCssObj.top) - $("#ContentPage .box-mapa-interativo .box-info-item").height() - 7,
                'left': pCssObj.left
            }).show();
        }
        catch (e) {
            //alert(e);
        }
    }

    /**********************
    BALANCA
    **********************/
    //Carrega Informacoes das Servico
    //pContent[Objeto Xml]
    this.LoadScales = function(pContent) {
        try {
            var Type = new String("Balancas");
            $(pContent).find("balanca").each(function(i, e) {
                var positionTop = ucMapaInterativo.GetPositionByRoad($(e).attr("rodovia") + "-" + $(e).attr("sentido"), "45px");
                var positionLeft = ucMapaInterativo.GetPositionByKm($(e).attr("km"), "69px");
                //Cria instrucoes Css e posicionamento da imagem
                var cssObjImg = {
                    'position': "absolute",
                    'top': positionTop,
                    'left': positionLeft,
                    'cursor': "pointer",
                    'zIndex': "10"
                }

                //Cria elemento Img
                $(document.createElement("img"))
                    .attr({ src: ucMapaInterativo.GetScalesImageName($(e).attr("sentido")), id: Type + "_" + i, alt: " " })
                    .css(cssObjImg)
                    .appendTo("#ContentPage .box-mapa-interativo .content-mapa-interativo")
                    .hover(function() {
                        ucMapaInterativo.OpenScalesInfo(e, cssObjImg);
                        clearTimeout(ucMapaInterativo.setTimeOpenBoxInfo);
                    },
                    function() {
                        ucMapaInterativo.setTimeOpenBoxInfo = setTimeout(ucMapaInterativo.CloseBoxInfo, 2000);
                    })
                   .click(function() {
                       //location.href = "#idBoxInfo_" + Type;
                   });
            });
            ucMapaInterativo.CreateBoxInfo(Type);
        }
        catch (e) {
            //alert(e);
        }
    }

    //Retorna caminho da image servico
    this.GetScalesImageName = function(pWay) {
        try {
            var ImagePath = new String("/Themes/" + Main.Theme + "/Img/ucMapaInterativo/");
            var ImageName = (pWay == "Paranaguá") ? "ico-Truck-d.png" : "ico-Truck-u.png";

            return ImagePath + ImageName;
        }
        catch (e) {
            //alert(e);
        }
    }

    //Abre modal com informacoes do servico
    //pObj[objeto Fluxo] 
    //pCssObj[objeto css da img carro]
    this.OpenScalesInfo = function(pObj, pCssObj) {
        try {
            $("#MapInfoScalesInfo").text($(pObj).attr("nome") + ": ");
            $("#MapInfoScalesKm").text("Km " + $(pObj).attr("kmExibe"));

            $("#ContentPage .box-mapa-interativo .box-info-item").css({
                'top': parseInt(pCssObj.top) - $("#ContentPage .box-mapa-interativo .box-info-item").height() - 7,
                'left': pCssObj.left
            }).show();
        }
        catch (e) {
            //alert(e);
        }
    }
}
