var FlashBox = Class.create(); FlashBox.prototype = { initialize: function( ccTextData, options ) { this.options = Object.extend({ }, options || {}); if ( this.isPlayerOpen() ) { this.destroy(); } this.width = ( document.body && document.body.clientWidth != 0 ) ? document.body.clientWidth : innerWidth; this.height = ( document.body && document.body.clientHeight != 0 ) ? document.body.clientHeight : innerHeight; this.scrollY = ( document.body && document.body.scrollTop != undefined ) ? document.body.scrollTop : pageYOffset; this.player = this.createPlayer(); document.body.appendChild( this.player ); var so; if(options != null && options.cgm == true) { so = new SWFObject( ccTextData+'&autoplay=1', "clip", "320", "285", "8", "#FFFFFF" ); } else { so = new SWFObject( "http://www.criticalmention.com/components/flash_player/swf/player.swf", "clip", "320", "280", "8", "#FFFFFF" ); so.addVariable( "playlist_url", "http://www.criticalmention.com/components/flash_player/flash_playlist.php?clip_data=" + ccTextData ); so.addVariable( "auto_play", "1" ); } so.write( "flashplayer" ); this.onClose = this.destroy.bindAsEventListener( this ); Event.observe( $('closelink'), 'click', this.onClose ); Event.observe( window, 'unload', this.onClose ); new Draggable( 'flashplayerwindow', { handle: 'flashplayertitle', ghosting: false, starteffect: null, endeffect: null }); }, destroy: function() { $('flashplayerwindow').remove(); //$('shadow').remove(); }, isPlayerOpen: function() { return ( $('flashplayerwindow') != null ); }, createShadow: function() { var shadow = new Element( 'div', { id: 'shadow' }); shadow.setStyle({ position: 'absolute', top: scrollY + 'px', left: '0px', width: '100%', height: '100%', backgroundColor: '#000000', opacity: '0.70', filter: 'alpha(opacity=70)', display: 'block' }); return shadow; }, createPlayer: function() { var flashPlayerWindow = new Element( 'div', { id: 'flashplayerwindow' }); flashPlayerWindow.setStyle({ width: '320px', position: 'absolute', top: ((this.height / 2) - 140 + this.scrollY) + 'px', left: ((this.width / 2) - 160) + 'px', zIndex: '1000', border: '1px solid black', color: '#FFFFFF' }); var titleBar = new Element( 'div', { id: 'flashplayertitle' }); titleBar.setStyle({ height: '20px', font: 'bold 12pt Arial', backgroundColor: '#66829E', padding: '4px', cursor: 'pointer' }); titleBar.innerHTML = 'Critical Mention Media Player'; var flashPlayer = new Element( 'div', { id: 'flashplayer' }); flashPlayer.setStyle({ width: '100%' }); var footerBar = new Element( 'div', { id: 'flashplayerfooter' }); footerBar.setStyle({ height: '20px', font: 'normal 10pt Arial', backgroundColor: '#66829E', padding: '4px', textAlign: 'right' }); var closeLink = new Element( 'a', { id: 'closelink', href: '#' }); closeLink.setStyle({ color: '#FFFFFF', fontSize: '10pt', fontWeight: 'normal' }); closeLink.innerHTML = 'close'; footerBar.appendChild( closeLink ); flashPlayerWindow.appendChild( titleBar ); flashPlayerWindow.appendChild( flashPlayer ); flashPlayerWindow.appendChild( footerBar ); return flashPlayerWindow; } }