var googleMap = {
	elementsMove:new Array(
		new Array('mrp_container','marginTop',600,0)
	),

	fps:150,
	duration:1500,

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

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

		this.buttonText = $('mrp_menu').getElement('.item9').getFirst();
        if($('locationmap'))
            this.buttonText2 = $('locationmap').getElement('.item25').getFirst().getFirst();
		
		var googlemaps = $("gmaps");
		
		this.mapShowAnimation = googlemaps.effect("height", {
			fps:this.fps,
			duration:this.duration
		});
		this.mapHideAnimation = googlemaps.effect("height", {
			fps:this.fps,
			duration: this.duration
		});

		
		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
				});
			}
		});

		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 'nl-NL': this.showMap = "Kaart tonen"; this.closeMap = "Kaart verbergen";break;
			case 'sv-SE': this.showMap = "Visa kartan"; this.closeMap = "Göm kartan";break;
			case 'nb-NO': this.showMap = "Vis kart"; this.closeMap = "Skjul kart";break;
			default: this.showMap = "Show Map"; this.closeMap = "Hide Map";
		}

	},	

	googleAnimation:function() {
		if(!this.animation || !this.mapHideAnimation || !this.mapShowAnimation)
			return;
		if(this.visible)
			this.hideGoogle();
		else
			this.showGoogle();
	},
	
	showGoogle:function() {
		if(this.firstClick){
			this.firstClick = false;
			if(!myGoogleMapHotelObj_v0.options.autoLoad)
				myGoogleMapHotelObj_v0.start();
		}
	
        this.visible = true;
		this.mapHideAnimation.stop();
		this.mapShowAnimation.start(600);
		this.buttonText.innerHTML = this.closeMap;
		if(this.buttonText2)
			this.buttonText2.innerHTML = this.closeMap;

		this.stopAnimations();
		if(!this.ie6){
			this.elementsMove.each(function(array){
				if(array[4]){
					array[4].start(array[2]);
				}
			});
		}
	},
	
	hideGoogle:function() {
		this.visible = false;
		this.mapShowAnimation.stop();
		this.mapHideAnimation.start(0);
		this.buttonText.innerHTML = this.showMap;
		if(this.buttonText2)
			this.buttonText2.innerHTML = this.showMap;

		this.stopAnimations();
		if(!this.ie6){
			this.elementsMove.each(function(array){
				if(array[4]){
					array[4].start(array[3]);
				}
			});
		}
	},
	
	stopAnimations:function(){
		this.elementsMove.each(function(array){
			if(array[4]){
				array[4].stop();
			}
		});
	}
}



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