﻿/*
http://estc.msn.com/br/intl/spec/fr-fr/specials/cinema/public-enemies/public-enemies-map.js
http://localhost/tests/specials/cinema/public-enemies-v2/public-enemies-map.js
*/


document.write("<script type='text/javascript' src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6&mkt=fr-fr'></script>");


//var prefixpins = "http://estc.msn.com/br/intl/spec/fr-fr/news/elections-europeennes/hub/img-carte/pins_EU_";
var urlpinicon = "http://estc.msn.com/br/intl/spec/fr-fr/divertissements/cinema/public-enemies/map/pins.png";
if(navigator.appVersion.toString().indexOf("MSIE 6") != -1)
{
    urlpinicon = "http://estc.msn.com/br/intl/spec/fr-fr/divertissements/cinema/public-enemies/map/pins.png";
}
var map = null;


function GetMap()
{
	map = new VEMap('mymap');
	document.getElementById("mymap").style.position = "relative";
	document.getElementById("mymap").style.width = "794px";
	document.getElementById("mymap").style.height = "676px";
	
	map.LoadMap(new VELatLong(20.877899464972526, 107.19892501831055), 10 ,'h' ,false);
	//map.ShowMiniMap(10, 300, "large");
	AddMyLayer(VEDataType.VECollection);
}
function AddMyLayer(type)
{
	var l = new VEShapeLayer();
	var veLayerSpec = new VEShapeSourceSpecification(type, "AFD43CC07CA5BCBF!190", l);
	map.ImportShapeLayerData(veLayerSpec, onFeedLoad, l); 
} 
var guid = "";
var pinbody = "";
function onFeedLoad(feed) {
	//alert(feed.GetShapeByIndex(0).GetPoints());
	for (var p=0; p<feed.GetShapeCount(); p++) 
	{
        if(feed.GetShapeByIndex(p).GetDescription().toString().toLowerCase().indexOf('vid=') != -1)
        {
            //alert(feed.GetShapeByIndex(p).GetMoreInfoURL());
            guid = "";
            guid = feed.GetShapeByIndex(p).GetDescription().toString().toLowerCase().split('vid=')[1];    
            guid = guid.split("&")[0];    
            guid = guid.split('"')[0];    
		
            pinbody = feed.GetShapeByIndex(p).GetDescription().toString();
            //alert(guid);
			
            pinbody = pinbody.split("<")[0] + "<br /><div id=\""+ guid +"\" style=\"margin-top:3px; clear:both; cursor:pointer;\"><a id=\"lien-"+guid+"\" onclick=\"afficheVideo('"+ guid +"');\" style=\"line-height:20px;\"><img id=pucevideo src=http://estc.msn.com/br/intl/spec/fr-fr/img/msger/tabs/video/img/puce_noire.gif border=0 align=absmiddle /> Voir la vidéo</a></div><div><a href=\""+ feed.GetShapeByIndex(p).GetMoreInfoURL() +"\" target=\"_blank\">Plus d'infos...</div>";
            
            
            feed.GetShapeByIndex(p).SetDescription(pinbody);
            feed.GetShapeByIndex(p).SetMoreInfoURL("");
        }
        feed.GetShapeByIndex(p).SetCustomIcon("<img src=\"" + urlpinicon + "\"/>");
    }
    //alert('RSS or Collection loaded. There are '+feed.length+' items in this list.');
}	



//*********************************************
// Fonctions Player                            
//*********************************************
document.write('<script type="text/javascript" src="http://video.msn.com/js/ch/channels.js"></script>');
function afficheVideo(guid)
{
	var idPlayer = guid;
	
	Msn.Video.Build(idPlayer,"Installez la derniere version d\'Adobe Flash Player (gratuite). Pour obtenir de l\'aide sur Flash, consultez la page de support d\'Adobe Flash Player.",{skin:"0",mkt:"fr-fr",mk:"fr-fr",fr:"inline-divertissements-specials",fg:"Special-public-enemies-carte",ad:"false",ap:"true",partnerlogo:"false",timePlaying:"180",c:"v",v:idPlayer,p:"IV2_fr-fr_public-enemies-carte",rv:"false",t:"c1788"},300);
	
	document.getElementById(idPlayer+"_t").style.display="none";
	document.getElementById(idPlayer+"_m").style.display="none";
	document.getElementById(idPlayer+"_a").style.display="none";
	
}
//*********************************************


window.onload = GetMap;
