// JavaScript Document
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}
 $(document).ready(function () {
	 $(".attachmentListItem a[href*='.mp4'], .attachmentListItem a[href*='.m4v'], .attachmentListItem a[href*='.f4v'], .attachmentListItem a[href*='.mov'], .attachmentListItem a[href*='.flv'], .attachmentListItem a[href*='.ogv'], .attachmentListItem a[href*='.webm'], .attachmentListItem a[href*='.mp3'], .attachmentListItem a[href*='.mp3'], .attachmentListItem a[href*='.aac'], .attachmentListItem a[href*='.m4a'], .attachmentListItem a[href*='.f4a'], .attachmentListItem a[href*='.ogg'], .attachmentListItem a[href*='.oga'], .attachmentListItem a[href*='.jpg'], .attachmentListItem a[href*='.gif'], .attachmentListItem a[href*='.png'], .attachmentListItem a[href*='noaccess']").click(function(e){
		e.preventDefault();
	 	
	 });
	
	$(".attachmentListItem a[href*='.mp4'], .attachmentListItem a[href*='.m4v'], .attachmentListItem a[href*='.f4v'], .attachmentListItem a[href*='.mov'], .attachmentListItem a[href*='.flv'], .attachmentListItem a[href*='.ogv'], .attachmentListItem a[href*='.webm']").colorbox({
		onOpen: function(){
	
		},
	
		onComplete: function(){
	
			var thisHref=$(this).attr("href");
			var thisFileExt = thisHref.slice(-3);

				jwplayer("jwContent").setup({
				autostart: true,
				flashplayer: "/ngGlobal/swf/player.swf",
				height: 270,
				width: 480,
				provider:"video",
				skin:"/ngGlobal/swf/skins/newtubedark.zip",
				current: false
		
				});
	
				jwplayer().load(thisHref);
	
	
	
	
	
		},
	
		onCleanup: function(){
			$("#lbContainer img").remove();
			jwplayer().remove();
			
		},
	
		inline:true,
		href:"#jwContent",
		next: "",
		previous: "",
		current: "",
		arrowKey: "false"
	
	});
	
	$(".attachmentListItem a[href*='.mp3'], .attachmentListItem a[href*='.mp3'], .attachmentListItem a[href*='.aac'], .attachmentListItem a[href*='.m4a'], .attachmentListItem a[href*='.f4a'], .attachmentListItem a[href*='.ogg'], .attachmentListItem a[href*='.oga']").colorbox({
	        innerWidth:"508px",
		innerHeight:"28px",
		onOpen: function(){

		},
	
		onComplete: function(){
	
			var thisHref=$(this).attr("href");
			var thisFileExt = thisHref.slice(-3);
				jwplayer("jwContentAudio").setup({
				autostart: true,
				flashplayer: "/ngGlobal/swf/player.swf",
				height: 28,
				width: 480,
				provider:"audio",
				skin:"/ngGlobal/swf/skins/newtubedark.zip",
				controlbar: 'middle',
				current: false
				});
				
				jwplayer().load(thisHref);

		},
	
		onCleanup: function(){
			$("#lbContainer img").remove();
			jwplayer().remove();
			
		},
	
		inline:true,
		href:"#jwContentAudio",
		next: "",
		previous: "",
		current: "",
		arrowKey: "false"
	
	});
	
	$(".attachmentListItem a[href*='.jpg'], .attachmentListItem a[href*='.gif'], .attachmentListItem a[href*='.png']").colorbox({
		next: "",
		previous: "",
		current: "",
		arrowKey: "false"});
		
	$(".attachmentListItem a[href*='noaccess']").colorbox({
		next: "",
		previous: "",
		current: "",
		arrowKey: "false",
		inline:true});	
	
	$("#lbContainer, #lbContainerAudio, #lbContainerError").css("display", "none");
	
	if (getParameterByName("id") != ""){
		$("#"+getParameterByName("id")+" a").click();
	}

});

