/* Funciones para slideshow  */


var start_frame=0;
var frame=0;
var t;

function start_slideshow() {
		var span_botones=document.getElementById("slideshow_titulos")
		for(var i=0;i<=end_frame;i++){
			span_botones.innerHTML=span_botones.innerHTML+"<a href='#' id='slideshow-titulo-"+i+"' class='slideshow-titulo' onclick='slideshow_goto("+i+"); return false;'>"+slide_titulos[i]+"</a>";
		}
		insert_slide();
		document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo-activo";

}

function insert_slide(){
	var delay=slide_delay[frame];
	var imgcode= "<img src='"+carpeta+"/"+slide[frame]+"' id='slideshow_frame' style='display:none;' />";
	document.getElementById("slideshow").innerHTML=imgcode;
	$('#slideshow_frame').fadeIn(400);
	t=setTimeout(switch_slides(), delay);
}
 
function switch_slides() {
	frame=frame;
	return (function() {
	$('#slideshow_frame').fadeOut(400);
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo";
	if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo-activo";
	t=setTimeout("insert_slide();", 400);
		
	})
}

function slideshow_pause(){
	document.getElementById("slideshow_pause").style.display="none";
	document.getElementById("slideshow_play").style.display="block";
	clearTimeout(t);
}
function slideshow_play(){
	document.getElementById("slideshow_pause").style.display="block";
	document.getElementById("slideshow_play").style.display="none";
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo";
	if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo-activo";
	insert_slide();
}
function slideshow_goto(goto){
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo";
	frame = goto;
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo-activo";
	clearTimeout(t);
	insert_slide();
}
function slideshow_next(){
	clearTimeout(t);
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo";
	if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo-activo";
	t=setTimeout("insert_slide();", 400);
}
function slideshow_prev(){
	clearTimeout(t);
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo";
	if (frame == start_frame) { frame =end_frame; } else { frame = frame - 1; }
	document.getElementById("slideshow-titulo-"+frame+"").className="slideshow-titulo-activo";
	t=setTimeout("insert_slide();", 400);
}
/* Funciones para slideshow  */
