$(function () {
    // FLASH MAP ON HOMEPAGE
    if ($("body.home").length>0) {
        $("#map").flash({
            src: '/i/flash/map.swf',
            width: 670,
            height: 470,
            quality: 'high'
        },{
            version: 8
        })
    } else if ($(".everything h1").length>0) {
    } else if ($(".action").length>0) {
    } else {
        var headheight = $("#header").height();
    
        // SIFR
        $("h1").sifr({
         font: 'dinlight',
         width: 710,
         path: '/c/',
         color: '#ffffff'
        });
        $("h1 span").css("visibility","");
    //    $("h1").css("opacity","1");

        // RESIZE HEADER FOR 2-LINE HEALDINES
        // if ($("#header embed").height() > 80)
        //     $("#header").css("padding","0 0 30px 0").css("height","100px");

        $("#header").css({"height":(headheight)+'px'});
        if ($("#header embed").height() > 80)
            $("#header embed").css("top","-4px");

        // REPLACE CSS SYMBOLS WITH IMAGES, FOR PRINTING
        $(".Y").html('<img src="/i/card/check_sm.jpg" width="16" height="16" alt="Yes" />');
        $(".N").html('<img src="/i/card/x_sm.jpg" width="16" height="16" alt="No" />');
        $(".z").html('<img src="/i/card/novote.gif" width="10" height="10" alt="No vote" />');
    }

    // POSITION FOOTER
    if ($("#content").height() > $("#superwrap").height()) {
        var diff = $("#content").height() + parseInt($("#content").css("padding-top")) + parseInt($("#content").css("padding-bottom")) - $("#superwrap").height() + - 22;
        $("#footer").css("margin-top",diff+"px");
    }
    $("#footer").addClass("shown");

    // NAV BAR
	$(".everything #everything + li, .person #byperson + li, .state #bystate + li, .bill #bybill + li").css("background-position","-43px 0").css("width","170px");
	$(".everything #everything + li a, .person #byperson + li a, .state #bystate + li a, .bill #bybill + li a").css("margin-left","0");

    // BILL PAGE
	$(".nay").each(function () {
	    if ($(this).height()>25)
	        $(this).children("i").css({'position':'absolute','bottom':5,'right':$(this).width()+4});
	});
	
	$("#toggleFNs").click(function() {
	    $("#footnotes").toggle('fast');
	    return false;
	});
	
	// ACTIVATE QUICK-JUMP DROP-DOWNS
	$("select#mcjump").change(function() {
	    var slct = $(this)[0];
	    document.location.href = "/member/"+slct.options[slct.selectedIndex].value;
	});
	
	$("select#statejump").change(function() {
	    var slct = $(this)[0];
	    document.location.href = "/state/"+slct.options[slct.selectedIndex].value;
	});
	
	$("select#billjump").change(function() {
	    var slct = $(this)[0];
	    document.location.href = "/bill/"+slct.options[slct.selectedIndex].value;
	});
});


function setHovers (table) {
    $("tr:has(td.gr)").hover(function(){
        $(this).addClass("hover");
    },function(){
        $(this).removeClass("hover");
    })
}