$(function() {
	
	$('a.zoom').fancyZoom({directory: '/javascript/jquery/plugins/fancyzoom/images', scaleImg: true});
    
	doMp3();	

	resizeImages();
	
	// cleanup hardcoded fonts
	$('.text-body span[style]').removeAttr('style');			
})

function doMp3() {
 $('a[@href$="mp3"]').flash(
        { src: '/javascript/jquery/plugins/singlemp3player.swf', height: 20, width: 100 },
        { version: 7 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.file = $this.attr('href');
            $this.before($.fn.flash.transform(htmlOptions));						
        }
    ).hide();
	 
	$('a[@href$="mp3"]').parent().each(function() {
		var el = $(this); 
		el.html(el.children('embed'));
	})
	
	// remove duplicate flash players
	$('embed').siblings('embed:not(:first)').remove();
	$('[flashvars*=mp3]').before('<div class="listen">Listen Online: </div');		
}

function rtrim(str, n){
    if (n <= 0)
       return str;
    else if (n > String(str).length)
       return "";
    else {
       var iLen = String(str).length;
       return String(str).substring(0, iLen - n);
    }
}


function resizeImages() {
	var max = 500;
	$('.text-body img').each(function () {
		el = $(this);
		if (el.attr('width') > max) {
			el.attr('width', max);
		}						
	});	
	
	return true;
}
