// Steuerung der Location Map mittels Scriptaculous Lib
// Elmar Putz, 10.04.2007


// Objektadressierung mittels Prototype
var listAT = $('cityAT');
var listDE = $('cityDE');
var mapImgAT  = "images/map_oe.jpg";
var mapImgDE  = "images/map_de.jpg";
var Speed = 0.2;
var opActive = 0.9;
var treeItem = $('treeItem');

function init() {
	// ausblenden der Ortliste
	if ((listAT) && (listDE)) {
	  listAT.hide();
	  listDE.hide();	
	  treeItem.visible();
	} 
		// preload images
	mapA 		= new Image;
	mapA.src 	= mapImgAT;
	mapB 		= new Image;
	mapB.src 	= mapImgDE;
	counter = 1;
	while ((!(mapA.complete && mapB.complete)) && (counter < 5)) { 
		  counter = setTimeout("counter++", 1000);
	}	
} // init


function fadeInLocations(activeMenu, inactiveMenu) {
	 setTimeout("fadeIn('"+activeMenu+"','"+inactiveMenu+"')", 200);
}


function fadeIn(activeMenu, inactiveMenu) {
	myActiveList 		= eval('list'+activeMenu); 
	myInActiveList 		= eval('list'+inactiveMenu);
	// inactives ausblenden
	if ($(myInActiveList).style.display != 'none') {
		new Effect.Fade($(myInActiveList),
	 					  {duration:Speed+0.3, from:opActive, to:0.0}
	 					  );	
	} // if	
	
	// menue einblenden
	$(myActiveList).setStyle({ 
	  opacity: opActive
	}); 
	if ($(myActiveList).style.display == 'none') {
		// tree ausblenden
		hideLocation();
		// bild aktiv schalten
		new Effect.SlideDown($(myActiveList),
	 					  {duration:Speed, queue: 'end'}
	 					  );
	 	$('mapImg').src = eval('mapImg' + activeMenu);					  
	} // if		
} // fadeInLocations


function showLocation(xCoord, yCoord) {
	$(treeItem).hide();
	$(treeItem).setStyle({ 
	  'position': 'absolute',
	  'margin-top': xCoord + 'px',
	  'margin-left' : yCoord + 'px',
	  'display' : 'block',
	  'z-index': '1'
	}); 
	$(treeItem).visible();
} // showLocation


function hideLocation() {
	$(treeItem).hide();
} // hideLocation


init();
setTimeout("fadeInLocations('AT', 'DE');", 600);
