// JavaScript Document
oFlashMapa = new function flashMapa(){
	this.cont = document.getElementById('mapa');
	this.flash = null;
	this.ancho = 994;
	this.tween = null;
	this.estado = 'cerrado';
	
	this.cargarFlash = function(){
		var p = new FlashObject(DIR_SERVER_ROOT+"swf/mapaMundo.swf?clickTag=" + DIR_SERVER_ROOT, "mapaF", this.ancho, "600", "8", "");
		p.addParam("menu", "false");
		p.addParam("wmode", "opaque");
		p.write(this.cont.id);
		p = null;
		
		this.flash = this.cont.firstChild;
	};
	this.descargarFlash = function(){
		this.flash.parentNode.removeChild(this.flash);
		this.flash = null;
	};
	//
	this.cuandoCambio = function(){
		if(this.estado == 'abriendo'){
			if(Nav.esIE){
				this.cont.style.width = Math.abs(parseInt(this.cont.style.marginLeft))+'px';
			}
			else{
				this.cont.style.width = (this.ancho - Math.abs(parseInt(this.cont.style.marginLeft)))+'px';
			}
		}
		else{
			if(Nav.esIE){
				this.cont.style.marginLeft = (-parseInt(this.cont.style.width))+'px';
			}
			else{
				this.cont.style.marginLeft = (parseInt(this.cont.style.width) - this.ancho)+'px';
			}
		}
	}.closure(this);
	this.cuandoTermino = function(){
		if(this.estado == 'abriendo'){
			this.estado = 'abierto';
			if(Nav.esMz) this.flash.wmode = 'window';
		}
		else{
			this.estado = 'cerrado';
			topPlayFotos();
			//this.descargarFlash();
		}
		this.tween = null;
	}.closure(this);
	//
	this.abrir = function(e){
		if(e){ StopEvent(e); }
		if(this.estado != 'cerrado') return false;
		if(!this.flash) this.cargarFlash();
		
		topStopFotos();
		document.documentElement.scrollTop = 200;
		this.cont.style.top = '200px';
		
		var desde = 0;
		var hasta = -this.ancho;
		if(!Nav.esIE){
			desde = -this.ancho;
			hasta = 0;
		}
		
		this.tween = new Tween(this.cont.style, 'marginLeft', Tween.strongEaseOut, desde, hasta, 1, 'px');
		this.tween.onMotionFinished = this.cuandoTermino;
		this.tween.onMotionChanged = this.cuandoCambio;
		this.estado = 'abriendo';
		this.tween.start();
	}.closure(this);
	this.cerrar = function(){
		if(this.estado != 'abierto' || !this.flash) return false;
		
		if(Nav.esMz) this.flash.wmode = 'opaque';
		
		var desde = this.ancho;
		var hasta = 0;
		
		this.tween = new Tween(this.cont.style, 'width', Tween.strongEaseOut, desde, hasta, 1, 'px');
		this.tween.onMotionFinished = this.cuandoTermino;
		this.tween.onMotionChanged = this.cuandoCambio;
		this.estado = 'cerrando';
		this.tween.start();
	}.closure(this);
	//
	this.getEstado = function(){
		return this.estado;
	};
};