/*
 *
 * Add the header images here in the order that you want them to show.
 * If you want the image to link, replace null with ["URL", "TITLE" ]
 *
 * Remember to leave the "," on the last image
 *
 */
var headerslideshowimages = {
    "defaultheader.jpg" : ["http://riffknives.com/shop", "Riff Knives"],
    "fape-flip-ep.jpg"  : ["http://riffknives.com/shop/", "Ape Flip Ep"],
    "91.png"            : ["http://riffknives.com/", "Riff Knives"],
    "92.png"            : ["http://riffknives.com/", "Riff Knives"],
    "93.jpg"            : ["http://riffknives.com/", "Riff Knives"],
    "94.png"            : ["http://riffknives.com/", "Riff Knives"],
    "95.png"            : ["http://riffknives.com/", "Riff Knives"],
    "96.png"            : ["http://riffknives.com/", "Riff Knives"]
};

/*
 * Time to show each image in miliseconds
 */
var timeout = 9000;


/*
 *
 *
 */

var $j = jQuery.noConflict();

$j(document).ready(function() {

    for(var image in headerslideshowimages) {
        if($j.cookie('currentslideshowimage') == ($template_url + '/images/slideshow/' + image)) {
            if(headerslideshowimages[image]) {
                $j('#slideshowimages > img:eq(0)').wrap('<a href="' + headerslideshowimages[image][0] + '" title="' + headerslideshowimages[image][1] + '" />');
            }
        } else {
            if(headerslideshowimages[image]) {
                $j('#slideshowimages').append('<a href="' + headerslideshowimages[image][0] + '" title="' + headerslideshowimages[image][1] + '"><img src="' + $template_url + '/images/slideshow/' + image + '" />');
            } else {
                $j('#slideshowimages').append('<img src="' + $template_url + '/images/slideshow/' + image + '" />');
            }
        }
    }


    // start slideshow
    $j('#slideshowimages').cycle({
        timeout:    timeout,
        before:     setSlideshowCookie
    });

    function setSlideshowCookie() {
        if($j(this).attr('src') == undefined) {
            var img = $j(this).children().first().attr('src');
        } else {
            var img = $j(this).attr('src');
        }
        $j.cookie('currentslideshowimage', img);
    }
});

