/*
* Two part script. The first part writes out banner images onto the page.
* The second starts when the document is loaded and cycles those images randomly.
*/
document.write("<div class='banner'>"); // Write .banner div.

// Write out whatever images to the document.

// Advertising Posters



// Band Posters

image(
"http://jasonandthescorchers.com",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/Jason_Scorchers.png",
"Jason & The Scorchers",
"Jason & The Scorchers",
"0",
null, null);

image(
"http://myspace.com/marwood",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/Marwood-01.png",
"Request Marwood on DreamscapeRadio.com !",
"Marwood",
"0",
null, null);

image(
"http://myspace.com/thekunstconspiracy",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/TKC-01.png",
"Request The Kunst Conspiracy on DreamscapeRadio.com !",
"The Kunst Conspiracy",
"0",
null, null);

image(
"http://myspace.com/angelsonacid666",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/aoA-01.png",
"Request Angels on Acid on DreamscapeRadio.com !",
"Angels on Acid",
"0",
null, null);

image(
"http://myspace.com/seventhorns",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/SevenThorns-01.png",
"Request Seven Thorns on DreamscapeRadio.com !",
"Seven Thorns",
"0",
null, null);

image(
"http://myspace.com/kingratmusic",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/kingRat-01.png",
"Request King Rat on DreamscapeRadio.com !",
"King Rat",
"0",
null, null);

image(
"http://myspace.com/orbitalinfluencegeneaugust",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/orbitalInfluence-01.png",
"Request Orbital Influence on DreamscapeRadio.com !",
"Orbital Influence",
"0",
null, null);

image(
"http://myspace.com/nextpage2",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/NextPage01.png",
"Request Next Page on DreamscapeRadio.com !",
"Next Page",
"0",
null, null);

image(
"http://myspace.com/undisclosedky",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/Undisclosed.png",
"Request Undisclosed on DreamscapeRadio.com !",
"Undisclosed",
"0",
null, null);

image(
"http://myspace.com/phoenixwilliams",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/PxWlms-01-1.png",
"Request Phoenix Williams on DreamscapeRadio.com !",
"Phoenix Williams",
"0",
null, null);

image(
"http://myspace.com/dialogonline",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/DialogOnline.png",
"Request Dialog on DreamscapeRadio.com !",
"Dialog",
"0",
null, null);

image(
"http://www.myspace.com/elevendaysofrainband",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/11DaysOfRain.png",
"Request Eleven Days Of Rain on DreamscapeRadio.com !",
"Eleven Days Of Rain",
"0",
null, null);

image(
"http://www.myspace.com/maliciousdamage",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/MaliciousDamage.png",
"Request Malicious Damage on DreamscapeRadio.com !",
"Malicious Damage",
"0",
null, null);

 image(
"http://www.myspace.com/signal",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/Signal.png",
"Request Signal on DreamscapeRadio.com !",
"Signal",
"0",
null, null);

 image(
"http://www.myspace.com/willkevans",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/WillKevans.png",
"Request Will Kevans on DreamscapeRadio.com !",
"Will Kevans",
"0",
null, null);

 image(
"http://www.myspace.com/marcperrinmusic",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/MarcPerrin.png",
"Request Marc Perrin on DreamscapeRadio.com !",
"Marc Perrin",
"0",
null, null);

 image(
"http://www.myspace.com/islandthree",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/IslandThree.png",
"Request Island Three on DreamscapeRadio.com !",
"Island Three",
"0",
null, null);

 image(
"http://www.myspace.com/kosmos7",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/TheKosmos.png",
"Request The Kosmos on DreamscapeRadio.com !",
"The Kosmos",
"0",
null, null);

 image(
"http://www.myspace.com/lennon",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/Lennon.png",
"Request Lennon on DreamscapeRadio.com !",
"Lennon",
"0",
null, null);

 image(
"http://www.myspace.com/slumminangels",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/SAngels.png",
"Request Slummin Angels on DreamscapeRadio.com !",
"Slummin Angels",
"0",
null, null);

 image(
"http://www.myspace.com/sage4",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/Sage4.png",
"Request Sage4 on DreamscapeRadio.com !",
"Sage4",
"0",
null, null);

 image(
"http://www.dreamscaperadio.com",
"_blank",
"http://i198.photobucket.com/albums/aa2/djtbone001a/posters/OR_Group2.jpg",
"Request Ockums Razor on DreamscapeRadio.com !",
"Sage4",
"0",
null, null);

//End Poster List

document.write("</div>"); // Close div.

// Writes an <img> tag wrap inside a <a>. Pass null for default values.
function image(href, target, src, title, alt, border, width, height) {
    href = quote('href', href);
    target = quote('target', target);
    src = quote('src', src); // Use the quote function to format each attribute.
    title = quote('title', title);
    alt = quote('alt', alt);
    border = quote('border', border);
    width = quote('width', width);
    height = quote('height', height);

     // Set as invisble. The script will show them.
    var style = quote('style', 'display: none;');
    
    // Concat the <img> tag and write it out to the document.
    document.write('<a' + href + target + '>');
    document.write('<img' + src + title + alt + width + height + border + style + '/>');
    document.write('</a>');
}

// Takes a key value pair and formats it like (space)key='value'(space) for html attributes.
function quote(attribute, value) {
    if (value && attribute) // Only if null wasn't passed.
        return " " + attribute + "='" + value + "'" + " ";

    return ''; // Return blank if null was passed.
}

/*
* Second part of script. Should only run once.
*/

// Check pinstance.
if (!pinstance) {
    var pinstance = true;
    var minutes = 1; // How many minutes between updates.
    var currentbanner = 0; // Banner to change next.
    var banners; // jQuery selection of .banner divs
    
    // When document is loaded.
    $(document).ready(function () {
        banners = $('.banner'); // Select .banner divs.
        changeBanners(banners); // Change banners to bring up first images.
        setInterval('updateNext()', (1000 * 60) * minutes); // Now update every now and then.
    });
}

// Updates the currentbanner.
function updateNext () {
    // Select current banner and change it.
    changeBanners(banners.eq(currentbanner));
    
     // Cycle to next banner.
    currentbanner = (currentbanner + 1) % banners.length;
}

// Takes a jquery selection of banners and updates them.
function changeBanners (banners) {
    // $().each() the entire selection.
    banners.each(function (index) {
        // Find the hidden images inside this .banner.
        var hidden = $(this).find('img:hidden');
        
        // If no images there's nothing to do.
        if (hidden.length == 0) return; 
        
         // Pick a hidden image.
        var nextimage = hidden.eq(Math.ceil(Math.random() * hidden.length) - 1);
        $(this).find('img:visible').hide(); // Hide the visible one.
        nextimage.show(); // Show the next one.
    });
}