﻿preloadimage("img/virtualizacion1.gif");
preloadimage("img/virtualizacion2.gif");
preloadimage("img/infraestructura1.gif");
preloadimage("img/infraestructura2.gif");
preloadimage("img/seguridad1.gif");
preloadimage("img/seguridad2.gif");
preloadimage("img/servicios1.gif");
preloadimage("img/servicios2.gif");

var _menuActive = 1;



function setMenu(menu) {
    switch (menu) {
        case 1:
            $("#img_virtua").attr("src", "img/virtualizacion2.gif");

            $("#img_infra").attr("src", "img/infraestructura1.gif");
            $("#img_segu").attr("src", "img/seguridad1.gif");
            $("#img_serv").attr("src", "img/servicios1.gif");
            break;
        case 2:
            $("#img_infra").attr("src", "img/infraestructura2.gif");

            $("#img_virtua").attr("src", "img/virtualizacion1.gif");
            $("#img_segu").attr("src", "img/seguridad1.gif");
            $("#img_serv").attr("src", "img/servicios1.gif");
            break;
        case 3:
            $("#img_segu").attr("src", "img/seguridad2.gif");

            $("#img_virtua").attr("src", "img/virtualizacion1.gif");
            $("#img_infra").attr("src", "img/infraestructura1.gif");
            $("#img_serv").attr("src", "img/servicios1.gif");
            break;
        case 4:
            $("#img_serv").attr("src", "img/servicios2.gif");

            $("#img_virtua").attr("src", "img/virtualizacion1.gif");
            $("#img_infra").attr("src", "img/infraestructura1.gif");
            $("#img_segu").attr("src", "img/seguridad1.gif");
            break;
    }

    switch (_menuActive) {
        case 1:
            $("#virtua").hide();
            DisplayMenu(menu);
            break;
        case 2:
            $("#infra").hide();
            DisplayMenu(menu);
            break;
        case 3:
            $("#segu").hide();
            DisplayMenu(menu);
            break;
        case 4:
            $("#serv").hide();
            DisplayMenu(menu);
            break;
    }
}

function DisplayMenu(menu) {
    switch (menu) {
        case 1:
            $("#menu_content").animate({ borderBottomColor: "#14628c", borderLeftColor: "#14628c", borderRightColor: "#14628c", borderTopColor: "#14628c" }, 500);
            $("#virtua").fadeIn();
            break;
        case 2:
            $("#menu_content").animate({ borderBottomColor: "#006e5a", borderLeftColor: "#006e5a", borderRightColor: "#006e5a", borderTopColor: "#006e5a" }, 500);
            $("#infra").fadeIn();
            break;
        case 3:
            $("#menu_content").animate({ borderBottomColor: "#98a71a", borderLeftColor: "#98a71a", borderRightColor: "#98a71a", borderTopColor: "#98a71a" }, 500);
            $("#segu").fadeIn();
            break;
        case 4:
            $("#menu_content").animate({ borderBottomColor: "#2ca4df", borderLeftColor: "#2ca4df", borderRightColor: "#2ca4df", borderTopColor: "#2ca4df" }, 500);
            $("#serv").fadeIn();
            break;
    }
    _menuActive = menu;
}


var mouseenter_menu_content = false;
var mouseenter_banner_content = false;
var _bannerActivo = 1;
$(document).ready(function() {
    $('#navcontainer').mouseenter(function() {
        mouseenter_menu_content = true;
    });
    $('#navcontainer').mouseleave(function() {
        mouseenter_menu_content = false;
    });
    $('#menu_content').mouseenter(function() {
        mouseenter_menu_content = true;
    });
    $('#menu_content').mouseleave(function() {
        mouseenter_menu_content = false;
    });

    $('#banner1').mouseenter(function() {
        mouseenter_banner_content = true;
    });
    $('#banner1').mouseleave(function() {
        mouseenter_banner_content = false;
    });

    changeMenu();
    function changeMenu() {
        setTimeout(function() {
            if (mouseenter_menu_content == false) {
                _menuActive++;
                if (_menuActive == 5)
                    _menuActive = 1;
                $("#virtua").hide();
                $("#infra").hide();
                $("#segu").hide();
                $("#serv").hide();
                setMenu(_menuActive);
            }
            changeMenu();
        }, 5000);
    }

    $("#bc1").show();
    $("#linkB1").css({ 'background-color': '#81b0ca' });

    changeBanner();
    function changeBanner() {
        setTimeout(function() {
            if (mouseenter_banner_content == false) {
                var b = _bannerActivo;
                b++;
                if (b == 5)
                    b = 1;
                displayBanner(b);
            }
            changeBanner();
        }, 3000);
    }
});

function nextBanner() {
    if (procesandoBanner == true) return;
    var b = _bannerActivo;
    b++;
    if (b == 5)
        b = 1;
    displayBanner(b);
}

function backBanner() {
    if (procesandoBanner == true) return;
    var b = _bannerActivo;
    b--;
    if (b == 0)
        b = 4;
    displayBanner(b);
}

var procesandoBanner = false;
function displayBanner(banner) {
    if (procesandoBanner == true) return;

    procesandoBanner = true;
    var bAct = null;
    var bNext = null;
    var liAct = null;
    var liNext = null;
    switch (_bannerActivo) {
        case 1:
            bAct = $("#bc1");
            liAct = $("#linkB1");
            break;
        case 2:
            bAct = $("#bc2");
            liAct = $("#linkB2");
            break;
        case 3:
            bAct = $("#bc3");
            liAct = $("#linkB3");
            break;
        case 4:
            bAct = $("#bc4");
            liAct = $("#linkB4");
            break;
    }
    switch (banner) {
        case 1:
            bNext = $("#bc1");
            liNext = $("#linkB1");
            break;
        case 2:
            bNext = $("#bc2");
            liNext = $("#linkB2");
            break;
        case 3:
            bNext = $("#bc3");
            liNext = $("#linkB3");
            break;
        case 4:
            bNext = $("#bc4");
            liNext = $("#linkB4");
            break;
    }
    liAct.css({ 'background-color': '#ccc' });
    liNext.css({ 'background-color': '#81b0ca' });
    bAct.fadeOut(500, function() {
        bNext.fadeIn(500, function() {
            _bannerActivo = banner;
            procesandoBanner = false;
        });
    });
}  
