(function(a){function e(b){if(a.facebox.settings.inited)return true;else a.facebox.settings.inited=true;a(document).trigger("init.facebox");j();var c=a.facebox.settings.imageTypes.join("|");a.facebox.settings.imageTypesRegexp=new RegExp("."+c+"$","i");b&&a.extend(a.facebox.settings,b);a("body").append(a.facebox.settings.faceboxHtml);var d=[new Image,new Image];d[0].src=a.facebox.settings.closeImage;d[1].src=a.facebox.settings.loadingImage;a("#facebox").find(".b:first, .bl, .br, .tl, .tr").each(function(){d.push(new Image);
d.slice(-1).src=a(this).css("background-image").replace(/url\((.+)\)/,"$1")});a("#facebox .close").click(a.facebox.close);a("#facebox .close_image").attr("src",a.facebox.settings.closeImage)}function k(){var b,c;if(self.pageYOffset){c=self.pageYOffset;b=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){c=document.documentElement.scrollTop;b=document.documentElement.scrollLeft}else if(document.body){c=document.body.scrollTop;b=document.body.scrollLeft}return new Array(b,
c)}function l(){var b;if(self.innerHeight)b=self.innerHeight;else if(document.documentElement&&document.documentElement.clientHeight)b=document.documentElement.clientHeight;else if(document.body)b=document.body.clientHeight;return b}function j(){var b=a.facebox.settings;b.loadingImage=b.loading_image||b.loadingImage;b.closeImage=b.close_image||b.closeImage;b.imageTypes=b.image_types||b.imageTypes;b.faceboxHtml=b.facebox_html||b.faceboxHtml}function f(b,c){if(b.match(/#/)){var d=window.location.href.split("#")[0];
b=b.replace(d,"");a.facebox.reveal(a(b).clone().show(),c)}else b.match(a.facebox.settings.imageTypesRegexp)?g(b,c):h(b,c)}function g(b,c){var d=new Image;d.onload=function(){a.facebox.reveal('<div class="image"><img src="'+d.src+'" /></div>',c)};d.src=b}function h(b,c){a.get(b,function(d){a.facebox.reveal(d,c)})}function i(){return a.facebox.settings.overlay==false||a.facebox.settings.opacity===null}function m(){if(!i()){a("facebox_overlay").length==0&&a("body").append('<div id="facebox_overlay" class="facebox_hide"></div>');
a("#facebox_overlay").hide().addClass("facebox_overlayBG").css("opacity",a.facebox.settings.opacity).click(function(){a(document).trigger("close.facebox")}).fadeIn(200);return false}}function n(){if(!i()){a("#facebox_overlay").fadeOut(200,function(){a("#facebox_overlay").removeClass("facebox_overlayBG");a("#facebox_overlay").addClass("facebox_hide");a("#facebox_overlay").remove()});return false}}a.facebox=function(b,c){a.facebox.loading();if(b.ajax)h(b.ajax);else if(b.image)g(b.image);else if(b.div)f(b.div);
else a.isFunction(b)?b.call(a):a.facebox.reveal(b,c)};a.extend(a.facebox,{settings:{opacity:0,overlay:true,loadingImage:"/video4/images/facebox/loading.gif",closeImage:"/video4/images/facebox/closelabel.gif",imageTypes:["png","jpg","jpeg","gif"],faceboxHtml:'    <div id="facebox" style="display:none;">       <div class="popup">         <table>           <tbody>             <tr>               <td class="tl"/><td class="b"/><td class="tr"/>             </tr>             <tr>               <td class="b"/>               <td class="body">                 <div class="content">                 </div>                 <div class="footer">                   <a href="#" class="close">                     <img src="/video4/images/facebox/closelabel.gif" title="close" class="close_image" />                   </a>                 </div>               </td>               <td class="b"/>             </tr>             <tr>               <td class="bl"/><td class="b"/><td class="br"/>             </tr>           </tbody>         </table>       </div>     </div>'},
loading:function(){e();if(a("#facebox .loading").length==1)return true;m();a("#facebox .content").empty();a("#facebox .body").children().hide().end().append('<div class="loading"><img src="'+a.facebox.settings.loadingImage+'"/></div>');a("#facebox").css({top:k()[1]+l()/10,left:385.5}).show();a(document).bind("keydown.facebox",function(b){b.keyCode==27&&a.facebox.close();return true});a(document).trigger("loading.facebox")},reveal:function(b,c){a(document).trigger("beforeReveal.facebox");c&&a("#facebox .content").addClass(c);
a("#facebox .content").append(b);a("#facebox .loading").remove();a("#facebox .body").children().fadeIn("normal");a("#facebox").css("left",a(window).width()/2-a("#facebox table").width()/2);a(document).trigger("reveal.facebox").trigger("afterReveal.facebox")},close:function(){a(document).trigger("close.facebox");return false}});a.fn.facebox=function(b){function c(){a.facebox.loading(true);var d=this.rel.match(/facebox\[?\.(\w+)\]?/);if(d)d=d[1];f(this.href,d);return false}e(b);return this.click(c)};
a(document).bind("close.facebox",function(){a(document).unbind("keydown.facebox");a("#facebox").fadeOut(function(){a("#facebox .content").removeClass().addClass("content");n();a("#facebox .loading").remove()})})})(jQuery);

$(document).ready(function(){
  $("#accordion").accordion();
  $("#accordion div").css('height', '320px').css('overflow', 'auto');
  $("div.infinite").scrollable({
    size: 6,
    onSeek: function() {
      $('.current_page', this.getRoot().parent()).text(this.getPageIndex()+1);
    },
    onReload: function() {
      current_page = this.getPageIndex()+1;
      total_pages = this.getPageAmount();
      if (current_page > total_pages) current_page = total_pages;
      $('.current_page', this.getRoot().parent()).text(current_page);
      $('.total_pages', this.getRoot().parent()).text(total_pages);
    }
  }).navigator();
  
  jQuery('a[rel*=facebox]').facebox();
  
  $(document).bind('reveal.facebox', function() {
    
    // Pause the first flowplayer found on the page
    var player = $f();
    player.pause();
    
    // Make facebok use ajax submit
    $('#facebox form').each(function(i, form) {
      $(form).submit(function(event) {
        formData = $(this).serialize();
        jQuery.ajax({type: 'POST', url: this.action, data: formData, dataType: 'script'});
        return false;
      });
    });

  });
  
  $(document).bind('close.facebox', function() {
    // Play the first flowplayer found on the page
    var player = $f();
    player.play();
  });
  
  $(document).pngFix();
});

$(document).ready(function(){

// Turn all links that have 'data-share="facebook"' in to Facebook share links that will
// popup and editor to allow the user to post the link to their wall
//
// Example 1:
// Code: <a href="http://google.com" data-share="facebook">Share on Facebook</a>
// Result: Will pop up a window to allow the user to post the http://google.com page to their Facebook wall
//
// Example 2:
// Code: <a href="#" data-share="facebook">Share on Facebook</a>
// Result: Will pop up a window to allow the user to post the current page to their facebook wall
  
$("a[data-share=facebook]").each(function(e){
	$(this).click(function(){
		var facebook_url = "http://www.facebook.com/sharer.php";
		if (this.href == '#' || this.href == '') {
			var share_url = facebook_url;
		} else {
			var share_url = facebook_url + "?u=" + this.href;
		}
		window.open(share_url,'sharer','location=0,toolbar=0,status=0,width=626,height=436');
		return false;
	});
});

// Turn all links that have 'data-share="linkedin"' in to LinkedIn share links that will
// popup and editor to allow the user to post the link to their LinkedIn profile
//
// Example 1:
// Code: <a href="http://google.com" data-share="facebook">Share on LinkedIn</a>
// Result: Will pop up a window to allow the user to post the http://google.com page to their LinkedIn profile
//
// Example 2:
// Code: <a href="#" data-share="facebook">Share on LinkedIn</a>
// Result: Will pop up a window to allow the user to post the current page to their LinkedIn profile
  
$("a[data-share=linkedin]").each(function(e){
	$(this).click(function(){
		var linkedin_url = "http://www.linkedin.com/shareArticle?mini=true&";
		var params = [];
		if (this.href == '#' || this.href == '') {
			params.push('url='+escape(window.location));
		} else {
		  params.push('url='+escape(this.href));
		}
		if (this.title == '') {
			params.push('title='+escape(document.title));
		} else {
		  params.push('title='+escape(this.title));
		}
		params.push('source='+escape(window.location.host));
		var share_url = linkedin_url + params.join('&');
		window.open(share_url,'sharer','location=0,toolbar=0,status=0,width=520,height=570');
		return false;
	});
});

// Turn all links that have 'data-share="twitter"' in to 'tweeting' links
//
// Example 1:
// Code: <a href="http://google.com" data-share="twitter">Tweet</a>
// Result: Will link to twitter with the message box set to "http://google.com"
//
// Example 2:
// Code: <a href="http://google.com" data-share="twitter" data-share-message="My favorite search engine: $link">Tweet</a>
// Result: Will link to twitter with the message box set to "My favorite search engine: http://google.com"

$("a[data-share=twitter]").each(function(e){
	$(this).click(function(){
		var twitter_url = "http://twitter.com/home?status=";
		if (this.href == '#' || this.href == '') {
			var share_url = window.location;
		} else {
			var share_url = this.href;
		}
		var message = this.getAttribute('data-share-message');
		if (message == '') {
			message = share_url;
		} else {
			if (message.indexOf('$link') > -1) {
				message = message.replace('$link', share_url);
			} else {
				message = message + ' ' + share_url;
			}
		}
		var link_url = twitter_url + message;
		window.open(link_url,'_blank');
		return false;
	});
});

});