﻿(function ($) {
    var $topNav = $(".top-nav ul li a");
    if ($topNav.length) {
        $topNav.hover(function (e) {
            $(this).animate({ backgroundColor: $.Color("rgba(255,255,255,0.5)"), "color": "#0b4770" });
        },
        function (e) {
            $(this).animate({ backgroundColor: $.Color("rgba(255,255,255,0.3)"), color: "#FFFFFF" });
        });
    }

    if ($("#map").length) {
        //create gmap
        var westpoint = new google.maps.LatLng(50.71218, -3.43916);

        var myOptions = {
            zoom: 8,
            center: westpoint,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            streetViewControl: true,
            mapTypeControl: false,
            scrollwheel: false
        };
        var map = new google.maps.Map(document.getElementById("map"), myOptions);
        var westpoint_marker = new google.maps.Marker({
            position: westpoint,
            map: map,
            title: "Westpoint",
            flat: false
        });
    }

    var $hero = $("#hero .panels");
    function paginate(ind, el) {
        return "<li><a href='#'></a><span>" + $hero.children(":eq(" + ind + ")").attr("data-navtext") + "</span></li>";
    }

    if ($hero.length) {
        $hero.cycle({ fx: "scrollLeft", delay: -1000, timeout: 8000, pager: "#dots", prev: "#left", next: "#right", pagerAnchorBuilder: paginate, activePagerClass: "on", manualTrump: false, pause: true, pauseOnPagerHover: true });
    }

    var $share = $(".share");
    if ($share.length) {
        $share.click(function (e) {
            e.preventDefault();
            var name = $(this).parent().parent().parent().find("h3 a").text();
            var url = ($(this).hasClass("tweet")
            ? "http://twitter.com/home?status=Check out this talk from " + name + " " + encodeURIComponent(window.location.href)
            : "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(window.location.href));
            window.open(url, 'Share', 'height=400,width=600');
        });
    }

})(jQuery);
