function slideHome() {
    $("#foo2").carouFredSel({
        auto: false,
        items: 1,
        scroll: {
            pauseOnHover: true
        },
        prev: "#prev2",
        next: "#next2",
        pagination: "#pager2"
    });
}


$('#foo2 li').click(function () {
    var elThis = $(this), elImg = elThis.find('img');

    if ($(this).find('object').length) {
        elImg.hide();
    } else {

    }

    var idObject = $(this).find('object').attr('id');

    $('#pager2').find('a').click(function () {

        document.getElementById(idObject).pauseVideoYoutube();

        elImg.show();
    });
});
function imagemDeFundo() {
    $(".bgFundo").show(100)
}

function resizeBgImage() {
	imagemDeFundo();
    var b = $(".blocoMenuTop").offset();
    var a = parseInt(b.left) + 695;
    $(".bgFundo img").css("width", a);
	
    $(window).resize(function () {
        var d = $(".blocoMenuTop").offset();
        var c = parseInt(d.left) + 695;
        $(".bgFundo img").css("width", c)
    })
}

function animaBlocosHome() {

    window.setTimeout(function () {
        $(".bgFundo").show(100);
        $(".homePos1").show("slide", {
            direction: "left"
        }, 300, function () {
            $(".homePos2").show("slide", {
                direction: "left"
            }, 300, function () {
                $(".homePos3").show("slide", {
                    direction: "left"
                }, 300, function () {
                    $(".homePos4").show("slide", {
                        direction: "left"
                    }, 300, function () {
                        $(".homePos5").show("slide", {
                            direction: "left"
                        }, 300, function () {
                        })
                    })
                })
            })
        })
    }, 800);
    $(".homeBloco1 a").each(function () {
        $(this).find("img").hover(function () {
            $(".homeBloco1").find("img").stop().animate({
                opacity: 0.7
            }, 200);
            $(this).stop().animate({
                opacity: 1
            }, 1)
        }, function () {
            $(this).stop().animate({
                opacity: 1
            }, 1);
            $(".homeBloco1").find("img").stop().animate({
                opacity: 1
            }, 1)
        });
        $(".homeBloco1 ").hover(function () {
            $(this).find(".blocoOff").animate({
                marginTop: -89
            }, 100);
            $(".homeBloco1 ").hover.stop()
        }, function () {
            $(this).find(".blocoOff").animate({
                marginTop: 0
            }, 100);
            $(".homeBloco1 ").hover.stop()
        })
    })
}

function SubMenu() {
    $(".menu_list p").each(function (a) {
        a = a + 1;
        $(this).click(function () {
            if ($("#categoria_0" + a).hasClass("selectItem")) {
                $(this).next("div.menu_body").slideUp("slow");
                $(this).removeClass("selectItem")
            } else {
                $("div.menu_body").slideUp("slow");
                $(".menu_head").removeClass("selectItem");
                $(this).next("div.menu_body").slideDown("slow");
                $(this).addClass("selectItem")
            }
        })
    });
    $(".menu_body a").each(function (a) {
        a = a + 1;
        $(this).click(function () {
            if ($(this).hasClass("selected")) {
                $(this).next(".Submenu_body").slideUp("slow");
                $(this).removeClass("selected")
            } else {
                $(".Submenu_body").slideUp("slow");
                $(".menu_body a").removeClass("selected");
                $(this).next(".Submenu_body").slideDown("slow");
                $(this).addClass("selected")
            }
        })
    })
}

function resizeBlocoPortefolio() {
	

window.setTimeout(function () {	
    var c = $(window).width();
    var b = $(".blocoCentralFolio, .blocoCentralServicos, .blocoCentralNoticias,  .blocoCentralEmpresa").offset();
    var d = parseInt(b.left);
    var a = c - d;
    $(".blocoCentralFolio").css("width", a);
    $(".blocoCentralServicos").css("width", a);
    $(".blocoCentralNoticias").css("width", a);
   // $(".blocoCentralClientes").css("width", a);
    $(".blocoCentralEmpresa").css("width", a);
	animaBlocosFolio()

	}, 600);
	
    window.setTimeout(function () {		
		var alturaContainer = $('#container').height();
	    $('#container').css('height' , alturaContainer + 250 );
		
			
	}, 1800);	
	
    $(window).resize(function () {
        var g = $(window).width();
        var f = $(".blocoCentralFolio, .blocoCentralServicos, .blocoCentralNoticias,  .blocoCentralEmpresa").offset();
        var h = parseInt(f.left);
        var e = g - h;
        $(".blocoCentralFolio").css("width", e);
        $(".blocoCentralServicos").css("width", e);
        $(".blocoCentralNoticias").css("width", e);
        //$(".blocoCentralClientes").css("width", e);
        $(".blocoCentralEmpresa").css("width", e);
        animaBlocosFolio()
			    window.setTimeout(function () {		
		var alturaContainer = $('#container').height();
	
	$('#container').css('height' , alturaContainer + 250 );
	}, 1300);	
    })
	

}

function animaBlocosFolio() {
    $(".homeBloco1").each(function () {
        var a = $(this).find("img").width();
        $(this).css("width", a)
    });
    window.setTimeout(function () {
        var a = $("#container");
        a.find(".element").each(function () {
            if (Math.random() > 0.6) {
                $(this).addClass("width2")
            }
            if (Math.random() > 0.6) {
                $(this).addClass("height2")
            }
        });
        a.isotope({
            itemSelector: ".element",
            masonry: {
                columnWidth: 215
            },
            masonryHorizontal: {
                rowHeight: 235
            },
            cellsByRow: {
                columnWidth: 430,
                rowHeight: 235
            },
            cellsByColumn: {
                columnWidth: 430,
                rowHeight: 235
            }
        })
    }, 400);
    $(".bgFundo").show(100);
    $(".homeBloco1 a").each(function () {
        $(this).find("img").hover(function () {
            $(".homeBloco1").find("img").stop().animate({
                opacity: 0.7
            }, 200);
            $(this).stop().animate({
                opacity: 1
            }, 1)
        }, function () {
            $(this).stop().animate({
                opacity: 1
            }, 100);
            $(".homeBloco1").find("img").stop().animate({
                opacity: 1
            }, 1)
        })
    });
    $(".homeBloco1 ").hover(function () {
        $(this).find(".blocoOff").animate({
            marginTop: -89
        }, 100);
        $(".homeBloco1 ").hover.stop()
    }, function () {
        $(this).find(".blocoOff").animate({
            marginTop: 0
        }, 100);
        $(".homeBloco1 ").hover.stop()
    })
}

function carroselFotos() {
   
    var imagesLoad = $(".image_carousel").find("img").length - 1;

    $(".image_carousel").find("img").each(function () {

        $(this).bind('load', function () {

            if (imagesLoad == 0) {

                if ($("#foo1").parent().hasClass("caroufredsel_wrapper") == false) {

                    $("#foo1").carouFredSel({
                        items: {
                            visible: 5,
                            minimum: 1
                        },
                        scroll: {
                            items: 1

                        },
                        direction: "up",
                        auto: false,
                        prev: {
                            button: "#foo2_prev",
                            key: "left"
                        },
                        next: {
                            button: "#foo2_next",
                            key: "right"
                        }
                    });

                    $("#foo1 a").fancybox({
                        autoDimensions: true,
                        cyclic: true,
                        onStart: function () {
                            $("#foo1").trigger("pause")
                        },
                        onClosed: function () {
                            $("#foo1").trigger("play")
                        }
                    });
                }
            }
            else
                imagesLoad--;
        });
    });
	
window.setTimeout(function () {		
	var alturaPortefolio = $('.image_carousel').height();
		 $('.main').css('height' , alturaPortefolio + 280 );
		 $('.copyright').removeClass('copyright').addClass('copyrightTrabalhos');
			 
	}, 1500);
	
}

function slideVideos() {
    var a = $(".homeBloco1");
    a.css({
        display: "block",
        left: "-900px",
        position: "relative"
    });
    var b = 100;
    a.each(function (d) {
        $(this).css("z-index", b - d)
    });
    var c = a.length;
    window.setTimeout(function () {
        a.each(function (d) {
            $(this).stop().delay(1000 * d).animate({
                left: 0
            }, {
                duration: 1000,
                complete: function () {
                    if (--c == 0) {
                    }
                }
            })
        })
    }, 100)

    $('.blocoPlayer').click(function () {
        $('.playerVideo').hide();

    });
}

function animaBlocosServicos() {

    $(".homeBloco1").each(function () {
        var a = $(this).find("img").width();
        $(this).css("width", a)
    });
    window.setTimeout(function () {
        var b = $("#container");
        b.find(".element").each(function () {
            if (Math.random() > 0.6) {
                $(this).addClass("width2")
            }
            if (Math.random() > 0.6) {
                $(this).addClass("height2")
            }
        });
        b.isotope({
            itemSelector: ".element",
            masonry: {
                columnWidth: 215
            },
            masonryHorizontal: {
                rowHeight: 235
            },
            cellsByRow: {
                columnWidth: 430,
                rowHeight: 235
            },
            cellsByColumn: {
                columnWidth: 430,
                rowHeight: 235
            }
        });
        b.isotope({
            itemSelector: ".element"
        });
        var a = $("#options .option-set"), c = a.find("a");
        c.click(function () {
            var h = $(this);
            if (h.hasClass("selected")) {
                return false
            }
            var f = h.parents(".option-set");
            f.find(".selected").removeClass("selected");
            h.addClass("selected");
            var d = {}, e = f.attr("data-option-key"), g = h.attr("data-option-value");
            g = g === "false" ? false : g;
            d[e] = g;
            if (e === "layoutMode" && typeof changeLayoutMode === "function") {
                changeLayoutMode(h, d)
            } else {
                b.isotope(d)
            }
            return false
        })
    }, 500);
    $(".bgFundo").show(100);
    $(".homeBloco1 a").each(function () {
        $(this).find("img").hover(function () {
            $(".homeBloco1").find("img").stop().animate({
                opacity: 0.7
            }, 200);
            $(this).stop().animate({
                opacity: 1
            }, 1)
        }, function () {
            $(this).stop().animate({
                opacity: 1
            }, 100);
            $(".homeBloco1").find("img").stop().animate({
                opacity: 1
            }, 1)
        })
    });
    $(".homeBloco1 ").hover(function () {
        $(this).find(".blocoOff").animate({
            marginTop: -89
        }, 100);
        $(".homeBloco1 ").hover.stop()
    }, function () {
        $(this).find(".blocoOff").animate({
            marginTop: 0
        }, 100);
        $(".homeBloco1 ").hover.stop()
    })
}

function animaBlocosNoticias() {
    $(".homeBloco1").each(function () {
        var a = $(this).find("img").width();
        $(this).css("width", a)
    });
    window.setTimeout(function () {
        var a = $("#container");
        a.find(".element").each(function () {
            if (Math.random() > 0.6) {
                $(this).addClass("width2")
            }
            if (Math.random() > 0.6) {
                $(this).addClass("height2")
            }
        });
        a.isotope({
            itemSelector: ".element",
            masonry: {
                columnWidth: 215
            },
            masonryHorizontal: {
                rowHeight: 235
            },
            cellsByRow: {
                columnWidth: 430,
                rowHeight: 235
            },
            cellsByColumn: {
                columnWidth: 430,
                rowHeight: 235
            }
        })
    }, 400);
    $(".bgFundo").show(100);
    $(".homeBloco1").each(function () {
        $(this).find("img").hover(function () {
            $(".homeBloco1").find("img").stop().animate({
                opacity: 0.7
            }, 200);
            $(this).stop().animate({
                opacity: 1
            }, 1)
        }, function () {
            $(this).stop().animate({
                opacity: 1
            }, 100);
            $(".homeBloco1").find("img").stop().animate({
                opacity: 1
            }, 1)
        })
    })
}

function animaBlocosClientes() {

    window.setTimeout(function () {
        var a = $("#container");
        a.find(".element").each(function () {
            if (Math.random() > 0.6) {
                $(this).addClass("width2")
            }
            if (Math.random() > 0.6) {
                $(this).addClass("height2")
            }
        });
        a.isotope({
            itemSelector: ".element",
            masonry: {
                columnWidth: 143
            },
            masonryHorizontal: {
                rowHeight: 120
            },
            cellsByRow: {
                columnWidth: 430,
                rowHeight: 120
            },
            cellsByColumn: {
                columnWidth: 143,
                rowHeight: 120
            }
        })
    }, 300);
    $(".bgFundo").show(100);
    $(".homeBloco1 ").hover(function () {
        $(this).find("img").animate({
            marginTop: -120
        }, 1);
        $(".homeBloco1 ").hover.stop()
    }, function () {
        $(this).find("img").animate({
            marginTop: 0
        }, 1);
        $(".homeBloco1 ").hover.stop()
    })
}

function animaBlocosEmpresa() {
    $(".homeBloco1").each(function () {
        var a = $(this).find("img").width();
        $(this).css("width", a)
    });
    window.setTimeout(function () {
        var a = $("#container");
        a.find(".element").each(function () {
            if (Math.random() > 0.6) {
                $(this).addClass("width2")
            }
            if (Math.random() > 0.6) {
                $(this).addClass("height2")
            }
        });
        a.isotope({
            itemSelector: ".element",
            masonry: {
                columnWidth: 215
            },
            masonryHorizontal: {
                rowHeight: 235
            },
            cellsByRow: {
                columnWidth: 430,
                rowHeight: 235
            },
            cellsByColumn: {
                columnWidth: 430,
                rowHeight: 235
            }
        })
    }, 300);
    $(".bgFundo").show(100);
    $(".homeBloco1").each(function () {
        $(this).find("img").hover(function () {
            $(".homeBloco1").find("img").stop().animate({
                opacity: 0.7
            }, 200);
            $(this).stop().animate({
                opacity: 1
            }, 1)
        }, function () {
            $(this).stop().animate({
                opacity: 1
            }, 100);
            $(".homeBloco1").find("img").stop().animate({
                opacity: 1
            }, 1)
        })
    });
    $(".homeBloco1 ").hover(function () {
        $(this).find(".blocoOff").animate({
            marginTop: -89
        }, 100);
        $(".homeBloco1 ").hover.stop()
    }, function () {
        $(this).find(".blocoOff").animate({
            marginTop: 0
        }, 100);
        $(".homeBloco1 ").hover.stop()
    })
}
