$(function() {

	// setup button action. it will fire our overlay 
	$("a[rel]").overlay({
		
	
		mask: '#bbb',
		
		
		onBeforeLoad: function() {

			// get the url contained in the link we used as the trigger and write it to our div where we'll load the player
			var wrap = this.getOverlay().find(".player");
			var clipurl = this.getTrigger().attr("href");
			wrap.replaceWith("<a id='player' href='"+clipurl+"'></a>");
		},
		
		
		// when overlay is opened, load the player
		onLoad: function() {
			 
	// install flowplayer into flowplayer container
	var player = $f("player", "/siteelements/flash/flowplayer-321.swf", {
	
	clip: {
		scaling: 'fit'
	},
	plugins: {
		controls: {
url:'/siteelements/flash/flowplayercontrols-320.swf',	  
      tooltipTextColor: '#ffffff',
      backgroundColor: '#cccccc',
      borderRadius: '0px',
      volumeSliderGradient: 'none',
      timeBgColor: '#999999',
      buttonColor: '#555555',
      durationColor: '#dddddd',
      backgroundGradient: 'high',
      progressGradient: 'medium',
      sliderGradient: 'none',
      tooltipColor: '#555555',
      bufferGradient: 'none',
      progressColor: '#336699',
      bufferColor: 'pink',
      sliderColor: '#555555',
      buttonOverColor: '#336699',
      timeColor: '#555555',
      volumeSliderColor: '#555555',
      height: 24,
      opacity: 1.0
   	}
	}
					}
	);
		},
		
		// when overlay is closed, unload our player - IE seems to need the stop function too, otherwise audio continues. Way to go IE!
		onClose: function() {
			$f().stop();
			$f().unload();
		}
	});
			
});
