//javascript

$(document).ready(function(){
    var type = 1;
    var bgdTime = 10000;
    var bglimit = 6;
    setInterval (function () {        
        $('#bgd_gnrl_sitio ').animate({
             opacity: 0.1
        },        
        (bgdTime/10),
        'linear',
        function(){
            $("#bgd_gnrl_sitio ").css({'backgroundImage':'url(media/images/background/'+type+'-01.jpg)','backgroundRepeat': 'repeat-x'});
            }
        );
    
        $('#bgd_gnrl_sitio ').animate({opacity: 10},(bgdTime));        
        if(type == bglimit){type = 1;}else{ type++; }
    }, bgdTime);


    type    = 2;
    bgdTime = 10090;
    bglimit = 6;
    setInterval (function () {
        $('#cbtndr_img_leyenda ').animate({
             opacity: 0.1
        },
        (bgdTime/10),'linear',
        function(){
            $("#cbtndr_img_leyenda ").html('<img src="media/images/frases/'+ type +'-01.png" width="500" alt=" " />');
            }
        );

        $('#cbtndr_img_leyenda ').animate({opacity: 10},(bgdTime));
        if(type == bglimit){type = 1;}else{ type++; }
    }, bgdTime);
   
    /*-widgets :: noticias-*/
    $("#crrl_noticias").cycle({
        fx:     'fade',
        speed:   1000,
        timeout: 6400,
        pause:   1
    });   
    /*-widgets :: productos-*/
    $("#crrl_productos").cycle({
        fx:     'fade',
        speed:   1000,
        timeout: 8400,
        pause:   1
    });
     /*-widgets :: proyectos-*/
    $("#crrl_proyectos").cycle({
        fx:     'fade',
        speed:   1000,
        timeout: 10400,
        pause:   1
    });
     /*-widgets :: aliados-*/
    $("#crrl_aliados").cycle({
        fx:     'fade',
        speed:   1000,
        timeout: 12400,
        pause:   1
    });
    /*-redes sociales roll over-*/
    $("#cntndr_gnrl_lgs_rds img").mouseenter(function() {
    	var myStr = ($(this).attr("src")).replace(".png", "");
    	$(this).attr("src", myStr+"_color.png");
    });
    $("#cntndr_gnrl_lgs_rds img").mouseleave(function() {
    	var myStr = ($(this).attr("src")).replace("_color", "");
    	$(this).attr("src", myStr);
    });
    /*-modalbox-*/
    $("#cntdr-opacity").click(function(){
        $("#opacity-conter").fadeOut('fast',function(){
            $("#cntdr-opacity").fadeOut();
            $("#opacity-conter").html('');
        })

    });
    /*-boton cierre-*/
    /*-buton: cierre-*/
    $("#btn-cierre").click(btnCierre);
})

function btnCierre(){
    $("#opacity-conter").fadeOut('fast',function(){
        $("#cntdr-opacity").fadeOut();
        $("#opacity-conter").html('');
    });
}

function validateForm(){
    $("#frmValidate").validate ({
        showErrors: function(errorMap, errorList) {
        this.defaultShowErrors();
    },
    debug: false,
    errorElement: "em",
    errorContainer: $("#display_errors"),
    success: function(label) {
        label.addClass("success");
    }
    });
}
