$(function() {
    var date = new Date();
    $("#year").text(date.getFullYear());

    $("#breadcrumb li:not(:last-child)").append("<span class='separator'>&#187;</a>");

  // $("#main, #main nav, #main article, #sidebar").equalHeight();





    //news landing page script
    if ($("#news").length >= 1) {
        var _iterator = $("#news-rotator-iterator li");

        _iterator.bind("mouseover", function() {
            $(this).addClass("news-rotator-on");
        }).bind("mouseout", function() {
            $(this).removeClass("news-rotator-on");
        }).bind("click", function() {
            var index = $(this).index();
            _iterator.removeClass("news-rotator-selected");
            $(".news-item").hide();
            $(".news-item:eq(" + index + ")").fadeIn("slow");
            $(this).addClass("news-rotator-selected");
        });

        var _socialTabs = $("#social-networks .tabs");
        _socialTabs.find("li img")
				.bind("click", function() {
				    $("#tab-facebook, #tab-twitter").hide();
				    $(this).parent().parent().find("li").removeClass("tab-selected");
				    var tab = $(this).parent().addClass("tab-selected").end().data("tab");
				    $("#" + tab).show();
				});
    }

    if ($("#home").length >= 1) {
        yepnope({
            load: '/js/plugins/jquery.cycle.all.min.js',
            complete: function() {
                //intro animation
                var baseT = 3500;
                $("#intro img").fadeOut(baseT + 1000, function() {
                    $(this).attr("src", "/images/intro_cleaner.jpg").fadeIn(100);
                });
                $("#intro h1").animate({
                    left: '-1745px'
                }, baseT, function() {
                    $(this).fadeOut(750);
                    $("#intro").fadeOut(baseT, function() {
                        $("#home .stories").show();
                    });
                });

                //featured stories
                $("#home .stories").cycle({
                    fx: 'scrollHorz',
                    prev: '#prev',
                    next: '#next',
                    timeout: baseT + 7000,
                    before: function(curr, next, opts, fwd) {
                        $("#total-slides").text(opts.slideCount);
                        $("#slide-num").text($(next).index() + 1);
                    }
                });


              


            }
        })
    }
    if ($("a.video").length >= 1) {
        yepnope({
            load: '/js/plugins/jquery.objectOverlay.js',
            complete: function() {
                $('a.video').objectOverlay();
            }
        });
    }



    if ($("#devproj")) {
        yepnope({
            load: '/js/plugins/jquery.cycle.all.min.js',
            complete: function() {

                //featured UK Dev Projects
                $("#devproj").cycle({
                fx: 'scrollLeft',
                speed: 2000,
                timeout: 4000,
                pause: 1
               
                    
                   

                });
              
            }
            
        });
    }





    //if the placeholder attribute is not supported in an older browser 
    //load a polyfill using yepnope & modernizr to handle
    //polyfill: defaultBlur jQuery Plugin
    yepnope({
        test: Modernizr.input.placeholder,
        nope: ['/js/plugins/jquery.defaultBlur-1.1.min.js'],
        callback: function(url, result, key) {
            if (!result) {
                $("#search").defaultBlur({ defaultText: "Search" });
            }
        }
    });
});
