// JavaScript Document

var n_actual_id = 1;
var num="imagen0";
function cambiar(idimagen) {
document.getElementById(num).style.visibility='hidden';
num = idimagen;
document.getElementById(idimagen).style.visibility='visible'; }

function rotarAnuncio() {
var vinput = document.getElementsByName("cantidad");
var cant = vinput.item(0).value;
if (cant > 1){
   document.getElementById("anuncio1").style.visibility='hidden';
   var randomnumber=(Math.ceil(Math.random()*cant));
   document.getElementById("anuncio"+randomnumber).style.visibility='visible'; 
    }
}




function galeria(idimagen) {
	//Activo galeria
	var randomnumber=(Math.ceil(Math.random()*idimagen));
	randomnumber = n_actual_id + 1;
	if ( randomnumber > idimagen) {
		randomnumber = 1;
	}
	n_actual_id = randomnumber;
	document.getElementById('imagen'+randomnumber).className = 'seleccionado';	
	for(i = 1; i < idimagen + 1; i++){
		//desactivo galeria
		if(i != randomnumber){
			document.getElementById("imagen" + i).className = 'oculto';
		}
	}
	ID=window.setTimeout("galeria("+idimagen+");",3000);
}

function videos(idimagen, contador) {
	//Activo galeria
	document.getElementById('videoGrande'+idimagen).className = 'seleccionadoVideo';	
	for(i = 1; i < contador; i++){
		//desactivo galeria
		if(i != idimagen){
			document.getElementById("videoGrande" + i).className = 'oculto';
		}
	}

}


function botones(a,b,c,idimagen,ver,mas) {
	//Activo galeria
	for(i = 1; i < a; i++){
	document.getElementById('boton'+i).className = 'muestra';
	}
	document.getElementById('botonmas'+ver).className = 'vermas';
	document.getElementById('botonmas'+mas).className = 'oculto';
	for(j = 1; j < a; j++){
		//desactivo galeria
	document.getElementById("imagen" + j).className = 'oculto';
	}
	document.getElementById(idimagen).className = 'seleccionado';	
	for(c; c < b; c++){
		//desactivo galeria		
	    document.getElementById("boton"+c).className = 'oculto';
	}

	
}



/* Mover tickes de noticias*/
	var pos =300;
	var size = 0;
	//alert(document.getElementById("noticias"));
	//var numeroNoticias = document.getElementById("noticias");
	//var cant = numeroNoticias.item(0).value; //

	
	var longitudDiv =  500;
	var numeroNoticias = 0;
	var cant = 0;
	var tol;
	var velocidad = 60;
	function moverBanner(mover) {
		try{
			numeroNoticias = document.getElementById("numeroNoticias");
			cant = numeroNoticias.value;
			if(cant == 1){
				longitudDiv =  501;
			}else{
				longitudDiv =  cant * 502;
			}
			var valor = longitudDiv + "px";
			document.getElementById("tiraMarquesina").style.width = longitudDiv + "px";
			size =0;
			for ( i=1; i<cant ;i++){	
				size=size+document.getElementById("img"+i).width;
			}
			
			size = longitudDiv;
			if(Math.abs(pos) < size){
				document.getElementById("tiraMarquesina").style.left = pos +"px";
				pos = pos - 3;
			} else {
				document.getElementById("tiraMarquesina").style.left = 500 +"px";
				pos = parseInt("500");
			}
			
		}catch(e){
		}
		if(mover){
			to1 = setTimeout("moverBanner(true)", velocidad);
		}
	}
	
	function pararBanner(){
		try{
			if(velocidad != 1000){
				velocidad = 1000;
			}
			//clearTimeout(tol);
		}catch(e){
		}
		//to1 = setTimeout("moverBanner()", 60);
	}
	
	function startMarquesina(){
		velocidad = 60;
		/*try{
			if(velocidad != 60){
				velocidad = 60;
				to1 = setTimeout("moverBanner(true)", velocidad);
			}
		}catch(e){
		}*/
	}



