/**
 * An interactive timeline
 *
 * (c)2006 Jimmy Moore
 */
    timeline1 = new TimelineGroup();
    tl1e1 = new TimelineEvent(new Date(Date.UTC(1978, 3, 19, 17, 00, 0, 0)), "Jimmy was born")
    tl1e1.description = "Jimmy was born!";
    tl1e1.displayThresholdMin = (1000*60*60*24*365*100);
    timeline1.addEvent(tl1e1);
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(1979,11,  4, 15, 43, 0, 0)), "Sarah was born"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(1979, 0,  1,  0, 00, 0, 0)), "Jim+Sarah were born"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(1998,11,  2, 14, 06, 0, 0)), "Thomas was born"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(2001, 4, 28, 13, 30, 0, 0)), "J+S met"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(2002, 6, 27, 15, 30, 0, 0)), "J+S Married"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(2002, 6, 31, 15, 30, 0, 0)), "J+S Honeymoon"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(2002,11, 15, 17, 06, 0, 0)), "Ellie was born"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(2003,11, 13,  1, 01, 0, 0)), "Ellie walked"));
    timeline1.addEvent(new TimelineEvent(new Date(Date.UTC(2005,11, 12,  9, 56, 0, 0)), "Harrison was born"));
    // TODO...
    /*
    timeline1.events[3].description = "Thomas was born. <img src=tomBaby.jpg>";
    timeline1.events[1].displayThresholdMin = (1000*60*60*24*365*100);
    timeline1.events[2].displayThresholdMax = (1000*60*60*24*365*100);
    timeline1.events[6].displayThresholdMin = (1000*60*60*24*365*4);
    timeline1.events[8].displayThresholdMin = (1000*60*60*24*365*8);
    timeline1.events[2].color = "#8080ff";
    timeline1.events[2].bcolor = "#0000ff";
    */
    timeline2 = new TimelineGroup();
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1963, 2, 22,  0, 0, 0, 0)), "'Please please me' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1963,10, 22,  0, 0, 0, 0)), "'With the beatles' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1964, 6, 10,  0, 0, 0, 0)), "'A hard days night' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1964,11,  4,  0, 0, 0, 0)), "'Beatles for sale' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1965, 7,  6,  0, 0, 0, 0)), "'Help!' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1965,11,  3,  0, 0, 0, 0)), "'Rubber soul' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1966, 7,  5,  0, 0, 0, 0)), "'Revolver' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1967, 5,  1,  0, 0, 0, 0)), "'Sgt. Pepper's lonely hearts club band' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1967,10,  1,  0, 0, 0, 0)), "'Magical mystery tour' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1968,10, 22,  0, 0, 0, 0)), "'The Beatles white album' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1969, 0,  1,  0, 0, 0, 0)), "'Yellow submarine' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1969, 8, 26,  0, 0, 0, 0)), "'Abbey road' released."));
    timeline2.addEvent(new TimelineEvent(new Date(Date.UTC(1970, 2, 22,  0, 0, 0, 0)), "'Let it be' released."));
    
    timeline3 = new TimelineGroup();
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1066, 0, 1,  0, 0, 0, 0)), "William I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1087, 0, 1,  0, 0, 0, 0)), "William II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1100, 0, 1,  0, 0, 0, 0)), "Henry I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1135, 0, 1,  0, 0, 0, 0)), "Stephen"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1141, 0, 1,  0, 0, 0, 0)), "Empress Matilda"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1154, 0, 1,  0, 0, 0, 0)), "Henry II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1189, 0, 1,  0, 0, 0, 0)), "Richard I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1199, 0, 1,  0, 0, 0, 0)), "John"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1216, 0, 1,  0, 0, 0, 0)), "Henry III"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1272, 0, 1,  0, 0, 0, 0)), "Edward I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1307, 0, 1,  0, 0, 0, 0)), "Edward II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1327, 0, 1,  0, 0, 0, 0)), "Edward III"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1377, 0, 1,  0, 0, 0, 0)), "Richard II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1399, 0, 1,  0, 0, 0, 0)), "Henry IV"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1413, 0, 1,  0, 0, 0, 0)), "Henry V"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1422, 0, 1,  0, 0, 0, 0)), "Henry VI"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1461, 0, 1,  0, 0, 0, 0)), "Edward IV"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1483, 0, 1,  0, 0, 0, 0)), "Edward V"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1483, 0, 1,  0, 0, 0, 0)), "Richard III"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1485, 0, 1,  0, 0, 0, 0)), "Henry VII"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1509, 0, 1,  0, 0, 0, 0)), "Henry VIII"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1547, 0, 1,  0, 0, 0, 0)), "Edward VI"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1553, 0, 1,  0, 0, 0, 0)), "Jane Grey"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1553, 0, 1,  0, 0, 0, 0)), "Mary I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1558, 0, 1,  0, 0, 0, 0)), "Elizabeth I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1603, 0, 1,  0, 0, 0, 0)), "James I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1625, 0, 1,  0, 0, 0, 0)), "Charles I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1649, 0, 1,  0, 0, 0, 0)), "Oliver Cromwell"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1658, 0, 1,  0, 0, 0, 0)), "Richard Cromwell"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1660, 0, 1,  0, 0, 0, 0)), "Charles II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1685, 0, 1,  0, 0, 0, 0)), "James II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1689, 0, 1,  0, 0, 0, 0)), "William III"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1689, 0, 1,  0, 0, 0, 0)), "Mary II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1702, 0, 1,  0, 0, 0, 0)), "Anne"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1714, 0, 1,  0, 0, 0, 0)), "George I"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1727, 0, 1,  0, 0, 0, 0)), "George II"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1760, 0, 1,  0, 0, 0, 0)), "George III"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1820, 0, 1,  0, 0, 0, 0)), "George IV"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1830, 0, 1,  0, 0, 0, 0)), "William IV"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1837, 0, 1,  0, 0, 0, 0)), "Victoria"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1901, 0, 1,  0, 0, 0, 0)), "Edward VII"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1910, 0, 1,  0, 0, 0, 0)), "George V"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1936, 0, 1,  0, 0, 0, 0)), "Edward VIII"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1936, 0, 1,  0, 0, 0, 0)), "George VI"));
    timeline3.addEvent(new TimelineEvent(new Date(Date.UTC(1952, 0, 1,  0, 0, 0, 0)), "Elizabeth II"));

    timeline4 = new TimelineGroup();
    te = new TimelineEvent(new Date(Date.UTC(1985, 0, 1,  0, 0, 0, 0)), "NES");
    te.description = "Back in the days of the dinosaur, the Nintendo started its early days with the NES. NES was a big thing back then with a variety of over 700 games. The graphics where better than those in the arcade and they were cheap to hold and connect to the T.V. Nintendo had begun its life.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1989, 0, 1,  0, 0, 0, 0)), "Gameboy");
    te.description = "The first hand held gaming system became popular instantly on its release and sold 100 milion copies proving one of the best gaming devices made in years. Game Boy was seen nation wide and with its small LCD screen, black and white gameplay and great sound, people dove for a chance to have GB.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1989, 0, 1,  0, 0, 0, 0)), "Gameboy color");
    te.description = "The GBC was the follow up to he GB but with a break through. Colour had been introduced to the small LCD screen and the GBC soon took eyes of the GB. GB went out of buisiness and GBC took flight selling millions of copys and making special limited edition copies like the \"Pocket Pikachu\", exclusive to Pokemon and \"Pocket Game Boy's\" especially made for your pocket";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1991, 0, 1,  0, 0, 0, 0)), "Super nintendo (SNES)");
    te.description = "After the first Nintendo console had been made, a second was made in sequal to NES. The SNES was very popular and sold over 20 million consoles in the U.S alone and 46 million worldwide. The SNES had better graphics, gameplay and stereo sound. Not as many as GB though.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1996, 0, 1,  0, 0, 0, 0)), "N64");
    te.description = "N64 arrived in 96' and the future had with it. 64 bit technology allowed graphics to reach a climax with this console and Nintendo had its best sales ever, introducing vrious features with the N64. N64 made itself a legend but something bigger was about to arrive.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2001, 0, 1,  0, 0, 0, 0)), "Gameboy advance");
    te.description = "Advancing the shape and style of its ancestor, the GB, GBA taken people by storm. GBA has graphics better than SNES and plays very good with its streamline shape and small pocket size. GBA is the evolved version of the GB and has shown that it is truly incredible in comparison.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2001, 0, 1,  0, 0, 0, 0)), "Gamecube");
    te.description = "With totally mind-blowing graphics, the Gamecube makes its debut in 2001, November 4th to be exact. This console pushes all the previous consoles away and shows what Nintendo can really do. Sadly, the console does not have good sales and is thought of as the 'kid' console.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2004, 0, 1,  0, 0, 0, 0)), "Nintendo DS");
    te.description = "To compete against the Sony PSP, indirectly according to Nintendo, the DS is released. Featuring very unique capabilities such as voice chat, wi-fi online capabilities, and especially the ability to touch the screen like a PDA. The DS does not pull the gamer crowd in like the previous Game Boy's, but thus far, it is holding its own weight.";
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2006, 0, 1,  0, 0, 0, 0)), "Revolution");
    te.description = "The next generation console for Nintendo. After suffering to the hands of Playstation with the Nintendo 64, Nintendo goes from bad to worse with the Gamecube. Finally attempting to please the gaming crowd and maturing into what seems to be a better console, the Revolution is set to be out mid-2006. The console will be going online with a well organized plan this time around. Other neat features also include being able to purchase older titles from all Nintendo consoles like the NES, SNES, or Nintendo 64. Finally, Nintendo will be attempting to get many more mature and overall better quality titles this time around. Hopefully the quantity of titles will also increase as well.";
    timeline4.addEvent(te);
    
    te = new TimelineEvent(new Date(Date.UTC(1995, 0, 1,  0, 0, 0, 0)), "PlayStation");
    te.setColors("#d0d0ff", "#8080ff"); 
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2000, 0, 1,  0, 0, 0, 0)), "PlayStation2");
    te.setColors("#d0d0ff", "#8080ff"); 
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2005, 2,24,  0, 0, 0, 0)), "PSP");
    te.setColors("#d0d0ff", "#8080ff"); 
    timeline4.addEvent(te);
    
    te = new TimelineEvent(new Date(Date.UTC(2001,10,15,  0, 0, 0, 0)), "XBox");
    te.setColors("#d0ffff", "#80ffff"); 
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(2005,10,22,  0, 0, 0, 0)), "XBox 360");
    te.setColors("#d0ffff", "#80ffff");
    timeline4.addEvent(te);
    
    te = new TimelineEvent(new Date(Date.UTC(1986, 0, 1,  0, 0, 0, 0)), "Sega master system");
    te.setColors("#ffd0ff", "#ff80ff");
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1989, 0, 1,  0, 0, 0, 0)), "Sega Genesis");
    te.setColors("#ffd0ff", "#ff80ff");
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1990, 0, 1,  0, 0, 0, 0)), "Sega GameGear");
    te.setColors("#ffd0ff", "#ff80ff");
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1995, 0, 1,  0, 0, 0, 0)), "Sega Saturn");
    te.setColors("#ffd0ff", "#ff80ff");
    timeline4.addEvent(te);
    te = new TimelineEvent(new Date(Date.UTC(1998, 0, 1,  0, 0, 0, 0)), "Sega Dreamcast");
    te.setColors("#ffd0ff", "#ff80ff");
    timeline4.addEvent(te);


function example1() {
    clearTimeline();
    sd = new Date(Date.UTC(1976, 0, 0, 0, 0, 0, 0));
    ed = new Date(Date.UTC(2008, 0, 0, 0, 0, 0, 0));
    showTimeline(sd, ed, timeline1);
}

function example2() {
    clearTimeline();
    sd = new Date(Date.UTC(1963, 0, 0, 0, 0, 0, 0));
    ed = new Date(Date.UTC(1971, 0, 0, 0, 0, 0, 0));
    showTimeline(sd, ed, timeline2);
}

function example3() {
    clearTimeline();
    sd = new Date(Date.UTC(1000, 0, 0, 0, 0, 0, 0));
    ed = new Date(Date.UTC(1960, 0, 0, 0, 0, 0, 0));
    showTimeline(sd, ed, timeline3);
}

function example4() {
    clearTimeline();
    sd = new Date(Date.UTC(1984, 0, 0, 0, 0, 0, 0));
    ed = new Date(Date.UTC(2008, 0, 0, 0, 0, 0, 0));
    showTimeline(sd, ed, timeline4);
}

/**
 * Show details for each event...
 *
 *
 */

var selectedElement = null;
var selectedText = "";

function nextevent() {
    // Find the current event...
    for (i=0;i<timeline.events.length;i++) {
        if (selectedText==timeline.events[i].shorttext) {
            // now find the next one...
            for (j=(i+1);j!=i;j++) {
                if (j==timeline.events.length) j=0;
                if (timeline.events[j].element) {
                    // This is the one!
                    highlightItem(findItem(selectedElement), false);
                    selectedElement = timeline.events[j].element;
                    selectedText = timeline.events[j].shorttext;
                    highlightItem(timeline.events[j], true);
                    showDetails(selectedText);
                    return;     // all done...
                }
            }
        }
    }
}

function prevevent() {
    // Find the current event...
    for (i=0;i<timeline.events.length;i++) {
        if (selectedText==timeline.events[i].shorttext) {
            // now find the prev one...
            for (j=(i-1);j!=i;j--) {
                if (j==-1) j=timeline.events.length-1;
                if (timeline.events[j].element) {
                    // This is the one!
                    highlightItem(findItem(selectedElement), false);
                    selectedElement = timeline.events[j].element;
                    selectedText = timeline.events[j].shorttext;
                    highlightItem(timeline.events[j], true);
                    showDetails(selectedText);
                    return;     // all done...
                }
            }
        }
    }
}

function showdet(ev) {
    var el;
    if (!ev) ev = window.event;  // Crappy IE
    
    if (ev.target) {
        el = ev.target;
    } else {
        el = ev.srcElement;
    }
    // Now update the details...
    if (selectedElement) {
        highlightItem(findItem(selectedElement), false);
    }
    selectedElement = el;
    selectedText = el.innerHTML;
    highlightItem(findItem(el), true);

    showDetails(selectedText);
}

function showDetails(t) {
    d = "The details for <b>'" + t + "'</b> will go here...<br>Including exact date/time, picture, links, keywords, etc";
    // Find the current event...
    var v = null;
    for (i=0;i<timeline.events.length;i++) {
        if (selectedText==timeline.events[i].shorttext) {
            v = timeline.events[i];
            break;
        }
    }
    
    if (v==null) return;        // Error!
    
    if (v.description) d = v.description;
    tl = document.getElementById("details");
    tl.innerHTML = d;
    ta = document.getElementById("detailsdate");
    ta.innerHTML = v.date;
    tb = document.getElementById("detailsshorttext");
    tb.innerHTML = v.shorttext;
}

