
var myTilesPath = "http://mapy.ceskedalnice.cz/interaktivni-mapy/d3-st-2006/";

    var Page = {
        load: function() {        
            var map = new AMap("map", {
                mapTypes: [miniMap]            
            });                                          
            map.addMapPart(new AMapControl());
            map.loadMaps();                            
  
            var ppIco = new AIcon({           
                fastRollover    : false,
                fixPng          : true,
                imageSrc        : 'ico-foto.png',
                imageSize       : new ASize(23, 19),
                shadowSrc       : null,
                iconOffset      : new APoint(13, 11)                
            });

// fotky
            var pl01 = new AGeoPoint(454528, 3844512, ACoordinateSystem.Geodetic);
            var f01 = new AMarker(pl01,{"icon":ppIco}); f01.addEvent('onClick', function() { map.showBubble(pl01, 
							"<img src=foto/01.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Mimoúrovňová křižovatka s Pražským okruhem - začátek dálnice D3 &nbsp; &nbsp;"});});
				      map.addOverlay(f01);

            var pl02 = new AGeoPoint(249600, 3618080, ACoordinateSystem.Geodetic);
            var f02 = new AMarker(pl02,{"icon":ppIco}); f02.addEvent('onClick', function() { map.showBubble(pl02, 
							"<img src=foto/02.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Tunel u obce Libeř, v pozadí kopec Spáleniště, pod kterým byl také zvažován tunel &nbsp; &nbsp;"});});
				      map.addOverlay(f02);

            var pl03 = new AGeoPoint(166144, 3480608, ACoordinateSystem.Geodetic);
            var f03 = new AMarker(pl03,{"icon":ppIco}); f03.addEvent('onClick', function() { map.showBubble(pl03, 
							"<img src=foto/03.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Most přes Záhořanský potok &nbsp; &nbsp;"});});
				      map.addOverlay(f03);

            var pl04 = new AGeoPoint(189568, 3338656, ACoordinateSystem.Geodetic);
            var f04 = new AMarker(pl04,{"icon":ppIco}); f04.addEvent('onClick', function() { map.showBubble(pl04, 
							"<img src=foto/04.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"MÚK se silnicí II/104 napojující na D3 Jílové u Prahy a okolí &nbsp; &nbsp;"});});
				      map.addOverlay(f04);

            var pl05 = new AGeoPoint( 220160, 3344736, ACoordinateSystem.Geodetic);
            var f05 = new AMarker(pl05,{"icon":ppIco}); f05.addEvent('onClick', function() { map.showBubble(pl05, 
							"<img src=foto/05.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"MÚK u Jílové se nachází mezi dvěma tunely, Svatováclavské lázně (vpravo) a V Obrázku &nbsp;"});});
				      map.addOverlay(f05);

            var pl06 = new AGeoPoint(195456, 3235040, ACoordinateSystem.Geodetic);
            var f06 = new AMarker(pl06,{"icon":ppIco}); f06.addEvent('onClick', function() { map.showBubble(pl06, 
							"<img src=foto/06.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Tunel Kopanina, za ním je vidět hluboký kaňon řeky Sázavy &nbsp; &nbsp;"});});
				      map.addOverlay(f06);

            var pl07 = new AGeoPoint(134400, 3197152, ACoordinateSystem.Geodetic);
            var f07 = new AMarker(pl07,{"icon":ppIco}); f07.addEvent('onClick', function() { map.showBubble(pl07, 
							"<img src=foto/07.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Tunel Hůrka, za ním trasa překonává řeku Sázavu &nbsp; &nbsp;"});});
				      map.addOverlay(f07);

            var pl08 = new AGeoPoint(183808, 3069600, ACoordinateSystem.Geodetic);
            var f08 = new AMarker(pl08,{"icon":ppIco}); f08.addEvent('onClick', function() { map.showBubble(pl08, 
							"<img src=foto/08.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Obloukový most přes řeku Sázavu s maximální výškou cca 100m nad údolím &nbsp; &nbsp;"});});
				      map.addOverlay(f08);

            var pl09 = new AGeoPoint(208512, 3106592, ACoordinateSystem.Geodetic);
            var f09 = new AMarker(pl09,{"icon":ppIco}); f09.addEvent('onClick', function() { map.showBubble(pl09, 
							"<img src=foto/09.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Pohled na most od řeky z údolí &nbsp; &nbsp;"});});
				      map.addOverlay(f09);

            var pl10 = new AGeoPoint(470016, 2671136, ACoordinateSystem.Geodetic);
            var f10 = new AMarker(pl10,{"icon":ppIco}); f10.addEvent('onClick', function() { map.showBubble(pl10, 
							"<img src=foto/10.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Středisko správy a údržby a služební sjezd u Netvořic (pozn.: jedna z variant) &nbsp; &nbsp;"});});
				      map.addOverlay(f10);

            var pl11 = new AGeoPoint(713504, 2448880, ACoordinateSystem.Geodetic);
            var f11 = new AMarker(pl11,{"icon":ppIco}); f11.addEvent('onClick', function() { map.showBubble(pl11, 
							"<img src=foto/11.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"MÚK s tzv. Václavickou spojkou (napojení Benešova a okolí na D3) &nbsp; &nbsp;"});});
				      map.addOverlay(f11);

            var pl12 = new AGeoPoint(635776, 2083872, ACoordinateSystem.Geodetic);
            var f12 = new AMarker(pl12,{"icon":ppIco}); f12.addEvent('onClick', function() { map.showBubble(pl12, 
							"<img src=foto/12.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Most Doloplazy &nbsp; &nbsp;"});});
				      map.addOverlay(f12);

            var pl13 = new AGeoPoint(481280, 1908320, ACoordinateSystem.Geodetic);
            var f13 = new AMarker(pl13,{"icon":ppIco}); f13.addEvent('onClick', function() { map.showBubble(pl13, 
							"<img src=foto/13.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Most Zderadice &nbsp; &nbsp;"});});
				      map.addOverlay(f13);

            var pl14 = new AGeoPoint(413824, 1818592, ACoordinateSystem.Geodetic);
            var f14 = new AMarker(pl14,{"icon":ppIco}); f14.addEvent('onClick', function() { map.showBubble(pl14, 
							"<img src=foto/14.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Most Maršovice &nbsp; &nbsp;"});});
				      map.addOverlay(f14);

            var pl15 = new AGeoPoint(409472, 882016, ACoordinateSystem.Geodetic);
            var f15 = new AMarker(pl15,{"icon":ppIco}); f15.addEvent('onClick', function() { map.showBubble(pl15, 
							"<img src=foto/15.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Výjezd u obce Loudilka &nbsp; &nbsp;"});});
				      map.addOverlay(f15);

            var pl16 = new AGeoPoint(573264, 624320, ACoordinateSystem.Geodetic);
            var f16 = new AMarker(pl16,{"icon":ppIco}); f16.addEvent('onClick', function() { map.showBubble(pl16, 
							"<img src=foto/16.jpg width=500 height=382>",{width:545,maxHeight:510, footerContent : 
							"Most Mastník (pozn.: v mapě je zakreslen násep) &nbsp; &nbsp;"});});
				      map.addOverlay(f16);

// skrytí foto ikonek při startu
						f01.hide(); f02.hide(); f03.hide(); f04.hide(); f05.hide(); f06.hide(); f07.hide(); f08.hide();
						f09.hide(); f10.hide(); f11.hide(); f12.hide(); f13.hide(); f14.hide(); f15.hide(); f16.hide();

// skrytí foto ikonek při maximálním oddálení
						map.addEvent('onZoomEnd', function() { 
							if (map.getCurrentScaleIdx() != 0) f01.show(); else f01.hide();
							if (map.getCurrentScaleIdx() != 0) f02.show(); else f02.hide();
							if (map.getCurrentScaleIdx() != 0) f03.show(); else f03.hide();
							if (map.getCurrentScaleIdx() != 0) f04.show(); else f04.hide();
							if (map.getCurrentScaleIdx() != 0) f05.show(); else f05.hide();
							if (map.getCurrentScaleIdx() != 0) f06.show(); else f06.hide();
							if (map.getCurrentScaleIdx() != 0) f07.show(); else f07.hide();
							if (map.getCurrentScaleIdx() != 0) f08.show(); else f08.hide();
							if (map.getCurrentScaleIdx() != 0) f09.show(); else f09.hide();
							if (map.getCurrentScaleIdx() != 0) f10.show(); else f10.hide();
							if (map.getCurrentScaleIdx() != 0) f11.show(); else f11.hide();
							if (map.getCurrentScaleIdx() != 0) f12.show(); else f12.hide();
							if (map.getCurrentScaleIdx() != 0) f13.show(); else f13.hide();
							if (map.getCurrentScaleIdx() != 0) f14.show(); else f14.hide();
							if (map.getCurrentScaleIdx() != 0) f15.show(); else f15.hide();
							if (map.getCurrentScaleIdx() != 0) f16.show(); else f16.hide();
						});


// tmp - for point debug only
//			map.addEvent('onClick', function() { map.showInfoBubble(map.getGeoMousePos().toString()) }); 


       }
       
    } 
    
// vlastní mapa
    var miniMap = {             
        "copyright" : "Dálnice D3 ve Středočeském kraji <img src=cd.png align=absmiddle>",
        "tileUrlFormat": "",
        "displayName"   : "Mini",
        "tileFormat"    : "jpg",
        "coordinateSystem"  : 0, 
        "centerX"           : 524288,
        "centerY"           : 2397152,
        "scaleInfos"    : [
		{
        "coordinateSystem": 0,
        "scale": 16000000,
        "minX": 1,
        "minY": 1,
        "maxX": 1048576,
        "maxY": 4194304,
        "tileFormat": "jpg",
        "tileWidthPx": 256,
        "tileHeightPx": 256,
        "coefficientX": 4096,
        "coefficientY": 4096,
        "tileNumX": 1,
        "tileNumY": 4,
        "tileUrlFormat": myTilesPath + "res5/{column}-{row}"
    }
    ,
		{
        "coordinateSystem": 0,
        "scale": 8000000,
        "minX": 1,
        "minY": 1,
        "maxX": 1048576,
        "maxY": 4194304,
        "tileFormat": "jpg",
        "tileWidthPx": 256,
        "tileHeightPx": 256,
        "coefficientX": 2048,
        "coefficientY": 2048,
        "tileNumX": 2,
        "tileNumY": 8,
        "tileUrlFormat": myTilesPath + "res4/{column}-{row}"
    }
    ,
		{
        "coordinateSystem": 0,
        "scale": 4000000,
        "minX": 1,
        "minY": 1,
        "maxX": 1048576,
        "maxY": 4194304,
        "tileFormat": "jpg",
        "tileWidthPx": 256,
        "tileHeightPx": 256,
        "coefficientX": 1024,
        "coefficientY": 1024,
        "tileNumX": 4,
        "tileNumY": 16,
        "tileUrlFormat": myTilesPath + "res3/{column}-{row}"
    }
    ,
 		{
        "coordinateSystem": 0,
        "scale": 2000000,
        "minX": 1,
        "minY": 1,
        "maxX": 1048576,
        "maxY": 4194304,
        "tileFormat": "jpg",
        "tileWidthPx": 256,
        "tileHeightPx": 256,
        "coefficientX": 512,
        "coefficientY": 512,
        "tileNumX": 8,
        "tileNumY": 32,
        "tileUrlFormat": myTilesPath + "res2/{column}-{row}"
    }
    ,
 		{
        "coordinateSystem": 0,
        "scale": 1000000,
        "minX": 1,
        "minY": 1,
        "maxX": 1048576,
        "maxY": 4194304,
        "tileFormat": "jpg",
        "tileWidthPx": 256,
        "tileHeightPx": 256,
        "coefficientX": 256,
        "coefficientY": 256,
        "tileNumX": 16,
        "tileNumY": 64,
        "tileUrlFormat": myTilesPath + "res1/{column}-{row}"
    }
    ,
 		{
        "coordinateSystem": 0,
        "scale": 500000,
        "minX": 1,
        "minY": 1,
        "maxX": 1048576,
        "maxY": 4194304,
        "tileFormat": "jpg",
        "tileWidthPx": 256,
        "tileHeightPx": 256,
        "coefficientX": 128,
        "coefficientY": 128,
        "tileNumX": 32,
        "tileNumY": 128,
        "tileUrlFormat": myTilesPath + "res0/{column}-{row}"
    }
		
		],
        "scaleIdx"      : 0
    }   
    window.addEvent('domready', Page.load.bind(Page));    



// resizovani okna - zmena velikosti mapy

function MyResize() {
	var ppw = 0, pph = 0;
	if( self.innerHeight ) {
		ppw = self.innerWidth;
		pph = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		ppw = document.documentElement.clientWidth;
		pph = document.documentElement.clientHeight;
	} else if( document.body ) {
		ppw = document.body.clientWidth;
		pph = document.body.clientHeight;
	};
	if (pph<100) { pph=100 };
	if (ppw<300) { ppw=300 };
	document.getElementById("map").style.height = (pph - 42) + "px";
	document.getElementById("map").style.width = (ppw - 201) + "px";
	document.getElementById("sidebar").style.height = (pph - 41) + "px";
	document.getElementById("sidebar").style.left = (ppw - 200) + "px";
}
window.onresize = MyResize;

// odstraneni scroolbaru v IE
if( document.documentElement && document.documentElement.clientHeight ) {
	document.getElementsByTagName("html")[0].style.overflow = "hidden";
}

