/*------------- [ EVENTS DECLARATION ] -------------*/

	Event.observe(window, 'load', function(){
		$$('.content .box').each(function(element){
			element.insert({ top: '<div class="border-topleft"></div>' });
			element.insert({ top: '<div class="border-topright"></div>' });
			element.insert({ top: '<div class="border-bottomleft"></div>' });
			element.insert({ top: '<div class="border-bottomright"></div>' });
		});

		$$('.content .user-type').each(function(element){
			element.observe('change', function(){
				if(this.getValue() == '1'){
					this.up('tr').next('tr').fade();

					element = $$('.user-contact')[0];
					element.hide();
					element.previous('h3').hide();
				}

				if(this.getValue() == '2'){
					this.up('tr').next('tr').appear();

					element = $$('.user-contact')[0];
					element.show();
					element.previous('h3').show();
				}
			});
		});

		Validation.addAllThese([
			['validate-unique-document-type', 'El tipo de documento especificado ya existe para esta actividad.', function(v, elm){
				formElement = elm.up('form');

				if(inputElement = formElement.down('input[name="id"]')){
					if(!(inputValue = inputElement.getValue()))
						inputValue = 0;
				}
				else
					inputValue = 0;

				returnValue = changeContent(2, {
					asynchronous: false,
					valueElement: {
						reference: elm
					},
					parameters: {
						idactividad: inputValue,
						idsalon: formElement.down('input[name="idsalon"]').getValue(),
						idsesion: formElement.down('select[name="idsesion"]').getValue()
					},
					changeElement: {
						action: 'return'
					}
				});

				if(returnValue == 1)
					return(true);
				else
					return(false);
			}]
		]);
	});