

var googleMap = {

	offset:function() {
		var a = 0;
		//console.log($$(".path"));
		if($$(".path").length) a = 30;
		return a;
	},

	elementsMove:null,

	fps:150,
	duration:1500,

	mapShowAnimation:false,
	mapHideAnimation:false,
	visible:false,
	animation:false,
	
	//buttonText:null,
	buttonText:null,
	showMap:null,
	closeMap:null,

	ie6:false,
	
	closeButton:false,
	
	initialize:function() {
		if(navigator.userAgent.indexOf('MSIE 6')!=-1)
			this.ie6 = true;

		//this.buttonText = $('absolute_show_map').getElements('.mainlevel')[0];
		//if ($('menumap'))
		//	this.buttonText2 = $('menumap').getElements('.mainlevel')[0];
		
		this.elementsMove = new Array(
			new Array('map','top',30,604),
			new Array('container','padding-top',25,0),
			//new Array('bus','top',635,500),
			new Array('article','margin-top',600+googleMap.offset(),googleMap.offset())
		);		
		
		
		var googlemaps = $("map");
		this.mapShowAnimation = googlemaps.effect("height", {fps:this.fps, duration: this.duration});
		this.mapHideAnimation = googlemaps.effect("height", {fps:this.fps, duration: this.duration});

		this.setMessages();
		this.animation = true;
	},
	
	setMessages:function(){
		switch(Cookie.get("jfcookie[lang]")){
			case 'en-GB': this.showMap = "Show Map"; this.closeMap = "Hide Map";break;
			case 'pt-PT': this.showMap = "Mostrar Mapa"; this.closeMap = "Esconder Mapa";break;
			case 'de-DE': this.showMap = "Karte anzeigen"; this.closeMap = "Karte verbergen";break;
			case 'es-ES': this.showMap = "Mostrar mapa"; this.closeMap = "Ocultar mapa";break;
			case 'fr-FR': this.showMap = "Voir la carte"; this.closeMap = "Masquer la carte";break;
			case 'it-IT': this.showMap = "Mostra Mappa"; this.closeMap = "Nascondi Mappa";break;
			case 'ru-RU': this.showMap = "Показать карту"; this.closeMap = "Спрятать карту";break;
			case 'da-DK': this.showMap = "Vis kort"; this.closeMap = "Skjul kort";break;
			case 'fi-FI': this.showMap = "Näytä kartta"; this.closeMap = "Piilota kartta";break;
			case 'nb-NO': this.showMap = "Vis kart"; this.closeMap = "Skjul kart";break;
			case 'sv-SE': this.showMap = "Visa kartan"; this.closeMap = "Göm kartan";break;
			case 'nl-NL': this.showMap = "Kaart tonen"; this.closeMap = "Kaart verbergen";break;
			default: this.showMap = "Show Map"; this.closeMap = "Hide Map";
		}

	},	
	
	changeLevel:function(zoom,lat,lon,mov){
		if(mov==1){
			this.elementsMove.push( new Array('bus','top',570,500),
									new Array('page','padding-top',45,0),
									new Array('map','z-index',2,-1));
		}else{
			this.elementsMove.push( new Array('bus','top',530,500));
		}
		
		this.elementsMove.each(function(array,index){
			var obj = $(array[0]);
			if(obj)
				googleMap.elementsMove[index][4] = obj.effect(array[1], {fps:googleMap.fps,duration: googleMap.duration});
		});
	
		myGoogleMapObj_v0.changeZoom(zoom,lat,lon);
		if(!this.visible)
			this.googleAnimation();
	},

	googleAnimation:function() {
		if(!this.animation || !this.mapHideAnimation || !this.mapShowAnimation)
			return;
	
		if(this.visible)
			this.hideGoogle();
		else
			this.showGoogle();
	},
	
	showGoogle:function() {
		this.visible = true;
		this.mapHideAnimation.stop();
		this.mapShowAnimation.start(599);
		
		this.stopAnimations();
		if(!this.ie6)
		{
			this.elementsMove.each(function(array){
				
				if(array[4])
					array[4].start(array[2]);
			});
		}
		//$("map").addClass("activemap");
	},
	
	hideGoogle:function() {
		this.visible = false;
		this.mapShowAnimation.stop();
		this.mapHideAnimation.start(0);

		this.stopAnimations();
		if(!this.ie6)
		{
			this.elementsMove.each(function(array){
				if(array[4])
					array[4].start(array[3]);
			});
		}
		//$("map").removeClass("activemap");
	},
	
	stopAnimations:function(){
		this.elementsMove.each(function(array){
			if(array[4])
				array[4].stop();
		});
	}
}



window.addEvent("domready",function(){
	googleMap.initialize();
});	
