﻿function bloco_formularios() {
    
    $("#orcamentos").colorbox({
        iframe: true,
        href: "orcamento.html",
        width: 700,
        height: 1100
    });
    $("#contato").colorbox({
        iframe: true,
        href: "contato.html",
        width: 700,
        height: 700
    })
    
    
}
function flickr() {
    $("#menu-portfolio").html("");
    $.ajax({
        url: "http://api.flickr.com/services/rest/",
        data: {
            format: "json",
            method: "flickr.photosets.getList",
            api_key: "1ee648df982f58b198f3d1dd5fcbc9e8",
            user_id: "48224929@N05"
        },
        async: false,
        dataType: "jsonp",
        jsonp: "jsoncallback",
        success: function (a) {
            $.each(a.photosets.photoset, function (a, b) {
                categoria = b.title._content;
                qtd = b.photos;
                id = b.id;
                if (a < 4) {
                    $("#menu-portfolio").append('<li><h3><a target="_blank" href="http://www.flickr.com/photos/icomp/sets/' + id + '/detail/">' + categoria + ' <span class="over"></span></a></h3><span class="qtd">' + qtd + " peças</span></li>")
                }
            });
            $("#menu-portfolio li h3 a").mouseover(function () {
                $(this).children(".over").animate({
                    right: "0",
                    top: "0"
                }, 200, function () {
                    $(this).addClass("hover")
                })
            }).mouseleave(function () {
                $(this).children(".over").animate({
                    right: "-5",
                    top: "5"
                }, 200, function () {
                    $(this).removeClass("hover")
                })
            })
        }
    })
}
function bloco_rodape() {
    $("#telefones li:eq(1)").addClass("menor");
    $("#telefones li:eq(2)").addClass("menor");
    $("#telefones li:eq(4)").addClass("menor");
    $("#telefones li:eq(5)").addClass("menor");
    $("a#endereco").tooltip({
        effect: "slide",
        direction: "down",
        offset: [95, -10]
    });
    $(".mail").tooltip({
        effect: "slide",
        direction: "up",
        tipClass: "tooltip2",
        offset: [10, 0]
    });
    $(".fone").tooltip({
        effect: "slide",
        direction: "up",
        tipClass: "tooltip2",
        offset: [10, 0]
    })
}
function pauseOnHover(a) {
    a.clip.hover(function () {
        a.next()
    }, function () {
        a.next()
    })
}
function bloco_clientes() {
    $("#carousel_clientes").jcarousel({
        vertical: false,
        scroll: 1,
        wrap: "last",
        initCallback: pauseOnHover
    })
}
function bloco_facebook() {
    var a = "http://icomp.com.br/css/2011/facebook.css";
    $("#fb-likebox").html('<iframe frameborder="0" scrolling="no" style="border: none; width: 315px; height: 340px;" allowtransparency="true" src="http://www.facebook.com/connect/connect.php?id=392230634767&connections=15&css=' + encodeURIComponent(a) + '"></iframe>')
}
function bloco_video() {
    var videoID = 'xY0WxitWSiQ';
	var emmbed = '<object width="641" height="386"><param name="movie" value="http://www.youtube.com/v/'+videoID+'&hd=1&autoplay=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="opaque"></param><embed src="http://www.youtube.com/v/'+videoID+'&hd=1&autoplay=1&rel=0" type="application/x-shockwave-flash"width="641" height="386" allowscriptaccess="always" allowfullscreen="true"wmode="opaque"></embed></object>';
    $("#vt-campanha").html(emmbed)
}
function bloco_feeds() {}
function bloco_portfolio() {
    flickr()
}
function bloco_menu() {
    $("#menu li a").mouseover(function () {
        $(this).children(".over").animate({
            opacity: 1,
            top: "0"
        }, 100, function () {
            $(this).animate({
                top: "-5"
            }), 200
        })
    }).mouseleave(function () {
        $(this).children(".over").animate({
            opacity: 0
        }, 400)
    })
}
function bloco_animado() {
    irEsquerdaF2();
    irEsquerdaF1()
}
function irDireitaF2() {
    $("#faixa2").animate({
        width: "150%",
        left: "-50%"
    }, 3e3, "easeInOutQuad", irEsquerdaF2)
}
function irEsquerdaF2() {
    $("#faixa2").animate({
        width: "100%",
        left: "0%"
    }, 3e3, "easeInOutQuad", irDireitaF2)
}
function irDireitaF1() {
    $("#faixa1").animate({
        width: "100%",
        left: "0%"
    }, 4e3, "easeInOutQuart", irEsquerdaF1)
}
function irEsquerdaF1() {
    $("#faixa1").animate({
        width: "170%",
        left: "-70%"
    }, 4e3, "easeInOutQuart", irDireitaF1)
}
function chama_funcoes() {
    $('a[rel="external"]').attr("target", "_blank");
    $("#redes-sociais li:last-child").addClass("last-child");
    bloco_video();
    bloco_menu();
    bloco_portfolio();
    bloco_feeds();
    bloco_facebook();
    bloco_clientes();
    bloco_rodape();
    bloco_formularios()
}
$(document).ready(function () {
    chama_funcoes()
});
