// JavaScript Document
	oCalendario = {
		l:$('CalendarioLay'), 
		f:$('CalendarioBg'), 
		c:$('CalendarioContenido')
	};
	opacidad(oCalendario.f, 45);
	
	oPopCalendario = {
		l:$('calendarioProgramas'), 
		f:$('calendarioProgramasBg'), 
		c:$('calendarioProgramasCont')
	};
	opacidad(oPopCalendario.f, 85);
	
	Calendario = {
		req: null, 
		cont: $('CalendarioCont'),
		//
		open: function() {
			popupAbrir(oCalendario);
		}, 
		close: function() {
			popupCerrar(oCalendario);
		}, 
		popOpen: function() {
			popupAbrir(oPopCalendario);
		}, 
		popClose: function() {
			popupCerrar(oPopCalendario);
		}, 
		request: function(t, d) {
			if (!this.req) {
				this.req = new Request;
				this.req.listener = this.onLoad.closure(this);
			}
			
			var v = 'tipo' + SEP_IGUAL + (this.type = t) + SEP_AND;
			if (!!d) {
				var k;
				for (k in d) {
					v += k + SEP_IGUAL + d[k] + SEP_AND;
				}
				this.data = d;
			}
			
			this.showHideLoader(true);
			this.req.pedir(DIR_SERVER_ROOT + 'requests/calendario.php', v);
		}, 
		onLoad: function() {
			var d = this.req.respuestaXML;
			this.showHideLoader(false);
			if (!!d && d.hasChildNodes()) {
				if (this.type == 'ano' || this.type == 'mes') {
					this.cont.innerHTML = d.childNodes[0].data;
					eval(d.childNodes[1].data);
					this.loadFlash();
					this.open();
				}
				else if (this.type == 'dia') {
					$('calendarioProgramasTit').innerHTML = d.childNodes[0].data;
					$('calendarioProgramasLista').innerHTML = d.childNodes[1].data;
					eval(d.childNodes[2].data);
					this.popOpen();
				}
			}
		}, 
		loadFlash: function() {
			try {
				$('flashCalendario').setInfo(this.info);
			}
			catch (e) {}
		}, 
		setContinent: function(c) {
			if (!!this.type) {
				var t = (this.type == 'dia')? 'mes' : this.type;
				var d = (!!this.data)? this.data : {};
				
				if (!!c) { d['cont'] = c; }
				else{ delete(d['cont']); }
				
				this.request(t, d);
			}
		},
		showHideLoader: function(b){
			if (!this.loader) {
				this.loader = $('popCalendarioLoader');
				this.loaderBlq = $('popCalendarioLoaderBlq');
				opacidad(this.loaderBlq, 45);
			}
			if (b) {
				this.loaderBlq.style.height = (this.cont.offsetHeight + $('calendarioMapa').offsetHeight) + 'px';
				this.loaderBlq.style.width = this.cont.offsetWidth + 'px';
				this.loaderBlq.style.display = 'block';
				this.loader.style.display = 'block';
				this.loader.style.marginTop = ((this.loaderBlq.offsetHeight - this.loader.offsetHeight) / 2) + 'px';
				this.loader.style.marginLeft = ((this.loaderBlq.offsetWidth - this.loader.offsetWidth) / 2) + 'px';
			}
			else {
				this.loader.style.display = this.loaderBlq.style.display = 'none';
			}
		}
	}
	
	var f = new FlashObject(DIR_SERVER_ROOT + 'swf/mapaCalendario.swf', 'flashCalendario', '480', '150', '8', '');
	f.addParam('menu','false');
	f.addParam('wmode','opaque');
	f.write('calendarioMapa');
	
	AddEvent($('btnAbrirCalendario'), 'click', function(){
		Calendario.request('ano', false);
		Calendario.open();
	});
	AddEvent($('btnCerrarCalendario'), 'click', function(){ Calendario.close(); });
	AddEvent($('btnCerrarPopCalendario'), 'click', function(){ Calendario.popClose(); });