$(document).ready(function(){
	// embeds flash logo
	$('#logo').flash(
		{ src: '/flash/logo.swf', width: 158, height: 201, wmode: 'transparent' },
		{ version: 6, expressInstall: true }
    );	

    // embeds mp3 player on each post
    $('#content .player').each(function(i){
		var link = $('a', this);
		var mp3_link = $('a[@href$="mp3"]', this);
		link.css('display', 'none');
		$(this).flash(
			{ src: '/flash/player.swf', height: 24, width: 442, wmode: 'transparent' },
			{ version: 6, expressInstall: true },
			function(htmlOptions) {
			    htmlOptions.flashvars.soundFile = mp3_link.attr('href');
				htmlOptions.flashvars.playerID = i;
			    htmlOptions.flashvars.bg = '0xEFEFEF';
			    htmlOptions.flashvars.leftbg = '0xD9D9D9';
			    htmlOptions.flashvars.lefticon = '0x5F5F5F';
			    htmlOptions.flashvars.rightbg = '0xF5770B';
			    htmlOptions.flashvars.rightbghover = '0xC81F1F';
			    htmlOptions.flashvars.righticon = '0xFFFFFF';
			    htmlOptions.flashvars.righticonhover = '0xFFFFFF';
			    htmlOptions.flashvars.text = '0x333333';
			    htmlOptions.flashvars.slider = '0x357DCE';
			    htmlOptions.flashvars.track = '0xFFFFFF';
			    htmlOptions.flashvars.border = '0xFFFFFF';
			    htmlOptions.flashvars.loader = '0xC81F1F';
			    $(this).html($.fn.flash.transform(htmlOptions));
			}
    	);
	});
	
    // embeds sbe mp3 player on home page
    $('#banner a[@href$="mp3"]').flash(
        { src: '/flash/player_minimal.swf', height: 24, width: 73, wmode: 'transparent' },
        { version: 6, expressInstall: false },
        function(htmlOptions) {
            htmlOptions.flashvars.soundFile = $(this).attr('href');
            htmlOptions.flashvars.bg = '0xEFEFEF';
            htmlOptions.flashvars.leftbg = '0xD9D9D9';
            htmlOptions.flashvars.lefticon = '0x5F5F5F';
            htmlOptions.flashvars.rightbg = '0xF5770B';
            htmlOptions.flashvars.rightbghover = '0xC81F1F';
            htmlOptions.flashvars.righticon = '0xFFFFFF';
            htmlOptions.flashvars.righticonhover = '0xFFFFFF';
            htmlOptions.flashvars.text = '0x333333';
            htmlOptions.flashvars.slider = '0x357DCE';
            htmlOptions.flashvars.track = '0xFFFFFF';
            htmlOptions.flashvars.border = '0xFFFFFF';
            htmlOptions.flashvars.loader = '0xC81F1F';
            $('#banner #player').css('display','block').html($.fn.flash.transform(htmlOptions));
        }
    ).css('display', 'none');;
	
	// fixes png transparency in ie6
	$('#carousel .cell .content').css('display', 'block');
	$('img[@src$=.png]').iepng();
	
	// removes title attribute from sub-nav
	$('#nav li ul a').attr('title', '');

	// achieves nav drop-down
	$('#nav li').hover(function() {
		$('ul', this).css('display', 'block');
	}, function() {
		$('ul', this).css('display', 'none');
	});
	
	// fixes drop-down hover in ie
	$('#nav li.subnav').hover(function() {
		$(this).css('background', 'url("/images/nav_hover.gif") bottom center no-repeat');
	}, function() {
		$(this).css('background', 'none');
	});
	
	// toggles show description
	$('h2 span.description a').toggle(function() {
		$('div.description').css('display','block');
		$('#microphone').css('bottom','24px');
	}, function() {
		$('div.description').css('display','none');
		$('#microphone').css('bottom','23px');
	});
	
	// fixes microphone logo issue in safari- when showing/hiding divs, an absolutely position element does not move
	if($.browser.safari){
		$('#microphone').css('bottom','23px');
	}
	
	// fades headlines in/out
	$('#headlines p').innerfade({
		animationtype: 'slide',
		speed: 2000,
		timeout: 10000,
		type: 'sequence',
		containerheight: 'auto'
	});

	// fades carousel cells in/out
	$('#carousel .cell').innerfade({
		speed: 2000,
		timeout: 10000,
		type: 'sequence',
		containerheight: 'auto'
	});

	// fixes odd InnerFade margin behaviour in IE6
	if($.browser.msie){
		$('#content #carousel .cell .content').css('margin-left', '-94px');
	;}
});