$(window).load(function() 
{
	$("a[rel]").overlay({ 
		onBeforeLoad: function() {
			this.getBackgroundImage().expose();
		},

		onLoad: function(content) {
			$f("fms", "/flowplayer/flowplayer.commercial-3.1.4.swf", {
			
			    key: '#@dab19f1a38ba8ec2f53',
			    
				clip: {
					onStart: function(clip) {
						google._trackEvent("Videos", "Play", $("#ttl").text());
					},
					
					onPause: function(clip) {
						google._trackEvent("Videos", "Pause", $("#ttl").text(), parseInt(this.getTime()));
					},
					
					onResume: function(clip) {
						google._trackEvent("Videos", "Resume", $("#ttl").text(), parseInt(this.getTime()));
					},
					
					onSeek: function(clip) {
						google._trackEvent("Videos", "Seek", $("#ttl").text(), parseInt(this.getTime()));
					},
					
					onStop: function(clip) {             
						google._trackEvent("Videos", "Stop", $("#ttl").text(), parseInt(this.getTime())); 
					},                  
										
					onFinish: function(clip) {
						google._trackEvent("Videos", "Finish", $("#ttl").text());
					},
					
					provider: "rtmp"
				},
				
				// the logo, shown 10 seconds from the start
	            logo: {
		            url: 'http://www.amazingfacts.org/portals/0/mediamgrimgs/afax-bug.png',
		            fullscreenOnly: false,
		            displayTime: 10
	            },
	            
	            // gradually show on mouseover 
                onMouseOver: function() { 
                    this.getPlugin("logo").fadeTo(0.5, 1000); 
                }, 
             
                // gradually hide on mouseout 
                onMouseOut: function() { 
                    this.getPlugin("logo").fadeTo(0, 1000); 
                }, 

				// context menu
	            contextMenu: [
		            {'Amazing Facts Website': function() {
			            location.href = 'http://www.amazingfacts.org/';
		            }},
		            {'Free Online Bible School': function() {
			            location.href = 'http://www.amazingfacts.org/FreeStuff/BibleStudies/FreeOnlineBibleSchool/tabid/103/Default.aspx';
		            }},
		            
		            {'Submit a prayer request': function() {
			            location.href = 'http://www.amazingfacts.org/ContactUs/SubmitPrayerRequests/tabid/114/Default.aspx';
		            }},
		            {'Ask a Bible question': function() {
			            location.href = 'http://www.amazingfacts.org/ContactUs/SubmitBibleQuestions/tabid/116/Default.aspx';
		            }}
	            ],
	
				plugins: {
					rtmp: {
						url: '/flowplayer/flowplayer.rtmp-3.1.3.swf',
						netConnectionUrl: 'rtmp://rtmp.amazingfacts.org/play'
					}, 
					
				    pseudo: {
		                url: '/flowplayer/flowplayer.pseudostreaming-3.1.3.swf'
	                },
					
					controls: {
						stop: true
					}
				}
			});
		}, 
		 
		onClose: function() {
			$f().stop();
			$f().unload();
			$.expose.close();
		}
	});
});