var items_top_ancho=944;
var items_anim_ancho=960;
var tiempotransicion=10000;
var items_anim_current=0;
var items_anim_margen=0;
var items_anim_num=0;
var tiempo;
window.addEvent('domready', function(){	
	(function(){
		var $ = document.id;
		//iguala anchos del menutop
		var items_top=$('menutop').getElements('a');
		var items_top_num=items_top.length;
		var items_top_ancho_a=parseInt(items_top_ancho/items_top_num);
		items_top_ancho_res=items_top_ancho-(items_top_ancho_a*(items_top_num-1));
		items_top_ancho_a--;
		items_top.each(function(el){
			el.setStyle('width',items_top_ancho_a);	
		});
		items_top[items_top_num-1].setStyle('width',items_top_ancho_res );
		//slide
		var items_anim=$$('.animacion_bloque');
		items_anim_num=items_anim.length;
		
		$('animacion_total_bloques').setStyle('width', items_anim_ancho*items_anim_num);
		$("imgflecha1").addEvent('click', function() {
		   anterior();
		});
		$("imgflecha2").addEvent('click', function() {
			siguiente();
		});
		tiempo=setInterval('cambiar()',tiempotransicion);
		//tabla hosting
		if($('tabla_planes')){
			$('tabla_planes').addClass('tabla_expan1');
			$('flecha_expan').addEvent('click', function(){
				if($('tabla_planes').hasClass('tabla_expan1')){
					$('tabla_planes').removeClass('tabla_expan1');
					$('tabla_expan').addClass('tabla_expan1');
				}
				else {
					$('tabla_planes').addClass('tabla_expan1');
					$('tabla_expan').removeClass('tabla_expan1');
				}
			});
		}
	})();
	//tiempo=setInterval('siguiente()',4000);
});
function anterior(){
	var $ = document.id;
	items_anim_current--;
	$('animacion_total_bloques').set('tween', {transition: Fx.Transitions.Linear, duration:1000});
	if (items_anim_current<0){
		items_anim_current=items_anim_num-1;
	}
	$('animacion_total_bloques').tween('margin-left',items_anim_margen-items_anim_current*items_anim_ancho);
}
function siguiente(){
	var $ = document.id;
	items_anim_current++;
	$('animacion_total_bloques').set('tween', {transition: Fx.Transitions.Linear, duration:1000});
	if (items_anim_current==items_anim_num){
		items_anim_current=0;
	}
	$('animacion_total_bloques').tween('margin-left',items_anim_margen-items_anim_current*items_anim_ancho);
}
function cambiar(){
	clearInterval(tiempo);
	siguiente();
	tiempo=setInterval('cambiar()',tiempotransicion);
}
