var enlace_cont;
var enlace_intervalo;
var enlace_anterior = 0;
var enlace_actual = 0;

$(document).ready(function(){
  enlace_cont = $("div.enlace").size();
  $("div.enlace:eq("+enlace_actual+")").css('top','0px');
  
  enlace_intervalo = setInterval(enlace_rotate,5000); //time in milliseconds
  $('#scrollupe').hover(function() {
    clearInterval(enlace_intervalo);
  }, function() {
    enlace_intervalo = setInterval(enlace_rotate,5000); //time in milliseconds
    enlace_rotate();
  });
  
  setInterval( "slideSwitch()", 3000 );

});

function enlace_rotate() {
  enlace_actual = (enlace_anterior + 1) % enlace_cont; 
  $("div.enlace:eq(" + enlace_anterior + ")").animate({top: -205},"slow", function() {
    $(this).css('top','210px');
    });
  $("div.enlace:eq(" + enlace_actual + ")").show().animate({top: 0},"slow");  
  enlace_anterior = enlace_actual;
}


var RelojID24 = null  
var RelojEjecutandose24 = false  
var ahora;
  
function DetenerReloj24 (){  
    if(RelojEjecutandose24)  
        clearTimeout(RelojID24)  
    RelojEjecutandose24 = false  
}  
  
function MostrarHora24 () {
	
	//camp = document.getElementById(campo);
	//alert(ahora);//
	/*var camp = ""+campo+" ";
	arr1 = camp.split(" ");
	arr2 = arr1[0].split("/");
	arr3 = arr1[1].split(":");
	d = arr2[0]*1;
	m = arr2[1]*1;
	y = arr2[2]*1;
	h = arr3[0]*1;
	i = arr3[1]*1;*/
	//s = arr3[2]*1;
	//alert(d+"-"+m+"-"+y+" "+h+":"+i+":"+s);
	//var ahora = new Date(2009,1,17,5,45,23,0);
    var horas = ahora.getHours()  
    var minutos = ahora.getMinutes()  
    var segundos = ahora.getSeconds()  
	var dia = ahora.getDate();
	var mes = ahora.getMonth();
	var anio = ahora.getFullYear();
    var ValorHora  
  
    var ampm =" "; 
	if (horas > 12) { horas -= 12; ampm = " PM" } else ampm = " AM"
  
  	if (dia < 10)  ValorHora = "0" + dia  
    else  ValorHora = "" + dia  
	
	if (mes < 10)  ValorHora += "/0" + mes  
    else  ValorHora += "/" + mes  
	
	if (anio < 10)  ValorHora += "/0" + anio  
    else  ValorHora += "/" + anio  
  
    //establece las horas  
    if (horas < 10)  ValorHora += " 0" + horas  
    else  ValorHora += " " + horas  
  
    //establece los minutos  
    if (minutos < 10) ValorHora += ":0" + minutos  
    else  ValorHora += ":" + minutos  
  
    //establece los segundos  
    if (segundos < 10)  ValorHora += ":0" + segundos  
    else  ValorHora += ":" + segundos  
	
   
	ValorHora += ampm 
    document.getElementById("reloj").innerHTML = "Lima - Per&uacute;, " + ValorHora 
	ahora.setSeconds(ahora.getSeconds()+1);
    //si se desea tener el reloj en la barra de estado, reemplazar la anterior por esta  
    //window.status = ValorHora  
  
    RelojID24 = setTimeout("MostrarHora24()",1000)  
    RelojEjecutandose24 = true  
}  
  
function IniciarReloj24 () {  
    DetenerReloj24()  
    MostrarHora24()  
}  
  
  
  function slideSwitch() {

    var $active = $('#slideshow img.active');



    if ( $active.length == 0 ) $active = $('#slideshow img:last');



    var $next = $active.next().length ? $active.next() : $('#slideshow img:first');



    $active.addClass('last-active');



    $next.css({opacity: 0.0})

        .addClass('active')

        .animate({opacity: 1.0}, 1000, function() {

            $active.removeClass('active last-active');

        });

}

/*window.onload = IniciarReloj24;  
if (document.captureEvents) {           //N4 requiere invocar la funcion captureEvents  
    document.captureEvents(Event.LOAD)  
} */ 
  
