
var ERPimgSrc = new Array();
var ERPimgAlt = new Array();
var ERPheading = new Array();
var ERPdiscription = new Array();
var ERPoverlayHref = new Array();

ERPimgSrc[0] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_video4.png";
ERPimgAlt[0] = "Grupo Alcione de México";
ERPheading[0] = "Grupo Alcione de México";
ERPdiscription[0] = "Grupo Alcione de México optó por Microsoft Dynamics AX para aumentar su crecimiento y expansión.";
ERPoverlayHref[0] = "http://www.microsoft.com/latam/dynamics/clientes/video4.aspx ";

ERPimgSrc[1] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_video2.png";
ERPimgAlt[1] = "Grupo Farmacéutico SOMAR de México";
ERPheading[1] = "Grupo Farmacéutico SOMAR de México";
ERPdiscription[1] = "Grupo Farmacéutico SOMAR de México logró tener una base de datos unificada para todas sus compañías gracias a Microsoft Dynamics AX.";
ERPoverlayHref[1] = "http://www.microsoft.com/latam/dynamics/clientes/video2.aspx ";

ERPimgSrc[2] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_video1.png";
ERPimgAlt[2] = "Nexys de Colombia";
ERPheading[2] = "Nexys de Colombia";
ERPdiscription[2] = "Nexys de Colombia optó por Microsoft Dynamics AX para alcanzar la integración de sus procesos y expansión internacional.";
ERPoverlayHref[2] = "http://www.microsoft.com/latam/dynamics/clientes/video1.aspx";

ERPimgSrc[3] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_video3.png";
ERPimgAlt[3] = "Zentrix de México";
ERPheading[3] = "Zentrix de México";
ERPdiscription[3] = "Zentrix de la industrial textil de México reduce hasta un 40% de tiempo en la gestión de procesos después de su implementación de Microsoft Dynamics AX.";
ERPoverlayHref[3] = "http://www.microsoft.com/latam/dynamics/clientes/video3.aspx";



var CRMimgSrc = new Array();
var CRMimgAlt = new Array();
var CRMheading = new Array();
var CRMdiscription = new Array();
var CRMoverlayHref = new Array();

CRMimgSrc[0] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_videodefault.png";
CRMimgAlt[0] = "Banco de Guayaquil";
CRMheading[0] = "Banco de Guayaquil";
CRMdiscription[0] = "Banco de Guayaquil logra un mejor servicio al cliente con la herramienta Microsoft Dynamics CRM.";
CRMoverlayHref[0] = "http://www.microsoft.com/latam/dynamics/clientes/default.aspx";

CRMimgSrc[1] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_video7.png";
CRMimgAlt[1] = "Grupo Sancor Seguros";
CRMheading[1] = "Grupo Sancor Seguros";
CRMdiscription[1] = "Grupo Sancor Seguros alcanza su expansión internacional a través de Microsoft Dynamics CRM.";
CRMoverlayHref[1] = "http://www.microsoft.com/latam/dynamics/clientes/video7.aspx";

CRMimgSrc[2] = "/global/dynamics/es/xl/PublishingImages/img_lat_dynamics_video6.png";
CRMimgAlt[2] = "Gobierno de Panamá";
CRMheading[2] = "Gobierno de Panamá";
CRMdiscription[2] = "El Gobierno de Panamá implementó Microsoft Dynamics CRM y el sistema Respond© de Rock Solid Technologies para mejorar los servicios de atención a sus ciudadanos.";
CRMoverlayHref[2] = "http://www.microsoft.com/latam/dynamics/clientes/video6.aspx ";



$(document).ready(function () {

    $("#erpDiv").css('visibility', 'visible');
    $("#crmDiv").css('visibility', 'visible');
    $("#crmDiv").hide();
    var bnrRotationInner;
    var bnrRotation = setInterval(function () {
        switchCRM();
        bnrRotationInner = setTimeout(function () {
            switchERP();
        }, 10000);

    }, 20000);
    switchERP = function () {

        $("#crmDiv").fadeOut("slow");
        $("#erpDiv").fadeIn("slow");
        $(".erpExp").attr('src','/global/dynamics/es/xl/PublishingImages/hero_exp_erp_orange_btn.png');
        $(".crmExp").attr('src','/global/dynamics/es/xl/PublishingImages/hero_exp_crm_blue_btn.png');  

    }
    switchCRM = function () {

        $("#erpDiv").fadeOut("slow");
        $("#crmDiv").fadeIn("slow");
        $(".crmExp").attr('src','/global/dynamics/es/xl/PublishingImages/hero_exp_crm_orange_btn.png');
        $(".erpExp").attr('src','/global/dynamics/es/xl/PublishingImages/hero_exp_erp_blue_btn.png');  
    }
    $(".erpExp").click(function () {
        switchERP();
        clearInterval(bnrRotation);          
        clearInterval(bnrRotationInner);  
    });
    $(".crmExp").click(function () {
        switchCRM();
        clearInterval(bnrRotation);         
        clearInterval(bnrRotationInner); 
    });
    
   


    var thumbAlignCRM = -1;
    $(".bnrVidRotatorItemCRM").each(function () {
        $(".bnrVidRotatorItemCRM." + (thumbAlignCRM + 1)).css('left', 60 * thumbAlignCRM);
        thumbAlignCRM++;
        var thisX = parseInt($(this).css('left'));
        if (thisX >= 40 && thisX <= 70) {
            $(this).children().animate({ height: 60, width: 60 }, { duration: 300, queue: false });
            $(this).animate({ left: 55, top: -5 }, { duration: 300, queue: false });
        }
    });

    var thumbAlignERP = -1;
    $(".bnrVidRotatorItemERP").each(function () {
        $(".bnrVidRotatorItemERP." + (thumbAlignERP + 1)).css('left', 60 * thumbAlignERP);
        thumbAlignERP++;
        var thisX = parseInt($(this).css('left'));
        if (thisX >= 40 && thisX <= 70) {
            $(this).children().animate({ height: 60, width: 60 }, { duration: 300, queue: false });
            $(this).animate({ left: 55, top: -5 }, { duration: 300, queue: false });
        }
    });

    var rttnChck = true;

    //ERP Next and previous button action:
    $("#scrlPrvERP").click(function () {

        clearInterval(bnrRotation);
        clearInterval(bnrRotationInner); 
        if (rttnChck) {
            rttnChck = false;
            $(".bnrVidRotatorItemERP").each(function () {
                var thisX = parseInt($(this).css('left'));
                $(this).animate({ left: thisX - 60 }, 300);
                var ERPL = ERPimgSrc.length;
                if (ERPL <= 4) ERPL = ERPL * 2;
                if (parseInt($(this).css('left')) <= -55) {
                    $(this).animate({ left: ERPL * 60 - 120 }, 0);
                    setTimeout(function () { rttnChck = true; }, 400);
                }
                if (thisX >= 70 && thisX <= 120) {
                    $(this).children().animate({ height: 60, width: 60 }, { duration: 300, queue: false });
                    $(this).animate({ left: 55, top: -5 }, { duration: 300, queue: false });
                    var classNo = $(this).attr('class').split(' ')[1];
                    if (ERPimgSrc.length <= 4) {
                        if (classNo >= 4) classNo = classNo - 4;
                        $("#CStoriesERP h2").html(ERPheading[classNo]);
                        $("#CStoriesERP p").html(ERPdiscription[classNo]);
                    }
                    else {
                        $("#CStoriesERP h2").html(ERPheading[classNo]);
                        $("#CStoriesERP p").html(ERPdiscription[classNo]);
                    }

                }
                else if (thisX >= 40 && thisX <= 100) {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ left: 0, top: 0 }, { duration: 300, queue: false });
                }
                else {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ top: 0 }, { duration: 300, queue: false });
                }
            });
        }

    });

    $("#scrlNxtERP").click(function () {
        clearInterval(bnrRotation);
        clearInterval(bnrRotationInner); 
		if (rttnChck) {
            rttnChck = false;
            $(".bnrVidRotatorItemERP").each(function () {
                var thisX = parseInt($(this).css('left'));
                $(this).animate({ left: thisX + 60 }, 300);
                var ERPL = ERPimgSrc.length;
                if (ERPL <= 4) ERPL = ERPL * 2;
                if (parseInt($(this).css('left')) >= ERPL * 60 - 120) {
                    $(this).animate({ left: -60 }, 0);
                    setTimeout(function () { rttnChck = true; }, 400);
                }
                if (thisX >= -10 && thisX <= 50) {
                    $(this).children().animate({ height: 60, width: 60 }, { duration: 300, queue: false });
                    $(this).animate({ left: 55, top: -5 }, { duration: 300, queue: false });
                    var classNo = $(this).attr('class').split(' ')[1];
                    if (ERPimgSrc.length <= 4) {
                        if (classNo >= 4) classNo = classNo - 4;
                        $("#CStoriesERP h2").html(ERPheading[classNo]);
                        $("#CStoriesERP p").html(ERPdiscription[classNo]);
                    }
                    else {
                        $("#CStoriesERP h2").html(ERPheading[classNo]);
                        $("#CStoriesERP p").html(ERPdiscription[classNo]);
                    }
                }
                else if (thisX >= 40 && thisX <= 100) {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ left: 120, top: 0 }, { duration: 300, queue: false });
                }
                else {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ top: 0 }, { duration: 300, queue: false });
                }

            });
        }
    });


    //CRM Next and previous button action:

    $("#scrlPrvCRM").click(function () {
        clearInterval(bnrRotation);
        clearInterval(bnrRotationInner); 
        if (rttnChck) {
            rttnChck = false;
            $(".bnrVidRotatorItemCRM").each(function () {
                var thisX = parseInt($(this).css('left'));
                $(this).animate({ left: thisX - 60 }, 300);
                var CRML = CRMimgSrc.length;
                if (CRML <= 3) CRML = CRML * 2;
                if (parseInt($(this).css('left')) <= -55) {
                    $(this).animate({ left: CRML * 60 - 120 }, 0);
                    setTimeout(function () { rttnChck = true; }, 400);
                }
                if (thisX >= 70 && thisX <= 120) {
                    $(this).children().animate({ height: 60, width: 60 }, { duration: 300, queue: false });
                    $(this).animate({ left: 55, top: -5 }, { duration: 300, queue: false });
                    var classNo = $(this).attr('class').split(' ')[1];
                    if (CRMimgSrc.length <= 3) {
                        if (classNo >= 3) classNo = classNo - 3;
                        $("#CStoriesCRM h2").html(CRMheading[classNo]);
                        $("#CStoriesCRM p").html(CRMdiscription[classNo]);
                    }
                    else {
                        $("#CStoriesCRM h2").html(CRMheading[classNo]);
                        $("#CStoriesCRM p").html(CRMdiscription[classNo]);
                    }
                }
                else if (thisX >= 40 && thisX <= 100) {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ left: 0, top: 0 }, { duration: 300, queue: false });
                }
                else {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ top: 0 }, { duration: 300, queue: false });
                }
            });
        }

    });

    $("#scrlNxtCRM").click(function () {
        clearInterval(bnrRotation);
        clearInterval(bnrRotationInner); 
		if (rttnChck) {
            rttnChck = false;
            $(".bnrVidRotatorItemCRM").each(function () {
                var thisX = parseInt($(this).css('left'));
                $(this).animate({ left: thisX + 60 }, 300);
                var CRML = CRMimgSrc.length;
                if (CRML <= 3) CRML = CRML * 2;
                if (parseInt($(this).css('left')) >= CRML * 60 - 120) {
                    $(this).animate({ left: -60 }, 0);
                    setTimeout(function () { rttnChck = true; }, 400);
                }
                if (thisX >= -10 && thisX <= 50) {
                    $(this).children().animate({ height: 60, width: 60 }, { duration: 300, queue: false });
                    $(this).animate({ left: 55, top: -5 }, { duration: 300, queue: false });
                    var classNo = $(this).attr('class').split(' ')[1];
                    if (CRMimgSrc.length <= 3) {
                        if (classNo >= 3) classNo = classNo - 3;
                        $("#CStoriesCRM h2").html(CRMheading[classNo]);
                        $("#CStoriesCRM p").html(CRMdiscription[classNo]);
                    }
                    else {
                        $("#CStoriesCRM h2").html(CRMheading[classNo]);
                        $("#CStoriesCRM p").html(CRMdiscription[classNo]);
                    }
                }
                else if (thisX >= 40 && thisX <= 100) {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ left: 120, top: 0 }, { duration: 300, queue: false });
                }
                else {
                    $(this).children().animate({ height: 50, width: 50 }, { duration: 300, queue: false });
                    $(this).animate({ top: 0 }, { duration: 300, queue: false });
                }

            });
        }
    });


});
