$(document).ready(function() {

    // target="_blank" is invalid XHTML, so use rel="external" instead and assign an event to links with that attribute
    $("a[rel*='external']").click(function() {
        window.open($(this).attr('href'));
        return false;
    });

    //$("#topnav a").corner("keep top");    // 7/13/2011 - added border-radius rules to stylesheet, so moved this to IE fixes section below. upgraded plugin, too

    $("#sidenav li li a").prepend('<span class="arrow">›</span> ');
    $(".footer_highlights li").prepend('<span class="arrow">›</span> ');


    $("#searchtab").click(function() {
        $("#drawer").toggleClass("open");
        $(this).toggleClass("open");
    }, function() {
        $("#drawer").toggleClass("open");
        $(this).toggleClass("open");
    });


    if($("div#cmsbody").length == 0) {
        if($("div#slideshow img").length > 1) {
            $("div#slideshow").cycle({random: 1});
        }
        else {
            $("div#slideshow img").css("display", "block");
        }
    }

    $("#col3 div.homepage_box:nth-child(4n)").css("margin-right", "0");



    // IE6 fixes
    if(jQuery.browser.msie && parseInt(jQuery.browser.version) <= 6) {
        $("#header").pngFix({blankgif: "/img/blank.gif"});

        // pngFix needs CSS widths and heights for background images to work, so we copy them from the rendered dimensions
        /*$("body.homepage #sidebox a").each(function() {
            $(this).css("width", $(this).width());
            $(this).css("height", $(this).height());
        });*/
        //$("body.homepage #sidebox").pngFix({blankgif: "/img/blank.gif"}); // that doesn't work because it distorts the background image.
        //$("#drawer").pngFix({blankgif: "/img/blank.gif"});    // this was removed because it causes the tab to be unclickable because of the filter
        $("#footer .sitenav li:last-child").css("border", "none");
        $('ul#sidenav li').hover(function() {
            $(this).addClass('ie6_hovering');
        }, function() {
            $(this).removeClass('ie6_hovering');
        });
        $("q").prepend("“");
        $("q").append("”");
    }

    // IE6, IE7, IE8 fixes
    if(jQuery.browser.msie && parseInt(jQuery.browser.version) <= 8) {
        $("#topnav a").corner("keep top");
    }
});

