$(document).ready(on_ready);
function on_ready() {

 	$('#faqs').load('/cont/one/frequently/fthe13th.html');
 
	$('#faqs').ajaxStop(function() {
		//only show first two Q/As
		$('#faqs:eq(0)> p:gt(1)').hide();

		//add subheading identifying content
		$('<h4>from <a href="/frequently/">frequently</a>, where we answer Qs</h4>').insertAfter("#faqs>h3");
		//wrap subheading in containing div
		$('#faqs>h4').wrap("<div></div>");


		//add show or hide feature, set intial value
		$('<a class="tog">More answers</a>').insertAfter("#faqs>div>h4");
		//toggle between
		$("a.tog").click(function(){
			$('#faqs:eq(0)> p:gt(1)').slideToggle('fast');
			$(this).text($(this).text() == 'More answers' ? 'More questions' : 'More answers');
		});
	});
 
   
    enable_smooth_scroll();
	DD_belatedPNG.fix('.pngfx');
//	DD_belatedPNG.fix('#column2 #subscribe-amulet');

}



// http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links
// major changes by Paul Armstrong and Zachary Johnson
function enable_smooth_scroll() {
    function filterPath(string) {
        return string
                .replace(/^\//,'')
                .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
                .replace(/\/$/,'');
    }

    var locationPath = filterPath(location.pathname);

    var scrollElement = 'html, body';
    $('html, body').each(function () {
        var initScrollTop = $(this).attr('scrollTop');
        $(this).attr('scrollTop', initScrollTop + 1);
        if ($(this).attr('scrollTop') == initScrollTop + 1) {
            scrollElement = this.nodeName.toLowerCase();
            $(this).attr('scrollTop', initScrollTop);
            return false;
        }    
    });
    
    $('a[href*=#]').each(function() {
        var thisPath = filterPath(this.pathname) || locationPath;
        if  (   locationPath == thisPath
                && (location.hostname == this.hostname || !this.hostname)
                && this.hash.replace(/#/, '')
            ) {
                if ($(this.hash).length) {
                    $(this).click(function(event) {
                        var targetOffset = $(this.hash).offset().top;
                        var target = this.hash;
                        event.preventDefault();
                        $(scrollElement).animate({scrollTop: targetOffset}, 500, function() {
                            location.hash = target;
                        });
                    });
                }
        }
    });
}(jQuery);
