// these variables are all for the global nav var curtab = -1; var _gcurtab = -1; var navon = false; var navov = false; var navextov = false; var ival = new Number(); var ison = false; // specific to category display pages that aren't broadcast sites var category_videohide = false; var cat_has = new Array(); var _isipad = false; // crude mobile detection var _isiphone = false; var newsletter_enable = true; // make this false to disable the newsletter overlay var newsletter_up = false; // is the newsletter overlay on right now? var _localgaq = []; // google analytics global var newsletter_items = new Array('Find out what\'s happening first. Connect with FRONTLINE for exclusive news, updates, and information.','Connect with FRONTLINE. Join our email list for exclusive insider access, film previews, and program reminders.'); // options for the newsletter var newsletter_choice = new String(); var videoobject; // this is for the tabbed video var category_playback = false; // category video / broadcast site: are we playing back video yet? var category_tabbedvideo = false; // category video / broadcast site: is this tabbed video? var category_videotab_notyet = true; // tabbed video: have we hit a tab yet? var timedlinks_open = false; // if there are timed links is the area open yet? var timedlinks_itemwidth = 0; $(document).ready(function () { // first let's try to get event tracking running try { _localgaq = _gaq || []; _localgaq.push(['_setAccount', 'UA-3988874-2']); } catch (e){} // now let's add tracking to the sidebar $("#gsb3").click(function () { evtlogger('sidebar','a',$(this).attr('href')); }); $("#gsb2").click(function () { evtlogger('sidebar','b',$(this).attr('href')); }); $("#gsb1").click(function () { evtlogger('sidebar','c',$(this).attr('href')); }); // now let's do some crude mobile detection if(navigator.userAgent){ if(navigator.userAgent.indexOf('iPad') != -1){ _isipad = true; } if(navigator.userAgent.indexOf('iPhone') != -1){ _isiphone = true; } } // now let's set up the top nav bar $("#_gnav").find("a").each(function () { $(this).mouseenter(function () { $(".non").removeClass('non'); $(this).addClass('non'); nav_tab($(this).attr('tab')); if(!navon){ nav_in_decide(); ison = true; } }); }); $("#_gnav").mouseenter(function () { navov = true; }); $("#_gnav").mouseleave(function () { navov = false; ison = false; nav_out_decide(); }); // decide whether we want to do the newsletter overlay if(newsletter_enable && !_isiphone && !_isipad){ if(!(cookie_get('frontline_newsletter') == 1)){ setTimeout("newsletter_decider()",2000); } } // ipad pointer popup var ipadpoint = '
'; ipadpoint += 'On your iPad?
'; ipadpoint += '
';
ipadpoint += 'Visit FRONTLINE's new iPad experience
'; ipadpoint += 'No thanks
'; if (_isipad){ $('body').append(ipadpoint); $("#ipadpoint").fadeIn(); $("#ipadpoint_nothanks").click(function () { ipadpoint_closer() }); } }); function filmhandle () { // this is for category video pages (broadcast film sites) - handles the overlaid text, sets up timed links if(!category_playback){ category_playback = true; // make sure we only fire this once if(!category_tabbedvideo){ // get the video object that's already out there videoobject = topvideo; } $("#topvideo_overlay").hide(); // hide the overlay if($("#timedlinks").length != 0){ // are there timed links? var currentmediaID = videoobject.getMediaID(); var entitycount = 0; $(".timedlink").each(function () { // traverse the li entities (which are controlled in category.php in the wordpress theme) timedlinks_itemwidth = parseInt($(this).css("width")) + (parseInt($(this).css("padding-right")) * 2) + 2; // get the size of these entities videoobject.timelinemode(); // set the timeline mode for timed links videoobject.addtimedcall({ persistent: true, callback: timedlink_focus, time: parseInt($(this).attr('data-starttime')), argument: $(this).attr('id') }); // add the timepoint to the video api so that we can get called back $(this).click(function () { // click handler for timed links var pos = $(this).attr('id').substring(7,$(this).attr('id').length); window.open($(this).attr('data-url')); evtlogger('timedlink','position ' + pos, $(this).attr('data-url')); }); entitycount++; }); $("#timedlinkcontainer").css({ 'width': entitycount * timedlinks_itemwidth }); // resize the outer container } // this is a failed attempt to make the video bigger on click. leaving it here because I'd like to try it // $("#film_videoouter").css({ 'position': 'absolute', 'top': 0, 'left': 0, 'z-index':990, width: ($(window).width() - 200), height: ($(window).height() - 200) }); // $("#videoembed").css({ '-webkit-transform': 'scale(2)' }); } } function timedlink_focus (idarg){ // routine that is called by the video api at specific times, scrolls the timed links to the right point and toggles the classes if(!timedlinks_open){ // if this is the first run of this show the box $("#timedlinks").slideDown(); } var pos = parseInt($("#" + idarg).attr('id').substring(7,$("#" + idarg).attr('id').length)); $(".tl_on").removeClass('tl_on').addClass('tl_off'); $("#" + idarg).removeClass('tl_off').addClass('tl_on'); if(pos > 0){ // scroll to the offset of this li $("#timedlinks").animate({ 'scrollLeft': (pos * timedlinks_itemwidth) }); } else { $("#timedlinks").animate({ 'scrollLeft': 0 }); } } function email_verify (email) { // simple email validator var ret = false; var val = $("#"+email).val(); if(val.length > 4 && val != 'Enter e-mail address' && val.indexOf('@') != -1 && val.indexOf('.') != -1){ ret = true; } else { alert('Please double-check your e-mail address - it should look like "frontline@pbs.org"'); } var google_conversion_id = 1071718161; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "Y5waCIO4tgIQkb6E_wM"; var google_conversion_value = 0; return ret; } function evtlogger (eventname,attrib,target){ // this a wrapper to log events to google analytics if(target){ _localgaq.push(['_trackEvent', eventname, attrib, target]); } else { _localgaq.push(['_trackEvent', eventname, attrib]); } } function nav_in () { // open the top global nav if(navov){ navon = true; $("#_gnext").stop(); $("#_gnext").css({ 'opacity':1 }); $("#_gnext").fadeIn(); $("#_gnext").mouseenter(function () { navextov = true; }); $("#t"+_gcurtab).removeClass('non').addClass('non'); $("#_gnext").mouseleave(function () { navextov = false; nav_out_decide(); }); $("#extscl").click(function () { navov = false; navextov = false; nav_out(); }); } } function nav_in_decide () { // add a delay before opening the nav in case it's rolled over on by mistake oval = setTimeout("nav_in()",400); } function nav_tab (idx){ // switch tabs in the open nav _gcurtab = idx; $(".tab").hide(); $("#_gtab"+idx).show(); } function nav_out_decide () { // add a delay before the nav goes out ival = setTimeout("nav_out()",400); } function nav_out () { // turn off the nav if there's no mouse in the area if(!navov && !navextov){ $("#extscl").unbind('click'); $("#_gnext").unbind('mouseenter'); $("#_gnext").unbind('mouseleave'); $("#_gnext").stop(); $("#_gnext").fadeOut(); $(".non").removeClass('non'); navon = false; } } function morevideo_toggle () { // this is for category pages - reveals / hides older programs if(category_videohide){ $("#morevideo").hide(); $("#morevideo_tag").html('+ MORE PROGRAMS'); category_videohide = false; } else { $("#morevideo").show(); $("#morevideo_tag").html('- LESS PROGRAMS'); category_videohide = true; } } function cat_tabcheck() { // this is for category pages - remove unused tabs if(cat_has.length > 2){ $("#cat_selecta").remove(); } } function videotab (targetvideo){ // for tabbed video on broadcast sites - a handler category_tabbedvideo = true; category_playback = false; var thistab = $('div.videotab[dtab="'+targetvideo+'"]:first'); var finalvideo = thistab.attr('vid'); if(currentvideo != finalvideo){ currentvideo = finalvideo; if(category_videotab_notyet){ videoobject = new fl_video(); videoobject.create({ div: 'videoembed', width: 666, height: 375, autoplay: true, mediaid: finalvideo }); category_videotab_notyet = false; $("#videoselecta").animate({'height':34},300); $("div.videotab").each(function (){ $(this).html(''); if($(this).hasClass('videotablarge_disabled')){ $(this).html($(this).attr('vtitle')) } else { $(this).html('' + $(this).attr('vtitle')) } $(this).css({'height':30}); }); $("#videoembed").show(); $(".videotablarge_off").removeClass("videotablarge_off").addClass("videotab_off"); $(".videotablarge_on").removeClass("videotablarge_on").addClass("videotab_on"); $(".videotablarge_disabled").removeClass("videotablarge_disabled").addClass("videotab_disabled"); } else { videoobject.update({ mediaid: finalvideo }); if($("#timedlinks").length != 0){ $("#timedlinks").slideUp(); } } if($("#timedlinks").length != 0){ // are there timed links? var currentmediaID = finalvideo; var entitycount = 0; $(".timedlink").each(function () { // traverse the li entities (which are controlled in category.php in the wordpress theme) var go = true; // if there's multiple tabs of video hide everything that isn't this mediaid if(currentmediaID != $(this).attr('data-mediaid')){ $(this).hide(); go = false; } else { $(this).show(); } if(go){ timedlinks_itemwidth = parseInt($(this).css("width")) + (parseInt($(this).css("padding-right")) * 2) + 2; // get the size of these entities videoobject.timelinemode(); // set the timeline mode for timed links videoobject.addtimedcall({ persistent: true, callback: timedlink_focus, time: parseInt($(this).attr('data-starttime')), argument: $(this).attr('id') }); // add the timepoint to the video api so that we can get called back $(this).click(function () { // click handler for timed links var pos = $(this).attr('id').substring(7,$(this).attr('id').length); window.open($(this).attr('data-url')); evtlogger('timedlink','position ' + pos, $(this).attr('data-url')); }); entitycount++; } }); $("#timedlinkcontainer").css({ 'width': entitycount * timedlinks_itemwidth }); // resize the outer container } $('.videotab_on').removeClass('videotab_on').addClass('videotab_off'); $(thistab).removeClass('videotab_off').addClass('videotab_on'); } window.location.hash = "#" + targetvideo; } function newsletter_decider () { // decide if we should open a lightbox var go = true; var x = Math.random() * 40; newsletter_choice = (x > 19)? newsletter_items[0]:newsletter_items[1]; var finalstr = ''; finalstr += '