$(document).ready(function() {
    /* homepage slider parameters */
    if($('.home-slider').size() > 0){
        $('.home-slider').after('<div id="nav">').cycle({
            fx: 'fade',
            speed: 500,
            timeout: 5000,
            pager: '#nav'
        });
    }

    /* entire block clickable for latest news */
    $(".ln-list li").click(function() {
        window.location = $(this).find("a").attr("href");
        return false;
    });

    $(".ln-list li").mouseover(function() {
        $(this).addClass('ln-active');
        $(this).find("a").attr("class", "ln-link");

    }).mouseout(function() {
        $(this).removeClass('ln-active');
        $(this).find("a").attr("class", "");
    });

    /* entire block clickable for header contact box(present in all interior pages) */
    $(".header-contact").click(function() {
        window.location = $(this).find("a").attr("href");
        return false;
    });
    //Triggers for the slidingPanels on the innerPage
    $(".strigger-1").click(function() {
        $(".spanel-1").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });

    $(".strigger-2").click(function() {
        $(".spanel-2").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
    $(".strigger-3").click(function() {
        $(".spanel-3").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });

    $(".strigger-4").click(function() {
        $(".spanel-4").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
    $(".strigger-5").click(function() {
        $(".spanel-5").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });

    $(".strigger-6").click(function() {
        $(".spanel-6").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
    $(".strigger-7").click(function() {
        $(".spanel-7").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });

    //Move headers on sidebar content
    $("div.block div.pad").each(function() {
        $(this).find("h3:first").each(function(){
            $(this).insertBefore($(this).closest("div.block"));
        });
    });

    //Add Bottom Images to Sidebar Modules
    //$("div.block div.pad").parent().append($(innerShiv('<div class="padBottom">&nbsp;</div>', false)));
    //$('<div class="padBottom"/>').insertAfter($("div.block div.pad"));
    //$('<h3>Quick Navigation</h3>').insertBefore("#foxboro_sub-menu");

    if ($("#headerTagline").size() > 0) {
        //this is an inner page
        var topBarHeight = $("#foxboro_top").height();
        $("#foxboro_content").css("background-position","0px " + topBarHeight + "px !important");
    }
});


// http://jdbartlett.github.com/innershiv
window.innerShiv=(function(){var d,r;return function(h,u){if(!d){d=document.createElement('div');r=document.createDocumentFragment();/*@cc_on d.style.display = 'none'@*/}var e=d.cloneNode(true);/*@cc_on document.body.appendChild(e);@*/e.innerHTML=h;/*@cc_on document.body.removeChild(e);@*/if(u===false)return e.childNodes;var f=r.cloneNode(true),i=e.childNodes.length;while(i--)f.appendChild(e.firstChild);return f}}());
