var $j = jQuery.noConflict();



$j(function() {

    // VERTICALLY ALIGN FUNCTION

    $j.fn.vAlign = function() {

        return this.each(function(i){

            var ah = $j(this).height();

            var ph = $j(this).parent().height();

            var mh = Math.ceil((ph-ah) / 2);

            var newheight = (ah - mh);

            $j(this).css('padding-top', mh);

            $j(this).css('height', newheight);

        });

    };

});

$j(document).ready(function() {

    $j('.homeblocks h3').vAlign();
    
    $j('a.ext-link').click(function(event) {
        event.preventDefault()
        var url = $j(this).attr('href');
        var confirm_box = confirm('You are now leaving the Peoples Federal Savings Bank website, please click OK to continue');
        if (confirm_box) {
            window.open(url,'_blank');
        }
    });
        
    $j('.homeblocks .grid_10').equalHeights();

	// jQuery.cycle() for Header Ads
	$j('#headerad').cycle();


});



$j.fn.equalHeights = function(px) {

    var currentTallest = 0;

    $j(this).each(function(){

        if ($j(this).height() > currentTallest) {

            currentTallest = $j(this).height();

        }

    });

    $j(this).each(function(){

        if ($j.browser.msie && $j.browser.version == 6.0) {

            $j(this).children().css({

                'height': currentTallest

            });

        }

        $j(this).css({

            'min-height': currentTallest

        });

    });

    return this;

};
