﻿/// <reference path="~/js/jQuery/jquery-1.3.2.js"/>
/// <reference path="~/js/jQuery/jquery-1.3.2-vsdoc2.js"/>
/// <reference name="MicrosoftAjax.js"/>
/// <reference path="veMap.js"/>



var __veMapLoaded = false;

function isMapLoaded() {

    return __veMapLoaded;
}

function isMapScriptLoaded() {

    if (typeof (VEMap) != 'function' || typeof (LoadMap) != 'function') {

        return false;

    } else {

        return true;
    }
}

function checkIfMapContolScriptIsLoaded() {

    if (isMapScriptLoaded() == false) {

        setTimeout(checkIfMapContolScriptIsLoaded, 200);

    } else {
    if (!isMapLoaded())
        jsMapContolLoadCompleted();
    }
}

function WaitForMapContolScript() {

    setTimeout(checkIfMapContolScriptIsLoaded, 500);
}

function loadMapContoljscssfile(filename, filetype, onReady) {

    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script');
        fileref.setAttribute("type", "text/javascript");
        if (onReady != null) {
            fileref.onreadystatechange = onReady;
            fileref.onload = onReady;
        }
        fileref.setAttribute("src", filename);
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref)
}



function getMapContolInfo() {
    var info;

    if (map.IsBirdseyeAvailable()) {
        var be = map.GetBirdseyeScene();

        info = "ID: " + be.GetID() + "\n";
        info += "orientation: " + be.GetOrientation() + "\n";
        info += "height: " + be.GetHeight() + "\n";
        info += "width: " + be.GetWidth() + "\n";

        var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

        info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";

        // Check to see if the current birdseye view contains the pushpin pixel point.
        info += "contains pixel " + pinPixel.x + ", " + pinPixel.y + ": " +
                        be.ContainsPixel(pinPixel.x, pinPixel.y, map.GetZoomLevel()) + "\n";

        // Check to see if the current view contains the pushpin LatLong.
        info += "contains latlong " + pinPoint + ": " + be.ContainsLatLong(pinPoint) + "\n";

        // This method may return null, depending on the selected view and map style.
        info += "latlong: " + map.PixelToLatLong(pixel);

        alert(info);
    }
    else {
        var center = map.GetCenter();

        info = "Zoom level:\t" + map.GetZoomLevel() + "\n";
        info += "Latitude:\t" + center.Latitude + "\n";
        info += "Longitude:\t" + center.Longitude;

        alert(info);
    }
}
