// JavaScript Document Funkcje Projekt Dawny Sopot Daniel Szmytkowski 2006 -2009

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var iZoom=0;
document.imageArray = new Array(6);

//PreloadImages();

function PreloadImages(){

  ZOOM_0= new Image(); 
  ZOOM_0.src="zoom_0.gif"; 
  ZOOM_1= new Image(); 
  ZOOM_1.src="zoom_1.gif"; 
  ZOOM_2= new Image(); 
  ZOOM_2.src="zoom_2.gif"; 
  ZOOM_3= new Image(); 
  ZOOM_3.src="zoom_3.gif"; 
  ZOOM_4= new Image(); 
  ZOOM_4.src="zoom_4.gif"; 
  
  ZOOM2_0= new Image(); 
  ZOOM2_0.src="zoom2_0.gif"; 
  ZOOM2_1= new Image(); 
  ZOOM2_1.src="zoom2_1.gif"; 
  ZOOM2_2= new Image(); 
  ZOOM2_2.src="zoom2_2.gif"; 
  ZOOM2_3= new Image(); 
  ZOOM2_3.src="zoom2_3.gif"; 
  ZOOM2_4= new Image(); 
  ZOOM2_4.src="zoom2_4.gif"; 
  
}



// rozne funkcje --- rozmycie obrazka

function imgbon(which2){ theobject=which2; 
highlighting=setInterval("highlightit(theobject)",20)
}
function imgboff(which2){ clearInterval(highlighting)
which2.filters.alpha.opacity=80
}

function highlightit(cur2){
if (cur2.filters.alpha.opacity<100) 
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}



function Floc(obId){	

adres=obId
localize(adres);
	

}
function localize(adres,x,y,typ){	
	
	
	var Obj =InternetExplorer ? window.omap : window.document.omap;
	
	if (Obj.PercentLoaded()<100){
		//alert("Mapa w trakcie ładowania. Proszę czekać...");
		location.reload();
		return;
		}
	
	if (x ){ //&& y && typ
		
			if (screen.height > 800) { x=x*1.60; y=y*1.65; } //reskalowanie w rozdzielczosci 800 x 900 //alert ("x:"+x+" y:"+y);

					//Obj.Zoom(0);
					//Obj.Zoom(50);
					//Obj.Pan( x, y, 1);
					// ( left, top, right, bottom )
					Obj.SetZoomRect( 0, 0, 400*20, 400*20);
					Obj.Pan( x, y, 0);
					
					// nie powiekszaj maksymalnie jezeli:
					if (typ=="BUDYNEK" && ( ( parseInt(y)>0 && parseInt(y)<3000 && parseInt(x)>100 ) ) ){
					
					document.mlform.wartosc.value=500;
					Obj.Zoom(50);
					SwapImg(4);
					
					}
					else{
					
					document.mlform.wartosc.value=255;
					SwapImg(3);
					
					}
		
	}
			Obj.TSetProperty("/map/nazwy", 7, 0 );
			Obj.mapPaint(adres); // zaznaczanie obiektu  
			
			 
			// reset zoom plaszczyzna nazw geograficznych	
			Obj.TSetProperty("/map/nazwy", 7, 0 ); 
			document.mlform.nazwy.disabled=true;
				
				
				
		WinOpis=window.open('http://www.dawnysopot.pl/przewodnikopis.php?a=1&obiekt='+adres+'','Opis','scrollbars=yes,width=750,height=650,top=0,left='+screen.width+',status=yes,toolbar=no,location=no,menubar=no,copyhistory=no,directories=no'); //left=420 toolbar=yes,location=yes,status=yes,menubar=yes,
			
		WinOpis.focus();
		WinOpis.document.close();
				
			 


			
}// koniec funkcji 




function SwapImg(iZoomn){
	
	
	//alert(iZoom);
 	iZoom=parseInt(iZoom);
		
		//for (i=0; i<5; i++){
			IMG=new Image();	
			IMG="ZOOM_"+iZoom;
			document[IMG].src="zoom_"+iZoom+".gif";
		//	}
			
		IMG2=new Image();
		IMG2="ZOOM_"+iZoomn;
		document[IMG2].src = "zoom2_"+iZoomn+".gif";
		iZoom=iZoomn;
		return iZoom;
}

function testmovie_DoFSCommand(command, args) { 
	if (command == "call_alert") { 
		alert("Here's the Flash message: " + args);
	}
}

function FSfunkcja(command,args){


 var zoomval=document.mlform.wartosc.value;
 var Obj=InternetExplorer ? window.omap : window.document.omap;
 
if (Obj.PercentLoaded()<100){
			alert("Mapa w trakcie ładowania. Proszę czekać...");
			 location.reload();
			 return;}
 
//alert(command);
// zoom -----------------------------------------------------------------------------------

	if (command=="zoomchange"){		
				//PreloadImages();
				 var args=parseInt(args);
				 
					var a=parseInt(Math.pow(2,args));
					var zoomn=(100)/a;
					
					//alert (zoomp+' '+zoomn+' '+(100-(zoomp-zoomn)));
				
				if (iZoom>args){
					
					if (args==0){ Obj.Zoom(0); }
					else{
						var c=iZoom-args;
						zoomn=zoomn+(200*c);
						Obj.Zoom(zoomn);
						}
					}
				else if (iZoom<args){
					var c=args-iZoom;
					var d=parseInt(Math.pow(2,c));
					var zoom=(100)/d;
					//var zoom=100-(zoomp-zoomn);
					Obj.Zoom(zoom);
					}
					else if (iZoom==args){
					}
				
				document.mlform.wartosc.value=(500/a);
				//iZoom=args;
				
				if (document.mlform.nazwy.checked==true){ // czy plaszczyzna nazwy jest wlaczona
				if (args<2) { Obj.TSetProperty("/map/nazwy", 7, 1 ); document.mlform.nazwy.disabled=false;} else { Obj.TSetProperty("/map/nazwy", 7, 0 ); document.mlform.nazwy.disabled=true;}
				}
				else { if (args<2) { document.mlform.nazwy.disabled=false;} else { document.mlform.nazwy.disabled=true;} }
				SwapImg(args);
				
				
				
		   }
		   	   
	if (command=="zoomin"){	
			//PreloadImages();	 
			if (iZoom<4){
				Obj.Zoom(50);
				document.mlform.wartosc.value=(zoomval)/2;
				
				//var id=document.mlform.wartosc.value;
				//id=parseInt(Math.log(500/iZoom,2))
					
					iZoomn=iZoom+1
					
					if (document.mlform.nazwy.checked==true){ // czy plaszczyzna nazwy jest wlaczona
						if (iZoom<1) { Obj.TSetProperty("/map/nazwy", 7, 1 ); document.mlform.nazwy.disabled=false;} else { Obj.TSetProperty("/map/nazwy", 7, 0 ); document.mlform.nazwy.disabled=true;}
					}
					else { if (iZoom<1) { document.mlform.nazwy.disabled=false;} else { document.mlform.nazwy.disabled=true;} }
					SwapImg(iZoomn);
					
				}
		   }
		   
	if ((command=="zoomout")){		
		//PreloadImages();
			if (iZoom>0){
			Obj.Zoom(200);
			document.mlform.wartosc.value=(zoomval)*2
			
			//var id=document.mlform.wartosc.value;
			//id=parseInt(Math.log(500/iZoom,2))
			iZoomn=iZoom-1;
			
			if (document.mlform.nazwy.checked==true){ // czy plaszczyzna nazwy jest wlaczona
				if (iZoom<3) { Obj.TSetProperty("/map/nazwy", 7, 1 ); document.mlform.nazwy.disabled=false;} else { Obj.TSetProperty("/map/nazwy", 7, 0 ); document.mlform.nazwy.disabled=true;}
			}
			else { if (iZoom<3) { document.mlform.nazwy.disabled=false;} else { document.mlform.nazwy.disabled=true;} }
			SwapImg(iZoomn);

			}
		}
	
	// visibility-----------------------------------------------------------------------------------	
	if 	((command=="visibility")){
		
		
		
		var vis = Obj.TGetProperty("/map/"+args+"", 7);
		vis=(vis=="true")?"0":"1";	
		//_level0.map.ulice     /map/ulice    _root.map
		Obj.TSetProperty("/map/"+args+"", 7, vis ); // zastosowanie metody na obiekcie
	
		}	
    

}
