$(document).ready(function() {
    $("li:last-child").addClass("last");
    $("li:first-child").addClass("first");
    
    var ActiveLength = $("#side li.active ul .active").size();
    if (ActiveLength == 0)
    {
       $("#side li.active ul .first").addClass("active");
    }
    
    $("#small").click(function() {
        $(".article p").css("font-size", ".8em");
        return false;
    });
    
    $("#medium").click(function() {
        $(".article p").css("font-size", "1em");
        return false;
    });
    
    $("#large").click(function() {
        $(".article p").css("font-size", "1.3em");
        return false;
    });
    
    $("#more_icons").click(function() {
        $("#hidden_popup").addClass("show_popup");
    });
    
    $('#hidden_popup').click(function(e)
	{
		e.stopPropagation();
	});
    
     $('body').click(function(event) {
        if(event.target.className != "more") {
           event.stopPropagation();
           $('#hidden_popup').removeClass("show_popup");
           $('#show_all').removeClass("show_popup");
           $('#more_link').removeClass("hide_link");
        }
    });
    
    $('#close_button').click(function() {
        $('#hidden_popup').removeClass("show_popup");
        $('#show_all').removeClass("show_popup");
        $('#more_link').removeClass("hide_link");
    });
    
    $('#more_link').click(function() {
       $('#show_all').addClass("show_popup");
       $('#more_link').addClass("hide_link");
       return false;
    });
    
    $("#side li.active:first-child").addClass("active-first");

    //$("#side li.active").append('<div class="arrow"><img src="/images/links/reader_nav_arrow.gif" alt="" /></div>');

    $("#browse_toggle").click(function(){
        $(".browse_sections").toggleClass("browse_sections_active");
        return false;
    });

	$filename = new RegExp("^(.*?)\.(gif|jpg|png)", "i");
	$filename_hover = new RegExp("^(.*?)_hover\.(gif|jpg|png)", "i");
	jQuery('input[type="image"].hover').hover(function(){
		$m = $filename.exec(jQuery(this).attr('src'));
		jQuery(this).attr('src', $m[1] + "_hover." + $m[2]);
	}, function(){
		$m = $filename_hover.exec(jQuery(this).attr('src'));
		jQuery(this).attr('src', $m[1] + "." + $m[2]);		
	});

	// Killing blue triangle for IE6
	if(($("#toc").length > 0) && ($.browser.msie && parseInt($.browser.version) == 6))
		$("#side li.active div.arrow").css("display", "none");
//	if($("#toc").length > 0) {
//		$("p.back").attr("style", "position: absolute; bottom: 2px; border-bottom: none; margin-bottom: 0px; border-top: 1px solid #E0E0E0; width: 208px; padding-top: 8px; padding-bottom: 7px;");
//		$("#side").css("padding-bottom", "80px");
//	}







//	var divHeight = $("div.report-reader-printhead-content").height();
//	$("div.report-reader-printhead-content .image").css("padding-top",(divHeight/2)-16 + "px");



});






