// Create Mylan Namespace only if needed
var Mylan = window.Mylan || {};

// Video Player is a Singleton Object
Mylan.VideoPlayer = (function(){
	
	///
	/// Private Constants
	FLASH_URL = "/assets/mylan-corp/flash/60VideoPlayer_BU.swf";
	FLASH_DIMENSIONS = { width: 659, height: 396 };
	FLASH_REQUIRED_VERSION = "9.0.124";
	EXPRESS_INSTALLER_URL = "/assets/mylan-corp/flash/expressInstall.swf";
	
	
	FLASH_PARAMS = {
		menu: "false",
  		wmode: "transparent",
  		allowScriptAccess: "always"
	};
		
	FLASH_ATTRIBUTES = {
  		id: "videoPlayerContent",
  		name: "videoPlayerContent"
	};
	VIDEO_PLAYER_ID = "video-player";
	VIDEO_LAUNCHER_CSS_CLASS = "video-launcher";
	
	///
	/// Private Variables
	_resetPlayerId = 0;
	
	///
	/// Private Methods
	function showPlayer() {
		
		
		jQuery('html, body').animate({scrollTop:0}, 'slow');
		jQuery("#" + VIDEO_PLAYER_ID).fadeIn("slow", showPlayerComplete);
	
		return false;
	}
	function showPlayerComplete() {
		var flashObj = document.getElementById(FLASH_ATTRIBUTES.id);
		
		if( flashObj.reset != undefined && flashObj.reset != null) {
			flashObj.reset();
		} else {
			setTimeout(showPlayerComplete, 250);
		}
		
	}
	
	///
	/// Public Methods
	return {
		init: function(videoName,videoTitle) {
			
			FLASH_VARS = { 
				videoURL: "/assets/mylan-corp/video/" + videoName,
		  		videoTitle: videoTitle,
			  	videoTitleURL: "http://www.mylan.com/about_us/",
			  	ctaURL: "http://www.mylan.com/about_us/"
			};
			_jsIsReady = true;
			swfobject.embedSWF(FLASH_URL, FLASH_ATTRIBUTES.id, FLASH_DIMENSIONS.width, FLASH_DIMENSIONS.height, FLASH_REQUIRED_VERSION, EXPRESS_INSTALLER_URL, FLASH_VARS, FLASH_PARAMS, FLASH_ATTRIBUTES);
			showPlayer();
		},
		closePlayer: function() { 
			

			jQuery("#"+VIDEO_PLAYER_ID).fadeOut("slow"); 
			window.location.href=window.location.href;


		},
		isCallbackFunctionRegistered: function(functionName) { return document.getElementById(FLASH_TTRIBTES.id).hasOwnProperty(functionName); }
	
	}; 
	/// END Public Methods
	///
	
})();
