/* TestPlayer



*/
var TestPlayer = {
	
	env: 'incorrect',
	active_player: {},
	active_player_id: 'embed_player',
	media_type: 'wmv',
	
	init: function(options) {
		
//alert('wait.');
//alert('innerWidth: ' + window.innerWidth + ', innerHeight: ' + window.innerHeight + ', window.getScrollTop(): ' + window.getScrollTop() + ', body.style.width: ' + document.body.style.width + ', window.getHeight(): ' + window.getHeight() + ', window.getWidth(): ' + window.getWidth() + ', document.width: ' + document.width );
		
		if (navigator.platform.indexOf("Win") == -1) {
			this.env = 'correct';
			this.active_player = $('embed_player');
		}	else {
			// Detected MS OS, so check whether embed or object is being used:
			if ($('embed_player')) {
				this.active_player = $('embed_player');
			} else {
				this.active_player = $('Player');
			} 
//alert(this.active_player.id);
		}
		// Now that we know which element is being used:
		this.active_player_id = this.active_player.id;

//alert(this.active_player.tagName);
		
		if (($(this.active_player_id).tagName == 'object' && $(this.active_player_id).url.indexOf(".mov") != -1) || ($(this.active_player_id).tagName == 'embed' && $(this.active_player_id).src.indexOf(".mov") != -1)) {
			this.media_type = 'mov';
		}

//alert($(this.active_player_id).tagName + ' ' + this.media_type);

		
/*		this.log('Environment is ' + this.env);
		this.log('Active Player ID: ' + this.active_player_id);
		this.log('Media Type: ' + this.media_type);
*/		
//		this.log('Original Position: x=' + this.active_player.getPosition().x + ', y=' + this.active_player.getPosition().y);
		this.configure(this.active_player, this.env, this.media_type);
//		window.onresize = this.resizeOverlay;
//		this.resizeOverlay();
	},
	
	configure: function(p, e, m) {
		var enlarge_button = $('enlarge_button');
		if (e == 'incorrect' && p.id == 'embed_player' && m == 'wmv') {
			enlarge_button.onclick = void(0);
			enlarge_button.className += " disabled";
			enlarge_button.innerHTML = "Double-click the movie to enlarge.";
		} else {
			enlarge_button.onclick = function() {
				$('lbImage').addClass('big');
				if (TestPlayer.active_player.id == 'Player') {
					TestPlayer.active_player.style.height = '508px';
					TestPlayer.active_player.style.height = '640px';
				}
				$('overlay').style.display = 'block';
				$('shrink_button').style.display = 'inline';
				this.style.display ='none';
			};
			
			$('shrink_button').onclick = function() {
				$('lbImage').removeClass('big');
				$('overlay').style.display = 'none';
				if (TestPlayer.active_player.id == 'Player') {
					TestPlayer.active_player.style.height = '288px';
					TestPlayer.active_player.style.height = '384px';
				}
				$('enlarge_button').style.display = 'inline';
				this.style.display ='none';
			};
		}
		
	}
	
	/*,
	
	 resizeOverlay: function() {
			var clipwindow = $('lbImage');
			if (clipwindow.className == 'big') {
				clipwindow.style.width = window.getWidth() + 'px';
				clipwindow.style.height = window.getHeight() + window.getScrollTop() + 'px';
			} else {
				clipwindow.style.height = '288px';
			}
		},
		
	
	log: function(logentry) {
		$('debugdiv').innerHTML += logentry + "<br />\n";
	} */

};

window.addEvent('domready', TestPlayer.init.bind(TestPlayer));