var Slider = Class.create();

Slider.prototype = {

    options: {

        shift: 900

    },

    

    initialize: function(container, controlLeft, controlRight){

        this.animating = false;

        this.containerSize = {

            width: $(container).offsetWidth,

            height: $(container).offsetHeight

        },

        this.content = $(container).down();

        this.controlLeft = $(controlLeft);

        this.controlRight = $(controlRight);

        

        this.initControls();

    },

    

    initControls: function(){

        this.controlLeft.href = this.controlRight.href = 'javascript:void(0)';

        Event.observe(this.controlLeft,  'click', this.shiftLeft.bind(this));

        Event.observe(this.controlRight, 'click', this.shiftRight.bind(this));

        this.updateControls(1, 0);

    },

    

    shiftRight: function(){

        if (this.animating)

            return;

        

        var left = isNaN(parseInt(this.content.style.left)) ? 0 : parseInt(this.content.style.left);

        

        if ((left + this.options.shift) < 0) {

            var shift = this.options.shift;

            this.updateControls(1, 1);

        } else {

            var shift = Math.abs(left);

            this.updateControls(1, 0);

        }

        this.moveTo(shift);

    },

    

    shiftLeft: function(){

        if (this.animating)

            return;

        

        var left = isNaN(parseInt(this.content.style.left)) ? 0 : parseInt(this.content.style.left);

        

        var lastItemLeft = this.content.childElements().last().positionedOffset()[0];

        var lastItemWidth = this.content.childElements().last().getWidth();

        var contentWidth = lastItemLeft + lastItemWidth + 8;

        

        if ((contentWidth + left - this.options.shift) > this.containerSize.width) {

            var shift = this.options.shift;

            this.updateControls(1, 1);

        } else {

            var shift = contentWidth + left - this.containerSize.width;

            this.updateControls(0, 1);

        } 

        this.moveTo(-shift);

    },

    

    moveTo: function(shift){

        var scope = this;

                     

        this.animating = true;

        

        new Effect.Move(this.content, {

            x: shift,

            duration: 0.4,

            delay: 0,

            afterFinish: function(){

                scope.animating = false;

            }

        });

    },

    

    updateControls: function(left, right){

        if (!left)

            this.controlLeft.addClassName('disabled');

        else

            this.controlLeft.removeClassName('disabled');

        

        if (!right)

            this.controlRight.addClassName('disabled');

        else

            this.controlRight.removeClassName('disabled');

    }

}



//example 1  

new Control.Tabs('tabs_example_one');  

  

//example 2  

var tabs_example_two = new Control.Tabs('tabs_example_two',{  

    afterChange: function(new_container){  

        $A($('tabs_example_two_select').options).each(function(option,i){  

            if(option.value == new_container.id){  

                $('tabs_example_two_select').options.selectedIndex = i;  

                throw $break;  

            }  

        });  

    }  

});  

$('tabs_example_two_select').observe('change',function(){  

    tabs_example_two.setActiveTab($('tabs_example_two_select').value);  

});  

$('tabs_example_two_first').observe('click',function(event){  

    this.first();  

    Event.stop(event);  

}.bindAsEventListener(tabs_example_two));  

$('tabs_example_two_previous').observe('click',function(event){  

    this.previous();  

    Event.stop(event);  

}.bindAsEventListener(tabs_example_two));  

$('tabs_example_two_next').observe('click',function(event){  

    this.next();  

    Event.stop(event);  

}.bindAsEventListener(tabs_example_two));  

$('tabs_example_two_last').observe('click',function(event){  

    this.last();  

    Event.stop(event);  

}.bindAsEventListener(tabs_example_two));  



function bajaListaMulti()
{	
	var email = document.getElementById("email_baja").value;			
	var error_vacio = document.getElementById("error_vacio").value;	
	var error_email = document.getElementById("error_email").value;	
	var confirmar_baja_tit = document.getElementById("confirmar_baja_tit").value;	
	var confirmar_baja_texto = document.getElementById("confirmar_baja_texto").value;	
	var email_no_existe = document.getElementById("email_no_existe").value;
	
	var error = 0;
	var error_vacio_1 = 0;	
	var error_email_1 = 0;	

	new Ajax.Updater('notificacion', '/scripts/boletin/mensaje_multi.php?mensaje=' , { method: 'get' });	
	if ((email == email_oculto) || (email == ""))
	{
		
		error_vacio_1=1;
		error=1;
		
	}
	else
	{
		if ((validarEmail(email)) == false)
		{			
			error=1;
			error_email_1=1;
		}
		else
		{
				
		}
	}
	
	
	if (error_vacio_1 == 1)
	{
		new Ajax.Updater('notificacion', '/scripts/boletin/mensaje_multi.php?mensaje='+error_vacio, { method: 'get' });		
		
	}
	if (error_email_1 == 1)
	{
		new Ajax.Updater('notificacion', '/scripts/boletin/mensaje_multi.php?mensaje='+error_email, { method: 'get' });
		
	}
	if ((error == 0) && (error_vacio_1 == 0) && (error_email_1 == 0))
	{
		
		
		new Ajax.Request('/scripts/boletin/boletin_baja_multi.php?isAjax=1&email='+email, {  method: 'get', 
			onSuccess: function(transport) 
			{ 
			
				if (transport.responseText == 0)
				{	
					new Ajax.Updater('notificacion', '/scripts/boletin/mensaje_multi.php?mensaje='+email_no_existe, { method: 'get' });	
					error = 1;			
				}
				if (transport.responseText == 1)
				{
					alert("Revise su correo para confirmar la baja");
				}
			
			
			} });	
		
			
	}
	
}

function altaListaMulti()
{	
	var email = document.getElementById("email_baja").value;			
	var error_vacio = document.getElementById("error_vacio").value;	
	var error_email = document.getElementById("error_email").value;	
	var confirmar_baja_tit = document.getElementById("confirmar_baja_tit").value;	
	var confirmar_baja_texto = document.getElementById("confirmar_baja_texto").value;	
	var email_existe = document.getElementById("email_existe").value;
	
	var error = 0;
	var error_vacio_1 = 0;	
	var error_email_1 = 0;	

	new Ajax.Updater('notificacion', '/scripts/boletin/mensaje.php?mensaje=' , { method: 'get' });	
	if ((email == email_oculto) || (email == ""))
	{
		
		error_vacio_1=1;
		error=1;
		
	}
	else
	{
		if ((validarEmail(email)) == false)
		{			
			error=1;
			error_email_1=1;
		}
		else
		{
				
		}
	}
	
	
	if (error_vacio_1 == 1)
	{
		new Ajax.Updater('notificacion', '/scripts/boletin/mensaje.php?mensaje='+error_vacio, { method: 'get' });		
		
	}
	if (error_email_1 == 1)
	{
		new Ajax.Updater('notificacion', '/scripts/boletin/mensaje.php?mensaje='+error_email, { method: 'get' });
		
	}
	if ((error == 0) && (error_vacio_1 == 0) && (error_email_1 == 0))
	{
		
		
		new Ajax.Request('/scripts/boletin/boletin.php?isAjax=1&email='+email, {  method: 'get', 
			onSuccess: function(transport) 
			{ 
			
				if (transport.responseText == 0)
				{	
					new Ajax.Updater('notificacion', '/scripts/boletin/mensaje.php?mensaje='+email_existe, { method: 'get' });	
					error = 1;			
				}
				if (transport.responseText == 1)
				{
					alert("Revise su correo para confirmar el alta");
				}
			
			
			} });	
		
			
	}
	
}


