function PlayerManager(){

	var mediaRow;
	this.changeClass = function(obj){
	 	if (mediaRow) mediaRow.className='';
	 	obj.className='selected';
	 	mediaRow=obj;
	}
	
	var mediaLink;
	this.changeLinkClass = function(obj){
	 	if (mediaLink) mediaLink.className='';
	 	obj.className='selected_link';
	 	mediaLink=obj;	 	
	}
	
	/*
	//This method helps testing and debugging different file formats
	this.play = function(theContainer, theFile, go){				
		if ( theFile.indexOf('.mp3')>-1 ){
			this.windowsMediaPlayer(theContainer, theFile, go);
		} else if ( theFile.indexOf('.avi')>-1 ){
			this.windowsMediaPlayer(theContainer, '/ocs/js/media/video.avi', go);
		} else if ( theFile.indexOf('.mov')>-1 || 
					theFile.indexOf('.qt')>-1 ||					
					theFile.indexOf('.mpeg')>-1 ||
					theFile.indexOf('.mp4')>-1 ||
					theFile.indexOf('.m4v')>-1 ||
					theFile.indexOf('.mpg')>-1 ){
			this.quickTime(theContainer, '/ocs/js/media/video.avi, go);
		} else if ( theFile.indexOf('.flv')>-1 ){
			this.flashPlayer(theContainer, theFile, go);
		} else if ( theFile.indexOf('.wmv')>-1 ||
					theFile.indexOf('.asf')>-1 ){
			this.windowsMediaPlayer(theContainer, '/ocs/js/media/video.avi, go);
		} else if ( theFile.indexOf('.rv')>-1 ){
			this.realPlayer(theContainer, '/ocs/js/media/video.avi, go);
		}
	}
	*/
	
	this.play = function(theContainer, theFile, go){				
				 
		if ( theFile.toLowerCase().indexOf('.mpa')>-1 ||
			 theFile.toLowerCase().indexOf('.mov')>-1  || 
			 theFile.toLowerCase().indexOf('.qt')>-1   ||					
			 theFile.toLowerCase().indexOf('.mpeg')>-1 ||
			 theFile.toLowerCase().indexOf('.mp4')>-1  ||
			 theFile.toLowerCase().indexOf('.m4v')>-1  ||
			 theFile.toLowerCase().indexOf('.mpg')>-1 ){
			 
			 this.quickTime(theContainer, theFile, go);
		} 
		else 
		if ( theFile.toLowerCase().indexOf('.fla')>-1 ||
			 theFile.toLowerCase().indexOf('.flv')>-1 ){
			 
			 this.flashPlayer(theContainer, theFile, go);
		} 
		else 
		if ( theFile.toLowerCase().indexOf('.mp3')>-1 ||
			 theFile.toLowerCase().indexOf('.wav')>-1 ||
			 theFile.toLowerCase().indexOf('.ogg')>-1 ||
			 theFile.toLowerCase().indexOf('.wma')>-1 ||
			 theFile.toLowerCase().indexOf('.wmv')>-1 ||
			 theFile.toLowerCase().indexOf('.asf')>-1 ||
			 theFile.toLowerCase().indexOf('.avi')>-1 ||
			 theFile.toLowerCase().indexOf('.ogm')>-1 ){
			 
			 this.windowsMediaPlayer(theContainer, theFile, go);
		} 
		else 
		if ( theFile.toLowerCase().indexOf('.ra')>-1 ||
			 theFile.toLowerCase().indexOf('.rv')>-1 ){
			 
			this.realPlayer(theContainer, theFile, go);
		}
	}
	
	
	this.realPlayer = function(theContainer, theFile, go){
		document.getElementById(theContainer).innerHTML = ""+
		"<table border='0' cellpadding='0'> "+
		        "<tr><td> "+
			        "<OBJECT id='rvocx' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' "+
			        	"width='400' height='230'> "+
				        "<param name='src' value='"+theFile+"'> "+
					"<param name='autostart' value='"+go+"'> "+
				        "<param name='controls' value='imagewindow'> "+
				        "<param name='console' value='video'> "+
        				"<param name='loop' value='false'> "+
		        	"<EMBED src='"+theFile+"' " +
				    "width='400' "+ 
				    "height='230' "+ 
				    "loop='false' "+
				    "type='audio/x-pn-realaudio-plugin' "+
				    "controls='imagewindow' "+
				    "console='video' "+
				    "autostart='"+go+"'> "+
			        "</EMBED> "+
			        "</OBJECT> "+
		        "</td></tr> "+
			"<tr><td> "+
			        "<OBJECT id='rvocx' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' "+
			        	"width='400' height='20'> "+
				        "<param name='src' value='"+theFile+"'> "+
					"<param name='autostart' value='"+go+"'> "+
				        "<param name='controls' value='ControlPanel'> "+
				        "<param name='console' value='video'> "+        				
		        	"<EMBED src='"+theFile+"' " +
				    "width='400' "+ 
				    "height='20' "+ 				    				    
				    "controls='ControlPanel' "+
				    "type='audio/x-pn-realaudio-plugin' "+
				    "console='video' "+
				    "autostart='"+go+"'> "+
			        "</EMBED> "+
			        "</OBJECT> "+
		        "</td></tr> "+         
		 "</table> ";
	}
	
	
	this.quickTime = function(theContainer, theFile, go){
		document.getElementById(theContainer).innerHTML = ""+
		   "<OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' "+
			"width='400' "+
			"height='250' "+
			"codebase='http://www.apple.com/qtactivex/qtplugin.cab'> "+
			"<param name='src' value='"+theFile+"'> "+
			"<param name='scale' value='tofit'> "+
			"<param name='autoplay' value='"+go+"'> "+
			"<param name='controller' value='true'> "+
			"<param name='loop' value='false'> "+
			"<EMBED src='"+theFile+"' "+
				    "width='400' "+ 
				    "height='250' "+
				    "scale='tofit' "+
				    "autoplay='"+go+"' "+
		                    "controller='true' "+
		                    "loop='false' "+
				    "pluginspage='http://www.apple.com/quicktime/download/'> "+
			"</EMBED> "+
		    "</OBJECT> ";    
	}
	
	
	this.flashPlayer = function(theContainer, theFile, go){
		document.getElementById(theContainer).innerHTML = "";
		
		var s1 = new SWFObject('/ocs/js/media/player-licensed-viral.swf','ply','400','250','9','#ffffff'); 
		s1.addParam('allowfullscreen','true');
		s1.addParam('allowscriptaccess','always'); 
		s1.addParam('wmode','opaque'); 
		s1.addParam('flashvars','file='+theFile+'&autostart='+go); 
		s1.write(theContainer); 
	}
	
	var player = null;
	this.jwWindowsMediaPlayer = function(theContainer, theFile, go) {
		document.getElementById(theContainer).innerHTML = "";
		
		var cnt = document.getElementById(theContainer);
		var src = "/ocs/js/media/wmvplayer.xaml";	
		var cfg = {height:"250", width:"400", file:theFile, autostart:go};
		player = new jeroenwijering.Player(cnt,src,cfg);
	}
	
	
	this.windowsMediaPlayer = function(theContainer, theFile, go) {
		document.getElementById(theContainer).innerHTML = ""+
		"<OBJECT id='mediaPlayer' width='400' height='250' "+
		      "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' "+
		      "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' "+
		      "standby='Loading Microsoft Windows Media Player components...' "+
		      "type='application/x-oleobject'> "+
		      "<param name='fileName' value='"+theFile+"'> "+
		      "<param name='animationatStart' value='true'> "+
		      "<param name='transparentatStart' value='true'> "+
		      "<param name='autoStart' value='"+go+"'> "+
		      "<param name='showControls' value='true'> "+
		      "<param name='ShowStatusBar' value='true'> "+
		      "<param name='loop' value='false'> "+
		      "<EMBED type='application/x-mplayer2' "+
		      		 "pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' "+
		        	 "id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1' bgcolor='darkblue' showtracker='-1' "+
			         "showdisplay='0' showstatusbar='1' videoborder3d='-1' designtimesp='5311' "+
			         "width='400' height='250' "+
			         "src='"+theFile+"' "+
			         "showcontrols='true' "+
			         "autostart='"+go+"' "+
			         "loop='false'> "+
		      "</EMBED> "+
		"</OBJECT>";
	}
	
	
	this.initMedia= function(mediaType) {
		/*this.windowsMediaPlayer('sound', 
						    "",//"http://www.jeroenwijering.com/upload/silverlight.wmv", 
				            "false");
		this.windowsMediaPlayer('video', 
						    "",//"http://www.jeroenwijering.com/upload/silverlight.wmv", 
				            "false");*/
		
		document.getElementById("video").innerHTML = "";
		document.getElementById("sound").innerHTML = "";		            
		
		if (mediaType.indexOf('headshot')>-1) {
			document.getElementById('media_type').innerHTML = 'Headshot Gallery';
		} else if (mediaType.indexOf('sound')>-1) {
			document.getElementById('media_type').innerHTML = 'Sound Gallery';
		} else if (mediaType.indexOf('video')>-1) {
			document.getElementById('media_type').innerHTML = 'Video Gallery';
		}
	}
	
}

