if(typeof PIECESOFUK=="undefined"){var PIECESOFUK={}}PIECESOFUK.visualizationsPtr=null;PIECESOFUK.initVisualizations=function(){$("body").show();$(".aDialog").hide();if(PIECESOFUK.visualizationsPtr==null){PIECESOFUK.visualizationsPtr=new PIECESOFUK.visualizations()}PIECESOFUK.visualizationsPtr.display()};PIECESOFUK.googleChartsLoaded=false;google.load("visualization","1",{packages:["piechart","areachart"]});google.setOnLoadCallback(function(){PIECESOFUK.googleChartsLoaded=true});PIECESOFUK.visualizations=function(){$(".aVisDescription").hide();$("#visOverview").show();var A=this;$("#visOptions").val("blank");this.albumTotals={};this.albumColors={"Pieces of You":"#ffa6a6",Spirit:"#ffd081","This Way":"#ffff7e","0304":"#6aff6a","Goodbye Alice...":"#8b8bff","Perfectly Clear":"#ca63ff",Lullaby:"#e9ddaf",Other:"#f3c4f3",unreleased:"#cce2cd","not found":"#a7eee1"};this.writerColors={all:"#0000ff",Jewel:"#00ff00",JewelOther:"#FFA500",Other:"#ff0000"};PIECESOFUK.albumFullName={"Goodbye Alice...":"Goodbye Alice In Wonderland"};$("#visOptions").change(function(){if($(this).val()=="setlists"){A.calendarCharts()}else{if($(this).val()=="songsByYear"){PIECESOFUK.songsByYear()}}});$(".visOptionImg").click(function(){if($(this).attr("src")=="Graphics/visSongsByYear.gif"){PIECESOFUK.songsByYear()}else{if($(this).attr("src")=="Graphics/visAlbumsBySetlists.gif"){A.calendarCharts()}}});this.display=function(){if($("#visualizations").hasClass("ui-dialog-content")){if($("#visualizations").dialog("isOpen")){$("#visualizations").dialog("moveToTop")}else{$("#visualizations").dialog("open")}}else{$("#visualizations").dialog({width:500,height:400,title:"Visualizations",close:this.close,focus:this.focus});$("#ui-dialog-title-visualizations").prepend('<img class="infoViewTitleImg" src="Graphics/visualizations.png" width="16" height="16" alt="icon">').parent().css("paddingLeft","3px")}};this.displaySummary=function(){if($("#visSummary").hasClass("ui-dialog-content")){if($("#visSummary").dialog("isOpen")){$("#visSummary").dialog("moveToTop")}else{$("#visSummary").dialog("open")}}else{$("#visSummary").dialog({width:450,height:300,title:"Setlist Summary",close:this.close,focus:this.focus})}};this.calendarCharts=function(){$("#visDiv").html("");$(".visSubControl").hide();$("#visHead").html("<b>Jewel albums by setlist</b>");$(".aVisDescription").hide();$("#visAlbumSetlists").show();if(PIECESOFUK.feeds==undefined){PIECESOFUK.feeds=new Array}if(PIECESOFUK.feeds.calendar==undefined){PIECESOFUK.feeds.calendar=new PIECESOFUK.calendar();setTimeout(PIECESOFUK.controller,1000);PIECESOFUK.initCalendarView()}A.display();if(!PIECESOFUK.songs){PIECESOFUK.loadSongs()}$(".cbmEntry.aConcert").live("click",function(){$(".aVisDescription").hide();var B="";B=$(this).parent().prev().text()+" "+PIECESOFUK.months[$("#calSelectMonth").val()-1]+" "+$("#calSelectYear").val();A.accumulateSongData($(this),B)});$(".cblEntry.aConcert").live("click",function(){$(".aVisDescription").hide();var B="";var D=$(this).parent().prev().attr("id");var C=D.match(/d(\d\d)m(\d\d)y(\d{4})/);B=C[1]+" "+PIECESOFUK.months[C[2]-1]+" "+C[3];A.accumulateSongData($(this),B)})};this.accumulateSongData=function(I,D){A.songsInAlbum=[];var C=I.attr("title").match(/setlist: \[(.*?)\]/);if(C){C=C[1];A.resetChartData();var H=C.replace(/ Encore:/,"").split("; ");for(var E=0;E<H.length;E++){var F=H[E];var B="not found";if(H[E].search(/ {/)!=-1){H[E]=H[E].replace(/ {.*}/,"")}if(H[E].search(/^The /)==0){H[E]=H[E].replace(/^The /,"")+", The"}if(H[E].search(/^A /)==0){H[E]=H[E].replace(/^A /,"")+", A"}if(PIECESOFUK.songs[H[E]]!=undefined){var B="unreleased";var G=PIECESOFUK.songs[H[E]].match(/Album-(\w*)/);if(G){B=PIECESOFUK.albumMap[G[1]]}}else{$("#visErrors").append(" "+H[E]+" not found")}if(A.songsInAlbum[B]==undefined){A.songsInAlbum[B]=F}else{A.songsInAlbum[B]+="; "+F}A.albumTotals[B]++}A.drawChart(D+" "+I.data("where"))}else{alert("No setlist found for this event")}};this.resetChartData=function(){$("#visDiv").html("");$("#visSongs").html("");$("#visSummary").html("");$("#visErrors").html("");A.albumTotals={};for(var B in PIECESOFUK.albumMap){A.albumTotals[PIECESOFUK.albumMap[B]]=0}};this.drawChart=function(H){if($("#visualizations").dialog("isOpen")){$("#charts").dialog("moveToTop")}else{$("#visualizations").dialog("open")}var F=new google.visualization.DataTable();if(PIECESOFUK.googleChartsLoaded){var G=0;for(var B in A.albumTotals){if(A.albumTotals[B]>0){++G}}F.addColumn("string","Album");F.addColumn("number","#songs");F.addRows(G);var E=0;var D=new Array;for(var B in A.albumTotals){if(A.albumTotals[B]>0){F.setValue(E,0,B);F.setValue(E,1,A.albumTotals[B]);D[E]=A.albumColors[B];++E}}var C=new google.visualization.PieChart($("#visDiv")[0]);google.visualization.events.addListener(C,"select",function(){if(this.getSelection()[0].column!=undefined){var I=F.getValue(this.getSelection()[0].row,0);A.displaySummary();if(I=="unreleased"){$("#visSummary").html("The unreleased songs that Jewel performed were...<br><br>"+A.songsInAlbum[I])}else{if(I=="Other"){$("#visSummary").html("The songs Jewel performed from other albums, eg compilations or soundtracks, were...<br><br>"+A.songsInAlbum[I])}else{var J=I;if(PIECESOFUK.albumFullName[I]!=undefined){J=PIECESOFUK.albumFullName[I]}$("#visSummary").html("The songs Jewel performed from "+J+" were...<br><br>"+A.songsInAlbum[I])}}}});C.draw(F,{width:$("#visualizations").width()-10,height:$("#visualizations").height()-40,is3D:true,title:H,backgroundColor:"#f9f9f9",colors:D,legend:"bottom",borderColor:"#888888",focusBorderColor:"#111111",enableTooltip:false});$("#visualizations").dialog("moveToTop")}};this.focus=function(){$(".aControl").hide();$("#visControls").show()};this.close=function(){var C=0,B=null;$(".aDialog").parent(".ui-dialog:visible").each(function(){if($(this).css("zIndex")>C){C=$(this).css("zIndex");B=$(this).children(".aDialog")}});if(B){if(B.attr("id")=="calView"){PIECESOFUK.feeds.calendar.focus()}}}};PIECESOFUK.songsByYear=function(){songsByYear=this;this.writerColors={all:"#0000ff",Jewel:"#00ff00",JewelOther:"#FFA500",Other:"#ff0000"};$("#visDiv").html("");$(".visSubControl").hide();$("#visSBYoptsForm").show();$("#visHead").html("<b>Jewel songs by Year</b>");$(".aVisDescription").hide();$("#visSongsByYearDesc").show();$("#visDrawButton").click(function(){$(".aVisDescription").hide();songsByYear.draw()});this.yearTotals={};this.songTotals={};this.numYears=0;this.songCount=0;this.accumulateData=function(){if(!PIECESOFUK.songs){PIECESOFUK.loadSongs()}songsByYear.songTotals.all=new Array;for(song in PIECESOFUK.songs){++songsByYear.songCount;var C=PIECESOFUK.songs[song].match(/Year-(\d{4})/)[1];var D=PIECESOFUK.songs[song].match(/Writer-([a-zA-Z]*)/)[1];if(songsByYear.songTotals[D]==undefined){songsByYear.songTotals[D]=new Array}songsByYear.songTotals[D].push(C);songsByYear.songTotals.all.push(C)}songsByYear.yearTotals.all={};for(var B in songsByYear.songTotals){songsByYear.songTotals[B].sort();songsByYear.yearTotals[B]={};for(var A=0;A<songsByYear.songTotals[B].length;++A){if(songsByYear.yearTotals[B][songsByYear.songTotals[B][A]]==null){if(B=="all"){++songsByYear.numYears}songsByYear.yearTotals[B][songsByYear.songTotals[B][A]]=1}else{++songsByYear.yearTotals[B][songsByYear.songTotals[B][A]]}}}};songsByYear.accumulateData();this.draw=function(){var F=new google.visualization.DataTable();F.addColumn("string","Year");var E=new Array;var D=0;if($("#visSBYWriterJewel").is(":checked")){F.addColumn("number","Jewel");E[D++]=songsByYear.writerColors.Jewel}if($("#visSBYWriterJewelOther").is(":checked")){F.addColumn("number","JewelOther");E[D++]=songsByYear.writerColors.JewelOther}if($("#visSBYWriterOther").is(":checked")){F.addColumn("number","Other");E[D++]=songsByYear.writerColors.Other}F.addColumn("number","all");E[D++]=songsByYear.writerColors.all;F.addRows(songsByYear.numYears);var H=0;for(var C in songsByYear.yearTotals.all){if(songsByYear.yearTotals.Jewel[C]==undefined){songsByYear.yearTotals.Jewel[C]=0}if(songsByYear.yearTotals.JewelOther[C]==undefined){songsByYear.yearTotals.JewelOther[C]=0}if(songsByYear.yearTotals.Other[C]==undefined){songsByYear.yearTotals.Other[C]=0}var B=0;F.setValue(H,B++,C);var G=0;if($("#visSBYWriterJewel").is(":checked")){G+=songsByYear.yearTotals.Jewel[C];F.setValue(H,B++,songsByYear.yearTotals.Jewel[C])}if($("#visSBYWriterJewelOther").is(":checked")){G+=songsByYear.yearTotals.JewelOther[C];F.setValue(H,B++,songsByYear.yearTotals.JewelOther[C])}if($("#visSBYWriterOther").is(":checked")){G+=songsByYear.yearTotals.Other[C];F.setValue(H,B++,songsByYear.yearTotals.Other[C])}F.setValue(H,B++,G);++H}$("#visHead").html("");$("#visDiv").html("");$("#visFooter").html("There are currently "+songsByYear.songCount+" songs in the <a href='songs.html'>Jewel song database</a>");var A=new google.visualization.AreaChart($("#visDiv")[0]);google.visualization.events.addListener(A,"select",function(){if(this.getSelection()[0].row!=undefined){PIECESOFUK.visualizationsPtr.displaySummary();var N=F.getColumnLabel(this.getSelection()[0].column);var L=F.getValue(this.getSelection()[0].row,0);var I=F.getValue(this.getSelection()[0].row,this.getSelection()[0].column);var K="";for(var J in PIECESOFUK.songs){if(PIECESOFUK.songs[J].indexOf("Year-"+L)!=-1){if(N=="all"){K+=J+"; "}else{var M=new RegExp("Writer-"+N+"\\b");if(PIECESOFUK.songs[J].match(M)){K+=J+"; "}}}}$("#visSummary").html("Of the "+songsByYear.songCount+" Jewel songs in the database, the following "+I+" written by "+N+" "+(I>1?" were":" was")+" first performed or written in "+L+"...<br><br>");$("#visSummary").append(K.slice(0,-2))}});A.draw(F,{width:$("#visualizations").width()-10,height:$("#visualizations").height()-40,legend:"bottom",title:"Total number of Jewel songs by Year",backgroundColor:"#f9f9f9",enableTooltip:false,colors:E})}};