function sendForm() {
    $(".pp_inline > #sendingForm").fadeIn();
    $.post("sendForm.php", {
        name: $(".pp_inline > #formName").val(),
        email: $(".pp_inline > #formEmail").val(),
        message: $(".pp_inline > #contactMessage").val()
    }, function () {
        $(".pp_inline > #sendingForm").fadeOut();
        $.prettyPhoto.close()
    })
}
$(function () {
    $('<img/>').attr('src', 'img/dawn.png').load(function () {
        $('body').css({
            backgroundColor: '#009cc0'
        });
        $('#mtns').css({
            opacity: 1.0
        });
    });

    function f() {
        var a = -320 * b + "px";
        $("#webScroller").animate({
            marginTop: a
        }, 750, "easeInOutExpo");
        b == 0 ? $("#arrowUp").fadeOut() : $("#arrowUp").fadeIn();
        b == 2 ? $("#arrowDown").fadeOut() : $("#arrowDown").fadeIn()
    }
    $(".building").children().each(function () {
        Math.floor(Math.random() * 5) == 1 && $(this).css({
            opacity: 0.7
        })
    });
    var g = !0;
    if (navigator.userAgent.indexOf("iPhone") != -1 || navigator.userAgent.indexOf("iPad") != -1 || navigator.userAgent.indexOf("Blackberry") != -1 || navigator.userAgent.indexOf("Android") != -1) g = !1;
    var c = !1,
        b = 0;
    $("#musicPlayer").ttwMusicPlayer([{
        mp3: "audio/demo.mp3",
        oga: "audio/demo.ogg",
        title: "Jingle Demo",
        artist: "Bell Creative Studio",
        rating: 5,
        buy: "#",
        price: "0.99",
        duration: "6:26",
        cover: "audio/clef.jpg"
    }, {
        mp3: "audio/orchmix.mp3",
        oga: "audio/orchmix.ogg",
        title: "Orchestral demo",
        artist: "Bell Creative Studio",
        rating: 5,
        buy: "#",
        price: "0.99",
        duration: "10:20",
        cover: "audio/clef.jpg"
    }], {
        autoPlay: !1,
        description: ""
    });
    document.createElement("canvas").getContext ? ($("#rope").show(), $("#altRope").hide()) : ($("#rope").hide(), $("#altRope").show());
    $("a[class*='prettyPhoto']").prettyPhoto();
    $("#arrowUp").mouseover(function () {
        $(this).stop().animate({
            opacity: 1
        })
    }).mouseout(function () {
        $(this).stop().animate({
            opacity: 0.5
        })
    }).mouseup(function () {
        b > 0 && b--;
        f(b)
    });
    $(".building").children().mouseover(function () {
        $(this).css("opacity") > 0.5 && $(this).stop().animate({
            opacity: 1
        }, 200)
    }).mouseout(function () {
        $(this).css("opacity") > 0.5 && $(this).stop().animate({
            opacity: 0.7
        }, 200)
    }).mouseup(function () {
        $(this).css("opacity") > 0.5 ? $(this).stop().animate({
            opacity: 0
        }, 200) : $(this).stop().animate({
            opacity: 0.7
        }, 200)
    });
    $("#arrowDown").mouseover(function () {
        $(this).stop().animate({
            opacity: 1
        })
    }).mouseout(function () {
        $(this).stop().animate({
            opacity: 0.5
        })
    }).mouseup(function () {
        b < 2 && b++;
        f(b)
    });
    $("#bulb").mouseover(function () {
        $(this).stop().animate({
            opacity: 1
        })
    }).mouseout(function () {
        $(this).stop().animate({
            opacity: 0.75
        })
    }).mouseup(function () {
        $.prettyPhoto.open("http://vimeo.com/28794668", "Vegas Inception")
    });
    $("#play").mouseover(function () {
        $(this).stop().animate({
            opacity: 1
        })
    }).mouseout(function () {
        $(this).stop().animate({
            opacity: 0.75
        })
    }).mouseup(function () {
        c ? (c = !1, $("#musicPlayer").fadeOut(500)) : (c = !0, $("#musicPlayer").fadeIn(500))
    });
    var a = 0,
        d = !1;
    $("#birdHitspot").mouseup(function () {
        d ? ($("#tweets").animate({
            opacity: 0
        }, function () {
            $("#tweets").hide()
        }), d = !1) : ($("#tweets").show().animate({
            opacity: 0.7
        }), d = !0)
    });
    $(".home").mouseup(function () {
        $.smoothScroll({
            scrollTarget: "document"
        })
    });
    $(".about").mouseup(function () {
        $.smoothScroll({
            scrollTarget: "#skyText"
        })
    });
    $(".design").mouseup(function () {
        $.smoothScroll({
            scrollTarget: "#oceanText"
        })
    });
    $(".production").mouseup(function () {
        $.smoothScroll({
            scrollTarget: "#musicText"
        })
    });
    $(".marketing").mouseup(function () {
        $.smoothScroll({
            scrollTarget: "#bottomText"
        })
    });
    var e = !1;
    g && $(document).scroll(function () {
        a = $(document).scrollTop() * 0.25;
        e ? a <= 37 && ($("#bird").css({
            backgroundPosition: "0 0"
        }), e = !1) : a > 37 && ($("#bird").css({
            backgroundPosition: "0 -232px"
        }), e = !0);
        $("#bird").css({
            marginLeft: -127 + a * 2
        });
        a < 150 && $("#birdHitspot").css({
            marginLeft: -127 + a * 2
        });
        $("#nightCloud").css({
            backgroundPosition: "0 " + (100 + Math.floor(-1 * a)) + "px"
        });
        $("#cloudTops").css({
            backgroundPosition: "0 " + (100 + Math.floor(a * -1.3)) + "px"
        });
        $("#cityWrapper").css({
            marginTop: a * -1.5
        });
        $("#mtns").css({
            backgroundPosition: "0 " + (200 + Math.floor(a * -1.9)) + "px"
        });
        $("#quoteText").css({
            marginTop: 690 - a * 2
        });
        var b = a / 200;
        b > 1 && (b = 1);
        $("#quoteText").css({
            opacity: b
        });
        $("#cloud5").css({
            backgroundPosition: "0 " + (100 + Math.floor(a * -0.5)) + "px"
        });
        $("#cloud6").css({
            backgroundPosition: "0 " + (500 + Math.floor(a * -0.75)) + "px"
        });
        $("#fish1").css({
            marginRight: -850 + a * 2.2
        });
        $("#fish2").css({
            marginRight: -500 + Math.floor(a * 1.4)
        });
        $("#fish3").css({
            marginRight: -650 + Math.floor(a * 1.2)
        });
        $("#diver").css({
            backgroundPosition: "0 " + (1400 + Math.floor(a * -2)) + "px"
        });
        $("#diverBubblesA").css({
            backgroundPosition: "0 " + (1640 + Math.floor(a * -2.1)) + "px"
        });
        $("#diverBubblesB").css({
            backgroundPosition: "0 " + (1750 + Math.floor(a * -2.3)) + "px"
        });
        $("#notesA").css({
            backgroundPosition: "0 " + (568 + Math.floor(a * -0.52)) + "px"
        });
        $("#notesB").css({
            backgroundPosition: "0 " + (950 + Math.floor(-1 * a)) + "px"
        })
    });
    $("#tweets").corner("10px");
    $(".ttw-music-player").corner("10px");
    $(".rounded").corner("10px");
    (function (a, b) {
        url = "http://api.twitter.com/1/statuses/user_timeline/" + a + ".json?callback=?";
        $.getJSON(url, function (a) {
            for (var c = 0; c < b; c++) $("#tweets").append("<p>" + a[c].text + "</p>").linkify()
        })
    })("rtbz", 5);
    init()
});
