/* seasonality.js */ var msg = ""; var count = 0; function initChart(){ //Assign event handlers to each row of the chart var row, mth, mthLabel, i, childCollection; for(mth=1; mth <= 12; mth++){ //Mouseovers for month labels mthLabel = document.getElementById("mth" + mth); if(mthLabel) { addEvent(mthLabel, "mouseover", showDetails); //addEvent(mthLabel, "mouseout", showExplanation); mthLabel.style.cursor = "pointer"; mthLabel.style.cursor = "hand"; } //Mouseovers for bar graphs (only the actual bar chart and not the whole row) positiveBar = document.getElementById("posBarForMth" + mth); if(positiveBar) { addEvent(positiveBar, "mouseover", showDetails); //addEvent(positiveBar, "mouseout", showExplanation); positiveBar.style.cursor = "pointer"; positiveBar.style.cursor = "hand"; } negativeBar = document.getElementById("negBarForMth" + mth); if(negativeBar) { addEvent(negativeBar, "mouseover", showDetails); //addEvent(negativeBar, "mouseout", showExplanation); negativeBar.style.cursor = "pointer"; negativeBar.style.cursor = "hand"; } } // default to current month var monthToday = 1 + new Date().getMonth(); turnOnDetails(monthToday); } function doNothing() { return false; } var lastDetailsShown = ""; //Show details for returns for this month function showDetails(event) { var e = event || window.event || false; var srcElement = false; if (e) { srcElementId = getSrcElement(e).id; var month = srcElementId.replace(/mth|posBarForMth|negBarForMth/, ""); cancelEvent(event); turnOnDetails(month); } } /* //Restore the general explanation text function showExplanation(event) { var e = event || window.event || false; var srcElement = false; if (e) { srcElementId = getSrcElement(e).id; cancelEvent(event); turnOffDetails(); } } */ function turnOnDetails(monthNum) { //document.getElementById("explanation").style.display = "none"; for(var d, i=1; i <= 12; i++) { //Hide all d = document.getElementById("detailsMth" + i); if(d){ d.style.display = "none"; } } //Turn on the one required var curr = document.getElementById("detailsMth" + monthNum); if (curr){ curr.style.display = "block"; } } function turnOffDetails() { var i; for(i=1; i <= 12; i++) { //Hide all if(document.getElementById("detailsMth" + i)) document.getElementById("detailsMth" + i).style.display = "none"; } //document.getElementById("explanation").style.display = "block"; } //Onload function addEvent(window, "load", initChart);