var googleMap = {
	elementsMove:new Array(
		new Array('content','marginTop',1290,700),
		new Array('wraprotator','top',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,
	
	initialize:function() {
		if(navigator.userAgent.indexOf('MSIE 6')!=-1)
			this.ie6 = true;

		this.buttonText = $('topm').getElement('.item23').getElement('.linkmenu').getFirst().getFirst();
		if ($('maplink'))
		this.buttonText2 = $('maplink').getElements('.item30')[0].getFirst().getFirst();
		
		var googlemaps = $("gmap");
		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 '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";
		}

	},	

	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(600);
		
		this.stopAnimations();
		if(!this.ie6)
		{
			this.elementsMove.each(function(array){
				if(array[4])
					array[4].start(array[2]);
			});
		}

		this.buttonText.innerHTML = this.closeMap;
		if (this.buttonText2)
		this.buttonText2.innerHTML = this.closeMap;
	},
	
	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("domready",function(){
	googleMap.initialize();
});