﻿//funcion principal
var timer_count_Promociones = 0;
var timeout_Promociones = 200;
var list_promociones = new Array();
var index_promocion_actual = 0;
var twitter_user = "";
$(document).ready(Init);
function Init() {
    Init_General();
    $('.lnkPromocion').each(function(index){
       list_promociones.push($(this).attr("fondo"));
   });

  setInterval(timerPromociones, 10);
  $('.lnkPromocion').hover(lnkPromocionOver, lnkPromocionOut);
  showTweets();
  //  setInterval(showTweets, 60000);
  // La siguiente linea es para el popup de inicio
  //setTimeout(function() { tb_show('','aviso.asp?width=300&height=520',false); }, 1000);
}
function showTweets() {
    $("#twitter").getTwitter({
        userName: twitter_user,
        numTweets: 5,
        loaderText: "Cargando tweets...",
        slideIn: true,
        showHeading: false,
        headingText: "Ultimas noticias",
        showProfileLink: false
    });
}
function lnkPromocionOver() {
    showPromocion_Fondo_url($(this).attr("fondo"));
}
function lnkPromocionOut() {
}

function timerPromociones() {
    timer_count_Promociones++;
    if (timer_count_Promociones >= timeout_Promociones) {
        timer_count_Promociones = 0;
        showPromocion_Fondo(index_promocion_actual++);
    }
}
function showPromocion_Fondo(index) {
    if (index >= list_promociones.length-1) {
        index_promocion_actual = 0;
    }
    $('#seccion_4').css('background', 'url(' + list_promociones[index_promocion_actual] + ') no-repeat');
}
function showPromocion_Fondo_url(url) {
    timer_count_Promociones = 0;
    $('#seccion_4').css('background', 'url(' + url + ') no-repeat');
}
