var Shell = { Browser: {}, Init: function () { $$('a').each(function (s, index) { s.observe('mouseover', function () {this.style.cursor = 'pointer';}); s.observe('mouseout', function () {this.style.cursor = '';}); }); //this.Footer.setup(); this.Table.stripe(); }, Header: { setup: function() { this.Head = $('header') || null; if (this.Head) { this.Login = this.Head.down('form'); this.Block = this.Head.down('blockquote'); this.Head.down('a', 3).observe('mousedown', function() {swap(Shell.Header.Login, Shell.Header.Block);}); // Login button this.Head.down('a#loginX').observe('mousedown', function() {swap(Shell.Header.Block, Shell.Header.Login);}); var swap = function(show, fade) {new Effect.Fade(fade, {duration: 0.1, afterFinish: function (){new Effect.Appear(show, {duration: 0.1});}});} } } }, Window: { URL: function(queryPrefix, queryEnd) { var referrer = window.location.href; if (!referrer) {return false;} var startPos = referrer.toLowerCase().indexOf(queryPrefix); if ((startPos < 0) || (startPos + queryPrefix.length == referrer.length)) {return false;} var endPos = referrer.indexOf(queryEnd, startPos); if (endPos < 0 || queryEnd === '') {endPos = referrer.length;} var queryString = referrer.substring(startPos + queryPrefix.length, endPos); queryString = queryString.replace(/\+/gi, " "); queryString = queryString.replace(/^\s*|\s(?=\s)|\s*$/g, ""); return queryString; }, popup: function(url,name,windowWidth,windowHeight, resize, scrollable) { myleft=(screen.width)?(screen.width-windowWidth)/2:100; mytop=(screen.height)?(screen.height-windowHeight)/2:100; resizeable = (resize) ? 1 : 0; scrolling = (scrollable) ? 1 : 0; properties = "width="+windowWidth+",height="+windowHeight+",toolbar=0,scrollbars="+scrolling+",statusbar=0,menubar=0,resizable="+resizeable+", top="+mytop+",left="+myleft; window.open(url,name,properties); } }, // Video Functionality for global handling of media and players // Using new jwplayer embed method and applied for all videos // located in lessons, qna, licks, and entertainment Video: { Players: { Lesson: 'http://www-ecs.jamplay.com/client/global/flash/players/jw_markers_looping_54/loopplayer.swf',// Used for Lessons and Lick & Riff Library FiveFour: 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/player.swf', // has cdn link Default: 'http://www-ecs.jamplay.com/global/player/jw_4-6-535/player.swf', // Not used on shell really.. ControlHeight: 46, Plugins: { Looping: 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/plugins/LoopVideo.swf', Markers: 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/plugins/ShellMarker.swf', Radius: 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/plugins/RadiusOverlay.swf' } }, Qualities: { Available: 'low|medium|high|super_high|720p', low: {Width:640, Height:406}, medium: {Width:640, Height:406}, high: {Width:640, Height:406}, super_high:{Width:800, Height:494}, '720p': {Width:800, Height:494}, setup: function() { var available = this.Available.split('|'); var settings = new Element('form').update('Video Quality:'); this.selectMenu = new Element('select', {'name':''}); settings.insert({'bottom':this.selectMenu}); $('videoDisplay').insert({'before':settings}); available.each(function(quality, i) { var selectOptions = new Element('option', {'value':quality}).update(quality.split('_')[0].capitalize()); Shell.Video.Qualities.selectMenu.insert(selectOptions); if (Shell.Video.QUALITY === quality) { selectOptions.selected = true; } }); this.selectMenu.observe('change', function() {Shell.Video.Qualities.change(this.options[this.selectedIndex].value);}) }, change: function(newQuality) { Shell.Video.CurrentTime = Shell.Video.Player.JW.getPosition(); Shell.Video.QualityChange = true; Shell.Video.Player.getList(newQuality, true, true); if (Shell.Video.TYPE == 'lesson') { // if it's the lesson page with resizing layouts VideoLesson.Player.update(newQuality); } } }, // Changing up the recommended jwembedder syntax and making our own object // so we can configure and customize the parameters based on varying // situations, plugins, and playlist features. Embed: function(attributes) { var jw = {}; jw.controlbar = 'over'; jw.type = 'http'; jw.provider = 'http'; jw['http.startparam'] = 'ec_seek', jw['gapro.accountid'] = 'UA-1659323-1'; jw['gapro.trackstarts'] = 'true'; jw['gapro.trackpercentage'] = 'true'; jw['gapro.tracktime'] = 'true'; jw.stretching = 'none'; jw.wmode = 'transparent'; jw.players = (Shell.Browser.AppleMobile == 'true') ? [{type: 'html5'}] : null; if(attributes.autostart == 'TRUE') attributes.autostart = true; if(attributes.autostart == 'FALSE') attributes.autostart = false; if(!attributes.autostart) attributes.autostart = false; // Assign these parameters only for these situations when specified. // Shell.Video.Embed({playerType:'marker'}).. whatever you put for 'marker' // will call the method below. var customize = { engage: function() { jw.flashplayer = Shell.Video.Players.FiveFour; jw.file = attributes.file; jw.height = 75; jw.width = 75; jw.controlbar = 'none'; jw.image = attributes.image; jw.autostart = true; jw.events = {onReady: function(evt) {Teachers.Engage.onReady(evt, attributes.divID);}}; }, profile: function() { // teacher full bio page jw.flashplayer = Shell.Video.Players.Lesson; jw.height = 360; jw.width = 640; jw.autostart = false; jw.plugins = Shell.Video.Players.Plugins.Radius; jw.skin = 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/skins/jamplay/jamplay.zip'; jw.events = {onReady: function(evt) {Teachers.Profile.Video.onReady(evt, attributes.divID);}}; }, radius: function() { jw.flashplayer = Shell.Video.Players.FiveFour; jw.file = attributes.file; jw.height = attributes.Height; jw.width = attributes.Width; jw.playlist = 'none'; jw.screencolor = '#121212'; jw.image = attributes.image; jw.autostart = attributes.autostart; jw.plugins = Shell.Video.Players.Plugins.Radius; jw.stretching = attributes.stretching || 'none'; jw.skin = 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/skins/jamplay/jamplay.zip'; }, marker: function() { jw.stretching = 'uniform'; var URL = Shell.Window.URL('?','') || ''; jw.flashplayer = Shell.Video.Players.Lesson; jw.plugins = Shell.Video.Players.Plugins.Looping+','+Shell.Video.Players.Plugins.Markers; jw.height = (Shell.Browser.AppleMobile == 'false') ? Shell.Video.Qualities[Shell.Video.QUALITY].Height : Shell.Video.Qualities[Shell.Video.QUALITY].Height-46; jw.width = Shell.Video.Qualities[Shell.Video.QUALITY].Width; jw['playlist.position'] = 'bottom'; jw.screencolor = '#000000'; jw.controlbar = 'bottom'; jw['playlist.size'] = 22; jw.video_type = Shell.Video.TYPE; jw.video_id = Shell.Video.ID; jw.item = (URL.playlist_item === '' || !URL.playlist_item) ? 0 : (parseInt(URL.playlist_item)-1); jw.start_time = (URL.start_time === '' || !URL.start_time) ? 0.00 : URL.start_time; jw.js_call = 1; jw.custom_repeat = 'true'; Shell.Video.Player.Autostart = (URL.autostart === '' || !URL.autostart) ? 0 : URL.autostart; jw.events = {onReady: function(evt) {Shell.Video.Player.onReady(evt, attributes.divID);}}; }, index: function() { jw.flashplayer = Shell.Video.Players.FiveFour; jw.plugins = Shell.Video.Players.Plugins.Radius; jw.height = (Shell.Browser.AppleMobile == 'true') ? attributes.Height-46 : attributes.Height; jw.width = attributes.Width; jw.playlist = 'none'; jw.skin = 'http://www-ecs.jamplay.com/client/global/flash/players/jwplayer/skins/jamplay/jamplay.zip'; } }; customize[attributes.playerType](); return jwplayer(attributes.divID).setup(jw); // cDawg likes only 1 jwplayer embedder call now. }, Player: { JW: {}, onReady: function(evt, divID) { this.JW = jwplayer(divID); this.getList(Shell.Video.QUALITY, false, false); this.JW.onPlaylistItem(function(evt) {Shell.Video.Player.onPlaylistItem(evt);}); this.JW.onPlay(function(evt) { Shell.Video.Player.onPlay(evt);}); this.JW.onComplete(function(evt) { Shell.Video.Player.onComplete(evt);}); this.JW.onPlaylist(function(evt) { Shell.Video.Player.onPlaylist(evt);}); Shell.Video.Qualities.setup(); // If Apple Mobile, let's create manual controls to handle the playlist if (Shell.Browser.AppleMobile == 'true') { var div = new Element('div', {'id':'videoCurrentScene'}); this.prevButton = new Element('a', {'class':'prev'}).observe('click', function() {Shell.Video.Player.JW.playlistPrev();}); this.nextButton = new Element('a', {'class':'next'}).observe('click', function() {Shell.Video.Player.JW.playlistNext();}); this.sceneText = new Element('b'); div.insert(this.prevButton); div.insert(this.nextButton); div.insert(this.sceneText); $(divID).up('div').className = "vidMobile"; $(divID).up('div').insert({'after':div}); // insert new controls in the player's parent div } }, getList: function(quality, time, updateUserDefaultQuality) { // used to be Fark var jsonn = new Ajax.Request('/services/playlist/'+Shell.Video.TYPE+'/'+Shell.Video.ID+'-'+quality, {method:'get', onComplete: function(transport){ var playlist = transport.responseText.evalJSON(); Shell.Video.Player.JW.load(playlist); } }); }, onPlaylist: function(evt) { if (Shell.Browser.AppleMobile == 'false' && (Shell.Video.QualityChange === true || Shell.Video.Player.Autostart == 1 || Shell.Video.Player.Autostart == true)) { Shell.Video.Player.JW.play(true); } }, onPlaylistItem: function(evt) { Shell.Video.CurrentScene = evt.index; // globally save the current scene for quality swapping if (Shell.Browser.AppleMobile == 'true') { this.sceneText.update(this.JW.getPlaylistItem(evt.index).title); } }, onPlay: function(evt) { if (Shell.Video.QualityChange === true) { if (Shell.Browser.AppleMobile == 'false') { Shell.Video.Player.JW.seek(Shell.Video.CurrentTime); Shell.Video.Player.JW.play(true); } Shell.Video.QualityChange = false; } }, onComplete: function(evt) {this.JW.playlistNext();} } }, Table: { stripe: function() { var tables= $$('table'); if (tables[0]) { tables.each(function(table) { if (table.className.indexOf('Table') != -1) { table.select('tr').each(function(el,i) { if (i%2==0) {el.className = 'stripe1';} else {el.className = 'stripe2';} Event.observe(el, 'mouseover', function(){el.addClassName('stripeHover');}); Event.observe(el, 'mouseout', function(){el.removeClassName('stripeHover');}); }); } }); } } }, Timezone: { change: function(element, teacherID) { var value = $F(element); new Ajax.Request('/services/live-schedule/'+value+'/'+teacherID, {method:'get', onFailure: function(){ alert('Something went wrong...') }, onSuccess: function(transport) { var response = transport.responseText || "no response text"; $('schedule-display').innerHTML = response; } }); } }, Newsletter: { send: function(element) { var btn = $(element); var status = btn.next('b'); var paragraph = btn.up('ul').previous('p'); var value = $F(btn.previous('input')); [btn, status].each(Element.toggle); new Ajax.Request('/services/check-newsletter-email/', {method:'post', parameters: {newsletter_email:value}, onSuccess: function(evt) {// 1 means good, non duplicate, 0 means duplicate if (evt.responseJSON.e == -1) {alert('An error has occured, please try again later.. sorry!'); return;} else { if (evt.responseJSON.e == 0) {paragraph.update("Duplicate Found.You are already on our newsletter list!");} if (evt.responseJSON.e == 2) {paragraph.update("Invalid Email. Please review your entry.");} if (evt.responseJSON.e == 1) { paragraph.update("Valid Email Accepted! You are in, thanks for your interest."); Element.update.delay(5, paragraph, "Enter your email to get freebies, updates and some sweet offers from our company."); } [btn, status].each(Element.toggle); } } }); } } } document.observe("dom:loaded", function() { Shell.Init(); }); //Event.observe(window, 'load', function () { //});