﻿document.write("<script type='text/javascript' src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2'></script>");
//document.write("<script type='text/javascript' src='http://maps.live.com/GeoCommunity.asjx?action=export&format=rss&mkt=en-gb&cid=5265D3F2C7462C3D!113'></script>");

//http://maps.live.com/?v=2&encType=1&cid=AF7AF5C1D88F9D6D!204

//Body Metadata : 5AAFC4C6E7450202!166;10;r;en;1

var params=document.getElementsByTagName("body")[0].id.split(";");
var cid=params[0];
var zoom=params[1];
var strstyle=params[2];
var strlang=params[3];
var strdash=params[4];

cid = "AF7AF5C1D88F9D6D!204";

if(strlang==null) strlang="en";
if(strstyle==null) strstyle="a";
if(zoom==null) zoom=10;
if(strdash==null) strdash=1;

var map = null;
//var layerid=1;
var lnklist = document.getElementById("pins");
var lnkdetail = document.getElementById("detail");
var lnklive = document.getElementById("live");
var PPins;


var strInfo="<b>Interaktiver Karteninhalt</b> (<i>Zum Zoomen bitte klicken</i>)";
var strMore="Weitere informationen";
var strAll="Alle anzeigen";
var strLive="Auf Live Search Maps anzeigen";

switch (strlang)
{
    case "pt":
    strInfo="<b>Mapa interativo</b> (<i>Clique para ampliar</i>)";
    strMore="Mais";
    strAll="Mostrar todos";
    strLive="Mostrar tamb&eacute;m nos Mapas do Live Search" ;
    break;

    case"es":
    strInfo="<b>Mapa Interactivo</b> (<i>Clic para ampliar</i>)";
    strMore="M&aacute;s";
    strAll="Mostrar todos";
    strLive="Mostrar tambi&eacute;n en mapas de Live Search";
    break;

    case "en":
    strInfo="<b>Interactive map</b> (<i>Click to zoom</i>)";
    strMore="More";
    strAll="Show all";
    strLive="Show also on Live Search Maps";
    break;

    case "nl":
    strInfo="<b>Interactieve kaart</b> (<i>Klik om in te zoomen</i>)";
    strMore="Meer";
    strAll="Toon allen";
    strLive="Toon ook op kaart van Live Search";
    break;

    case "fr":
    strInfo="<b>Carte interactive</b> (<i>Cliquez pour agrandir</i>)";
    strMore="Plus";
    strAll="Montrez tout";
    strLive="Montrez aussi sur Live Search Maps";
    break;

    case "it":
    strInfo="<b>Mappa interattiva</b> (<i>Clicca per ingrandire</i>)";
    strMore="Altro";
    strAll="Visualizza tutto";
    strLive="Visualizza anche su Live Search Maps";
    break;

    case "dk":
    strInfo="<b>Interaktivt kort</b> (<i>Klik for at zoome</i>)";
    strMore="Mere";
    strAll="Vis alt";
    strLive="Vis ogs&aring; p&aring; Live Search kort";
    break;

    case "no":
    strInfo="<b>Interaktivt kart</b> (<i>Klikk for &aring; zoome</i>)";
    strMore="Mer";
    strAll="Vis alle";
    strLive="Vis ogs&aring; i Live Search Maps";
    break;

    case "se":
    strInfo="<b>Interaktiv karta</b> (<i>Klicka f&ouml;r att zooma</i>)";
    strMore="Mer";
    strAll="Visa alla";
    strLive="Visa ocks&aring; i Live Search Maps";
    break;
}


function GetMap()
 {
     map = new VEMap('vemap');
     //map.LoadMap();
     //map.LoadMap(new VELatLong(53.284922,-3.098145)); //Commented by Shekhar Patil on 14/05/2009
     map.LoadMap(new VELatLong(53.284922,-3.098145), 10 ,'h' ,false);
     
     map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
     map.SetMapStyle(strstyle);
     map.SetDashboardSize(VEDashboardSize.Small);
     
     if (strdash==0)
        map.HideDashboard();
     
     //alert(cid);
     
     if (cid!=null)
     {
        LoadPins(); 
        //SetLive("<a href=http://local.live.com/?v=2&cid="+cid+"&encType=1>"+strLive+"</a>");
        SetLive("<a href=http://maps.live.com/?v=2&cid="+cid+"&encType=1>"+strLive+"</a>");    
     }
 }

function LoadPins()
{
     var l = new VEShapeLayer();

     var veLayerSpec = new VEShapeSourceSpecification(VEDataType.VECollection, cid, l);
     map.ImportShapeLayerData(veLayerSpec, onFeedLoad , 1);
}

function onFeedLoad(points)
 {
    PPins=points;

    var outline= "<b>"+strInfo+"</b><BR><ul>";
    var cnt=0;
    var panz=points.GetShapeCount();
    
    if (panz>1)
    {
        for (cnt=0;cnt < panz; cnt++)
        {
            //alert(points.GetShapeByIndex(cnt).Geturl());
            
            outline = outline + "<li onclick='javascript:AdjustView(" + cnt + ");'><a href='#'>" + points.GetShapeByIndex(cnt).GetTitle() + "</a></li>" ;
            //outline = outline + "<li onclick='javascript:AdjustView(" + cnt + ");'><a href='http://specials.uk.msn.com/v-chpati/LiveMap.aspx?cid=5265D3F2C7462C3D!299'>" + points.GetShapeByIndex(cnt).GetTitle() + "</a></li>" ;            
            //outline = outline + "<li onclick='javascript:AdjustView(" + cnt + ");'><a href='http://specials.uk.msn.com/v-chpati/LiveMap.aspx?cid=" + points.GetShapeByIndex(cnt).GetDescription() +"'>" + points.GetShapeByIndex(cnt).GetTitle() + "</a></li>" ;    //Commented by Shekhar Patil on 14/05/2009        
        }
        outline = outline + "<li onclick='javascript:AdjustView(-1);'><b><a href='#'>" + strAll + "</a></b></li>" ;

        outline = outline + "</ul>";
        SetLinks(outline);
    }
    else
    {
         var pposi = PPins.GetShapeByIndex(0);
         SetDetails("<b>" + pposi.GetTitle() + "</b><br/>" + pposi.GetDescription());
         map.SetZoomLevel(zoom);
    }
}

function AdjustView(index)
 {
    if (index==-1)
    {
        SetDetails("");
        map.ShowAllShapeLayers();
    }
    else
    {
         var pposi = PPins.GetShapeByIndex(index);
         var pdef = pposi.GetPoints(); 
         map.SetCenterAndZoom(new VELatLong(pdef[0].Latitude,pdef[0].Longitude) , zoom);
         
         SetDetails("<b>" + pposi.GetTitle() + "</b><br/>" + pposi.GetDescription());
    }
 }


function SetLinks(strin)
 {
    if (lnklist!=null) lnklist.innerHTML=strin;
 }

function SetDetails(strin)
 {
    if (lnkdetail!=null) lnkdetail.innerHTML=strin;
 }

function SetLive(strin)
 {
    if (lnklive!=null) lnklive.innerHTML=strin;
 }

window.onload = GetMap;