var channel = { path:'', source:'channel.xml', contentGroup:'unset-vpr', theme: 'default', transitionTime: 300, base: "http://" + document.domain + ":" + window.location.port, capture: function(object, action, description, contentType, conversion) { try { if(conversion != null && conversion != "null") { conversion = ',WT.z_convert,' + conversion; } else { conversion == ""; } dcsMultiTrack( 'DCS.dcsuri', channel.path + 'tracking/' + contentType + '/' + object + '/' + action, 'WT.ti', action + ": " + description, 'DCSext.contentId', object, 'WT.cg_n', channel.contentGroup + conversion ); } catch(err) { //alert(object + "," + action + "," + description + "," + contentType); //No analytics installed } }, contentList: { setContentlistView: function(type, target) { if(target == null) { target = ".channel_contentList"; } switch(type) { case 'grid': $(target).addClass('grid'); $(target + "_gridViewBtn").addClass('selected'); $(target + "_listViewBtn").removeClass('selected'); break; default: $(target).removeClass('grid'); $(target + "_listViewBtn").addClass('selected'); $(target + "_gridViewBtn").removeClass('selected'); break; } }, setContentlistSort: function(type, target) { if(target == null) { target = ".channel_contentList"; } if(channel.memory.contentListSortType == type) { channel.memory.contentListSortDirection = (channel.memory.contentListSortDirection == 'asc') ? 'desc' : 'asc'; } else { channel.memory.contentListSortDirection = 'desc'; } channel.memory.contentListSortType = type; var indices = new Array(); switch(type) { case 'title': $(target + " .channel_contentListItem").each(function() { indices.push($(this).find("li[class='titleSortOrder']").attr("title")); }); indices.sort(); if(channel.memory.contentListSortDirection == 'desc') { indices.reverse(); } $(target + "_titleSortBtn").addClass('selected'); $(target + "_dateSortBtn").removeClass('selected'); break; default: $(target + " .channel_contentListItem").each(function() { indices.push($(this).find("li[class='dateSortOrder']").attr("title")); }); indices.sort(function(a,b) { if(channel.memory.contentListSortDirection == 'desc') { return b - a; } else { return a - b; } }); $(target + "_dateSortBtn").addClass('selected'); $(target + "_titleSortBtn").removeClass('selected'); break; } for(var i = 0; i < indices.length; i++) { $(target + " .channel_contentListItem li[title='" + indices[i] + "']").parent().parent().filter(":visible").fadeOut(channel.transitionTime, function() { $(this).prependTo(target + " .channel_contentListItems"); $(this).fadeIn(channel.transitionTime); }); } }, setActiveCategory: function(category, target) { if(target == null) { target = ".channel_contentList"; } if(category.toString().toLowerCase().match(/^all/)) { $(target + " .channel_contentListItem").fadeIn(channel.transitionTime); } else { $(target + " .channel_contentListItem li[title!='" + category + "']").parent().parent().fadeOut(channel.transitionTime); $(target + " .channel_contentListItem li[title='" + category + "']").parent().parent().fadeIn(channel.transitionTime); } channel.slideshow.setCategoryLabel(category); }, setActiveContent: function(target) { if(target != channel.memory.contentListActiveId) { if(channel.memory.contentListActiveId != null) { $(channel.memory.contentListActiveId).removeClass('selected'); } $(target).addClass('selected'); channel.memory.contentListActiveId = target; if(channel.slideshow.active) { if(!channel.memory.firstLoad) { channel.capture($(channel.memory.contentListActiveId).find("li[class='contentID']").attr('title'), 'viewSlideshowImage', $(channel.memory.contentListActiveId).find("h3 a").html(), 'images', 'View'); } else { channel.memory.firstLoad = false; } channel.slideshow.slideTo(target); } else if(channel.videoplayer.active) { channel.videoplayer.play(target); } else { if(!channel.memory.firstLoad) { channel.capture($(channel.memory.contentListActiveId).find("li[class='contentID']").attr('title'), 'openInNewWindow', $(channel.memory.contentListActiveId).find("h3 a").html(), 'open', 'View'); window.open($(channel.memory.contentListActiveId).find("li[class='webSource'] a").attr('href')); } else { channel.memory.firstLoad = false; } } } } }, videoplayer: { active: false, play: function(target) { try { $(".channel_videoplayerContent_text").fadeOut(channel.transitionTime, function() { $(".channel_videoplayerContent_title").html($(channel.memory.contentListActiveId).find("h3 a").html()); $(".channel_videoplayerContent_date").html($(channel.memory.contentListActiveId).find(".channel_contentListItem_date").html()); $(".channel_videoplayerContent_caption").html($(channel.memory.contentListActiveId).find("p").html()); $(".channel_videoplayerContent_text").fadeIn(channel.transitionTime); }); var silverlightControl = document.getElementById("silverlightVideoPlayer"); silverlightControl.Content.VideoPlayer.DoVideoLoad($(channel.memory.contentListActiveId).find("li[class='contentID']").attr('title')); } catch(err) { if(channel.memory.firstLoad) { //Silverlight isn't initialized, it will pick up the active video when it's ready channel.memory.firstLoad = false; } else { //Silverlight is unavailable, //try to load the content directly in the browser channel.capture($(channel.memory.contentListActiveId).find("li[class='contentID']").attr('title'), 'videoView', $(channel.memory.contentListActiveId).find("h3 a").html(), 'video_nosl', null); window.open($(channel.memory.contentListActiveId).find("li[class='webSource'] a").attr('href')); } } if(channel.memory.firstLoad) { channel.memory.firstLoad = false; } }, share: function(url) { window.open(url); var temp = url.toString().replace("http://",""); var domain = temp.substr(0,temp.indexOf('/')); channel.capture( channel.utilities.getContentId(), 'share', channel.utilities.getContentTitle(), 'VideoShareLink', 'Share' ); }, email: function(url) { window.open(url); channel.capture( channel.utilities.getContentId(), 'email', channel.utilities.getContentTitle(), 'VideoEmailLink', 'Email' ); }, download: function() { channel.capture( channel.utilities.getContentId(), 'videoDownload', channel.utilities.getContentTitle(), 'videos', 'Download' ); }, installSilverlight: function() { channel.capture( channel.utilities.getContentId(), 'SilverlightInstall', channel.utilities.getContentTitle(), 'videos', null ); } }, slideshow: { active: false, slide: function(dir) { if(dir > 0) { var nextFound = false; $(channel.memory.contentListActiveId).nextAll().each(function(index, element) { if($(element).is(":visible")) { nextFound = true; channel.contentList.setActiveContent('#' + $(element).attr('id')); return false; } }); if(!nextFound) { if(channel.memory.category == $(channel.memory.contentListActiveId).parent().find("div:first-child").find("li[class='category']").attr('title')) { channel.contentList.setActiveContent('#' + $(channel.memory.contentListActiveId).parent().find("div:first-child").attr('id')); } else if($(channel.memory.contentListActiveId).parent().find($("div:first-child")).is(":visible")) { channel.contentList.setActiveContent('#' + $(channel.memory.contentListActiveId).parent().find($("div:first-child")).attr('id')); } else { $(channel.memory.contentListActiveId).parent().find("div:first-child").nextAll().each(function(index, element) { if($(element).is(":visible")) { channel.contentList.setActiveContent('#' + $(element).attr('id')); return false; } }); } } } else { var prevFound = false; $(channel.memory.contentListActiveId).prevAll().each(function(index, element) { if($(element).is(":visible")) { prevFound = true; channel.contentList.setActiveContent('#' + $(element).attr('id')); return false; } }); if(!prevFound) { if($(channel.memory.contentListActiveId).parent().find("div:last-child").is(":visible")) { channel.contentList.setActiveContent('#' + $(channel.memory.contentListActiveId).parent().find("div:last-child").attr('id')); } else { $(channel.memory.contentListActiveId).parent().find("div:last-child").prevAll().each(function(index, element) { if($(element).is(":visible")) { channel.contentList.setActiveContent('#' + $(element).attr('id')); return false; } }); } } } }, slideTo: function(target) { $(".channel_slideshowImage").fadeOut(channel.transitionTime); if($(channel.memory.contentListActiveId).find("li[class='printSource'] a").attr('href') == "") { $(".channel_slideshowContent_printBtn").fadeOut(channel.transitionTime); } else if(!$(".channel_slideshowContent_printBtn").is(":visible")) { $(".channel_slideshowContent_printBtn").fadeIn(channel.transitionTime); } var imageIndex = ($(channel.memory.contentListActiveId).parent().find(".channel_contentListItem:visible").index($(channel.memory.contentListActiveId)) + 1) + " of " + $(channel.memory.contentListActiveId).parent().find(".channel_contentListItem:visible").length + " from "; $(".channel_slideshowMenu_label").html(imageIndex + channel.memory.category); $(".channel_slideshowContent_text").fadeOut(channel.transitionTime, function() { $(".channel_slideshowImage").attr('src', $(channel.memory.contentListActiveId).find("li[class='webSource'] a").attr('href')); $(".channel_slideshowContent_title").html($(channel.memory.contentListActiveId).find("h3 a").html()); $(".channel_slideshowContent_date").html($(channel.memory.contentListActiveId).find(".channel_contentListItem_date").html()); $(".channel_slideshowContent_caption").html($(channel.memory.contentListActiveId).find("p").html()); $(".channel_slideshowContent_webBtn").attr('href', $(channel.memory.contentListActiveId).find("li[class='webSource'] a").attr('href')); $(".channel_slideshowContent_printBtn").attr('href', $(channel.memory.contentListActiveId).find("li[class='printSource'] a").attr('href')); $(".channel_slideshowImage").fadeIn(channel.transitionTime); $(".channel_slideshowContent_text").fadeIn(channel.transitionTime); }); }, setCategoryLabel: function(category) { channel.memory.category = category; $(".channel_slideshowMenu_label").html(category); } }, contactPress: function() { channel.capture('contactPress','contact','Press Contact','link','contactPress'); }, relatedLinkClick: function(target) { channel.capture('relatedLink','relatedLinkClick',target,'relatedLink','view'); window.open(target); }, utilities: { getContentId: function() { var id; if(channel.memory.contentId == null) { id = $(channel.memory.contentListActiveId).find("li[class='contentID']").attr('title'); } else { id = channel.memory.contentId; } return id; }, getContentTitle: function() { var title; if(channel.memory.contentTitle == null) { title = $(channel.memory.contentListActiveId).find("h3 a").html(); } else { title = channel.memory.contentTitle; } return title; } }, memory: { contentListActiveId: null, contentListActiveCategory: null, contentListSortDirection: 'asc', category: "All images", firstLoad: true, contentId: null, contentTitle: null } }; //////////////////////////// //Video player functions //////////////////////////// //Called by the Silverlight app when it is initialized to set the initial video function CheckVideoLoaded() { silverlightControl = document.getElementById("silverlightVideoPlayer"); silverlightControl.Content.VideoPlayer.DoVideoLoad($(channel.memory.contentListActiveId).find("li[class='contentID']").attr('title')); } //Share wrapper function channelVideoplayerShare(URL) { channel.videoplayer.share(URL); } //Capture wrapper function channelCapture(videoID,action,videoTitle,contentType,conversionOnView) { channel.capture(videoID,action,videoTitle,contentType,conversionOnView); } //Preloader progress indicator function progressChanged(sender, eventArgs) { var myHost = document.getElementById("silverlightVideoPlayer"); if (myHost) { var text1 = myHost.content.findName("LoadingTextCtrl"); if (text1) { text1.Text = Math.round(eventArgs.progress * 100) + "%"; } } } function ShowURLNewWindow(URL) { channel.videoplayer.email(URL); window.open(URL); } function ShowURLSameWindow(URL) { document.location.href = URL; } function GetOffsets() { silverlightControl = document.getElementById("silverlightVideoPlayer"); silverlightControl.Content.VideoPlayer.SetOffsets(0, -$("#silverlightVideoPlayer").height()); } function ShowDiv(LocX, OffX, LocY, OffY, vidLink, vidAltTitle) { linkDiv = document.getElementById("channel_videoplayer_link"); linkDiv.style.display = 'block'; linkDiv.style.left = LocX + OffX + 'px'; linkDiv.style.top = LocY + OffY + 'px'; linkDiv.href = vidLink; linkDiv.title = vidAltTitle; } function HideDiv() { linkDiv = document.getElementById("channel_videoplayer_link"); linkDiv.style.display = 'none'; } function SetDownloadContent(id, cg) { //Placeholder for legacy purposes }