	// JavaScript Document

	
	window.addEvent("domready", function() {
		
		document.addEvent("keydown", function(event) {
			e = new Event( event );
			switch( e.key ) {
				case 'l':
					if( e.control )
						TB_show( "Login", "?mod=load_panels_login-forms.login&width=200&height=110" );
				break;
			}
		});
		$$(".del").each( function( el ) {
			el.addEvents( {
				'click': function( event ) {
					event.preventDefault();
					if( window.confirm( "Realmente quiere eliminar el registro" ) )
						document.location.href = el.href;
				}
			});
		});

		$$(".menu3").each( function( el ) {

		});

		$$(".calendar_month .button").each( function( el ) {
			el.addEvents( {
				'click': function() {
					var miAjax = new Request(
						{
							url: el.rel,
							method: 'get',
							onSuccess: function(html) {
								$('calendar_month').set('html', '');
								$('calendar_month').set( 'html', html);
								window.fireEvent( "domready" );
							},
							onFailure: function() {
								$('calendar_month').set('text', 'Se ha producido un error.');
							}
						}
					);
					miAjax.send();
				}
			} );
		});

		$$("#calendar_list .button").each( function( el ) {
			el.addEvents( {
				'click': function() {
					var miAjax = new Request(
						{
							url: el.rel,
							method: 'get',
							onSuccess: function(html) {
								$('calendar_list').set('html', '');
								$('calendar_list').set( 'html', html);
								window.fireEvent( "domready" );
							},
							onFailure: function() {
								$('calendar_list').set('text', 'Se ha producido un error.');
							}
						}
					);
					miAjax.send();
				}
			} );
		});
		$$(".file").each( function( el ) {
			el.addEvents( {
				'change': function( ) {
					form = el.form;

					form.submit();
					tag = el.getParent().getParent().getParent().getParent().getFirst().getFirst();
					tr = new Element( 'div' ).set("class","uploadedfile").inject( tag );
					tr.set("html", "<div class='loading' colspan='3'></div>");
					$('form_frame').addEvents( {
						load: function(response) {
							if( Browser.Engine.trident )
								tr.set( "html", "<div class='uploadedfile' colspan='3'> cargado <br /> Recarga la p&aacute;gina para ver el fichero.</div>" );
							else {
								tr.set( "html", $("form_frame").contentWindow.document.body.innerHTML );
								// necesario para reinicilizar la variable tr
								tr = null;
								TB_init();
							}
						}
					});

				}
			});
		});

		$$(".delete").each( function( el ) {
			el.addEvents( {
				'click': function( ) {
					el.getParent().dispose();
				}
			});
		});


		$$('.lopd').each( function( element ) {
			element.getElement( "div[class=formulario]" ).setStyle( "display", "none" );
		});
		lopd = $('lopd');
		if( lopd )
		lopd.addEvents( {
			'click': function(){
				// This morphes the opacity and backgroundColor
				form = $$( "div[class=formulario]" );
				if( ! this.checked )
					form.setStyle( 'display', 'none' );
				else
					form.setStyle( 'display', 'block' );

			}
		});


	});
