var busy = false;

  $.fn.loadAudioPlayer = function(pTitle,filePath) {
	  		if(pTitle.length > 26) {
	  			pTitle = pTitle.substr(0,26) + " . . . ";
	  		}
	  		
	  		$(this).attr('id','currentPlayer');
	  		
			var flashvars = { Track: filePath, AutoPlay: 'true' };			
			var params = { };			
			params.wmode = "transparent";	
			
			var attributes = {};	
		
			swfobject.embedSWF("/swf/NewFlashAudioPlayer.swf", "currentPlayer", "470", "33", "9.0.0", "swfs/expressInstall.swf", flashvars, params, attributes);

			busy = false;
	
  };
  
  $.fn.loadVideoPlayer = function(pTitle,filePath) {
	  
	  /*
	   if ($(".thumbHolder img").attr('src') != '') {
		   previewPath = $(".thumbHolder img").attr('src');
	   }
	   */
	
		
		$(this).attr('id','currentPlayer');
		
		/*
		 var flashvars = { config: "{'clip': 'http://www.edgestudio.com/Production/Production Portfolio/" + filePath + "' }}"  };
		 var params = { };
		*/
		
		var flashvars = { flashlet: "{_thumbnailTitles:['phase1'],_videoType:'YouTube video (get URL from the opening page)',_videoList:['Production/Production Portfolio/" + filePath + "'],_videoAdsList:[''],_previewImageList:[''],_thumbnailPlayList:[''],_save_as:'Flash parameters',PlayListXML_path:'',_loadSkin:false,_skin:'Default',_mainbarAutoHide:false,_mainbar_Alpha:70,_mainbar_Top:#666666,_mainbar_Bottom:#000000,_videoProportions:true,_autoSize:true,_autoPlay:true,_bufferTime:5,_ownerLogoIMGPath:'',_ownerLogoAlpha:,_ownerLogoLink:'',_thumbnailCarousel:false,_buttonToolTips:false,_buttonsColor:#FFFFFF,_volumeAudio:100,_seekBar_color:#0033CC,_fontFamily:'Century Gothic',_fontSize:16,_buttonToolTipsList:['stop','play','pause','played time / all time','sound volume','playlist','html code and link','send to friend','video properties','fullscreen mode'],_hideEmailButton:false,_hideEmbedButton:true,_hideFullscreenButton:false,_hidePlayListButton:true,_hideTimerButton:false,_hideVideoPropButton:true,_hideVolumeButton:false,_emailSubjectTitle:'Check out this company, Accurate...',_emailBodyText:'We saw your information on the internet...',_objectID:'WSplayer'}" };			
		var params = { };			
		params.wmode = "opaque";
		params.allowScriptAccess = "always";
		params.swliveconnect = "true";
		params.allowFullScreen = "true";
		
		var attributes = {};	
	
		swfobject.embedSWF("/player.swf", "currentPlayer", "320", "240", "8.0.0", "swfs/expressInstall.swf", flashvars, params, attributes);
		
		
		
		busy = false;

};




  $(document).ready(function() {
	  
	  
	  
	  if ($(".section-nodeorder #ordernodes").hasClass(".sticky-table")) {
		  
		 var setHeight = $("#ordernodes").height();
		  
		 $("#ordernodes").height(setHeight);
		  
	  }
	  
	  


		var audioPlayers = $(".audioPlayer");
		
		
		$(".node-type-pplisting, .node-type-twap, .script-recording").each(function(){
			
			var audioPlayer = $(this).find(".audioPlayer");
			var videoPlayer = $(this).find(".videoPlayer");
		
			var audioFilePath = $(this).find(".audioFilePath").text();
			var videoFilePath = $(this).find(".videoFilePath").text();
			
			var pTitle = $(this).find(".title").text();
			var downloadLink = $(this).find(".downloadLink");
			
			/********** .audioLink click ***********/
			
			$(this).find(".audioLink").click(function(){
				if (!busy) {
					busy = true;
					
					
					$("#currentPlayer").attr('id','').find('object').remove();
					$(".audioPlayer:visible").not(audioPlayer).slideUp(500);
					$(".videoPlayer:visible").slideUp(500);
					
					$(audioPlayer).slideDown(500,function(){
						
						$(this).find(".player").loadAudioPlayer(pTitle,audioFilePath);
						
					});
					$(downloadLink).slideDown(500);
				}
				
				return false;
			}); // end .audioLink click
			
			/*********** .videoLink click **********/
			
			$(this).find(".videoLink").click(function(){
				
				if (!busy) {
					busy = true;
					
					$("#currentPlayer").attr('id','').find('object').remove();
					$(".audioPlayer:visible").slideUp(500);
					$(".videoPlayer:visible").not(videoPlayer).slideUp(500);
					
					$(videoPlayer).slideDown(500,function(){
						
			
						$(this).find(".player").loadVideoPlayer(pTitle,videoFilePath);
						
					});
				
				}
				
				
			});
			
			
			
		}); // end each
		
		

	  
	 }); // end (document).ready
		