window.addEvent('domready', function() {	
	if($('form_sugerir_categoria') != null) {
		$('form_sugerir_categoria').addEvent('submit', function(e) {
			// Prevents the default submit event from loading a new page.
			e.stop();
			
			// Set the options of the form's Request handler.
			// ("this" refers to the $$('form_invitacion') element).
			this.set('send', { onComplete: function(response) {
				if(response == 1) {
					alert("El e-mail se ha enviado correctamente");
				}
				else {
					alert(response);
				}
			}});
	
			// Send the form.
			this.send();
		});	
	}
	
	/*
		Formulario de acceso al panel de proveedor
	*/
	if($('form_acceso') != null) {
		$('form_acceso').addEvent('submit', function(e) {
			// Prevents the default submit event from loading a new page.
			e.stop();
			
			// Set the options of the form's Request handler.
			// ("this" refers to the $$('form_invitacion') element).
			this.set('send', { onComplete: function(response) {
				if(response == 1) {
					go_to_panel_page();
				}
				else {			  
				  alert(response);
				}
			}});
	
			// Send the form.
			this.send();
		});
		
		$('recordar_password').addEvent('click', function(e) {
			// Prevents the default submit event from loading a new page.
			e.stop();
			
			/**
			 * Set default options, overrideable from later calls.
			 */
			SqueezeBox.initialize({
				size: {x: 450, y: 120}
			});
			
			/**
			 * Open some content manually
			 */
			SqueezeBox.open('/recordar_password.php', {handler: 'iframe'});			
		});
		
		// Recomendar
		if($('recomendar') != null) {
			$('recomendar').addEvent('click', function(e) {
				// Prevents the default submit event from loading a new page.
				e.stop();
				
				/**
				 * Set default options, overrideable from later calls.
				 */
				SqueezeBox.initialize({
					size: {x: 450, y: 300}
				});
				
				/**
				 * Open some content manually
				 */
				SqueezeBox.open('/recomendar.php', {handler: 'iframe'});			
			});
		}
	}
});

function go_to_panel_page()
{
	window.location = '/panel'; // Panel
}
