var IMAGE_BASE = "images/nav/";
var EMAIL = "gtda@gtda.org";

var menu = new Array(
        ["index", "Home"],
        ["aboutus", "About Us"],
        ["contactus", "Contact Us"],
        ["faq", "FAQ"],
        ["calendar", "Calendar"]);

function getMenu(page) {
    var result = "";

    for (var i=0; i<menu.length; i++) {
        if (menu[i][0] == page) {
            result = '<div class="on">' + menu[i][1] + '</div>';
        } else {
            result = '<div class="off" onmouseover="navOn(this);" onmouseout="navOff(this);">' +
                     '<a href="' + menu[i][0] + '.html">' + menu[i][1] + '</a>' +
                     '</div>';
        }
        document.writeln(result);
    }
}

function getTextMenu() {
    var result = "";
    
    for (var i=0; i<menu.length; i++) {
        result += ' | <a href="' + menu[i][0] + '.html">' + menu[i][1] + '</a>';
    }
    document.writeln(result.substr(3));
}

function navOn(div) {
    div.className = "on";
}
function navOff(div) {
    div.className = "off";
}

function getEmail() {
    document.write('<a href="mailto:' + EMAIL + '">' + EMAIL + '</a>');
}

function getCurrentYear() {
    var now = new Date();
    document.write(now.getFullYear());
}


  var months = 
    [
     "January",
     "February",
     "March",
     "April",
     "May",
     "June",
     "July",
     "August",
     "September",
     "October",
     "November",
     "December"
];

var days = [
	"Sunday",
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday"
];

function getDances(type) { // type can be ("past" or 0) or ("upcoming" or 1)
  var months = new Object();
  months["Jan"] = 1; months["Feb"] = 2; months["Mar"] = 3; months["Apr"] = 4; months["May"] = 5; months["Jun"] = 6; months["Jul"] = 7; months["Aug"] = 8; months["Sep"] = 9; months["Oct"] = 10; months["Nov"] = 11; months["Dec"] = 12;
  var dances = 
    [
//     ["Mon 00, YEAR", "Band", "Notes "---", "---", "false = dont display"],
     ["Sep 17, 2010", "TBA", "---", "---", "---", "---"],
     ["Aug 20, 2010", "TBA", "---", "---", "---", "---"],
     ["Jul 26, 2010", "TBA", "---", "---", "---", "---"],
     ["Jun 18, 2010", "TBA", "---", "---", "---", "---"],
     ["May 14, 2010", "TBA", "---", "---", "---", "---"],
     ["Apr 23, 2010", "TBA", "---", "---", "---", "---"],
     ["Mar 12, 2010", "TBA", "---", "---", "---", "---"],
     ["Jan 15, 2010", "The Usual Suspects", "---", "---", "---", "---"],
     ["Dec 11, 2009", "TBA", "---", "---", "---", "---"],
     ["Oct 30, 2009", "The Sentimental Journey Orchestra", "Halloween-Themed Dance", "---", "---", "---"],
     ["Sep 25, 2009", "Solomon Douglas Swingtet", "---", "---", "---", "---"],
     ["Aug 21, 2009", "TBA", "GTDA presents the Southern Belle Swing Bash", "---", "---", "---"],
     ["Jul 10, 2009", "TBA", "---", "---", "---", "---"],
     ["Jun 19, 2009", "DJ Jim", "---", "---", "---", "---"],
     ["May 15, 2009", "Peachtree Jazz Edition", "Special 10 Year Anniversary", "---", "---", "---"],
     ["Apr 24, 2009", "Etowah Jazz Society", "---", "---", "---", "---"],
     ["Apr 4, 2009", "Kingsized", "GTDA presents ATLX 6. <br/>GT Students: $5. All others: $25. <br/>Visit www.atlx.org for more information.", "---", "---", "---"],
     ["Mar 13, 2009", "Capitol City Xpress", "---", "---", "---", "---"],
     ["Jan 16, 2009", "The Usual Suspects", "---", "---", "---", "---"],
     ["Dec 5, 2008", "Big Band Atlanta", "---", "---", "---", "---"],
     ["Nov 22, 2008", "Sentimental Journey Orchestra", "---", "---", "---", "---"],
     ["Oct 18, 2008", "Peachtree Jazz Edition", "---", "---", "---", "---"],
     ["Sep 19, 2008", "Solomon Douglas Swingtet", "---", "---", "---", "---"],
     ["Aug 29, 2008", "Ol' Spin Daddy Alan White", "---", "---", "---", "---"],
     ["Jul 25, 2008", "DJ Patrick", "---", "---", "---", "---"],
     ["Jun 27, 2008", "TBA", "---", "---", "---", "---"],
     ["May 16, 2008", "DJ David", "DJed Dance", "---", "---", "---"],
     ["Apr 25, 2008", "TBA", "---", "---", "---", "---"],
     ["Mar 28, 2008", "TBA", "---", "---", "---", "---"],
     ["Feb 22, 2008", "TBA", "---", "---", "---", "---"],
     ["Jan 18, 2008", "TBA", "---", "---", "---", "---"],
     ["Dec 14-16, 2007", "TBA", "---", "---", "---", "---"],
     ["Dec 7-9, 2007", "TBA", "GTDA presents<br><strong>Swing and Soul</strong>", "---", "---", "---"],
     ["Nov 16, 2007", "Capitol City XPress", "Thanksgiving Dance", "---", "---", "---"],
     ["Oct 27, 2007", "Big Band Atlanta", "Halloween-Themed Dance", "---", "---", "---"],
     ["Sep 21, 2007", "Still Swinging", "", "---", "---", "---"],
     ["Sep 14-16, 2007", "Bonaventure Quartet and Hotlanta Dixieland Jazz Band", "GTDA is proud to present the<br><strong>Southern Belle Swing Bash 2007</strong><br>Please note that the Friday night dance is $15 for everyone.", "---", "---", "false"],
     ["Aug 24, 2007", "Peachtree Jazz Edition", "---", "---", "---", "---"],
     ["Jul 20, 2007", "DJ: David", "---", "---", "---", "---"],
     ["Jun 15, 2007", "DJ: Malon/Jim", "---", "---", "---", "---"],
     ["May 18, 2007", "DJ: Alan White", "---", "---", "---", "---"],
     ["Apr 21, 2007", "TBA", "---", "---", "---", "---"],
     ["Mar 31, 2007", "Bon Aventure", "March 30th Dance has been CANCELLED", "---", "---", "---"],
     ["Feb 09, 2007", "TBA", "---", "---", "---", "---"],
     ["Jan 19, 2007", "TBA", "---", "---", "---", "---"],
     ["Dec 15, 2006", "TBA", "---", "---", "---", "---"],
     ["Nov 17, 2006", "TBA", "---", "---", "---", "---"],
     ["Oct 27, 2006", "TBA", "Halloween Themed Costume Dance", "---", "---", "---"],
     ["Sep 22, 2006", "Gwen Hughes", "First dance for incoming freshmen.", "---", "---", "---"],
     ["Aug 26, 2006", "TBA", "Yes, it's on a Saturday.", "---", "---", "---"],
     ["Jul 15, 2006", "TBA", "Yes, it's on a Saturday.", "---", "---", "---"],
     ["Jun 23, 2006", "TBA", "---", "---", "---", "---"],
     ["May 26, 2006", "TBA", "---", "---", "---", "---"],
     ["Apr 28, 2006", "TBA", "---", "---", "---", "---"],
     ["Mar 10, 2006", "TBA", "Dance held at Agnes Scott (<a href=\"/spec/03-10-2006.html\">Details</a>)", "---", "---", "---"],
     ["Feb 03, 2006", "Atlanta 17", "Valentine's Day Theme", "---", "---", "---"],
     ["Jan 13, 2006", "Still Swinging", "---", "---", "---", "---"],
     ["Nov 18, 2005", "Take Note Big Band", "---", "---", "---", "---"],
     ["Oct 28, 2005", "Night Train", "Halloween Themed Costume Dance", "---", "---", "---"],
     ["Sep 23, 2005", "Peachtree Jazz Edition", "---", "---", "---", "---"],
     ["Aug 26, 2005", "Atlanta 17", "---", "---", "---", "---"],
     ["Jul 22, 2005", "DJ: Alan White", "---", "---", "---", "---"],
     ["Jun 10, 2005", "DJ: David Rothenberg", "Lesson: 7-8, Dance: 8-11", "---", "---", "---"],
     ["May 20, 2005", "DJs: Patrick Manigault &amp; Malon Fripp", "---", "---", "---", "---"],
     ["Apr 22, 2005", "Big Peach Swing Band", "---", "---", "---", "---"],
     ["Mar 18, 2005", "Peachtree Jazz Edition", "---", "---", "---", "---"],
     ["Feb 25, 2005", "Night Train", "Baby Doll Competition, Big Apple Taught", "---", "---", "---"],
     ["Jan 14, 2005", "Take Note", "---", "---", "---", "---"],
     ["Nov 19, 2004", "Atlanta 17", "Alternate Location", "---", "---", "---"],
     ["Oct 15, 2004", "Night Train", "---", "---", "---", "---"],
     ["Sep 17, 2004", "Kickin' DJed Hurricane Dance", "---", "---", "Nima Farsinejad", "---"],
     ["Aug 20, 2004", "Atlanta 17", "Big George Savoy Dancer Demo", "---", "---", "---"],
     ["Jul 2, 2004", "DJ Bugg", "---", "---", "---", "---"],
     ["Apr 23, 2004", "Macon Jazz Band", "---", "---", "---", "---"],
     ["Mar 12, 2004", "Atlanta 17", "Salsa Workshop", "Salsa lessons with Jose Maldonado and Belle Uzeche", "Salsa dance with DJ Juan", "---"],
     ["Feb 13, 2004", "Night Train", "Dance Demos", "---", "---", "---"],
     ["Jan 23, 2004", "Artie Ball Band", "---", "---", "---", "---"],
     ["Dec 12, 2003", "DJ Manu Smith", "Dance and Discuss", "DJ Manu Smith", "DJ Manu Smith", "---"],
     ["Nov 14, 2003", "Modernaires", "Joint with Emory", "---", "---", "---"],
     ["Oct 17, 2003", "DJ music", "Cancelled", "---", "---", "---"],
     ["Sep 19, 2003", "Take Note Big Band", "---", "---", "---", "---"],
     ["Aug 22, 2003", "Atlanta 17", "Lindy and Balboa Workshops", "---", "---", "---"],
     ["Jul 25, 2003", "Gwen Hughes", "Swing Jam", "---", "---", "---"],
     ["Jun 20, 2003", "Night Train", "---", "---", "---", "---"],
     ["Apr 25, 2003", "DJ Alan", "Free, and almost had it outside :)", "---", "---", "---"],
     ["Mar 14-15, 2003", "Take Note Big Band", "Workshop", "Maggie Moon", "---", "---"],
     ["Dec 13-14, 2002", "San Francisco's DJ Jesse Miner", "Dance and Discuss", "San Francisco's DJ Jesse Miner", "San Francisco's DJ Jesse Miner", "---"],
     ["Nov 15-16, 2002", "Macon Jazz Band", "Dance Exhibitions", "Matt Smiley & Naomi Uyama", "---", "---"],
     ["Oct 18-19, 2002", "Atlanta 17", "Dance Exhibitions", "Sylvia Sykes & Jason Christodoulou", "---", "---"],
     ["Sep 20-21, 2002", "Caroline & The Ramblers", "Dance Exhibitions", "Frank & Mara Santiago", "---", "---"],
     ["Aug 23, 2002", "Night Train", "Dance Exhibitions", "Kathy & Butch Dukes and Kerry Frost & Kenny Livingston", "GTDA & ASEDA dance w/DJs", "---"],
     ["Apr 5, 2002", "Atlanta 17", "Dance Exhibitions", "---", "---", "---"],
     ["Dec 14-15, 2001", "Night Train", "---", "---", "GTDA & ASEDA dance w/DJs", "---"],
     ["Nov 9-10, 2001", "Night Train", "Charlie & Linda Reese", "Charlie & Linda Reese", "---", "---"],
     ["Oct 12-13, 2001", "DJs Everett, Kacie, Christopher, & Jim", "---", "Practice Day!", "---", "---"],
     ["Sep 14-15, 2001", "Cancelled", "Cancelled", "Kenny & Kerry, Ronda & Manuel, Joel & Melanie, Butch & Kathy, Anthony, Lewis", "DJs", "---"],
     ["Aug 10-11, 2001", "Take Note Big Band", "Exhibition by Paulette and Matt May", "Paulette Brockington", "Night Train", "---"],
     ["Jul 6-7, 2001", "DJs David, Malon, Sara, & Stephanie", "---", "Practice Day!", "---", "---"],
     ["Jun 1-2, 2001", "Sentimental Journey Orchestra", "Ballroom exhibition by Birta", "Birta Ringstad - CANCELLED", "---", "---"],
     ["May 11-12, 2001", "The Atlanta Blue Notes", "Exhibition by Angie and Roddy", "Angie Whitworth and Roddy Caravella", "---", "---"],
     ["Apr 13-14, 2001", "Atlanta 17 Big Band", "Exhibition by Erik and Sylvia", "Erik Robison and Sylvia Skylar", "---", "---"],
     ["Mar 2-3, 2001", "Cancelled", "Cancelled", "Cancelled", "Cancelled", "---"],
     ["Feb 9-10, 2001", "The Atlanta Blue Notes", "Exhibition by Steve and Carla", "Steve Bailey and Carla Heiney", "Yalloppin' Hounds", "---"],
     ["Jan 12-13, 2001", "Joe Dance Big Band", "Exhibition by Evin and Noel", "Evin and Noel", "---", "---"],
     ["Dec 8-9, 2000", "Take Note Big Band", "Exhibition by Kenny and Kerry", "Kenny Livingston and Kerry Frost", "---", "---"],
     ["Nov 17-18, 2000", "Sentimental Journey Orchestra", "Exhibition by Ravitte and Damon, Groovie Moovie Screening", "Ravitte Gall and Damon Stone", "Jim Wheatley", "---"],
     ["Oct 27-28, 2000", "The Cashmen with DJ Alan White", "Exhibition by Julian Mejia, Audience Mixer", "Julian Mejia (SalsAtlanta)", "DJ Tito", "---"],
     ["Sep 29-30, 2000", "Zoots and the Swingin' Suits", "Free Lessons by Joel and Melanie: Beginning Lindy (8:00pm) and Learning the Big Apple (10:30pm)", "Joel Domoe and Melanie Myers", "Alan White", "---"],
     ["Aug 25-26, 2000", "Victory Jazz Orchestra", "Exhibitions by SalsAtlanta and Deor Orzame", "Deor Orzame", "Alan White", "---"],
     ["Jul 7, 2000", "Chris Chandler with Southern Charm and Swing", "Jack and Jill Contest", "---", "---", "---"],
     ["Jun 30, 2000", "Joe Dance Big Band", "---", "---", "---", "---"],
     ["May 26, 2000", "West / Jim Wheatley / David Rothenberg", "Battle of the DJs!!!", "---", "---", "---"],
     ["Apr 28, 2000", "Dave Bass Ensemble", "---", "---", "---", "---"],
     ["Mar 31, 2000", "Victory Jazz Orchestra", "Exhibitions by Casino Salsa, Southern Fried Lindy Hoppers, and Steve Bailey and Carla Heiney", "Steve Bailey and Carla Heiney", "Bug (at Swingers)", "---"],
     ["Feb 11, 2000", "League of Decency", "Slow Swing Exhibition", "---", "---", "---"],
     ["Jan 15, 2000", "Cigar Store Indians / The Cashmen", "Jack and Jill Contest", "---", "---", "---"],
     ["Dec 10, 1999", "DJ Alan White (SpinDaddy)", "Exhibition by Evin and Noel", "---", "---", "---"],
     ["Nov 19, 1999", "Gwen Hughes and the Retro Jazz Kats", "---", "---", "---", "---"],
     ["Sep 24, 1999", "Rumbleseat", "---", "---", "---", "---"],
     ["Aug 27, 1999", "Rumbleseat", "Jack and Jill Contest", "---", "---", "---"],
     ["Jul 30, 1999", "Rumbleseat", "---", "---", "---", "---"],
     ["May 28, 1999", "DJ Charlie Smith", "---", "---", "---", "---"]
     ];
     
     if (type == "upcoming" || type == 1) {
         type = 1;
     } else {
         type = 0;
     }
     
     var now = new Date();
     var next = 0;
     
     for (var i=0; i<dances.length; i++) {
         var dance = dances[i];
         var dates = dance[0].split(" ");
         var dates_days = dates[1].split(",");
         dates_days = dates_days[0].split("-");
         dates_days = dates_days[0];
         
         if ( dates[2] > now.getUTCFullYear()
          || (dates[2] == now.getUTCFullYear() && getMonthNum(dates[0]) > now.getUTCMonth())
          || (dates[2] == now.getUTCFullYear() && getMonthNum(dates[0]) == now.getUTCMonth() && dates_days >= now.getUTCDate())) {
             next = i;
         } else {
             break;
         }
     }
     if (type == 1) {
         return arrSubset(dances, 0, next+1);
     } else {
         return arrSubset(dances, next + 1, dances.length);
     }
}

function getMonthNum(month){
  switch(month){
  case "Jan":
    return 0;
  case "Feb":
    return 1;
  case "Mar":
    return 2;
  case "Apr":
    return 3;
  case "May":
    return 4;
  case "Jun":
    return 5;
  case "Jul":
    return 6;
  case "Aug":
    return 7;
  case "Sep":
    return 8;
  case "Oct":
    return 9;
  case "Nov":
    return 10;
  case "Dec":
    return 11;
  default:
    return 0;  
  }
}

function arrSubset(arr, start, end) {
    if (end > arr.length) {
        end = arr.length;
    }
    if (start < 0) {
        start = 0;
    }
    if (end < start) {
        end = start;
    }
    
    var narr = new Array();
    
    for (var i=start; i<end; i++) {
        narr[i-start] = arr[i];
    }
    
    return narr;
}

function getUpcomingDances(sortorder) {
    var dances = getDances("upcoming");
    if (sortorder == 'asc') {
        dances = dances.reverse();
    }
    document.write("<table cellpadding='5'>");
    document.write("<tr><th width=\"180px\">Dance Date</th><th>Band / DJ</th><th>&nbsp;</th></tr>");
    for (var i=0; i<dances.length; i++) {
        var current_dance = dances[i];
        document.write(formatDance(current_dance));
    }
    document.write("</table>");
}

function getPastDances() {
    var dances = getDances("past");
    
    document.write("<table cellpadding='5'>");
    document.write("<tr><th width=\"180px\">Dance Date</th><th>Band / DJ</th><th>&nbsp;</th></tr>");
    for (var i=0; i<dances.length; i++) {
        var current_dance = dances[i];
        document.write(formatDance(current_dance));
    }
    document.write("</table>");
}

function formatDance(current_dance) {
    var dance_date  = current_dance[0].split(" ");
    var dance_date2 = new Date(dance_date[2], getMonthNum(dance_date[0]), dance_date[1].split(",")[0].split("-")[0]);
    var dance_date3 = days[dance_date2.getDay()] + ", " + months[dance_date2.getMonth()] + " " + dance_date2.getDate() + ", " + dance_date2.getFullYear();
    var announcement = current_dance[2] == "---" ? "" : current_dance[2];
    return "<tr><td>" + dance_date3 + "</td><td>" + current_dance[1] + "</td><td>" + announcement + "</td></tr>";
}

function getNextDance() {
    var dances = getDances("upcoming");
    var latest = dances[dances.length-1];
    var latest_date = latest[0].split(" ");
    var latest_day = latest_date[1].split(",")[0];
    var latest_day2 = latest_day.split("-")[0];
    var latest_date2 = new Date(latest_date[2], getMonthNum(latest_date[0]), latest_day2);
    
    document.write(days[latest_date2.getDay()] + ", " + months[latest_date2.getMonth()] + " " + latest_day + ", " + latest_date2.getFullYear()); //latest_date2.getDate()
}

function getAnnouncement() {
    var dances = getDances("upcoming");
    var latest = dances[dances.length-1];
    var announcement = latest[2];
    if (announcement && announcement != "---") {
        //<strong>Announcement:</strong> 
        document.write("<center><span style='color: red'><strong>Announcement:</strong> " + announcement + "</span></center>");
    }
}
