jQuery(document).ready(function() {


		jQuery.preLoadImages("/videos/images/play-button-hover.png");
		jQuery.preLoadImages("/videos/images/play-button.png");
		
		loadPlayer("SD");
		$f("player").playlist("div.clips");
		
		jQuery("div.video_thumbnail_image").each(function()
		{
			var height;
			var width;
			
			jQuery(this).find("img:first").load(function()
			{
				var height = jQuery(this).height();
				var width = jQuery(this).width();
				
				height = height/2-30;
				width = width/2 - 35;
				
				jQuery(this).parent().parent().find("span.play_button").css("top",height+"px").css("left",width + "px");
			});
							
		});
		
		
		jQuery("div.video_thumbnail").bind("mouseover", function()	
		{		
			jQuery(this).find("span.play_button").find("img").attr("src","/videos/images/play-button-hover.png");
		});

		jQuery("div.video_thumbnail").bind("mouseout", function()	
		{		
			jQuery(this).find("span.play_button").find("img").attr("src","/videos/images/play-button.png");
		});

				
		// setup overlay actions to buttons
		jQuery("div.video_thumbnail").overlay({
			
			// use the Apple effect for overlay
			expose: '#DDD',
			opacity: '1.0',								
			onLoad: function(content) {
				// find the player contained inside this overlay and load it
				
				var bandwidth = jQuery("input:radio[name=bandwidth]:checked").val();
				if(bandwidth =="")
					bandwidth = "SD";
				if(bandwidth == "SD")
				{
					loadPlayer("SD");
				}
				else
				{
					loadPlayer("HD");	
				}
				
				if(!flashembed.isSupported([9, 115]))
				{
					this.getOverlay().find("div.player").flowplayer(0).ipad();
				}

			},
							
			onClose: function(content) {

				$f().stop();
				$f().unload();
			}
		});
		

	});
	
	
(function() {
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
  po.src = 'https://apis.google.com/js/plusone.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();


(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) {return;}
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));
	


	window.fbAsyncInit = function() {
	  FB.init({
	    appId      : '', // App ID
	    channelURL : '', // Channel File
	    status     : true, // check login status
	    cookie     : true, // enable cookies to allow the server to access the session
	    oauth      : true, // enable OAuth 2.0
	    xfbml      : true  // parse XFBML
	  });
	
	  // Additional initialization code here
	};
	
	// Load the SDK Asynchronously
	(function(d){
	   var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
	   js = d.createElement('script'); js.id = id; js.async = true;
	   js.src = "//connect.facebook.net/en_US/all.js";
	   d.getElementsByTagName('head')[0].appendChild(js);
	 }(document));
