//Para la portada
var contadorBanner = 0;
function moverPortada(cuanto){
	var derecha = $('contenedor_banners').offsetLeft;
	anchoMover = Math.abs(cuanto);
	anchoTotal = $$('div.banner').length*anchoMover;
	
	desplazamientoPermitido = 10;		
		
		new Effect.Move ('contenedor_banners',
		{	x: cuanto,
			y: 0, 
			mode: 'relative',
			afterFinish: activarBotosPortada,
			beforeStart: desactivarBotosPortada 
		});
		
		
		
		
		banner_array = $$('div.banner a');
	
		
		if (banner_array.length == 2){
		
			if (cuanto > 0){
				$('boton_portada_ant').style.height="0px";
				$('boton_portada_sig').style.height="84px";
				contadorBanner--;
			}else{
				$('boton_portada_sig').style.height="0px";
				$('boton_portada_ant').style.height="84px";
				contadorBanner++;
			}
		
		}else{
		
		
			if(cuanto > 0){
				if (contadorBanner == 1){
					$('boton_portada_ant').style.height="0px";
				}else{
					$('boton_portada_sig').style.height="84px";
				}
				
				contadorBanner--;
			}
			
			
			if (cuanto < 0){
				if (contadorBanner == banner_array.length - 2){
					$('boton_portada_sig').style.height="0px";
				}else{
					$('boton_portada_ant').style.height="84px";
				}
				
				contadorBanner++;
			}
		}
		
	
	enlace_actual = banner_array[contadorBanner];
	
	
	document.getElementById("enlace_mascara_banner").href = enlace_actual;
	
}

function activarBotosPortada(obj){
	botonesArray = $$('#botones_banner a');
	botonesArray.each(function(item) {
	  	enableLink(item);
	});
}
function desactivarBotosPortada(obj){
	botonesArray = $$('#botones_banner a');
	botonesArray.each(function(item) {
	  	disableLink(item);
	});
}

//General
function cancelLink () {
  return false;
}
function disableLink (link) {
  if (link.onclick)
    link.oldOnClick = link.onclick;
  link.onclick = cancelLink;
  if (link.style)
    link.style.cursor = 'default';
}
function enableLink (link) {
  link.onclick = link.oldOnClick ? link.oldOnClick : null;
  if (link.style)
    link.style.cursor = 
      document.all ? 'hand' : 'pointer';
}





/*------------------------------Init--------------------------------*/
function init() {
	banner_array = $$('div.banner a');
	enlace_actual = banner_array[0];
	
	document.getElementById("enlace_mascara_banner").href = enlace_actual;
}
window.onload = init; 

