// JavaScript Document
var contadorIMG = 1;
var contadorN = 0;
if(BASE_URL==undefined)
	var BASE_URL = "";

function _nota(data)
{
	$('#tit_scroll').html("<a href='"+BASE_URL+"notas/"+data.id+"/"+"'>"+data.titulo+"</a>");
	$('#vol_scroll').html(data.volanta);
	$('#baj_scroll').html("<a href='"+BASE_URL+"notas/"+data.id+"/"+"'>"+data.bajada+"</a>");
	if(data.foto!=0){
		$("#img_scroll").attr("src", ""+BASE_URL+"imagenes/fotos/"+data.foto);
	} else {
		$("#img_scroll").attr("src", ""+BASE_URL+"img/vacio.png");
	}
}
	
function init_scroll_notas()
{
	CambiarNota();
	$('#boton').click(function(){
		CambiarImg2();
	})
	_nota(_scroll_notas_data[0]);
	$("#img_bkg").attr("src", ""+BASE_URL+"img/base_scroll.png");
	
	$('#boton1').click(function(){
		$("#boton1").css({ color: "#002859" });
		$("#boton2").css({ color: "#ffffff" });
		$("#boton3").css({ color: "#ffffff" });
		$("#boton4").css({ color: "#ffffff" });
		
		_nota(_scroll_notas_data[0]);
		$("#img_bkg").attr("src", ""+BASE_URL+"img/base_scroll.png");
		contadorN = 1;
	})
	$('#boton2').click(function(){
		$("#boton1").css({ color: "#ffffff" });
		$("#boton2").css({ color: "#002859" });
		$("#boton3").css({ color: "#ffffff" });
		$("#boton4").css({ color: "#ffffff" });
		
		_nota(_scroll_notas_data[1]);
		$("#img_bkg").attr("src", ""+BASE_URL+"img/base_scroll.png");
		contadorN = 2;
	})
	$('#boton3').click(function(){
		$("#boton1").css({ color: "#ffffff" });
		$("#boton2").css({ color: "#ffffff" });
		$("#boton3").css({ color: "#002859" });
		$("#boton4").css({ color: "#ffffff" });
		
		_nota(_scroll_notas_data[2]);
		$("#img_bkg").attr("src", ""+BASE_URL+"img/base_scroll.png");
		contadorN = 3;
	})
	$('#boton4').click(function(){
		$("#boton1").css({ color: "#ffffff" });
		$("#boton2").css({ color: "#ffffff" });
		$("#boton3").css({ color: "#ffffff" });
		$("#boton4").css({ color: "#002859" });
		
		_nota(_scroll_notas_data[3]);
		$("#img_bkg").attr("src", ""+BASE_URL+"img/base_scroll_comillas.png");
		contadorN = 0;
	})
}

function CambiarNota() {
	switch (contadorN) {
		case 0:
			$("#boton1").css({ color: "#002859" });
			$("#boton2").css({ color: "#ffffff" });
			$("#boton3").css({ color: "#ffffff" });
			$("#boton4").css({ color: "#ffffff" });
			
			_nota(_scroll_notas_data[0]);
			$("#img_bkg").attr("src", BASE_URL+"img/base_scroll.png");
			contadorN++;
			break;
		case 1:
			$("#boton1").css({ color: "#ffffff" });
			$("#boton2").css({ color: "#002859" });
			$("#boton3").css({ color: "#ffffff" });
			$("#boton4").css({ color: "#ffffff" });
			
			_nota(_scroll_notas_data[1]);
			$("#img_bkg").attr("src", BASE_URL+"img/base_scroll.png");
			contadorN++;
			break;
		case 2:
			$("#boton1").css({ color: "#ffffff" });
			$("#boton2").css({ color: "#ffffff" });
			$("#boton3").css({ color: "#002859" });
			$("#boton4").css({ color: "#ffffff" });
			
			_nota(_scroll_notas_data[2]);
			$("#img_bkg").attr("src", BASE_URL+"img/base_scroll.png");
			contadorN++;
			break;
		case 3:
			$("#boton1").css({ color: "#ffffff" });
			$("#boton2").css({ color: "#ffffff" });
			$("#boton3").css({ color: "#ffffff" });
			$("#boton4").css({ color: "#002859" });
			
			_nota(_scroll_notas_data[3]);
			$("#img_bkg").attr("src", BASE_URL+"img/base_scroll_comillas.png");
			contadorN = 0;
			break;
	}
	setTimeout("CambiarNota()", 10000);
}

function init_scroll_fotos()
{
	CambiarImg();
}

function CambiarImg() {
	if (contadorIMG < _scroll_fotos_data.length+1) {
		var valor=""+BASE_URL+"imagenes/fotos/"+_scroll_fotos_data[contadorIMG-1];
		$("#img").fadeOut("slow", function() {
			$("#img").attr("src", valor);
		})
		$("#img").fadeIn("slow");
		setTimeout("CambiarImg()", 4000);
		contadorIMG++;
	} else {
		contadorIMG = 1;
		setTimeout("CambiarImg()", 1000);	  
	}
}

function CambiarImg2() {
	if (contadorIMG < _scroll_fotos_data.length+1) {
		var valor=""+BASE_URL+"imagenes/fotos/"+_scroll_fotos_data[contadorIMG-1];
		$("#img").fadeOut("slow", function() {
			$("#img").attr("src", valor);
		})
		$("#img").fadeIn("slow");
		contadorIMG++;
	} else {
		contadorIMG = 1;
	}
	setTimeout("CambiarImg()", 20000);
}


